Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_ecc.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
26
27#ifndef __NILOREA_ECC_HEADER
28#define __NILOREA_ECC_HEADER
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <stddef.h>
35
40
41#ifdef HAVE_OPENSSL
42
44
46#define N_ECC_KEY_LEN 32
48#define N_ECC_SIG_LEN 64
49
57#define N_ECC_AVAILABLE N_OSSL_HAVE_RAW_EVP_25519
58
60int n_x25519_keypair(unsigned char* priv, unsigned char* pub);
62int n_ed25519_keypair(unsigned char* priv, unsigned char* pub);
64int n_x25519_derive(const unsigned char* priv, const unsigned char* peer_pub, unsigned char* shared);
66int n_ed25519_sign(const unsigned char* priv, const unsigned char* msg, size_t len, unsigned char* sig);
68int n_ed25519_verify(const unsigned char* pub, const unsigned char* msg, size_t len, const unsigned char* sig);
69
70#endif /* HAVE_OPENSSL */
71
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif /* __NILOREA_ECC_HEADER */
int n_ed25519_keypair(unsigned char *priv, unsigned char *pub)
generate an Ed25519 keypair as N_ECC_KEY_LEN-byte raw private and public keys.
Definition n_ecc.c:197
int n_ed25519_verify(const unsigned char *pub, const unsigned char *msg, size_t len, const unsigned char *sig)
Ed25519 verify the N_ECC_SIG_LEN-byte sig over len bytes of msg under the N_ECC_KEY_LEN-byte raw publ...
Definition n_ecc.c:221
int n_x25519_keypair(unsigned char *priv, unsigned char *pub)
generate an X25519 keypair as N_ECC_KEY_LEN-byte raw private and public keys.
Definition n_ecc.c:190
int n_ed25519_sign(const unsigned char *priv, const unsigned char *msg, size_t len, unsigned char *sig)
Ed25519 sign len bytes of msg with the N_ECC_KEY_LEN-byte raw private key into sig (N_ECC_SIG_LEN byt...
Definition n_ecc.c:212
int n_x25519_derive(const unsigned char *priv, const unsigned char *peer_pub, unsigned char *shared)
X25519 ECDH: derive the N_ECC_KEY_LEN-byte shared secret from our raw private key and the peer's raw ...
Definition n_ecc.c:204
One place deciding which OpenSSL/LibreSSL features the build can use.