libssh 0.12.0
The SSH library
Loading...
Searching...
No Matches
sntrup761.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2013 by Aris Adamantiadis <aris@badcode.be>
5 * Copyright (c) 2023 Simon Josefsson <simon@josefsson.org>
6 * Copyright (c) 2025 Jakub Jelen <jjelen@redhat.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation,
11 * version 2.1 of the License.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef SNTRUP761_H_
24#define SNTRUP761_H_
25
26#include "config.h"
27#include "curve25519.h"
28#include "libssh.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#ifdef HAVE_CURVE25519
35#define HAVE_SNTRUP761 1
36#endif
37
38/*
39 * Derived from public domain source, written by (in alphabetical order):
40 * - Daniel J. Bernstein
41 * - Chitchanok Chuengsatiansup
42 * - Tanja Lange
43 * - Christine van Vredendaal
44 */
45
46#include <stdint.h>
47#include <string.h>
48
49#define SNTRUP761_SECRETKEY_SIZE 1763
50#define SNTRUP761_PUBLICKEY_SIZE 1158
51#define SNTRUP761_CIPHERTEXT_SIZE 1039
52#define SNTRUP761_SIZE 32
53
54typedef void sntrup761_random_func(void *ctx, size_t length, uint8_t *dst);
55
56void sntrup761_keypair(uint8_t *pk,
57 uint8_t *sk,
58 void *random_ctx,
59 sntrup761_random_func *random);
60void sntrup761_enc(uint8_t *c,
61 uint8_t *k,
62 const uint8_t *pk,
63 void *random_ctx,
64 sntrup761_random_func *random);
65void sntrup761_dec(uint8_t *k, const uint8_t *c, const uint8_t *sk);
66
67typedef unsigned char ssh_sntrup761_pubkey[SNTRUP761_PUBLICKEY_SIZE];
68typedef unsigned char ssh_sntrup761_privkey[SNTRUP761_SECRETKEY_SIZE];
69typedef unsigned char ssh_sntrup761_ciphertext[SNTRUP761_CIPHERTEXT_SIZE];
70
71int ssh_client_sntrup761x25519_init(ssh_session session);
72void ssh_client_sntrup761x25519_remove_callbacks(ssh_session session);
73
74#ifdef WITH_SERVER
75void ssh_server_sntrup761x25519_init(ssh_session session);
76#endif /* WITH_SERVER */
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif /* SNTRUP761_H_ */