Coverage Report

Created: 2020-09-01 07:05

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