Coverage Report

Created: 2022-04-27 14:33

/libfido2/fuzz/wrap.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2019-2022 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 <sys/types.h>
8
#include <sys/socket.h>
9
10
#include <openssl/bn.h>
11
#include <openssl/evp.h>
12
#include <openssl/sha.h>
13
14
#include <cbor.h>
15
#include <stdbool.h>
16
#include <stdint.h>
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <zlib.h>
20
21
#include "mutator_aux.h"
22
23
extern int prng_up;
24
25
/*
26
 * Build wrappers around functions of interest, and have them fail
27
 * in a pseudo-random manner.
28
 */
29
30
#define WRAP(type, name, args, retval, param, prob)     \
31
extern type __wrap_##name args;                         \
32
extern type __real_##name args;                         \
33
9.44M
type __wrap_##name args {                               \
34
9.44M
        if (prng_up && uniform_random(400) < (prob)) {       \
35
25.0k
                return (retval);                        \
36
25.0k
        }                                                \
37
9.44M
                                                        \
38
9.44M
        return (__real_##name param);                       \
39
9.44M
}
__wrap_malloc
Line
Count
Source
33
488k
type __wrap_##name args {                               \
34
488k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
1.48k
                return (retval);                        \
36
1.48k
        }                                                \
37
488k
                                                        \
38
488k
        return (__real_##name param);                       \
39
488k
}
__wrap_calloc
Line
Count
Source
33
5.89M
type __wrap_##name args {                               \
34
5.89M
        if (prng_up && uniform_random(400) < (prob)) {       \
35
15.6k
                return (retval);                        \
36
15.6k
        }                                                \
37
5.89M
                                                        \
38
5.89M
        return (__real_##name param);                       \
39
5.89M
}
__wrap_realloc
Line
Count
Source
33
354
type __wrap_##name args {                               \
34
354
        if (prng_up && uniform_random(400) < (prob)) {       \
35
3
                return (retval);                        \
36
3
        }                                                \
37
354
                                                        \
38
354
        return (__real_##name param);                       \
39
354
}
__wrap_strdup
Line
Count
Source
33
1.35M
type __wrap_##name args {                               \
34
1.35M
        if (prng_up && uniform_random(400) < (prob)) {       \
35
3.43k
                return (retval);                        \
36
3.43k
        }                                                \
37
1.35M
                                                        \
38
1.35M
        return (__real_##name param);                       \
39
1.35M
}
__wrap_EVP_Cipher
Line
Count
Source
33
6.74k
type __wrap_##name args {                               \
34
6.74k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
21
                return (retval);                        \
36
21
        }                                                \
37
6.74k
                                                        \
38
6.74k
        return (__real_##name param);                       \
39
6.74k
}
__wrap_EVP_CIPHER_CTX_ctrl
Line
Count
Source
33
467
type __wrap_##name args {                               \
34
467
        if (prng_up && uniform_random(400) < (prob)) {       \
35
2
                return (retval);                        \
36
2
        }                                                \
37
467
                                                        \
38
467
        return (__real_##name param);                       \
39
467
}
__wrap_EVP_CIPHER_CTX_new
Line
Count
Source
33
5.87k
type __wrap_##name args {                               \
34
5.87k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
25
                return (retval);                        \
36
25
        }                                                \
37
5.87k
                                                        \
38
5.87k
        return (__real_##name param);                       \
39
5.87k
}
__wrap_EVP_CipherInit
Line
Count
Source
33
5.82k
type __wrap_##name args {                               \
34
5.82k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
17
                return (retval);                        \
36
17
        }                                                \
37
5.82k
                                                        \
38
5.82k
        return (__real_##name param);                       \
39
5.82k
}
Unexecuted instantiation: __wrap_EVP_PKEY_get0_RSA
__wrap_EVP_PKEY_get0_EC_KEY
Line
Count
Source
33
7.22k
type __wrap_##name args {                               \
34
7.22k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
36
                return (retval);                        \
36
36
        }                                                \
37
7.22k
                                                        \
38
7.22k
        return (__real_##name param);                       \
39
7.22k
}
__wrap_EVP_PKEY_get_raw_public_key
Line
Count
Source
33
2.73k
type __wrap_##name args {                               \
34
2.73k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
11
                return (retval);                        \
36
11
        }                                                \
37
2.73k
                                                        \
38
2.73k
        return (__real_##name param);                       \
39
2.73k
}
__wrap_EVP_MD_CTX_new
Line
Count
Source
33
444
type __wrap_##name args {                               \
34
444
        if (prng_up && uniform_random(400) < (prob)) {       \
35
12
                return (retval);                        \
36
12
        }                                                \
37
444
                                                        \
38
444
        return (__real_##name param);                       \
39
444
}
__wrap_EVP_DigestVerifyInit
Line
Count
Source
33
102
type __wrap_##name args {                               \
34
102
        if (prng_up && uniform_random(400) < (prob)) {       \
35
4
                return (retval);                        \
36
4
        }                                                \
37
102
                                                        \
38
102
        return (__real_##name param);                       \
39
102
}
__wrap_EVP_DigestInit_ex
Line
Count
Source
33
330
type __wrap_##name args {                               \
34
330
        if (prng_up && uniform_random(400) < (prob)) {       \
35
9
                return (retval);                        \
36
9
        }                                                \
37
330
                                                        \
38
330
        return (__real_##name param);                       \
39
330
}
__wrap_EVP_DigestUpdate
Line
Count
Source
33
914
type __wrap_##name args {                               \
34
914
        if (prng_up && uniform_random(400) < (prob)) {       \
35
22
                return (retval);                        \
36
22
        }                                                \
37
914
                                                        \
38
914
        return (__real_##name param);                       \
39
914
}
__wrap_EVP_DigestFinal_ex
Line
Count
Source
33
299
type __wrap_##name args {                               \
34
299
        if (prng_up && uniform_random(400) < (prob)) {       \
35
5
                return (retval);                        \
36
5
        }                                                \
37
299
                                                        \
38
299
        return (__real_##name param);                       \
39
299
}
__wrap_BN_bin2bn
Line
Count
Source
33
20.5k
type __wrap_##name args {                               \
34
20.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
94
                return (retval);                        \
36
94
        }                                                \
37
20.5k
                                                        \
38
20.5k
        return (__real_##name param);                       \
39
20.5k
}
__wrap_BN_bn2bin
Line
Count
Source
33
20.8k
type __wrap_##name args {                               \
34
20.8k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
103
                return (retval);                        \
36
103
        }                                                \
37
20.8k
                                                        \
38
20.8k
        return (__real_##name param);                       \
39
20.8k
}
__wrap_BN_CTX_get
Line
Count
Source
33
26.1k
type __wrap_##name args {                               \
34
26.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
134
                return (retval);                        \
36
134
        }                                                \
37
26.1k
                                                        \
38
26.1k
        return (__real_##name param);                       \
39
26.1k
}
__wrap_BN_CTX_new
Line
Count
Source
33
14.9k
type __wrap_##name args {                               \
34
14.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
56
                return (retval);                        \
36
56
        }                                                \
37
14.9k
                                                        \
38
14.9k
        return (__real_##name param);                       \
39
14.9k
}
__wrap_BN_new
Line
Count
Source
33
1.21k
type __wrap_##name args {                               \
34
1.21k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
26
                return (retval);                        \
36
26
        }                                                \
37
1.21k
                                                        \
38
1.21k
        return (__real_##name param);                       \
39
1.21k
}
__wrap_RSA_new
Line
Count
Source
33
571
type __wrap_##name args {                               \
34
571
        if (prng_up && uniform_random(400) < (prob)) {       \
35
5
                return (retval);                        \
36
5
        }                                                \
37
571
                                                        \
38
571
        return (__real_##name param);                       \
39
571
}
__wrap_RSA_set0_key
Line
Count
Source
33
566
type __wrap_##name args {                               \
34
566
        if (prng_up && uniform_random(400) < (prob)) {       \
35
14
                return (retval);                        \
36
14
        }                                                \
37
566
                                                        \
38
566
        return (__real_##name param);                       \
39
566
}
__wrap_RSA_pkey_ctx_ctrl
Line
Count
Source
33
136
type __wrap_##name args {                               \
34
136
        if (prng_up && uniform_random(400) < (prob)) {       \
35
4
                return (retval);                        \
36
4
        }                                                \
37
136
                                                        \
38
136
        return (__real_##name param);                       \
39
136
}
__wrap_EC_KEY_new_by_curve_name
Line
Count
Source
33
14.9k
type __wrap_##name args {                               \
34
14.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
54
                return (retval);                        \
36
54
        }                                                \
37
14.9k
                                                        \
38
14.9k
        return (__real_##name param);                       \
39
14.9k
}
__wrap_EC_KEY_get0_group
Line
Count
Source
33
11.3k
type __wrap_##name args {                               \
34
11.3k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
52
                return (retval);                        \
36
52
        }                                                \
37
11.3k
                                                        \
38
11.3k
        return (__real_##name param);                       \
39
11.3k
}
__wrap_EC_KEY_get0_private_key
Line
Count
Source
33
7.19k
type __wrap_##name args {                               \
34
7.19k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
31
                return (retval);                        \
36
31
        }                                                \
37
7.19k
                                                        \
38
7.19k
        return (__real_##name param);                       \
39
7.19k
}
__wrap_EC_POINT_new
Line
Count
Source
33
11.3k
type __wrap_##name args {                               \
34
11.3k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
63
                return (retval);                        \
36
63
        }                                                \
37
11.3k
                                                        \
38
11.3k
        return (__real_##name param);                       \
39
11.3k
}
__wrap_EC_POINT_get_affine_coordinates_GFp
Line
Count
Source
33
6.88k
type __wrap_##name args {                               \
34
6.88k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
29
                return (retval);                        \
36
29
        }                                                \
37
6.88k
                                                        \
38
6.88k
        return (__real_##name param);                       \
39
6.88k
}
__wrap_EVP_PKEY_new
Line
Count
Source
33
7.66k
type __wrap_##name args {                               \
34
7.66k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
31
                return (retval);                        \
36
31
        }                                                \
37
7.66k
                                                        \
38
7.66k
        return (__real_##name param);                       \
39
7.66k
}
__wrap_EVP_PKEY_assign
Line
Count
Source
33
7.63k
type __wrap_##name args {                               \
34
7.63k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
31
                return (retval);                        \
36
31
        }                                                \
37
7.63k
                                                        \
38
7.63k
        return (__real_##name param);                       \
39
7.63k
}
__wrap_EVP_PKEY_keygen_init
Line
Count
Source
33
7.29k
type __wrap_##name args {                               \
34
7.29k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
29
                return (retval);                        \
36
29
        }                                                \
37
7.29k
                                                        \
38
7.29k
        return (__real_##name param);                       \
39
7.29k
}
__wrap_EVP_PKEY_keygen
Line
Count
Source
33
7.26k
type __wrap_##name args {                               \
34
7.26k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
37
                return (retval);                        \
36
37
        }                                                \
37
7.26k
                                                        \
38
7.26k
        return (__real_##name param);                       \
39
7.26k
}
__wrap_EVP_PKEY_paramgen_init
Line
Count
Source
33
7.43k
type __wrap_##name args {                               \
34
7.43k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
41
                return (retval);                        \
36
41
        }                                                \
37
7.43k
                                                        \
38
7.43k
        return (__real_##name param);                       \
39
7.43k
}
__wrap_EVP_PKEY_paramgen
Line
Count
Source
33
7.36k
type __wrap_##name args {                               \
34
7.36k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
31
                return (retval);                        \
36
31
        }                                                \
37
7.36k
                                                        \
38
7.36k
        return (__real_##name param);                       \
39
7.36k
}
__wrap_EVP_PKEY_new_raw_public_key
Line
Count
Source
33
1.51k
type __wrap_##name args {                               \
34
1.51k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
16
                return (retval);                        \
36
16
        }                                                \
37
1.51k
                                                        \
38
1.51k
        return (__real_##name param);                       \
39
1.51k
}
__wrap_EVP_PKEY_CTX_new
Line
Count
Source
33
11.0k
type __wrap_##name args {                               \
34
11.0k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
56
                return (retval);                        \
36
56
        }                                                \
37
11.0k
                                                        \
38
11.0k
        return (__real_##name param);                       \
39
11.0k
}
__wrap_EVP_PKEY_CTX_new_id
Line
Count
Source
33
8.28k
type __wrap_##name args {                               \
34
8.28k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
41
                return (retval);                        \
36
41
        }                                                \
37
8.28k
                                                        \
38
8.28k
        return (__real_##name param);                       \
39
8.28k
}
__wrap_EVP_PKEY_derive
Line
Count
Source
33
7.63k
type __wrap_##name args {                               \
34
7.63k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
31
                return (retval);                        \
36
31
        }                                                \
37
7.63k
                                                        \
38
7.63k
        return (__real_##name param);                       \
39
7.63k
}
__wrap_EVP_PKEY_derive_init
Line
Count
Source
33
4.28k
type __wrap_##name args {                               \
34
4.28k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
22
                return (retval);                        \
36
22
        }                                                \
37
4.28k
                                                        \
38
4.28k
        return (__real_##name param);                       \
39
4.28k
}
__wrap_EVP_PKEY_derive_set_peer
Line
Count
Source
33
3.46k
type __wrap_##name args {                               \
34
3.46k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
12
                return (retval);                        \
36
12
        }                                                \
37
3.46k
                                                        \
38
3.46k
        return (__real_##name param);                       \
39
3.46k
}
__wrap_EVP_PKEY_verify_init
Line
Count
Source
33
185
type __wrap_##name args {                               \
34
185
        if (prng_up && uniform_random(400) < (prob)) {       \
35
6
                return (retval);                        \
36
6
        }                                                \
37
185
                                                        \
38
185
        return (__real_##name param);                       \
39
185
}
__wrap_EVP_PKEY_CTX_ctrl
Line
Count
Source
33
10.6k
type __wrap_##name args {                               \
34
10.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
84
                return (retval);                        \
36
84
        }                                                \
37
10.6k
                                                        \
38
10.6k
        return (__real_##name param);                       \
39
10.6k
}
__wrap_EVP_sha1
Line
Count
Source
33
26
type __wrap_##name args {                               \
34
26
        if (prng_up && uniform_random(400) < (prob)) {       \
35
0
                return (retval);                        \
36
0
        }                                                \
37
26
                                                        \
38
26
        return (__real_##name param);                       \
39
26
}
__wrap_EVP_sha256
Line
Count
Source
33
3.81k
type __wrap_##name args {                               \
34
3.81k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
37
                return (retval);                        \
36
37
        }                                                \
37
3.81k
                                                        \
38
3.81k
        return (__real_##name param);                       \
39
3.81k
}
__wrap_EVP_aes_256_cbc
Line
Count
Source
33
5.36k
type __wrap_##name args {                               \
34
5.36k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
17
                return (retval);                        \
36
17
        }                                                \
37
5.36k
                                                        \
38
5.36k
        return (__real_##name param);                       \
39
5.36k
}
__wrap_EVP_aes_256_gcm
Line
Count
Source
33
478
type __wrap_##name args {                               \
34
478
        if (prng_up && uniform_random(400) < (prob)) {       \
35
3
                return (retval);                        \
36
3
        }                                                \
37
478
                                                        \
38
478
        return (__real_##name param);                       \
39
478
}
__wrap_HMAC
Line
Count
Source
33
2.46k
type __wrap_##name args {                               \
34
2.46k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
12
                return (retval);                        \
36
12
        }                                                \
37
2.46k
                                                        \
38
2.46k
        return (__real_##name param);                       \
39
2.46k
}
__wrap_HMAC_CTX_new
Line
Count
Source
33
40
type __wrap_##name args {                               \
34
40
        if (prng_up && uniform_random(400) < (prob)) {       \
35
1
                return (retval);                        \
36
1
        }                                                \
37
40
                                                        \
38
40
        return (__real_##name param);                       \
39
40
}
__wrap_HMAC_Init_ex
Line
Count
Source
33
38
type __wrap_##name args {                               \
34
38
        if (prng_up && uniform_random(400) < (prob)) {       \
35
1
                return (retval);                        \
36
1
        }                                                \
37
38
                                                        \
38
38
        return (__real_##name param);                       \
39
38
}
__wrap_HMAC_Update
Line
Count
Source
33
73
type __wrap_##name args {                               \
34
73
        if (prng_up && uniform_random(400) < (prob)) {       \
35
2
                return (retval);                        \
36
2
        }                                                \
37
73
                                                        \
38
73
        return (__real_##name param);                       \
39
73
}
__wrap_HMAC_Final
Line
Count
Source
33
35
type __wrap_##name args {                               \
34
35
        if (prng_up && uniform_random(400) < (prob)) {       \
35
1
                return (retval);                        \
36
1
        }                                                \
37
35
                                                        \
38
35
        return (__real_##name param);                       \
39
35
}
__wrap_SHA1
Line
Count
Source
33
9
type __wrap_##name args {                               \
34
9
        if (prng_up && uniform_random(400) < (prob)) {       \
35
0
                return (retval);                        \
36
0
        }                                                \
37
9
                                                        \
38
9
        return (__real_##name param);                       \
39
9
}
__wrap_SHA256
Line
Count
Source
33
14.6k
type __wrap_##name args {                               \
34
14.6k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
72
                return (retval);                        \
36
72
        }                                                \
37
14.6k
                                                        \
38
14.6k
        return (__real_##name param);                       \
39
14.6k
}
__wrap_cbor_build_string
Line
Count
Source
33
156k
type __wrap_##name args {                               \
34
156k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
135
                return (retval);                        \
36
135
        }                                                \
37
156k
                                                        \
38
156k
        return (__real_##name param);                       \
39
156k
}
__wrap_cbor_build_bytestring
Line
Count
Source
33
56.5k
type __wrap_##name args {                               \
34
56.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
97
                return (retval);                        \
36
97
        }                                                \
37
56.5k
                                                        \
38
56.5k
        return (__real_##name param);                       \
39
56.5k
}
__wrap_cbor_build_bool
Line
Count
Source
33
2.90k
type __wrap_##name args {                               \
34
2.90k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
7
                return (retval);                        \
36
7
        }                                                \
37
2.90k
                                                        \
38
2.90k
        return (__real_##name param);                       \
39
2.90k
}
__wrap_cbor_build_negint8
Line
Count
Source
33
13.1k
type __wrap_##name args {                               \
34
13.1k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
56
                return (retval);                        \
36
56
        }                                                \
37
13.1k
                                                        \
38
13.1k
        return (__real_##name param);                       \
39
13.1k
}
__wrap_cbor_build_negint16
Line
Count
Source
33
278
type __wrap_##name args {                               \
34
278
        if (prng_up && uniform_random(400) < (prob)) {       \
35
1
                return (retval);                        \
36
1
        }                                                \
37
278
                                                        \
38
278
        return (__real_##name param);                       \
39
278
}
__wrap_cbor_load
Line
Count
Source
33
29.0k
type __wrap_##name args {                               \
34
29.0k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
75
                return (retval);                        \
36
75
        }                                                \
37
29.0k
                                                        \
38
29.0k
        return (__real_##name param);                       \
39
29.0k
}
__wrap_cbor_build_uint8
Line
Count
Source
33
98.5k
type __wrap_##name args {                               \
34
98.5k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
292
                return (retval);                        \
36
292
        }                                                \
37
98.5k
                                                        \
38
98.5k
        return (__real_##name param);                       \
39
98.5k
}
__wrap_cbor_build_uint16
Line
Count
Source
33
648
type __wrap_##name args {                               \
34
648
        if (prng_up && uniform_random(400) < (prob)) {       \
35
3
                return (retval);                        \
36
3
        }                                                \
37
648
                                                        \
38
648
        return (__real_##name param);                       \
39
648
}
__wrap_cbor_build_uint32
Line
Count
Source
33
460
type __wrap_##name args {                               \
34
460
        if (prng_up && uniform_random(400) < (prob)) {       \
35
4
                return (retval);                        \
36
4
        }                                                \
37
460
                                                        \
38
460
        return (__real_##name param);                       \
39
460
}
Unexecuted instantiation: __wrap_cbor_build_uint64
__wrap_cbor_map_handle
Line
Count
Source
33
54.4k
type __wrap_##name args {                               \
34
54.4k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
77
                return (retval);                        \
36
77
        }                                                \
37
54.4k
                                                        \
38
54.4k
        return (__real_##name param);                       \
39
54.4k
}
__wrap_cbor_array_handle
Line
Count
Source
33
32.9k
type __wrap_##name args {                               \
34
32.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
32
                return (retval);                        \
36
32
        }                                                \
37
32.9k
                                                        \
38
32.9k
        return (__real_##name param);                       \
39
32.9k
}
__wrap_cbor_array_push
Line
Count
Source
33
58.3k
type __wrap_##name args {                               \
34
58.3k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
64
                return (retval);                        \
36
64
        }                                                \
37
58.3k
                                                        \
38
58.3k
        return (__real_##name param);                       \
39
58.3k
}
__wrap_cbor_map_add
Line
Count
Source
33
156k
type __wrap_##name args {                               \
34
156k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
194
                return (retval);                        \
36
194
        }                                                \
37
156k
                                                        \
38
156k
        return (__real_##name param);                       \
39
156k
}
__wrap_cbor_new_definite_map
Line
Count
Source
33
69.9k
type __wrap_##name args {                               \
34
69.9k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
125
                return (retval);                        \
36
125
        }                                                \
37
69.9k
                                                        \
38
69.9k
        return (__real_##name param);                       \
39
69.9k
}
__wrap_cbor_new_definite_array
Line
Count
Source
33
3.67k
type __wrap_##name args {                               \
34
3.67k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
16
                return (retval);                        \
36
16
        }                                                \
37
3.67k
                                                        \
38
3.67k
        return (__real_##name param);                       \
39
3.67k
}
__wrap_cbor_new_definite_bytestring
Line
Count
Source
33
134
type __wrap_##name args {                               \
34
134
        if (prng_up && uniform_random(400) < (prob)) {       \
35
2
                return (retval);                        \
36
2
        }                                                \
37
134
                                                        \
38
134
        return (__real_##name param);                       \
39
134
}
__wrap_cbor_serialize_alloc
Line
Count
Source
33
23.3k
type __wrap_##name args {                               \
34
23.3k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
83
                return (retval);                        \
36
83
        }                                                \
37
23.3k
                                                        \
38
23.3k
        return (__real_##name param);                       \
39
23.3k
}
__wrap_fido_tx
Line
Count
Source
33
114k
type __wrap_##name args {                               \
34
114k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
362
                return (retval);                        \
36
362
        }                                                \
37
114k
                                                        \
38
114k
        return (__real_##name param);                       \
39
114k
}
__wrap_bind
Line
Count
Source
33
551k
type __wrap_##name args {                               \
34
551k
        if (prng_up && uniform_random(400) < (prob)) {       \
35
1.41k
                return (retval);                        \
36
1.41k
        }                                                \
37
551k
                                                        \
38
551k
        return (__real_##name param);                       \
39
551k
}
__wrap_deflateInit2_
Line
Count
Source
33
388
type __wrap_##name args {                               \
34
388
        if (prng_up && uniform_random(400) < (prob)) {       \
35
5
                return (retval);                        \
36
5
        }                                                \
37
388
                                                        \
38
388
        return (__real_##name param);                       \
39
388
}
40
41
WRAP(void *,
42
        malloc,
43
        (size_t size),
44
        NULL,
45
        (size),
46
        1
47
)
48
49
WRAP(void *,
50
        calloc,
51
        (size_t nmemb, size_t size),
52
        NULL,
53
        (nmemb, size),
54
        1
55
)
56
57
WRAP(void *,
58
        realloc,
59
        (void *ptr, size_t size),
60
        NULL,
61
        (ptr, size),
62
        1
63
)
64
65
WRAP(char *,
66
        strdup,
67
        (const char *s),
68
        NULL,
69
        (s),
70
        1
71
)
72
73
WRAP(int,
74
        EVP_Cipher,
75
        (EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in,
76
            unsigned int inl),
77
        -1,
78
        (ctx, out, in, inl),
79
        1
80
)
81
82
WRAP(int,
83
        EVP_CIPHER_CTX_ctrl,
84
        (EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr),
85
        0,
86
        (ctx, type, arg, ptr),
87
        1
88
)
89
90
WRAP(EVP_CIPHER_CTX *,
91
        EVP_CIPHER_CTX_new,
92
        (void),
93
        NULL,
94
        (),
95
        1
96
)
97
98
WRAP(int,
99
        EVP_CipherInit,
100
        (EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
101
            const unsigned char *key, const unsigned char *iv, int enc),
102
        0,
103
        (ctx, cipher, key, iv, enc),
104
        1
105
)
106
107
WRAP(RSA *,
108
        EVP_PKEY_get0_RSA,
109
        (EVP_PKEY *pkey),
110
        NULL,
111
        (pkey),
112
        1
113
)
114
115
WRAP(EC_KEY *,
116
        EVP_PKEY_get0_EC_KEY,
117
        (EVP_PKEY *pkey),
118
        NULL,
119
        (pkey),
120
        1
121
)
122
123
WRAP(int,
124
        EVP_PKEY_get_raw_public_key,
125
        (const EVP_PKEY *pkey, unsigned char *pub, size_t *len),
126
        0,
127
        (pkey, pub, len),
128
        1
129
)
130
131
WRAP(EVP_MD_CTX *,
132
        EVP_MD_CTX_new,
133
        (void),
134
        NULL,
135
        (),
136
        1
137
)
138
139
WRAP(int,
140
        EVP_DigestVerifyInit,
141
        (EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e,
142
            EVP_PKEY *pkey),
143
        0,
144
        (ctx, pctx, type, e, pkey),
145
        1
146
)
147
148
WRAP(int,
149
        EVP_DigestInit_ex,
150
        (EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl),
151
        0,
152
        (ctx, type, impl),
153
        1
154
)
155
156
WRAP(int,
157
        EVP_DigestUpdate,
158
        (EVP_MD_CTX *ctx, const void *data, size_t count),
159
        0,
160
        (ctx, data, count),
161
        1
162
)
163
164
WRAP(int,
165
        EVP_DigestFinal_ex,
166
        (EVP_MD_CTX *ctx, unsigned char *md, unsigned int *isize),
167
        0,
168
        (ctx, md, isize),
169
        1
170
)
171
172
WRAP(BIGNUM *,
173
        BN_bin2bn,
174
        (const unsigned char *s, int len, BIGNUM *ret),
175
        NULL,
176
        (s, len, ret),
177
        1
178
)
179
180
WRAP(int,
181
        BN_bn2bin,
182
        (const BIGNUM *a, unsigned char *to),
183
        -1,
184
        (a, to),
185
        1
186
)
187
188
WRAP(BIGNUM *,
189
        BN_CTX_get,
190
        (BN_CTX *ctx),
191
        NULL,
192
        (ctx),
193
        1
194
)
195
196
WRAP(BN_CTX *,
197
        BN_CTX_new,
198
        (void),
199
        NULL,
200
        (),
201
        1
202
)
203
204
WRAP(BIGNUM *,
205
        BN_new,
206
        (void),
207
        NULL,
208
        (),
209
        1
210
)
211
212
WRAP(RSA *,
213
        RSA_new,
214
        (void),
215
        NULL,
216
        (),
217
        1
218
)
219
220
WRAP(int,
221
        RSA_set0_key,
222
        (RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d),
223
        0,
224
        (r, n, e, d),
225
        1
226
)
227
228
WRAP(int,
229
        RSA_pkey_ctx_ctrl,
230
        (EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2),
231
        -1,
232
        (ctx, optype, cmd, p1, p2),
233
        1
234
)
235
236
WRAP(EC_KEY *,
237
        EC_KEY_new_by_curve_name,
238
        (int nid),
239
        NULL,
240
        (nid),
241
        1
242
)
243
244
WRAP(const EC_GROUP *,
245
        EC_KEY_get0_group,
246
        (const EC_KEY *key),
247
        NULL,
248
        (key),
249
        1
250
)
251
252
WRAP(const BIGNUM *,
253
        EC_KEY_get0_private_key,
254
        (const EC_KEY *key),
255
        NULL,
256
        (key),
257
        1
258
)
259
260
WRAP(EC_POINT *,
261
        EC_POINT_new,
262
        (const EC_GROUP *group),
263
        NULL,
264
        (group),
265
        1
266
)
267
268
WRAP(int,
269
        EC_POINT_get_affine_coordinates_GFp,
270
        (const EC_GROUP *group, const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx),
271
        0,
272
        (group, p, x, y, ctx),
273
        1
274
)
275
276
WRAP(EVP_PKEY *,
277
        EVP_PKEY_new,
278
        (void),
279
        NULL,
280
        (),
281
        1
282
)
283
284
WRAP(int,
285
        EVP_PKEY_assign,
286
        (EVP_PKEY *pkey, int type, void *key),
287
        0,
288
        (pkey, type, key),
289
        1
290
)
291
292
WRAP(int,
293
        EVP_PKEY_keygen_init,
294
        (EVP_PKEY_CTX *ctx),
295
        0,
296
        (ctx),
297
        1
298
)
299
300
WRAP(int,
301
        EVP_PKEY_keygen,
302
        (EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey),
303
        0,
304
        (ctx, ppkey),
305
        1
306
)
307
308
WRAP(int,
309
        EVP_PKEY_paramgen_init,
310
        (EVP_PKEY_CTX *ctx),
311
        0,
312
        (ctx),
313
        1
314
)
315
316
WRAP(int,
317
        EVP_PKEY_paramgen,
318
        (EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey),
319
        0,
320
        (ctx, ppkey),
321
        1
322
)
323
324
WRAP(EVP_PKEY *,
325
        EVP_PKEY_new_raw_public_key,
326
        (int type, ENGINE *e, const unsigned char *key, size_t keylen),
327
        NULL,
328
        (type, e, key, keylen),
329
        1
330
)
331
332
WRAP(EVP_PKEY_CTX *,
333
        EVP_PKEY_CTX_new,
334
        (EVP_PKEY *pkey, ENGINE *e),
335
        NULL,
336
        (pkey, e),
337
        1
338
)
339
340
WRAP(EVP_PKEY_CTX *,
341
        EVP_PKEY_CTX_new_id,
342
        (int id, ENGINE *e),
343
        NULL,
344
        (id, e),
345
        1
346
)
347
348
WRAP(int,
349
        EVP_PKEY_derive,
350
        (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen),
351
        0,
352
        (ctx, key, pkeylen),
353
        1
354
)
355
356
WRAP(int,
357
        EVP_PKEY_derive_init,
358
        (EVP_PKEY_CTX *ctx),
359
        0,
360
        (ctx),
361
        1
362
)
363
364
WRAP(int,
365
        EVP_PKEY_derive_set_peer,
366
        (EVP_PKEY_CTX *ctx, EVP_PKEY *peer),
367
        0,
368
        (ctx, peer),
369
        1
370
)
371
372
WRAP(int,
373
        EVP_PKEY_verify_init,
374
        (EVP_PKEY_CTX *ctx),
375
        0,
376
        (ctx),
377
        1
378
)
379
380
WRAP(int,
381
        EVP_PKEY_CTX_ctrl,
382
        (EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, void *p2),
383
        -1,
384
        (ctx, keytype, optype, cmd, p1, p2),
385
        1
386
)
387
388
WRAP(const EVP_MD *,
389
        EVP_sha1,
390
        (void),
391
        NULL,
392
        (),
393
        1
394
)
395
396
WRAP(const EVP_MD *,
397
        EVP_sha256,
398
        (void),
399
        NULL,
400
        (),
401
        1
402
)
403
404
WRAP(const EVP_CIPHER *,
405
        EVP_aes_256_cbc,
406
        (void),
407
        NULL,
408
        (),
409
        1
410
)
411
412
WRAP(const EVP_CIPHER *,
413
        EVP_aes_256_gcm,
414
        (void),
415
        NULL,
416
        (),
417
        1
418
)
419
420
WRAP(unsigned char *,
421
        HMAC,
422
        (const EVP_MD *evp_md, const void *key, int key_len,
423
            const unsigned char *d, int n, unsigned char *md,
424
            unsigned int *md_len),
425
        NULL,
426
        (evp_md, key, key_len, d, n, md, md_len),
427
        1
428
)
429
430
WRAP(HMAC_CTX *,
431
        HMAC_CTX_new,
432
        (void),
433
        NULL,
434
        (),
435
        1
436
)
437
438
WRAP(int,
439
        HMAC_Init_ex,
440
        (HMAC_CTX *ctx, const void *key, int key_len, const EVP_MD *md,
441
            ENGINE *impl),
442
        0,
443
        (ctx, key, key_len, md, impl),
444
        1
445
)
446
447
WRAP(int,
448
        HMAC_Update,
449
        (HMAC_CTX *ctx, const unsigned char *data, int len),
450
        0,
451
        (ctx, data, len),
452
        1
453
)
454
455
WRAP(int,
456
        HMAC_Final,
457
        (HMAC_CTX *ctx, unsigned char *md, unsigned int *len),
458
        0,
459
        (ctx, md, len),
460
        1
461
)
462
463
WRAP(unsigned char *,
464
        SHA1,
465
        (const unsigned char *d, size_t n, unsigned char *md),
466
        NULL,
467
        (d, n, md),
468
        1
469
)
470
471
WRAP(unsigned char *,
472
        SHA256,
473
        (const unsigned char *d, size_t n, unsigned char *md),
474
        NULL,
475
        (d, n, md),
476
        1
477
)
478
479
WRAP(cbor_item_t *,
480
        cbor_build_string,
481
        (const char *val),
482
        NULL,
483
        (val),
484
        1
485
)
486
487
WRAP(cbor_item_t *,
488
        cbor_build_bytestring,
489
        (cbor_data handle, size_t length),
490
        NULL,
491
        (handle, length),
492
        1
493
)
494
495
WRAP(cbor_item_t *,
496
        cbor_build_bool,
497
        (bool value),
498
        NULL,
499
        (value),
500
        1
501
)
502
503
WRAP(cbor_item_t *,
504
        cbor_build_negint8,
505
        (uint8_t value),
506
        NULL,
507
        (value),
508
        1
509
)
510
511
WRAP(cbor_item_t *,
512
        cbor_build_negint16,
513
        (uint16_t value),
514
        NULL,
515
        (value),
516
        1
517
)
518
519
WRAP(cbor_item_t *,
520
        cbor_load,
521
        (cbor_data source, size_t source_size, struct cbor_load_result *result),
522
        NULL,
523
        (source, source_size, result),
524
        1
525
)
526
527
WRAP(cbor_item_t *,
528
        cbor_build_uint8,
529
        (uint8_t value),
530
        NULL,
531
        (value),
532
        1
533
)
534
535
WRAP(cbor_item_t *,
536
        cbor_build_uint16,
537
        (uint16_t value),
538
        NULL,
539
        (value),
540
        1
541
)
542
543
WRAP(cbor_item_t *,
544
        cbor_build_uint32,
545
        (uint32_t value),
546
        NULL,
547
        (value),
548
        1
549
)
550
551
WRAP(cbor_item_t *,
552
        cbor_build_uint64,
553
        (uint64_t value),
554
        NULL,
555
        (value),
556
        1
557
)
558
559
WRAP(struct cbor_pair *,
560
        cbor_map_handle,
561
        (const cbor_item_t *item),
562
        NULL,
563
        (item),
564
        1
565
)
566
567
WRAP(cbor_item_t **,
568
        cbor_array_handle,
569
        (const cbor_item_t *item),
570
        NULL,
571
        (item),
572
        1
573
)
574
575
WRAP(bool,
576
        cbor_array_push,
577
        (cbor_item_t *array, cbor_item_t *pushee),
578
        false,
579
        (array, pushee),
580
        1
581
)
582
583
WRAP(bool,
584
        cbor_map_add,
585
        (cbor_item_t *item, struct cbor_pair pair),
586
        false,
587
        (item, pair),
588
        1
589
)
590
591
WRAP(cbor_item_t *,
592
        cbor_new_definite_map,
593
        (size_t size),
594
        NULL,
595
        (size),
596
        1
597
)
598
599
WRAP(cbor_item_t *,
600
        cbor_new_definite_array,
601
        (size_t size),
602
        NULL,
603
        (size),
604
        1
605
)
606
607
WRAP(cbor_item_t *,
608
        cbor_new_definite_bytestring,
609
        (void),
610
        NULL,
611
        (),
612
        1
613
)
614
615
WRAP(size_t,
616
        cbor_serialize_alloc,
617
        (const cbor_item_t *item, cbor_mutable_data *buffer,
618
            size_t *buffer_size),
619
        0,
620
        (item, buffer, buffer_size),
621
        1
622
)
623
624
WRAP(int,
625
        fido_tx,
626
        (fido_dev_t *d, uint8_t cmd, const void *buf, size_t count, int *ms),
627
        -1,
628
        (d, cmd, buf, count, ms),
629
        1
630
)
631
632
WRAP(int,
633
        bind,
634
        (int sockfd, const struct sockaddr *addr, socklen_t addrlen),
635
        -1,
636
        (sockfd, addr, addrlen),
637
        1
638
)
639
640
WRAP(int,
641
        deflateInit2_,
642
        (z_streamp strm, int level, int method, int windowBits, int memLevel,
643
            int strategy, const char *version, int stream_size),
644
        Z_STREAM_ERROR,
645
        (strm, level, method, windowBits, memLevel, strategy, version,
646
            stream_size),
647
        1
648
)
649
650
int __wrap_deflate(z_streamp, int);
651
int __real_deflate(z_streamp, int);
652
653
int
654
__wrap_deflate(z_streamp strm, int flush)
655
379
{
656
379
        if (uniform_random(400) < 1) {
657
1
                return Z_BUF_ERROR;
658
1
        }
659
        /* should never happen, but we check for it */
660
378
        if (uniform_random(400) < 1) {
661
1
                strm->avail_out = UINT_MAX;
662
1
                return Z_STREAM_END;
663
1
        }
664
665
377
        return __real_deflate(strm, flush);
666
378
}
667
668
int __wrap_asprintf(char **, const char *, ...);
669
670
int
671
__wrap_asprintf(char **strp, const char *fmt, ...)
672
559k
{
673
559k
        va_list ap;
674
559k
        int r;
675
676
559k
        if (uniform_random(400) < 1) {
677
1.42k
                *strp = (void *)0xdeadbeef;
678
1.42k
                return -1;
679
1.42k
        }
680
681
558k
        va_start(ap, fmt);
682
558k
        r = vasprintf(strp, fmt, ap);
683
558k
        va_end(ap);
684
685
558k
        return r;
686
559k
}