libssh: /build/libssh/src/libssh-0.12.0/include/libssh/mlkem.h Source File

libssh 0.12.0 The SSH library

Loading...
Searching...
No Matches
mlkem.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2025 by Red Hat, Inc.
5 *
6 * Author: Pavol Žáčik <pzacik@redhat.com>
7 *
8 * The SSH Library is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, version 2.1 of the License.
11 *
12 * The SSH Library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 * License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with the SSH Library; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 * MA 02111-1307, USA.
21 */
22
23#ifndef MLKEM_H_
24#define MLKEM_H_
25
26#include "libssh/crypto.h"
27#include "libssh/libssh.h"
28#include "libssh/session.h"
29
30#include "config.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36 struct mlkem_type_info {
37 size_t pubkey_size;
38 size_t ciphertext_size;
39#ifdef HAVE_GCRYPT_MLKEM
40 size_t privkey_size;
41 enum gcry_kem_algos alg;
42#elif defined(HAVE_OPENSSL_MLKEM)
43 const char *name;
44#else
45 size_t privkey_size;
46#endif
47};
48
49extern const struct mlkem_type_info MLKEM768_INFO;
50#ifdef HAVE_MLKEM1024
51extern const struct mlkem_type_info MLKEM1024_INFO;
52#endif
53
54#define MLKEM_SHARED_SECRET_SIZE 32
55
56typedef unsigned char ssh_mlkem_shared_secret[MLKEM_SHARED_SECRET_SIZE];
57
58const struct mlkem_type_info *
59kex_type_to_mlkem_info(enum ssh_key_exchange_e kex_type);
60
61int ssh_mlkem_init(ssh_session session);
62
63int ssh_mlkem_encapsulate(ssh_session session,
64 ssh_mlkem_shared_secret shared_secret);
65
66int ssh_mlkem_decapsulate(const ssh_session session,
67 ssh_mlkem_shared_secret shared_secret);
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* MLKEM_H_ */
mlkem_type_info
Definition mlkem.h:36