/src/openssl/include/internal/zeroization.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2026 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (the "License"). You may not use |
5 | | * this file except in compliance with the License. You can obtain a copy |
6 | | * in the file LICENSE in the source distribution or at |
7 | | * https://www.openssl.org/source/license.html |
8 | | */ |
9 | | |
10 | | /* |
11 | | * Utility functions for handling OPENSSL_PEDANTIC_ZEROIZATION. |
12 | | * |
13 | | * ISO 19790:2012/Cor.1:2015 7.9 requires cryptographic module to provide |
14 | | * methods to zeroise all unproctected security sensitive parameters |
15 | | * (which includes both Critical/Private and Public security parameters). |
16 | | * |
17 | | * To comply with these (arguably, unnecessarily onerous) requirements, |
18 | | * freeing of public parameters is done via ossl_public_security_param_free() |
19 | | * and ossl_public_security_param_bn_free() functions, and those implement |
20 | | * the required behaviour if OPENSSL_PEDANTIC_ZEROIZATION is defined. |
21 | | */ |
22 | | |
23 | | #ifndef OSSL_INTERNAL_ZEROIZATION_H |
24 | | #define OSSL_INTERNAL_ZEROIZATION_H |
25 | | |
26 | | #include <openssl/bn.h> |
27 | | #include <openssl/crypto.h> |
28 | | #include <openssl/e_os2.h> |
29 | | |
30 | | static ossl_unused ossl_inline void |
31 | | ossl_public_param_free(void *ptr, size_t size) |
32 | 0 | { |
33 | | #ifdef OPENSSL_PEDANTIC_ZEROIZATION |
34 | | OPENSSL_clear_free(ptr, size); |
35 | | #else |
36 | 0 | OPENSSL_free(ptr); |
37 | 0 | #endif |
38 | 0 | } Unexecuted instantiation: ffc_params.c:ossl_public_param_free Unexecuted instantiation: rsa_lib.c:ossl_public_param_free |
39 | | |
40 | | static ossl_unused ossl_inline void |
41 | | ossl_public_bn_free(BIGNUM *bn) |
42 | 102k | { |
43 | | #ifdef OPENSSL_PEDANTIC_ZEROIZATION |
44 | | BN_clear_free(bn); |
45 | | #else |
46 | 102k | BN_free(bn); |
47 | 102k | #endif |
48 | 102k | } Unexecuted instantiation: ffc_params.c:ossl_public_bn_free rsa_lib.c:ossl_public_bn_free Line | Count | Source | 42 | 102k | { | 43 | | #ifdef OPENSSL_PEDANTIC_ZEROIZATION | 44 | | BN_clear_free(bn); | 45 | | #else | 46 | 102k | BN_free(bn); | 47 | 102k | #endif | 48 | 102k | } |
|
49 | | |
50 | | #endif /* OSSL_INTERNAL_ZEROIZATION_H */ |