| 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 |
#include <libssh/sntrup761.h> |
| 32 |
|
| 33 |
#include "sntrup761_override.h" |
| 34 |
|
| 35 |
static bool internal_function_called = false; |
| 36 |
|
| 37 |
void __wrap_sntrup761_keypair(uint8_t *pk, |
| 38 |
uint8_t *sk, |
| 39 |
void *random_ctx, |
| 40 |
sntrup761_random_func *random) |
| 41 |
{ |
| 42 |
fprintf(stderr, "%s: Internal implementation was called\n", __func__); |
| 43 |
internal_function_called = true; |
| 44 |
return sntrup761_keypair(pk, sk, random_ctx, random); |
| 45 |
} |
| 46 |
|
| 47 |
void __wrap_sntrup761_enc(uint8_t *c, |
| 48 |
uint8_t *k, |
| 49 |
const uint8_t *pk, |
| 50 |
void *random_ctx, |
| 51 |
sntrup761_random_func *random) |
| 52 |
{ |
| 53 |
fprintf(stderr, "%s: Internal implementation was called\n", __func__); |
| 54 |
internal_function_called = true; |
| 55 |
return sntrup761_enc(c, k, pk, random_ctx, random); |
| 56 |
} |
| 57 |
|
| 58 |
void __wrap_sntrup761_dec(uint8_t *k, const uint8_t *c, const uint8_t *sk) |
| 59 |
{ |
| 60 |
fprintf(stderr, "%s: Internal implementation was called\n", __func__); |
| 61 |
internal_function_called = true; |
| 62 |
return sntrup761_dec(k, c, sk); |
| 63 |
} |
| 64 |
|
| 65 |
bool internal_sntrup761_function_called(void) |
| 66 |
{ |
| 67 |
return internal_function_called; |
| 68 |
} |
| 69 |
|
| 70 |
void reset_sntrup761_function_called(void) |
| 71 |
{ |
| 72 |
internal_function_called = false; |
| 73 |
} |