Debian Codegraph @

tests/external_override/mlkem768_override.c

raw
1 /*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2021 - 2025 Red Hat, Inc.
5 *
6 * Authors: Anderson Toshiyuki Sasaki
7 * Jakub Jelen <[email protected]>
8 *
9 * The SSH Library is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation, either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * The SSH Library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with the SSH Library; see the file COPYING. If not,
21 * see <https://www.gnu.org/licenses/>.
22 */
23
24 #include "config.h"
25
26 #include <stdint.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29
30 #include <libssh/priv.h>
31
32 #include "libssh/mlkem_native.h"
33 #include "mlkem768_override.h"
34
35 static bool internal_function_called = false;
36
37 libcrux_ml_kem_mlkem768_MlKem768KeyPair
38 __wrap_libcrux_ml_kem_mlkem768_portable_generate_key_pair(
39 uint8_t randomness[64U])
40 {
41 fprintf(stderr, "%s: Internal implementation was called\n", __func__);
42 internal_function_called = true;
43 return libcrux_ml_kem_mlkem768_portable_generate_key_pair(randomness);
44 }
45
46 bool __wrap_libcrux_ml_kem_mlkem768_portable_validate_public_key(
47 libcrux_ml_kem_types_MlKemPublicKey_30 *public_key)
48 {
49 fprintf(stderr, "%s: Internal implementation was called\n", __func__);
50 internal_function_called = true;
51 return libcrux_ml_kem_mlkem768_portable_validate_public_key(public_key);
52 }
53
54 tuple_c2 __wrap_libcrux_ml_kem_mlkem768_portable_encapsulate(
55 libcrux_ml_kem_types_MlKemPublicKey_30 *public_key,
56 uint8_t randomness[32U])
57 {
58 fprintf(stderr, "%s: Internal implementation was called\n", __func__);
59 internal_function_called = true;
60 return libcrux_ml_kem_mlkem768_portable_encapsulate(public_key, randomness);
61 }
62
63 void __wrap_libcrux_ml_kem_mlkem768_portable_decapsulate(
64 libcrux_ml_kem_types_MlKemPrivateKey_d9 *private_key,
65 libcrux_ml_kem_mlkem768_MlKem768Ciphertext *ciphertext,
66 uint8_t ret[32U])
67 {
68 fprintf(stderr, "%s: Internal implementation was called\n", __func__);
69 internal_function_called = true;
70 return libcrux_ml_kem_mlkem768_portable_decapsulate(private_key,
71 ciphertext,
72 ret);
73 }
74
75 bool internal_mlkem768_function_called(void)
76 {
77 return internal_function_called;
78 }
79
80 void reset_mlkem768_function_called(void)
81 {
82 internal_function_called = false;
83 }