Coverage Report

Created: 2021-07-20 18:14

/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
2.32M
type __wrap_##name args {                               \
30
2.32M
        if (prng_up && uniform_random(400) < (prob)) {       \
31
7.07k
                return (retval);                        \
32
7.07k
        }                                                \
33
2.32M
                                                        \
34
2.32M
        return (__real_##name param);                       \
35
2.32M
}
__wrap_malloc
Line
Count
Source
29
490k
type __wrap_##name args {                               \
30
490k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1.55k
                return (retval);                        \
32
1.55k
        }                                                \
33
490k
                                                        \
34
490k
        return (__real_##name param);                       \
35
490k
}
__wrap_calloc
Line
Count
Source
29
532k
type __wrap_##name args {                               \
30
532k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1.82k
                return (retval);                        \
32
1.82k
        }                                                \
33
532k
                                                        \
34
532k
        return (__real_##name param);                       \
35
532k
}
__wrap_strdup
Line
Count
Source
29
243k
type __wrap_##name args {                               \
30
243k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
744
                return (retval);                        \
32
744
        }                                                \
33
243k
                                                        \
34
243k
        return (__real_##name param);                       \
35
243k
}
__wrap_EVP_Cipher
Line
Count
Source
29
8.24k
type __wrap_##name args {                               \
30
8.24k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
29
                return (retval);                        \
32
29
        }                                                \
33
8.24k
                                                        \
34
8.24k
        return (__real_##name param);                       \
35
8.24k
}
__wrap_EVP_CIPHER_CTX_ctrl
Line
Count
Source
29
896
type __wrap_##name args {                               \
30
896
        if (prng_up && uniform_random(400) < (prob)) {       \
31
5
                return (retval);                        \
32
5
        }                                                \
33
896
                                                        \
34
896
        return (__real_##name param);                       \
35
896
}
__wrap_EVP_CIPHER_CTX_new
Line
Count
Source
29
6.50k
type __wrap_##name args {                               \
30
6.50k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
24
                return (retval);                        \
32
24
        }                                                \
33
6.50k
                                                        \
34
6.50k
        return (__real_##name param);                       \
35
6.50k
}
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
6.48k
type __wrap_##name args {                               \
30
6.48k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
23
                return (retval);                        \
32
23
        }                                                \
33
6.48k
                                                        \
34
6.48k
        return (__real_##name param);                       \
35
6.48k
}
Unexecuted instantiation: __wrap_EVP_DecryptInit_ex
Unexecuted instantiation: __wrap_EVP_DecryptUpdate
__wrap_SHA256_Init
Line
Count
Source
29
298
type __wrap_##name args {                               \
30
298
        if (prng_up && uniform_random(400) < (prob)) {       \
31
8
                return (retval);                        \
32
8
        }                                                \
33
298
                                                        \
34
298
        return (__real_##name param);                       \
35
298
}
__wrap_SHA256_Update
Line
Count
Source
29
665
type __wrap_##name args {                               \
30
665
        if (prng_up && uniform_random(400) < (prob)) {       \
31
26
                return (retval);                        \
32
26
        }                                                \
33
665
                                                        \
34
665
        return (__real_##name param);                       \
35
665
}
__wrap_SHA256_Final
Line
Count
Source
29
264
type __wrap_##name args {                               \
30
264
        if (prng_up && uniform_random(400) < (prob)) {       \
31
6
                return (retval);                        \
32
6
        }                                                \
33
264
                                                        \
34
264
        return (__real_##name param);                       \
35
264
}
__wrap_EVP_PKEY_get0_RSA
Line
Count
Source
29
79
type __wrap_##name args {                               \
30
79
        if (prng_up && uniform_random(400) < (prob)) {       \
31
4
                return (retval);                        \
32
4
        }                                                \
33
79
                                                        \
34
79
        return (__real_##name param);                       \
35
79
}
__wrap_EVP_PKEY_get0_EC_KEY
Line
Count
Source
29
7.07k
type __wrap_##name args {                               \
30
7.07k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
33
                return (retval);                        \
32
33
        }                                                \
33
7.07k
                                                        \
34
7.07k
        return (__real_##name param);                       \
35
7.07k
}
__wrap_EVP_PKEY_get_raw_public_key
Line
Count
Source
29
1.22k
type __wrap_##name args {                               \
30
1.22k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
6
                return (retval);                        \
32
6
        }                                                \
33
1.22k
                                                        \
34
1.22k
        return (__real_##name param);                       \
35
1.22k
}
__wrap_EVP_MD_CTX_new
Line
Count
Source
29
93
type __wrap_##name args {                               \
30
93
        if (prng_up && uniform_random(400) < (prob)) {       \
31
4
                return (retval);                        \
32
4
        }                                                \
33
93
                                                        \
34
93
        return (__real_##name param);                       \
35
93
}
__wrap_EVP_DigestVerifyInit
Line
Count
Source
29
89
type __wrap_##name args {                               \
30
89
        if (prng_up && uniform_random(400) < (prob)) {       \
31
4
                return (retval);                        \
32
4
        }                                                \
33
89
                                                        \
34
89
        return (__real_##name param);                       \
35
89
}
__wrap_BN_bin2bn
Line
Count
Source
29
20.1k
type __wrap_##name args {                               \
30
20.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
104
                return (retval);                        \
32
104
        }                                                \
33
20.1k
                                                        \
34
20.1k
        return (__real_##name param);                       \
35
20.1k
}
__wrap_BN_bn2bin
Line
Count
Source
29
20.2k
type __wrap_##name args {                               \
30
20.2k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
96
                return (retval);                        \
32
96
        }                                                \
33
20.2k
                                                        \
34
20.2k
        return (__real_##name param);                       \
35
20.2k
}
__wrap_BN_CTX_get
Line
Count
Source
29
25.4k
type __wrap_##name args {                               \
30
25.4k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
119
                return (retval);                        \
32
119
        }                                                \
33
25.4k
                                                        \
34
25.4k
        return (__real_##name param);                       \
35
25.4k
}
__wrap_BN_CTX_new
Line
Count
Source
29
14.6k
type __wrap_##name args {                               \
30
14.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
66
                return (retval);                        \
32
66
        }                                                \
33
14.6k
                                                        \
34
14.6k
        return (__real_##name param);                       \
35
14.6k
}
__wrap_BN_new
Line
Count
Source
29
1.35k
type __wrap_##name args {                               \
30
1.35k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
31
                return (retval);                        \
32
31
        }                                                \
33
1.35k
                                                        \
34
1.35k
        return (__real_##name param);                       \
35
1.35k
}
__wrap_RSA_set0_key
Line
Count
Source
29
638
type __wrap_##name args {                               \
30
638
        if (prng_up && uniform_random(400) < (prob)) {       \
31
6
                return (retval);                        \
32
6
        }                                                \
33
638
                                                        \
34
638
        return (__real_##name param);                       \
35
638
}
__wrap_EC_KEY_new_by_curve_name
Line
Count
Source
29
14.6k
type __wrap_##name args {                               \
30
14.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
66
                return (retval);                        \
32
66
        }                                                \
33
14.6k
                                                        \
34
14.6k
        return (__real_##name param);                       \
35
14.6k
}
__wrap_EC_KEY_get0_group
Line
Count
Source
29
17.7k
type __wrap_##name args {                               \
30
17.7k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
78
                return (retval);                        \
32
78
        }                                                \
33
17.7k
                                                        \
34
17.7k
        return (__real_##name param);                       \
35
17.7k
}
__wrap_EC_KEY_get0_private_key
Line
Count
Source
29
6.98k
type __wrap_##name args {                               \
30
6.98k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
30
                return (retval);                        \
32
30
        }                                                \
33
6.98k
                                                        \
34
6.98k
        return (__real_##name param);                       \
35
6.98k
}
__wrap_EC_POINT_new
Line
Count
Source
29
10.8k
type __wrap_##name args {                               \
30
10.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
48
                return (retval);                        \
32
48
        }                                                \
33
10.8k
                                                        \
34
10.8k
        return (__real_##name param);                       \
35
10.8k
}
__wrap_EC_POINT_get_affine_coordinates_GFp
Line
Count
Source
29
6.65k
type __wrap_##name args {                               \
30
6.65k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
33
                return (retval);                        \
32
33
        }                                                \
33
6.65k
                                                        \
34
6.65k
        return (__real_##name param);                       \
35
6.65k
}
__wrap_EVP_PKEY_new
Line
Count
Source
29
8.15k
type __wrap_##name args {                               \
30
8.15k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
41
                return (retval);                        \
32
41
        }                                                \
33
8.15k
                                                        \
34
8.15k
        return (__real_##name param);                       \
35
8.15k
}
__wrap_EVP_PKEY_assign
Line
Count
Source
29
8.11k
type __wrap_##name args {                               \
30
8.11k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
37
                return (retval);                        \
32
37
        }                                                \
33
8.11k
                                                        \
34
8.11k
        return (__real_##name param);                       \
35
8.11k
}
__wrap_EVP_PKEY_keygen_init
Line
Count
Source
29
7.07k
type __wrap_##name args {                               \
30
7.07k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
24
                return (retval);                        \
32
24
        }                                                \
33
7.07k
                                                        \
34
7.07k
        return (__real_##name param);                       \
35
7.07k
}
__wrap_EVP_PKEY_keygen
Line
Count
Source
29
7.04k
type __wrap_##name args {                               \
30
7.04k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
30
                return (retval);                        \
32
30
        }                                                \
33
7.04k
                                                        \
34
7.04k
        return (__real_##name param);                       \
35
7.04k
}
__wrap_EVP_PKEY_paramgen_init
Line
Count
Source
29
7.17k
type __wrap_##name args {                               \
30
7.17k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
35
                return (retval);                        \
32
35
        }                                                \
33
7.17k
                                                        \
34
7.17k
        return (__real_##name param);                       \
35
7.17k
}
__wrap_EVP_PKEY_paramgen
Line
Count
Source
29
7.14k
type __wrap_##name args {                               \
30
7.14k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
37
                return (retval);                        \
32
37
        }                                                \
33
7.14k
                                                        \
34
7.14k
        return (__real_##name param);                       \
35
7.14k
}
__wrap_EVP_PKEY_new_raw_public_key
Line
Count
Source
29
720
type __wrap_##name args {                               \
30
720
        if (prng_up && uniform_random(400) < (prob)) {       \
31
7
                return (retval);                        \
32
7
        }                                                \
33
720
                                                        \
34
720
        return (__real_##name param);                       \
35
720
}
__wrap_EVP_PKEY_CTX_new
Line
Count
Source
29
10.7k
type __wrap_##name args {                               \
30
10.7k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
51
                return (retval);                        \
32
51
        }                                                \
33
10.7k
                                                        \
34
10.7k
        return (__real_##name param);                       \
35
10.7k
}
__wrap_EVP_PKEY_CTX_new_id
Line
Count
Source
29
8.05k
type __wrap_##name args {                               \
30
8.05k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
48
                return (retval);                        \
32
48
        }                                                \
33
8.05k
                                                        \
34
8.05k
        return (__real_##name param);                       \
35
8.05k
}
__wrap_EVP_PKEY_derive
Line
Count
Source
29
8.04k
type __wrap_##name args {                               \
30
8.04k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
42
                return (retval);                        \
32
42
        }                                                \
33
8.04k
                                                        \
34
8.04k
        return (__real_##name param);                       \
35
8.04k
}
__wrap_EVP_PKEY_derive_init
Line
Count
Source
29
4.48k
type __wrap_##name args {                               \
30
4.48k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
31
                return (retval);                        \
32
31
        }                                                \
33
4.48k
                                                        \
34
4.48k
        return (__real_##name param);                       \
35
4.48k
}
__wrap_EVP_PKEY_derive_set_peer
Line
Count
Source
29
3.64k
type __wrap_##name args {                               \
30
3.64k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
13
                return (retval);                        \
32
13
        }                                                \
33
3.64k
                                                        \
34
3.64k
        return (__real_##name param);                       \
35
3.64k
}
__wrap_EVP_sha256
Line
Count
Source
29
3.40k
type __wrap_##name args {                               \
30
3.40k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
33
                return (retval);                        \
32
33
        }                                                \
33
3.40k
                                                        \
34
3.40k
        return (__real_##name param);                       \
35
3.40k
}
__wrap_HMAC
Line
Count
Source
29
2.49k
type __wrap_##name args {                               \
30
2.49k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
21
                return (retval);                        \
32
21
        }                                                \
33
2.49k
                                                        \
34
2.49k
        return (__real_##name param);                       \
35
2.49k
}
__wrap_HMAC_CTX_new
Line
Count
Source
29
42
type __wrap_##name args {                               \
30
42
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1
                return (retval);                        \
32
1
        }                                                \
33
42
                                                        \
34
42
        return (__real_##name param);                       \
35
42
}
__wrap_HMAC_Init_ex
Line
Count
Source
29
40
type __wrap_##name args {                               \
30
40
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1
                return (retval);                        \
32
1
        }                                                \
33
40
                                                        \
34
40
        return (__real_##name param);                       \
35
40
}
__wrap_HMAC_Update
Line
Count
Source
29
77
type __wrap_##name args {                               \
30
77
        if (prng_up && uniform_random(400) < (prob)) {       \
31
2
                return (retval);                        \
32
2
        }                                                \
33
77
                                                        \
34
77
        return (__real_##name param);                       \
35
77
}
__wrap_HMAC_Final
Line
Count
Source
29
37
type __wrap_##name args {                               \
30
37
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1
                return (retval);                        \
32
1
        }                                                \
33
37
                                                        \
34
37
        return (__real_##name param);                       \
35
37
}
__wrap_SHA256
Line
Count
Source
29
14.2k
type __wrap_##name args {                               \
30
14.2k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
78
                return (retval);                        \
32
78
        }                                                \
33
14.2k
                                                        \
34
14.2k
        return (__real_##name param);                       \
35
14.2k
}
__wrap_cbor_build_string
Line
Count
Source
29
135k
type __wrap_##name args {                               \
30
135k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
92
                return (retval);                        \
32
92
        }                                                \
33
135k
                                                        \
34
135k
        return (__real_##name param);                       \
35
135k
}
__wrap_cbor_build_bytestring
Line
Count
Source
29
57.8k
type __wrap_##name args {                               \
30
57.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
111
                return (retval);                        \
32
111
        }                                                \
33
57.8k
                                                        \
34
57.8k
        return (__real_##name param);                       \
35
57.8k
}
__wrap_cbor_build_bool
Line
Count
Source
29
1.88k
type __wrap_##name args {                               \
30
1.88k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
6
                return (retval);                        \
32
6
        }                                                \
33
1.88k
                                                        \
34
1.88k
        return (__real_##name param);                       \
35
1.88k
}
__wrap_cbor_build_negint8
Line
Count
Source
29
13.2k
type __wrap_##name args {                               \
30
13.2k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
62
                return (retval);                        \
32
62
        }                                                \
33
13.2k
                                                        \
34
13.2k
        return (__real_##name param);                       \
35
13.2k
}
__wrap_cbor_build_negint16
Line
Count
Source
29
223
type __wrap_##name args {                               \
30
223
        if (prng_up && uniform_random(400) < (prob)) {       \
31
1
                return (retval);                        \
32
1
        }                                                \
33
223
                                                        \
34
223
        return (__real_##name param);                       \
35
223
}
__wrap_cbor_load
Line
Count
Source
29
27.8k
type __wrap_##name args {                               \
30
27.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
102
                return (retval);                        \
32
102
        }                                                \
33
27.8k
                                                        \
34
27.8k
        return (__real_##name param);                       \
35
27.8k
}
__wrap_cbor_build_uint8
Line
Count
Source
29
93.6k
type __wrap_##name args {                               \
30
93.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
325
                return (retval);                        \
32
325
        }                                                \
33
93.6k
                                                        \
34
93.6k
        return (__real_##name param);                       \
35
93.6k
}
__wrap_cbor_build_uint32
Line
Count
Source
29
494
type __wrap_##name args {                               \
30
494
        if (prng_up && uniform_random(400) < (prob)) {       \
31
4
                return (retval);                        \
32
4
        }                                                \
33
494
                                                        \
34
494
        return (__real_##name param);                       \
35
494
}
__wrap_cbor_map_handle
Line
Count
Source
29
50.8k
type __wrap_##name args {                               \
30
50.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
87
                return (retval);                        \
32
87
        }                                                \
33
50.8k
                                                        \
34
50.8k
        return (__real_##name param);                       \
35
50.8k
}
__wrap_cbor_array_handle
Line
Count
Source
29
29.5k
type __wrap_##name args {                               \
30
29.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
33
                return (retval);                        \
32
33
        }                                                \
33
29.5k
                                                        \
34
29.5k
        return (__real_##name param);                       \
35
29.5k
}
__wrap_cbor_array_push
Line
Count
Source
29
40.0k
type __wrap_##name args {                               \
30
40.0k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
16
                return (retval);                        \
32
16
        }                                                \
33
40.0k
                                                        \
34
40.0k
        return (__real_##name param);                       \
35
40.0k
}
__wrap_cbor_map_add
Line
Count
Source
29
153k
type __wrap_##name args {                               \
30
153k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
230
                return (retval);                        \
32
230
        }                                                \
33
153k
                                                        \
34
153k
        return (__real_##name param);                       \
35
153k
}
__wrap_cbor_new_definite_map
Line
Count
Source
29
67.5k
type __wrap_##name args {                               \
30
67.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
106
                return (retval);                        \
32
106
        }                                                \
33
67.5k
                                                        \
34
67.5k
        return (__real_##name param);                       \
35
67.5k
}
__wrap_cbor_new_definite_array
Line
Count
Source
29
2.70k
type __wrap_##name args {                               \
30
2.70k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
14
                return (retval);                        \
32
14
        }                                                \
33
2.70k
                                                        \
34
2.70k
        return (__real_##name param);                       \
35
2.70k
}
__wrap_cbor_serialize_alloc
Line
Count
Source
29
21.2k
type __wrap_##name args {                               \
30
21.2k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
95
                return (retval);                        \
32
95
        }                                                \
33
21.2k
                                                        \
34
21.2k
        return (__real_##name param);                       \
35
21.2k
}
__wrap_fido_tx
Line
Count
Source
29
91.4k
type __wrap_##name args {                               \
30
91.4k
        if (prng_up && uniform_random(400) < (prob)) {       \
31
293
                return (retval);                        \
32
293
        }                                                \
33
91.4k
                                                        \
34
91.4k
        return (__real_##name param);                       \
35
91.4k
}
__wrap_usleep
Line
Count
Source
29
703
type __wrap_##name args {                               \
30
703
        if (prng_up && uniform_random(400) < (prob)) {       \
31
3
                return (retval);                        \
32
3
        }                                                \
33
703
                                                        \
34
703
        return (__real_##name param);                       \
35
703
}
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
)