Coverage Report

Created: 2021-03-26 11:35

/libfido2/fuzz/wrap.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2019-2021 Yubico AB. All rights reserved.
3
 * Use of this source code is governed by a BSD-style
4
 * license that can be found in the LICENSE file.
5
 */
6
7
#include <openssl/bn.h>
8
#include <openssl/evp.h>
9
#include <openssl/sha.h>
10
11
#include <cbor.h>
12
#include <stdbool.h>
13
#include <stdint.h>
14
#include <stdio.h>
15
#include <stdlib.h>
16
17
#include "mutator_aux.h"
18
19
extern int prng_up;
20
21
/*
22
 * Build wrappers around functions of interest, and have them fail
23
 * in a pseudo-random manner.
24
 */
25
26
#define WRAP(type, name, args, retval, param, prob)     \
27
extern type __wrap_##name args;                         \
28
extern type __real_##name args;                         \
29
1.65M
type __wrap_##name args {                               \
30
1.65M
        if (prng_up && uniform_random(400) < (prob)) {       \
31
5.25k
                return (retval);                        \
32
5.25k
        }                                                \
33
1.65M
                                                        \
34
1.65M
        return (__real_##name param);                       \
35
1.65M
}
__wrap_malloc
Line
Count
Source
29
416k
type __wrap_##name args {                               \
30
416k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1.34k
                return (retval);                        \
32
1.34k
        }                                                \
33
416k
                                                        \
34
416k
        return (__real_##name param);                       \
35
416k
}
__wrap_calloc
Line
Count
Source
29
250k
type __wrap_##name args {                               \
30
250k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1.07k
                return (retval);                        \
32
1.07k
        }                                                \
33
250k
                                                        \
34
250k
        return (__real_##name param);                       \
35
250k
}
__wrap_strdup
Line
Count
Source
29
52.1k
type __wrap_##name args {                               \
30
52.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
220
                return (retval);                        \
32
220
        }                                                \
33
52.1k
                                                        \
34
52.1k
        return (__real_##name param);                       \
35
52.1k
}
__wrap_EVP_Cipher
Line
Count
Source
29
7.46k
type __wrap_##name args {                               \
30
7.46k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
30
                return (retval);                        \
32
30
        }                                                \
33
7.46k
                                                        \
34
7.46k
        return (__real_##name param);                       \
35
7.46k
}
__wrap_EVP_CIPHER_CTX_ctrl
Line
Count
Source
29
751
type __wrap_##name args {                               \
30
751
        if (prng_up && uniform_random(400) < (prob)) {       \
31
7
                return (retval);                        \
32
7
        }                                                \
33
751
                                                        \
34
751
        return (__real_##name param);                       \
35
751
}
__wrap_EVP_CIPHER_CTX_new
Line
Count
Source
29
6.00k
type __wrap_##name args {                               \
30
6.00k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
19
                return (retval);                        \
32
19
        }                                                \
33
6.00k
                                                        \
34
6.00k
        return (__real_##name param);                       \
35
6.00k
}
Unexecuted instantiation: __wrap_EVP_EncryptInit_ex
Unexecuted instantiation: __wrap_EVP_CIPHER_CTX_set_padding
Unexecuted instantiation: __wrap_EVP_EncryptUpdate
__wrap_EVP_CipherInit
Line
Count
Source
29
5.98k
type __wrap_##name args {                               \
30
5.98k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
17
                return (retval);                        \
32
17
        }                                                \
33
5.98k
                                                        \
34
5.98k
        return (__real_##name param);                       \
35
5.98k
}
Unexecuted instantiation: __wrap_EVP_DecryptInit_ex
Unexecuted instantiation: __wrap_EVP_DecryptUpdate
__wrap_SHA256_Init
Line
Count
Source
29
301
type __wrap_##name args {                               \
30
301
        if (prng_up && uniform_random(400) < (prob)) {       \
31
7
                return (retval);                        \
32
7
        }                                                \
33
301
                                                        \
34
301
        return (__real_##name param);                       \
35
301
}
__wrap_SHA256_Update
Line
Count
Source
29
669
type __wrap_##name args {                               \
30
669
        if (prng_up && uniform_random(400) < (prob)) {       \
31
22
                return (retval);                        \
32
22
        }                                                \
33
669
                                                        \
34
669
        return (__real_##name param);                       \
35
669
}
__wrap_SHA256_Final
Line
Count
Source
29
272
type __wrap_##name args {                               \
30
272
        if (prng_up && uniform_random(400) < (prob)) {       \
31
7
                return (retval);                        \
32
7
        }                                                \
33
272
                                                        \
34
272
        return (__real_##name param);                       \
35
272
}
__wrap_EVP_PKEY_get0_RSA
Line
Count
Source
29
79
type __wrap_##name args {                               \
30
79
        if (prng_up && uniform_random(400) < (prob)) {       \
31
5
                return (retval);                        \
32
5
        }                                                \
33
79
                                                        \
34
79
        return (__real_##name param);                       \
35
79
}
__wrap_EVP_PKEY_get0_EC_KEY
Line
Count
Source
29
6.15k
type __wrap_##name args {                               \
30
6.15k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
29
                return (retval);                        \
32
29
        }                                                \
33
6.15k
                                                        \
34
6.15k
        return (__real_##name param);                       \
35
6.15k
}
__wrap_EVP_PKEY_get_raw_public_key
Line
Count
Source
29
1.10k
type __wrap_##name args {                               \
30
1.10k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
8
                return (retval);                        \
32
8
        }                                                \
33
1.10k
                                                        \
34
1.10k
        return (__real_##name param);                       \
35
1.10k
}
__wrap_EVP_MD_CTX_new
Line
Count
Source
29
80
type __wrap_##name args {                               \
30
80
        if (prng_up && uniform_random(400) < (prob)) {       \
31
4
                return (retval);                        \
32
4
        }                                                \
33
80
                                                        \
34
80
        return (__real_##name param);                       \
35
80
}
__wrap_EVP_DigestVerifyInit
Line
Count
Source
29
76
type __wrap_##name args {                               \
30
76
        if (prng_up && uniform_random(400) < (prob)) {       \
31
4
                return (retval);                        \
32
4
        }                                                \
33
76
                                                        \
34
76
        return (__real_##name param);                       \
35
76
}
__wrap_BN_bin2bn
Line
Count
Source
29
18.1k
type __wrap_##name args {                               \
30
18.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
82
                return (retval);                        \
32
82
        }                                                \
33
18.1k
                                                        \
34
18.1k
        return (__real_##name param);                       \
35
18.1k
}
__wrap_BN_bn2bin
Line
Count
Source
29
17.5k
type __wrap_##name args {                               \
30
17.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
91
                return (retval);                        \
32
91
        }                                                \
33
17.5k
                                                        \
34
17.5k
        return (__real_##name param);                       \
35
17.5k
}
__wrap_BN_CTX_get
Line
Count
Source
29
22.7k
type __wrap_##name args {                               \
30
22.7k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
107
                return (retval);                        \
32
107
        }                                                \
33
22.7k
                                                        \
34
22.7k
        return (__real_##name param);                       \
35
22.7k
}
__wrap_BN_CTX_new
Line
Count
Source
29
13.1k
type __wrap_##name args {                               \
30
13.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
58
                return (retval);                        \
32
58
        }                                                \
33
13.1k
                                                        \
34
13.1k
        return (__real_##name param);                       \
35
13.1k
}
__wrap_BN_new
Line
Count
Source
29
1.23k
type __wrap_##name args {                               \
30
1.23k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
29
                return (retval);                        \
32
29
        }                                                \
33
1.23k
                                                        \
34
1.23k
        return (__real_##name param);                       \
35
1.23k
}
__wrap_RSA_set0_key
Line
Count
Source
29
577
type __wrap_##name args {                               \
30
577
        if (prng_up && uniform_random(400) < (prob)) {       \
31
6
                return (retval);                        \
32
6
        }                                                \
33
577
                                                        \
34
577
        return (__real_##name param);                       \
35
577
}
__wrap_EC_KEY_new_by_curve_name
Line
Count
Source
29
13.1k
type __wrap_##name args {                               \
30
13.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
58
                return (retval);                        \
32
58
        }                                                \
33
13.1k
                                                        \
34
13.1k
        return (__real_##name param);                       \
35
13.1k
}
__wrap_EC_KEY_get0_group
Line
Count
Source
29
15.6k
type __wrap_##name args {                               \
30
15.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
81
                return (retval);                        \
32
81
        }                                                \
33
15.6k
                                                        \
34
15.6k
        return (__real_##name param);                       \
35
15.6k
}
__wrap_EC_KEY_get0_private_key
Line
Count
Source
29
6.06k
type __wrap_##name args {                               \
30
6.06k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
31
                return (retval);                        \
32
31
        }                                                \
33
6.06k
                                                        \
34
6.06k
        return (__real_##name param);                       \
35
6.06k
}
__wrap_EC_POINT_new
Line
Count
Source
29
9.65k
type __wrap_##name args {                               \
30
9.65k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
35
                return (retval);                        \
32
35
        }                                                \
33
9.65k
                                                        \
34
9.65k
        return (__real_##name param);                       \
35
9.65k
}
__wrap_EC_POINT_get_affine_coordinates_GFp
Line
Count
Source
29
5.77k
type __wrap_##name args {                               \
30
5.77k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
26
                return (retval);                        \
32
26
        }                                                \
33
5.77k
                                                        \
34
5.77k
        return (__real_##name param);                       \
35
5.77k
}
__wrap_EVP_PKEY_new
Line
Count
Source
29
7.51k
type __wrap_##name args {                               \
30
7.51k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
38
                return (retval);                        \
32
38
        }                                                \
33
7.51k
                                                        \
34
7.51k
        return (__real_##name param);                       \
35
7.51k
}
__wrap_EVP_PKEY_assign
Line
Count
Source
29
7.47k
type __wrap_##name args {                               \
30
7.47k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
36
                return (retval);                        \
32
36
        }                                                \
33
7.47k
                                                        \
34
7.47k
        return (__real_##name param);                       \
35
7.47k
}
__wrap_EVP_PKEY_keygen_init
Line
Count
Source
29
6.14k
type __wrap_##name args {                               \
30
6.14k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
22
                return (retval);                        \
32
22
        }                                                \
33
6.14k
                                                        \
34
6.14k
        return (__real_##name param);                       \
35
6.14k
}
__wrap_EVP_PKEY_keygen
Line
Count
Source
29
6.12k
type __wrap_##name args {                               \
30
6.12k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
33
                return (retval);                        \
32
33
        }                                                \
33
6.12k
                                                        \
34
6.12k
        return (__real_##name param);                       \
35
6.12k
}
__wrap_EVP_PKEY_paramgen_init
Line
Count
Source
29
6.23k
type __wrap_##name args {                               \
30
6.23k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
34
                return (retval);                        \
32
34
        }                                                \
33
6.23k
                                                        \
34
6.23k
        return (__real_##name param);                       \
35
6.23k
}
__wrap_EVP_PKEY_paramgen
Line
Count
Source
29
6.20k
type __wrap_##name args {                               \
30
6.20k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
29
                return (retval);                        \
32
29
        }                                                \
33
6.20k
                                                        \
34
6.20k
        return (__real_##name param);                       \
35
6.20k
}
__wrap_EVP_PKEY_new_raw_public_key
Line
Count
Source
29
652
type __wrap_##name args {                               \
30
652
        if (prng_up && uniform_random(400) < (prob)) {       \
31
6
                return (retval);                        \
32
6
        }                                                \
33
652
                                                        \
34
652
        return (__real_##name param);                       \
35
652
}
__wrap_EVP_PKEY_CTX_new
Line
Count
Source
29
9.55k
type __wrap_##name args {                               \
30
9.55k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
40
                return (retval);                        \
32
40
        }                                                \
33
9.55k
                                                        \
34
9.55k
        return (__real_##name param);                       \
35
9.55k
}
__wrap_EVP_PKEY_CTX_new_id
Line
Count
Source
29
6.98k
type __wrap_##name args {                               \
30
6.98k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
37
                return (retval);                        \
32
37
        }                                                \
33
6.98k
                                                        \
34
6.98k
        return (__real_##name param);                       \
35
6.98k
}
__wrap_EVP_PKEY_derive
Line
Count
Source
29
7.35k
type __wrap_##name args {                               \
30
7.35k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
35
                return (retval);                        \
32
35
        }                                                \
33
7.35k
                                                        \
34
7.35k
        return (__real_##name param);                       \
35
7.35k
}
__wrap_EVP_PKEY_derive_init
Line
Count
Source
29
4.08k
type __wrap_##name args {                               \
30
4.08k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
31
                return (retval);                        \
32
31
        }                                                \
33
4.08k
                                                        \
34
4.08k
        return (__real_##name param);                       \
35
4.08k
}
__wrap_EVP_PKEY_derive_set_peer
Line
Count
Source
29
3.35k
type __wrap_##name args {                               \
30
3.35k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
12
                return (retval);                        \
32
12
        }                                                \
33
3.35k
                                                        \
34
3.35k
        return (__real_##name param);                       \
35
3.35k
}
__wrap_EVP_sha256
Line
Count
Source
29
3.12k
type __wrap_##name args {                               \
30
3.12k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
27
                return (retval);                        \
32
27
        }                                                \
33
3.12k
                                                        \
34
3.12k
        return (__real_##name param);                       \
35
3.12k
}
__wrap_HMAC
Line
Count
Source
29
2.32k
type __wrap_##name args {                               \
30
2.32k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
15
                return (retval);                        \
32
15
        }                                                \
33
2.32k
                                                        \
34
2.32k
        return (__real_##name param);                       \
35
2.32k
}
__wrap_HMAC_CTX_new
Line
Count
Source
29
53
type __wrap_##name args {                               \
30
53
        if (prng_up && uniform_random(400) < (prob)) {       \
31
2
                return (retval);                        \
32
2
        }                                                \
33
53
                                                        \
34
53
        return (__real_##name param);                       \
35
53
}
__wrap_HMAC_Init_ex
Line
Count
Source
29
50
type __wrap_##name args {                               \
30
50
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1
                return (retval);                        \
32
1
        }                                                \
33
50
                                                        \
34
50
        return (__real_##name param);                       \
35
50
}
__wrap_HMAC_Update
Line
Count
Source
29
97
type __wrap_##name args {                               \
30
97
        if (prng_up && uniform_random(400) < (prob)) {       \
31
2
                return (retval);                        \
32
2
        }                                                \
33
97
                                                        \
34
97
        return (__real_##name param);                       \
35
97
}
__wrap_HMAC_Final
Line
Count
Source
29
47
type __wrap_##name args {                               \
30
47
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1
                return (retval);                        \
32
1
        }                                                \
33
47
                                                        \
34
47
        return (__real_##name param);                       \
35
47
}
__wrap_SHA256
Line
Count
Source
29
12.8k
type __wrap_##name args {                               \
30
12.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
71
                return (retval);                        \
32
71
        }                                                \
33
12.8k
                                                        \
34
12.8k
        return (__real_##name param);                       \
35
12.8k
}
__wrap_cbor_build_string
Line
Count
Source
29
119k
type __wrap_##name args {                               \
30
119k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
64
                return (retval);                        \
32
64
        }                                                \
33
119k
                                                        \
34
119k
        return (__real_##name param);                       \
35
119k
}
__wrap_cbor_build_bytestring
Line
Count
Source
29
51.5k
type __wrap_##name args {                               \
30
51.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
96
                return (retval);                        \
32
96
        }                                                \
33
51.5k
                                                        \
34
51.5k
        return (__real_##name param);                       \
35
51.5k
}
__wrap_cbor_build_bool
Line
Count
Source
29
1.98k
type __wrap_##name args {                               \
30
1.98k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
6
                return (retval);                        \
32
6
        }                                                \
33
1.98k
                                                        \
34
1.98k
        return (__real_##name param);                       \
35
1.98k
}
__wrap_cbor_build_negint8
Line
Count
Source
29
12.4k
type __wrap_##name args {                               \
30
12.4k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
47
                return (retval);                        \
32
47
        }                                                \
33
12.4k
                                                        \
34
12.4k
        return (__real_##name param);                       \
35
12.4k
}
__wrap_cbor_build_negint16
Line
Count
Source
29
215
type __wrap_##name args {                               \
30
215
        if (prng_up && uniform_random(400) < (prob)) {       \
31
2
                return (retval);                        \
32
2
        }                                                \
33
215
                                                        \
34
215
        return (__real_##name param);                       \
35
215
}
__wrap_cbor_load
Line
Count
Source
29
24.8k
type __wrap_##name args {                               \
30
24.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
101
                return (retval);                        \
32
101
        }                                                \
33
24.8k
                                                        \
34
24.8k
        return (__real_##name param);                       \
35
24.8k
}
__wrap_cbor_build_uint8
Line
Count
Source
29
85.9k
type __wrap_##name args {                               \
30
85.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
287
                return (retval);                        \
32
287
        }                                                \
33
85.9k
                                                        \
34
85.9k
        return (__real_##name param);                       \
35
85.9k
}
__wrap_cbor_build_uint32
Line
Count
Source
29
465
type __wrap_##name args {                               \
30
465
        if (prng_up && uniform_random(400) < (prob)) {       \
31
4
                return (retval);                        \
32
4
        }                                                \
33
465
                                                        \
34
465
        return (__real_##name param);                       \
35
465
}
__wrap_cbor_map_handle
Line
Count
Source
29
36.9k
type __wrap_##name args {                               \
30
36.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
66
                return (retval);                        \
32
66
        }                                                \
33
36.9k
                                                        \
34
36.9k
        return (__real_##name param);                       \
35
36.9k
}
__wrap_cbor_array_handle
Line
Count
Source
29
20.6k
type __wrap_##name args {                               \
30
20.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
34
                return (retval);                        \
32
34
        }                                                \
33
20.6k
                                                        \
34
20.6k
        return (__real_##name param);                       \
35
20.6k
}
__wrap_cbor_array_push
Line
Count
Source
29
35.1k
type __wrap_##name args {                               \
30
35.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
9
                return (retval);                        \
32
9
        }                                                \
33
35.1k
                                                        \
34
35.1k
        return (__real_##name param);                       \
35
35.1k
}
__wrap_cbor_map_add
Line
Count
Source
29
137k
type __wrap_##name args {                               \
30
137k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
197
                return (retval);                        \
32
197
        }                                                \
33
137k
                                                        \
34
137k
        return (__real_##name param);                       \
35
137k
}
__wrap_cbor_new_definite_map
Line
Count
Source
29
60.2k
type __wrap_##name args {                               \
30
60.2k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
91
                return (retval);                        \
32
91
        }                                                \
33
60.2k
                                                        \
34
60.2k
        return (__real_##name param);                       \
35
60.2k
}
__wrap_cbor_new_definite_array
Line
Count
Source
29
2.40k
type __wrap_##name args {                               \
30
2.40k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
10
                return (retval);                        \
32
10
        }                                                \
33
2.40k
                                                        \
34
2.40k
        return (__real_##name param);                       \
35
2.40k
}
__wrap_cbor_serialize_alloc
Line
Count
Source
29
19.3k
type __wrap_##name args {                               \
30
19.3k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
98
                return (retval);                        \
32
98
        }                                                \
33
19.3k
                                                        \
34
19.3k
        return (__real_##name param);                       \
35
19.3k
}
__wrap_fido_tx
Line
Count
Source
29
78.7k
type __wrap_##name args {                               \
30
78.7k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
271
                return (retval);                        \
32
271
        }                                                \
33
78.7k
                                                        \
34
78.7k
        return (__real_##name param);                       \
35
78.7k
}
__wrap_usleep
Line
Count
Source
29
629
type __wrap_##name args {                               \
30
629
        if (prng_up && uniform_random(400) < (prob)) {       \
31
3
                return (retval);                        \
32
3
        }                                                \
33
629
                                                        \
34
629
        return (__real_##name param);                       \
35
629
}
36
37
WRAP(void *,
38
        malloc,
39
        (size_t size),
40
        NULL,
41
        (size),
42
        1
43
)
44
45
WRAP(void *,
46
        calloc,
47
        (size_t nmemb, size_t size),
48
        NULL,
49
        (nmemb, size),
50
        1
51
)
52
53
WRAP(char *,
54
        strdup,
55
        (const char *s),
56
        NULL,
57
        (s),
58
        1
59
)
60
61
WRAP(int,
62
        EVP_Cipher,
63
        (EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in,
64
            unsigned int inl),
65
        -1,
66
        (ctx, out, in, inl),
67
        1
68
)
69
70
WRAP(int,
71
        EVP_CIPHER_CTX_ctrl,
72
        (EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr),
73
        0,
74
        (ctx, type, arg, ptr),
75
        1
76
)
77
78
WRAP(EVP_CIPHER_CTX *,
79
        EVP_CIPHER_CTX_new,
80
        (void),
81
        NULL,
82
        (),
83
        1
84
)
85
86
WRAP(int,
87
        EVP_EncryptInit_ex,
88
        (EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, ENGINE *impl,
89
            const unsigned char *key, const unsigned char *iv),
90
        0,
91
        (ctx, type, impl, key, iv),
92
        1
93
)
94
95
WRAP(int,
96
        EVP_CIPHER_CTX_set_padding,
97
        (EVP_CIPHER_CTX *x, int padding),
98
        0,
99
        (x, padding),
100
        1
101
)
102
103
WRAP(int,
104
        EVP_EncryptUpdate,
105
        (EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
106
            const unsigned char *in, int inl),
107
        0,
108
        (ctx, out, outl, in, inl),
109
        1
110
)
111
112
WRAP(int,
113
        EVP_CipherInit,
114
        (EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
115
            const unsigned char *key, const unsigned char *iv, int enc),
116
        0,
117
        (ctx, cipher, key, iv, enc),
118
        1
119
)
120
121
WRAP(int,
122
        EVP_DecryptInit_ex,
123
        (EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, ENGINE *impl,
124
            const unsigned char *key, const unsigned char *iv),
125
        0,
126
        (ctx, type, impl, key, iv),
127
        1
128
)
129
130
WRAP(int,
131
        EVP_DecryptUpdate,
132
        (EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
133
            const unsigned char *in, int inl),
134
        0,
135
        (ctx, out, outl, in, inl),
136
        1
137
)
138
139
WRAP(int,
140
        SHA256_Init,
141
        (SHA256_CTX *c),
142
        0,
143
        (c),
144
        1
145
)
146
147
WRAP(int,
148
        SHA256_Update,
149
        (SHA256_CTX *c, const void *data, size_t len),
150
        0,
151
        (c, data, len),
152
        1
153
)
154
155
WRAP(int,
156
        SHA256_Final,
157
        (unsigned char *md, SHA256_CTX *c),
158
        0,
159
        (md, c),
160
        1
161
)
162
163
WRAP(RSA *,
164
        EVP_PKEY_get0_RSA,
165
        (EVP_PKEY *pkey),
166
        NULL,
167
        (pkey),
168
        1
169
)
170
171
WRAP(EC_KEY *,
172
        EVP_PKEY_get0_EC_KEY,
173
        (EVP_PKEY *pkey),
174
        NULL,
175
        (pkey),
176
        1
177
)
178
179
WRAP(int,
180
        EVP_PKEY_get_raw_public_key,
181
        (const EVP_PKEY *pkey, unsigned char *pub, size_t *len),
182
        0,
183
        (pkey, pub, len),
184
        1
185
)
186
187
WRAP(EVP_MD_CTX *,
188
        EVP_MD_CTX_new,
189
        (void),
190
        NULL,
191
        (),
192
        1
193
)
194
195
WRAP(int,
196
        EVP_DigestVerifyInit,
197
        (EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e,
198
            EVP_PKEY *pkey),
199
        0,
200
        (ctx, pctx, type, e, pkey),
201
        1
202
)
203
204
WRAP(BIGNUM *,
205
        BN_bin2bn,
206
        (const unsigned char *s, int len, BIGNUM *ret),
207
        NULL,
208
        (s, len, ret),
209
        1
210
)
211
212
WRAP(int,
213
        BN_bn2bin,
214
        (const BIGNUM *a, unsigned char *to),
215
        -1,
216
        (a, to),
217
        1
218
)
219
220
WRAP(BIGNUM *,
221
        BN_CTX_get,
222
        (BN_CTX *ctx),
223
        NULL,
224
        (ctx),
225
        1
226
)
227
228
WRAP(BN_CTX *,
229
        BN_CTX_new,
230
        (void),
231
        NULL,
232
        (),
233
        1
234
)
235
236
WRAP(BIGNUM *,
237
        BN_new,
238
        (void),
239
        NULL,
240
        (),
241
        1
242
)
243
244
WRAP(int,
245
        RSA_set0_key,
246
        (RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d),
247
        0,
248
        (r, n, e, d),
249
        1
250
)
251
252
WRAP(EC_KEY *,
253
        EC_KEY_new_by_curve_name,
254
        (int nid),
255
        NULL,
256
        (nid),
257
        1
258
)
259
260
WRAP(const EC_GROUP *,
261
        EC_KEY_get0_group,
262
        (const EC_KEY *key),
263
        NULL,
264
        (key),
265
        1
266
)
267
268
WRAP(const BIGNUM *,
269
        EC_KEY_get0_private_key,
270
        (const EC_KEY *key),
271
        NULL,
272
        (key),
273
        1
274
)
275
276
WRAP(EC_POINT *,
277
        EC_POINT_new,
278
        (const EC_GROUP *group),
279
        NULL,
280
        (group),
281
        1
282
)
283
284
WRAP(int,
285
        EC_POINT_get_affine_coordinates_GFp,
286
        (const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx),
287
        0,
288
        (group, p, x, y, ctx),
289
        1
290
)
291
292
WRAP(EVP_PKEY *,
293
        EVP_PKEY_new,
294
        (void),
295
        NULL,
296
        (),
297
        1
298
)
299
300
WRAP(int,
301
        EVP_PKEY_assign,
302
        (EVP_PKEY *pkey, int type, void *key),
303
        0,
304
        (pkey, type, key),
305
        1
306
)
307
308
WRAP(int,
309
        EVP_PKEY_keygen_init,
310
        (EVP_PKEY_CTX *ctx),
311
        0,
312
        (ctx),
313
        1
314
)
315
316
WRAP(int,
317
        EVP_PKEY_keygen,
318
        (EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey),
319
        0,
320
        (ctx, ppkey),
321
        1
322
)
323
324
WRAP(int,
325
        EVP_PKEY_paramgen_init,
326
        (EVP_PKEY_CTX *ctx),
327
        0,
328
        (ctx),
329
        1
330
)
331
332
WRAP(int,
333
        EVP_PKEY_paramgen,
334
        (EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey),
335
        0,
336
        (ctx, ppkey),
337
        1
338
)
339
340
WRAP(EVP_PKEY *,
341
        EVP_PKEY_new_raw_public_key,
342
        (int type, ENGINE *e, const unsigned char *key, size_t keylen),
343
        NULL,
344
        (type, e, key, keylen),
345
        1
346
)
347
348
WRAP(EVP_PKEY_CTX *,
349
        EVP_PKEY_CTX_new,
350
        (EVP_PKEY *pkey, ENGINE *e),
351
        NULL,
352
        (pkey, e),
353
        1
354
)
355
356
WRAP(EVP_PKEY_CTX *,
357
        EVP_PKEY_CTX_new_id,
358
        (int id, ENGINE *e),
359
        NULL,
360
        (id, e),
361
        1
362
)
363
364
WRAP(int,
365
        EVP_PKEY_derive,
366
        (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen),
367
        0,
368
        (ctx, key, pkeylen),
369
        1
370
)
371
372
WRAP(int,
373
        EVP_PKEY_derive_init,
374
        (EVP_PKEY_CTX *ctx),
375
        0,
376
        (ctx),
377
        1
378
)
379
380
WRAP(int,
381
        EVP_PKEY_derive_set_peer,
382
        (EVP_PKEY_CTX *ctx, EVP_PKEY *peer),
383
        0,
384
        (ctx, peer),
385
        1
386
)
387
388
WRAP(const EVP_MD *,
389
        EVP_sha256,
390
        (void),
391
        NULL,
392
        (),
393
        1
394
)
395
396
WRAP(unsigned char *,
397
        HMAC,
398
        (const EVP_MD *evp_md, const void *key, int key_len,
399
            const unsigned char *d, int n, unsigned char *md,
400
            unsigned int *md_len),
401
        NULL,
402
        (evp_md, key, key_len, d, n, md, md_len),
403
        1
404
)
405
406
WRAP(HMAC_CTX *,
407
        HMAC_CTX_new,
408
        (void),
409
        NULL,
410
        (),
411
        1
412
)
413
414
WRAP(int,
415
        HMAC_Init_ex,
416
        (HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md,
417
            ENGINE *impl),
418
        0,
419
        (ctx, key, key_len, md, impl),
420
        1
421
)
422
423
WRAP(int,
424
        HMAC_Update,
425
        (HMAC_CTX *ctx, const unsigned char *data, int len),
426
        0,
427
        (ctx, data, len),
428
        1
429
)
430
431
WRAP(int,
432
        HMAC_Final,
433
        (HMAC_CTX *ctx, unsigned char *md, unsigned int *len),
434
        0,
435
        (ctx, md, len),
436
        1
437
)
438
439
WRAP(unsigned char *,
440
        SHA256,
441
        (const unsigned char *d, size_t n, unsigned char *md),
442
        NULL,
443
        (d, n, md),
444
        1
445
)
446
447
WRAP(cbor_item_t *,
448
        cbor_build_string,
449
        (const char *val),
450
        NULL,
451
        (val),
452
        1
453
)
454
455
WRAP(cbor_item_t *,
456
        cbor_build_bytestring,
457
        (cbor_data handle, size_t length),
458
        NULL,
459
        (handle, length),
460
        1
461
)
462
463
WRAP(cbor_item_t *,
464
        cbor_build_bool,
465
        (bool value),
466
        NULL,
467
        (value),
468
        1
469
)
470
471
WRAP(cbor_item_t *,
472
        cbor_build_negint8,
473
        (uint8_t value),
474
        NULL,
475
        (value),
476
        1
477
)
478
479
WRAP(cbor_item_t *,
480
        cbor_build_negint16,
481
        (uint16_t value),
482
        NULL,
483
        (value),
484
        1
485
)
486
487
WRAP(cbor_item_t *,
488
        cbor_load,
489
        (cbor_data source, size_t source_size, struct cbor_load_result *result),
490
        NULL,
491
        (source, source_size, result),
492
        1
493
)
494
495
WRAP(cbor_item_t *,
496
        cbor_build_uint8,
497
        (uint8_t value),
498
        NULL,
499
        (value),
500
        1
501
)
502
503
WRAP(cbor_item_t *,
504
        cbor_build_uint32,
505
        (uint32_t value),
506
        NULL,
507
        (value),
508
        1
509
)
510
511
WRAP(struct cbor_pair *,
512
        cbor_map_handle,
513
        (const cbor_item_t *item),
514
        NULL,
515
        (item),
516
        1
517
)
518
519
WRAP(cbor_item_t **,
520
        cbor_array_handle,
521
        (const cbor_item_t *item),
522
        NULL,
523
        (item),
524
        1
525
)
526
527
WRAP(bool,
528
        cbor_array_push,
529
        (cbor_item_t *array, cbor_item_t *pushee),
530
        false,
531
        (array, pushee),
532
        1
533
)
534
535
WRAP(bool,
536
        cbor_map_add,
537
        (cbor_item_t *item, struct cbor_pair pair),
538
        false,
539
        (item, pair),
540
        1
541
)
542
543
WRAP(cbor_item_t *,
544
        cbor_new_definite_map,
545
        (size_t size),
546
        NULL,
547
        (size),
548
        1
549
)
550
551
WRAP(cbor_item_t *,
552
        cbor_new_definite_array,
553
        (size_t size),
554
        NULL,
555
        (size),
556
        1
557
)
558
559
WRAP(size_t,
560
        cbor_serialize_alloc,
561
        (const cbor_item_t *item, cbor_mutable_data *buffer,
562
            size_t *buffer_size),
563
        0,
564
        (item, buffer, buffer_size),
565
        1
566
)
567
568
WRAP(int,
569
        fido_tx,
570
        (fido_dev_t *d, uint8_t cmd, const void *buf, size_t count),
571
        -1,
572
        (d, cmd, buf, count),
573
        1
574
)
575
576
WRAP(int,
577
        usleep,
578
        (unsigned int usec),
579
        -1,
580
        (usec),
581
        1
582
)