Coverage Report

Created: 2020-12-02 17:02

/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.40M
type __wrap_##name args {                               \
32
1.40M
        if (prng_up && uniform_random(400) < (prob)) {       \
33
4.12k
                return (retval);                        \
34
4.12k
        }                                                \
35
1.40M
                                                        \
36
1.40M
        return (__real_##name param);                       \
37
1.40M
}
__wrap_malloc
Line
Count
Source
31
367k
type __wrap_##name args {                               \
32
367k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
1.27k
                return (retval);                        \
34
1.27k
        }                                                \
35
367k
                                                        \
36
367k
        return (__real_##name param);                       \
37
367k
}
__wrap_calloc
Line
Count
Source
31
186k
type __wrap_##name args {                               \
32
186k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
689
                return (retval);                        \
34
689
        }                                                \
35
186k
                                                        \
36
186k
        return (__real_##name param);                       \
37
186k
}
__wrap_strdup
Line
Count
Source
31
53.5k
type __wrap_##name args {                               \
32
53.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
232
                return (retval);                        \
34
232
        }                                                \
35
53.5k
                                                        \
36
53.5k
        return (__real_##name param);                       \
37
53.5k
}
__wrap_EVP_CIPHER_CTX_new
Line
Count
Source
31
5.09k
type __wrap_##name args {                               \
32
5.09k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
16
                return (retval);                        \
34
16
        }                                                \
35
5.09k
                                                        \
36
5.09k
        return (__real_##name param);                       \
37
5.09k
}
__wrap_EVP_EncryptInit_ex
Line
Count
Source
31
2.91k
type __wrap_##name args {                               \
32
2.91k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
9
                return (retval);                        \
34
9
        }                                                \
35
2.91k
                                                        \
36
2.91k
        return (__real_##name param);                       \
37
2.91k
}
__wrap_EVP_CIPHER_CTX_set_padding
Line
Count
Source
31
5.06k
type __wrap_##name args {                               \
32
5.06k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
20
                return (retval);                        \
34
20
        }                                                \
35
5.06k
                                                        \
36
5.06k
        return (__real_##name param);                       \
37
5.06k
}
__wrap_EVP_EncryptUpdate
Line
Count
Source
31
2.89k
type __wrap_##name args {                               \
32
2.89k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
8
                return (retval);                        \
34
8
        }                                                \
35
2.89k
                                                        \
36
2.89k
        return (__real_##name param);                       \
37
2.89k
}
__wrap_EVP_DecryptInit_ex
Line
Count
Source
31
2.16k
type __wrap_##name args {                               \
32
2.16k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
8
                return (retval);                        \
34
8
        }                                                \
35
2.16k
                                                        \
36
2.16k
        return (__real_##name param);                       \
37
2.16k
}
__wrap_EVP_DecryptUpdate
Line
Count
Source
31
2.15k
type __wrap_##name args {                               \
32
2.15k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
7
                return (retval);                        \
34
7
        }                                                \
35
2.15k
                                                        \
36
2.15k
        return (__real_##name param);                       \
37
2.15k
}
__wrap_SHA256_Init
Line
Count
Source
31
275
type __wrap_##name args {                               \
32
275
        if (prng_up && uniform_random(400) < (prob)) {       \
33
7
                return (retval);                        \
34
7
        }                                                \
35
275
                                                        \
36
275
        return (__real_##name param);                       \
37
275
}
__wrap_SHA256_Update
Line
Count
Source
31
618
type __wrap_##name args {                               \
32
618
        if (prng_up && uniform_random(400) < (prob)) {       \
33
21
                return (retval);                        \
34
21
        }                                                \
35
618
                                                        \
36
618
        return (__real_##name param);                       \
37
618
}
__wrap_SHA256_Final
Line
Count
Source
31
247
type __wrap_##name args {                               \
32
247
        if (prng_up && uniform_random(400) < (prob)) {       \
33
7
                return (retval);                        \
34
7
        }                                                \
35
247
                                                        \
36
247
        return (__real_##name param);                       \
37
247
}
__wrap_EVP_PKEY_get0_RSA
Line
Count
Source
31
69
type __wrap_##name args {                               \
32
69
        if (prng_up && uniform_random(400) < (prob)) {       \
33
5
                return (retval);                        \
34
5
        }                                                \
35
69
                                                        \
36
69
        return (__real_##name param);                       \
37
69
}
__wrap_EVP_PKEY_get0_EC_KEY
Line
Count
Source
31
4.93k
type __wrap_##name args {                               \
32
4.93k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
20
                return (retval);                        \
34
20
        }                                                \
35
4.93k
                                                        \
36
4.93k
        return (__real_##name param);                       \
37
4.93k
}
__wrap_EVP_PKEY_get_raw_public_key
Line
Count
Source
31
1.10k
type __wrap_##name args {                               \
32
1.10k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
8
                return (retval);                        \
34
8
        }                                                \
35
1.10k
                                                        \
36
1.10k
        return (__real_##name param);                       \
37
1.10k
}
__wrap_EVP_MD_CTX_new
Line
Count
Source
31
87
type __wrap_##name args {                               \
32
87
        if (prng_up && uniform_random(400) < (prob)) {       \
33
4
                return (retval);                        \
34
4
        }                                                \
35
87
                                                        \
36
87
        return (__real_##name param);                       \
37
87
}
__wrap_EVP_DigestVerifyInit
Line
Count
Source
31
83
type __wrap_##name args {                               \
32
83
        if (prng_up && uniform_random(400) < (prob)) {       \
33
4
                return (retval);                        \
34
4
        }                                                \
35
83
                                                        \
36
83
        return (__real_##name param);                       \
37
83
}
__wrap_BN_bin2bn
Line
Count
Source
31
15.5k
type __wrap_##name args {                               \
32
15.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
73
                return (retval);                        \
34
73
        }                                                \
35
15.5k
                                                        \
36
15.5k
        return (__real_##name param);                       \
37
15.5k
}
__wrap_BN_bn2bin
Line
Count
Source
31
14.2k
type __wrap_##name args {                               \
32
14.2k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
58
                return (retval);                        \
34
58
        }                                                \
35
14.2k
                                                        \
36
14.2k
        return (__real_##name param);                       \
37
14.2k
}
__wrap_BN_CTX_get
Line
Count
Source
31
19.1k
type __wrap_##name args {                               \
32
19.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
67
                return (retval);                        \
34
67
        }                                                \
35
19.1k
                                                        \
36
19.1k
        return (__real_##name param);                       \
37
19.1k
}
__wrap_BN_CTX_new
Line
Count
Source
31
11.1k
type __wrap_##name args {                               \
32
11.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
41
                return (retval);                        \
34
41
        }                                                \
35
11.1k
                                                        \
36
11.1k
        return (__real_##name param);                       \
37
11.1k
}
__wrap_BN_new
Line
Count
Source
31
1.09k
type __wrap_##name args {                               \
32
1.09k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
24
                return (retval);                        \
34
24
        }                                                \
35
1.09k
                                                        \
36
1.09k
        return (__real_##name param);                       \
37
1.09k
}
__wrap_RSA_set0_key
Line
Count
Source
31
509
type __wrap_##name args {                               \
32
509
        if (prng_up && uniform_random(400) < (prob)) {       \
33
11
                return (retval);                        \
34
11
        }                                                \
35
509
                                                        \
36
509
        return (__real_##name param);                       \
37
509
}
__wrap_EC_KEY_new_by_curve_name
Line
Count
Source
31
11.1k
type __wrap_##name args {                               \
32
11.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
37
                return (retval);                        \
34
37
        }                                                \
35
11.1k
                                                        \
36
11.1k
        return (__real_##name param);                       \
37
11.1k
}
__wrap_EC_KEY_get0_group
Line
Count
Source
31
12.8k
type __wrap_##name args {                               \
32
12.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
42
                return (retval);                        \
34
42
        }                                                \
35
12.8k
                                                        \
36
12.8k
        return (__real_##name param);                       \
37
12.8k
}
__wrap_EC_KEY_get0_private_key
Line
Count
Source
31
4.85k
type __wrap_##name args {                               \
32
4.85k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
17
                return (retval);                        \
34
17
        }                                                \
35
4.85k
                                                        \
36
4.85k
        return (__real_##name param);                       \
37
4.85k
}
__wrap_EC_POINT_new
Line
Count
Source
31
8.06k
type __wrap_##name args {                               \
32
8.06k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
29
                return (retval);                        \
34
29
        }                                                \
35
8.06k
                                                        \
36
8.06k
        return (__real_##name param);                       \
37
8.06k
}
__wrap_EC_POINT_get_affine_coordinates_GFp
Line
Count
Source
31
4.69k
type __wrap_##name args {                               \
32
4.69k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
16
                return (retval);                        \
34
16
        }                                                \
35
4.69k
                                                        \
36
4.69k
        return (__real_##name param);                       \
37
4.69k
}
__wrap_EVP_PKEY_new
Line
Count
Source
31
6.57k
type __wrap_##name args {                               \
32
6.57k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
30
                return (retval);                        \
34
30
        }                                                \
35
6.57k
                                                        \
36
6.57k
        return (__real_##name param);                       \
37
6.57k
}
__wrap_EVP_PKEY_assign
Line
Count
Source
31
6.54k
type __wrap_##name args {                               \
32
6.54k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
27
                return (retval);                        \
34
27
        }                                                \
35
6.54k
                                                        \
36
6.54k
        return (__real_##name param);                       \
37
6.54k
}
__wrap_EVP_PKEY_keygen_init
Line
Count
Source
31
4.90k
type __wrap_##name args {                               \
32
4.90k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
17
                return (retval);                        \
34
17
        }                                                \
35
4.90k
                                                        \
36
4.90k
        return (__real_##name param);                       \
37
4.90k
}
__wrap_EVP_PKEY_keygen
Line
Count
Source
31
4.88k
type __wrap_##name args {                               \
32
4.88k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
17
                return (retval);                        \
34
17
        }                                                \
35
4.88k
                                                        \
36
4.88k
        return (__real_##name param);                       \
37
4.88k
}
__wrap_EVP_PKEY_paramgen_init
Line
Count
Source
31
4.95k
type __wrap_##name args {                               \
32
4.95k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
21
                return (retval);                        \
34
21
        }                                                \
35
4.95k
                                                        \
36
4.95k
        return (__real_##name param);                       \
37
4.95k
}
__wrap_EVP_PKEY_paramgen
Line
Count
Source
31
4.93k
type __wrap_##name args {                               \
32
4.93k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
20
                return (retval);                        \
34
20
        }                                                \
35
4.93k
                                                        \
36
4.93k
        return (__real_##name param);                       \
37
4.93k
}
__wrap_EVP_PKEY_new_raw_public_key
Line
Count
Source
31
659
type __wrap_##name args {                               \
32
659
        if (prng_up && uniform_random(400) < (prob)) {       \
33
8
                return (retval);                        \
34
8
        }                                                \
35
659
                                                        \
36
659
        return (__real_##name param);                       \
37
659
}
__wrap_EVP_PKEY_CTX_new
Line
Count
Source
31
7.88k
type __wrap_##name args {                               \
32
7.88k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
25
                return (retval);                        \
34
25
        }                                                \
35
7.88k
                                                        \
36
7.88k
        return (__real_##name param);                       \
37
7.88k
}
__wrap_EVP_PKEY_CTX_new_id
Line
Count
Source
31
4.97k
type __wrap_##name args {                               \
32
4.97k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
19
                return (retval);                        \
34
19
        }                                                \
35
4.97k
                                                        \
36
4.97k
        return (__real_##name param);                       \
37
4.97k
}
__wrap_EVP_PKEY_derive_init
Line
Count
Source
31
2.96k
type __wrap_##name args {                               \
32
2.96k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
12
                return (retval);                        \
34
12
        }                                                \
35
2.96k
                                                        \
36
2.96k
        return (__real_##name param);                       \
37
2.96k
}
__wrap_EVP_PKEY_derive_set_peer
Line
Count
Source
31
2.94k
type __wrap_##name args {                               \
32
2.94k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
11
                return (retval);                        \
34
11
        }                                                \
35
2.94k
                                                        \
36
2.94k
        return (__real_##name param);                       \
37
2.94k
}
__wrap_EVP_sha256
Line
Count
Source
31
2.45k
type __wrap_##name args {                               \
32
2.45k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
13
                return (retval);                        \
34
13
        }                                                \
35
2.45k
                                                        \
36
2.45k
        return (__real_##name param);                       \
37
2.45k
}
__wrap_HMAC
Line
Count
Source
31
2.37k
type __wrap_##name args {                               \
32
2.37k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
9
                return (retval);                        \
34
9
        }                                                \
35
2.37k
                                                        \
36
2.37k
        return (__real_##name param);                       \
37
2.37k
}
__wrap_HMAC_CTX_new
Line
Count
Source
31
67
type __wrap_##name args {                               \
32
67
        if (prng_up && uniform_random(400) < (prob)) {       \
33
1
                return (retval);                        \
34
1
        }                                                \
35
67
                                                        \
36
67
        return (__real_##name param);                       \
37
67
}
__wrap_HMAC_Init_ex
Line
Count
Source
31
65
type __wrap_##name args {                               \
32
65
        if (prng_up && uniform_random(400) < (prob)) {       \
33
1
                return (retval);                        \
34
1
        }                                                \
35
65
                                                        \
36
65
        return (__real_##name param);                       \
37
65
}
__wrap_HMAC_Update
Line
Count
Source
31
127
type __wrap_##name args {                               \
32
127
        if (prng_up && uniform_random(400) < (prob)) {       \
33
2
                return (retval);                        \
34
2
        }                                                \
35
127
                                                        \
36
127
        return (__real_##name param);                       \
37
127
}
__wrap_HMAC_Final
Line
Count
Source
31
62
type __wrap_##name args {                               \
32
62
        if (prng_up && uniform_random(400) < (prob)) {       \
33
1
                return (retval);                        \
34
1
        }                                                \
35
62
                                                        \
36
62
        return (__real_##name param);                       \
37
62
}
__wrap_SHA256
Line
Count
Source
31
10.9k
type __wrap_##name args {                               \
32
10.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
61
                return (retval);                        \
34
61
        }                                                \
35
10.9k
                                                        \
36
10.9k
        return (__real_##name param);                       \
37
10.9k
}
__wrap_cbor_build_string
Line
Count
Source
31
113k
type __wrap_##name args {                               \
32
113k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
62
                return (retval);                        \
34
62
        }                                                \
35
113k
                                                        \
36
113k
        return (__real_##name param);                       \
37
113k
}
__wrap_cbor_build_bytestring
Line
Count
Source
31
48.3k
type __wrap_##name args {                               \
32
48.3k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
66
                return (retval);                        \
34
66
        }                                                \
35
48.3k
                                                        \
36
48.3k
        return (__real_##name param);                       \
37
48.3k
}
__wrap_cbor_build_bool
Line
Count
Source
31
918
type __wrap_##name args {                               \
32
918
        if (prng_up && uniform_random(400) < (prob)) {       \
33
2
                return (retval);                        \
34
2
        }                                                \
35
918
                                                        \
36
918
        return (__real_##name param);                       \
37
918
}
__wrap_cbor_build_negint8
Line
Count
Source
31
11.9k
type __wrap_##name args {                               \
32
11.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
40
                return (retval);                        \
34
40
        }                                                \
35
11.9k
                                                        \
36
11.9k
        return (__real_##name param);                       \
37
11.9k
}
__wrap_cbor_build_negint16
Line
Count
Source
31
189
type __wrap_##name args {                               \
32
189
        if (prng_up && uniform_random(400) < (prob)) {       \
33
3
                return (retval);                        \
34
3
        }                                                \
35
189
                                                        \
36
189
        return (__real_##name param);                       \
37
189
}
__wrap_cbor_load
Line
Count
Source
31
18.7k
type __wrap_##name args {                               \
32
18.7k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
97
                return (retval);                        \
34
97
        }                                                \
35
18.7k
                                                        \
36
18.7k
        return (__real_##name param);                       \
37
18.7k
}
__wrap_cbor_build_uint8
Line
Count
Source
31
74.6k
type __wrap_##name args {                               \
32
74.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
199
                return (retval);                        \
34
199
        }                                                \
35
74.6k
                                                        \
36
74.6k
        return (__real_##name param);                       \
37
74.6k
}
__wrap_cbor_build_uint32
Line
Count
Source
31
470
type __wrap_##name args {                               \
32
470
        if (prng_up && uniform_random(400) < (prob)) {       \
33
4
                return (retval);                        \
34
4
        }                                                \
35
470
                                                        \
36
470
        return (__real_##name param);                       \
37
470
}
__wrap_cbor_map_handle
Line
Count
Source
31
29.1k
type __wrap_##name args {                               \
32
29.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
72
                return (retval);                        \
34
72
        }                                                \
35
29.1k
                                                        \
36
29.1k
        return (__real_##name param);                       \
37
29.1k
}
__wrap_cbor_array_handle
Line
Count
Source
31
12.1k
type __wrap_##name args {                               \
32
12.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
26
                return (retval);                        \
34
26
        }                                                \
35
12.1k
                                                        \
36
12.1k
        return (__real_##name param);                       \
37
12.1k
}
__wrap_cbor_array_push
Line
Count
Source
31
33.5k
type __wrap_##name args {                               \
32
33.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
8
                return (retval);                        \
34
8
        }                                                \
35
33.5k
                                                        \
36
33.5k
        return (__real_##name param);                       \
37
33.5k
}
__wrap_cbor_map_add
Line
Count
Source
31
127k
type __wrap_##name args {                               \
32
127k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
147
                return (retval);                        \
34
147
        }                                                \
35
127k
                                                        \
36
127k
        return (__real_##name param);                       \
37
127k
}
__wrap_cbor_new_definite_map
Line
Count
Source
31
54.8k
type __wrap_##name args {                               \
32
54.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
64
                return (retval);                        \
34
64
        }                                                \
35
54.8k
                                                        \
36
54.8k
        return (__real_##name param);                       \
37
54.8k
}
__wrap_cbor_new_definite_array
Line
Count
Source
31
1.87k
type __wrap_##name args {                               \
32
1.87k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
5
                return (retval);                        \
34
5
        }                                                \
35
1.87k
                                                        \
36
1.87k
        return (__real_##name param);                       \
37
1.87k
}
__wrap_cbor_serialize_alloc
Line
Count
Source
31
16.6k
type __wrap_##name args {                               \
32
16.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
98
                return (retval);                        \
34
98
        }                                                \
35
16.6k
                                                        \
36
16.6k
        return (__real_##name param);                       \
37
16.6k
}
__wrap_fido_tx
Line
Count
Source
31
52.6k
type __wrap_##name args {                               \
32
52.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
33
175
                return (retval);                        \
34
175
        }                                                \
35
52.6k
                                                        \
36
52.6k
        return (__real_##name param);                       \
37
52.6k
}
__wrap_usleep
Line
Count
Source
31
702
type __wrap_##name args {                               \
32
702
        if (prng_up && uniform_random(400) < (prob)) {       \
33
3
                return (retval);                        \
34
3
        }                                                \
35
702
                                                        \
36
702
        return (__real_##name param);                       \
37
702
}
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
)