Debian Codegraph @

tests/external_override/ed25519_override.c

raw
1 /*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2021 by Anderson Toshiyuki Sasaki - Red Hat, Inc.
5 *
6 * The SSH Library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation, either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * The SSH Library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with the SSH Library; see the file COPYING. If not,
18 * see <https://www.gnu.org/licenses/>.
19 */
20
21 #include "config.h"
22
23 #include <stdlib.h>
24 #include <stdint.h>
25 #include <stdio.h>
26 #include <libssh/ed25519.h>
27 #include <libssh/priv.h>
28
29 #include "ed25519_override.h"
30
31 static bool internal_function_called = false;
32
33 int __wrap_crypto_sign_ed25519_keypair(ed25519_pubkey pk,
34 ed25519_privkey sk)
35 {
36 fprintf(stderr, "%s: Internal implementation was called\n", __func__);
37 internal_function_called = true;
38 return crypto_sign_ed25519_keypair(pk, sk);
39 }
40
41 int __wrap_crypto_sign_ed25519(unsigned char *sm,
42 uint64_t *smlen,
43 const unsigned char *m,
44 uint64_t mlen,
45 const ed25519_privkey sk)
46 {
47 fprintf(stderr, "%s: Internal implementation was called\n", __func__);
48 internal_function_called = true;
49 return crypto_sign_ed25519(sm, smlen, m, mlen, sk);
50 }
51
52 int __wrap_crypto_sign_ed25519_open(unsigned char *m,
53 uint64_t *mlen,
54 const unsigned char *sm,
55 uint64_t smlen,
56 const ed25519_pubkey pk)
57 {
58 fprintf(stderr, "%s: Internal implementation was called\n", __func__);
59 internal_function_called = true;
60 return crypto_sign_ed25519_open(m, mlen, sm, smlen, pk);
61 }
62
63 bool internal_ed25519_function_called(void)
64 {
65 return internal_function_called;
66 }
67
68 void reset_ed25519_function_called(void)
69 {
70 internal_function_called = false;
71 }