libssh 0.11.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
38extern void crypto_hash_sha512(unsigned char *out,
39 const unsigned char *in,
40 unsigned long long inlen);
41
42/*
43 * Derived from public domain source, written by (in alphabetical order):
44 * - Daniel J. Bernstein
45 * - Chitchanok Chuengsatiansup
46 * - Tanja Lange
47 * - Christine van Vredendaal
48 */
49
50#include <stdint.h>
51#include <string.h>
52
53#define SNTRUP761_SECRETKEY_SIZE 1763
54#define SNTRUP761_PUBLICKEY_SIZE 1158
55#define SNTRUP761_CIPHERTEXT_SIZE 1039
56#define SNTRUP761_SIZE 32
57
58typedef void sntrup761_random_func(void *ctx, size_t length, uint8_t *dst);
59
60void sntrup761_keypair(uint8_t *pk,
61 uint8_t *sk,
62 void *random_ctx,
63 sntrup761_random_func *random);
64void sntrup761_enc(uint8_t *c,
65 uint8_t *k,
66 const uint8_t *pk,
67 void *random_ctx,
68 sntrup761_random_func *random);
69void sntrup761_dec(uint8_t *k, const uint8_t *c, const uint8_t *sk);
70
71typedef unsigned char ssh_sntrup761_pubkey[SNTRUP761_PUBLICKEY_SIZE];
72typedef unsigned char ssh_sntrup761_privkey[SNTRUP761_SECRETKEY_SIZE];
73typedef unsigned char ssh_sntrup761_ciphertext[SNTRUP761_CIPHERTEXT_SIZE];
74
75int ssh_client_sntrup761x25519_init(ssh_session session);
76void ssh_client_sntrup761x25519_remove_callbacks(ssh_session session);
77
78#ifdef WITH_SERVER
79void ssh_server_sntrup761x25519_init(ssh_session session);
80#endif /* WITH_SERVER */
81
82#ifdef __cplusplus
83}
84#endif
85
86#endif /* SNTRUP761_H_ */