/src/liboqs/src/kem/bike/additional_r4/cleanup.h
Line | Count | Source |
1 | | /* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
2 | | * SPDX-License-Identifier: Apache-2.0" |
3 | | * |
4 | | * Written by Nir Drucker, Shay Gueron and Dusan Kostic, |
5 | | * AWS Cryptographic Algorithms Group. |
6 | | */ |
7 | | |
8 | | #pragma once |
9 | | |
10 | | #include <oqs/common.h> |
11 | | |
12 | | #include "utilities.h" |
13 | | |
14 | | /* Runs _thecleanup function on _thealloc once _thealloc went out of scope */ |
15 | | #define DEFER_CLEANUP(_thealloc, _thecleanup) \ |
16 | 0 | __attribute__((cleanup(_thecleanup))) _thealloc |
17 | | |
18 | | /* Create a cleanup function for pointers from function func, which accepts a |
19 | | * pointer. This is useful for DEFER_CLEANUP, as it passes &_thealloc into |
20 | | * _thecleanup function. This way, |
21 | | * if _thealloc is a pointer _thecleanup would receive a pointer to a |
22 | | * pointer.*/ |
23 | | #define DEFINE_POINTER_CLEANUP_FUNC(type, func) \ |
24 | | static inline void func##_pointer((type)*p) \ |
25 | | { \ |
26 | | if(p && *p) { \ |
27 | | func(*p); \ |
28 | | } \ |
29 | | } \ |
30 | | struct __useless_struct_to_allow_trailing_semicolon__ |
31 | | |
32 | | // len is bytes length of in |
33 | 0 | #define secure_clean OQS_MEM_cleanse |
34 | | |
35 | | #define CLEANUP_FUNC(name, type) \ |
36 | | _INLINE_ void name##_cleanup(IN OUT type *o) \ |
37 | 0 | { \ |
38 | 0 | secure_clean((uint8_t *)o, sizeof(*o)); \ |
39 | 0 | } Unexecuted instantiation: kem.c:sk_cleanup Unexecuted instantiation: kem.c:pad_r_cleanup Unexecuted instantiation: kem.c:seed_cleanup Unexecuted instantiation: kem.c:m_cleanup Unexecuted instantiation: kem.c:ss_cleanup Unexecuted instantiation: kem.c:pad_e_cleanup Unexecuted instantiation: kem.c:func_k_cleanup Unexecuted instantiation: kem.c:e_cleanup Unexecuted instantiation: kem.c:r_cleanup Unexecuted instantiation: kem.c:ct_cleanup Unexecuted instantiation: kem.c:syndrome_cleanup Unexecuted instantiation: kem.c:upc_cleanup Unexecuted instantiation: kem.c:dbl_pad_r_cleanup Unexecuted instantiation: sampling.c:r_cleanup Unexecuted instantiation: sampling.c:m_cleanup Unexecuted instantiation: sampling.c:e_cleanup Unexecuted instantiation: sampling.c:sk_cleanup Unexecuted instantiation: sampling.c:ss_cleanup Unexecuted instantiation: sampling.c:ct_cleanup Unexecuted instantiation: sampling.c:pad_r_cleanup Unexecuted instantiation: sampling.c:pad_e_cleanup Unexecuted instantiation: sampling.c:seed_cleanup Unexecuted instantiation: sampling.c:syndrome_cleanup Unexecuted instantiation: sampling.c:upc_cleanup Unexecuted instantiation: sampling.c:func_k_cleanup Unexecuted instantiation: sampling.c:dbl_pad_r_cleanup Unexecuted instantiation: decode.c:pad_r_cleanup Unexecuted instantiation: decode.c:e_cleanup Unexecuted instantiation: decode.c:syndrome_cleanup Unexecuted instantiation: decode.c:upc_cleanup Unexecuted instantiation: decode.c:r_cleanup Unexecuted instantiation: decode.c:m_cleanup Unexecuted instantiation: decode.c:sk_cleanup Unexecuted instantiation: decode.c:ss_cleanup Unexecuted instantiation: decode.c:ct_cleanup Unexecuted instantiation: decode.c:pad_e_cleanup Unexecuted instantiation: decode.c:seed_cleanup Unexecuted instantiation: decode.c:func_k_cleanup Unexecuted instantiation: decode.c:dbl_pad_r_cleanup Unexecuted instantiation: gf2x_inv.c:pad_r_cleanup Unexecuted instantiation: gf2x_inv.c:dbl_pad_r_cleanup Unexecuted instantiation: gf2x_inv.c:r_cleanup Unexecuted instantiation: gf2x_inv.c:m_cleanup Unexecuted instantiation: gf2x_inv.c:e_cleanup Unexecuted instantiation: gf2x_inv.c:sk_cleanup Unexecuted instantiation: gf2x_inv.c:ss_cleanup Unexecuted instantiation: gf2x_inv.c:ct_cleanup Unexecuted instantiation: gf2x_inv.c:pad_e_cleanup Unexecuted instantiation: gf2x_inv.c:seed_cleanup Unexecuted instantiation: gf2x_inv.c:syndrome_cleanup Unexecuted instantiation: gf2x_inv.c:upc_cleanup Unexecuted instantiation: gf2x_inv.c:func_k_cleanup Unexecuted instantiation: gf2x_mul.c:dbl_pad_r_cleanup Unexecuted instantiation: gf2x_mul.c:r_cleanup Unexecuted instantiation: gf2x_mul.c:m_cleanup Unexecuted instantiation: gf2x_mul.c:e_cleanup Unexecuted instantiation: gf2x_mul.c:sk_cleanup Unexecuted instantiation: gf2x_mul.c:ss_cleanup Unexecuted instantiation: gf2x_mul.c:ct_cleanup Unexecuted instantiation: gf2x_mul.c:pad_r_cleanup Unexecuted instantiation: gf2x_mul.c:pad_e_cleanup Unexecuted instantiation: gf2x_mul.c:seed_cleanup Unexecuted instantiation: gf2x_mul.c:syndrome_cleanup Unexecuted instantiation: gf2x_mul.c:upc_cleanup Unexecuted instantiation: gf2x_mul.c:func_k_cleanup Unexecuted instantiation: gf2x_mul_portable.c:r_cleanup Unexecuted instantiation: gf2x_mul_portable.c:m_cleanup Unexecuted instantiation: gf2x_mul_portable.c:e_cleanup Unexecuted instantiation: gf2x_mul_portable.c:sk_cleanup Unexecuted instantiation: gf2x_mul_portable.c:ss_cleanup Unexecuted instantiation: gf2x_mul_portable.c:ct_cleanup Unexecuted instantiation: gf2x_mul_portable.c:pad_r_cleanup Unexecuted instantiation: gf2x_mul_portable.c:pad_e_cleanup Unexecuted instantiation: gf2x_mul_portable.c:seed_cleanup Unexecuted instantiation: gf2x_mul_portable.c:syndrome_cleanup Unexecuted instantiation: gf2x_mul_portable.c:upc_cleanup Unexecuted instantiation: gf2x_mul_portable.c:func_k_cleanup Unexecuted instantiation: gf2x_mul_portable.c:dbl_pad_r_cleanup Unexecuted instantiation: shake_prf.c:r_cleanup Unexecuted instantiation: shake_prf.c:m_cleanup Unexecuted instantiation: shake_prf.c:e_cleanup Unexecuted instantiation: shake_prf.c:sk_cleanup Unexecuted instantiation: shake_prf.c:ss_cleanup Unexecuted instantiation: shake_prf.c:ct_cleanup Unexecuted instantiation: shake_prf.c:pad_r_cleanup Unexecuted instantiation: shake_prf.c:pad_e_cleanup Unexecuted instantiation: shake_prf.c:seed_cleanup Unexecuted instantiation: shake_prf.c:syndrome_cleanup Unexecuted instantiation: shake_prf.c:upc_cleanup Unexecuted instantiation: shake_prf.c:func_k_cleanup Unexecuted instantiation: shake_prf.c:dbl_pad_r_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:r_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:m_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:e_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:sk_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:ss_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:ct_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:pad_r_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:pad_e_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:seed_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:syndrome_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:upc_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:func_k_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:dbl_pad_r_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:r_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:m_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:e_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:sk_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:ss_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:ct_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:pad_r_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:pad_e_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:seed_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:syndrome_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:upc_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:func_k_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:dbl_pad_r_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:r_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:m_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:e_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:sk_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:ss_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:ct_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:pad_r_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:pad_e_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:seed_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:syndrome_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:upc_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:func_k_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:dbl_pad_r_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:r_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:m_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:e_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:sk_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:ss_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:ct_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:pad_r_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:pad_e_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:seed_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:syndrome_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:upc_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:func_k_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:dbl_pad_r_cleanup |
40 | | |
41 | | CLEANUP_FUNC(r, r_t) |
42 | | CLEANUP_FUNC(m, m_t) |
43 | | CLEANUP_FUNC(e, e_t) |
44 | | CLEANUP_FUNC(sk, sk_t) |
45 | | CLEANUP_FUNC(ss, ss_t) |
46 | | CLEANUP_FUNC(ct, ct_t) |
47 | | CLEANUP_FUNC(pad_r, pad_r_t) |
48 | | CLEANUP_FUNC(pad_e, pad_e_t) |
49 | | CLEANUP_FUNC(seed, seed_t) |
50 | | CLEANUP_FUNC(syndrome, syndrome_t) |
51 | | CLEANUP_FUNC(upc, upc_t) |
52 | | CLEANUP_FUNC(func_k, func_k_t) |
53 | | CLEANUP_FUNC(dbl_pad_r, dbl_pad_r_t) |
54 | | |
55 | | // The functions below require special handling because we deal |
56 | | // with arrays and not structures. |
57 | | |
58 | | _INLINE_ void compressed_idx_d_ar_cleanup(IN OUT compressed_idx_d_ar_t *o) |
59 | 0 | { |
60 | 0 | for(int i = 0; i < N0; i++) { |
61 | 0 | secure_clean((uint8_t *)&(*o)[i], sizeof((*o)[0])); |
62 | 0 | } |
63 | 0 | } Unexecuted instantiation: kem.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: sampling.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: decode.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: gf2x_inv.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: gf2x_mul.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: gf2x_mul_portable.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: shake_prf.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:compressed_idx_d_ar_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:compressed_idx_d_ar_cleanup |
64 | | |
65 | | _INLINE_ void seeds_cleanup(IN OUT seeds_t *o) |
66 | 0 | { |
67 | 0 | for(int i = 0; i < NUM_OF_SEEDS; i++) { |
68 | 0 | seed_cleanup(&(o->seed[i])); |
69 | 0 | } |
70 | 0 | } Unexecuted instantiation: kem.c:seeds_cleanup Unexecuted instantiation: sampling.c:seeds_cleanup Unexecuted instantiation: decode.c:seeds_cleanup Unexecuted instantiation: gf2x_inv.c:seeds_cleanup Unexecuted instantiation: gf2x_mul.c:seeds_cleanup Unexecuted instantiation: gf2x_mul_portable.c:seeds_cleanup Unexecuted instantiation: shake_prf.c:seeds_cleanup Unexecuted instantiation: gf2x_ksqr_avx2.c:seeds_cleanup Unexecuted instantiation: gf2x_mul_avx2.c:seeds_cleanup Unexecuted instantiation: gf2x_ksqr_avx512.c:seeds_cleanup Unexecuted instantiation: gf2x_mul_avx512.c:seeds_cleanup |