eddsa.h
Go to the documentation of this file.
1 /**
2  * @file eddsa.h
3  * @brief EdDSA (Edwards-Curve Digital Signature Algorithm)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _EDDSA_H
32 #define _EDDSA_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "ecc/ec.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 
44 /**
45  * @brief EdDSA public key
46  **/
47 
48 typedef struct
49 {
50  Mpi q; ///<Public key
52 
53 
54 /**
55  * @brief EdDSA private key
56  **/
57 
58 typedef struct
59 {
60  Mpi d; ///<Private key
61  Mpi q; ///<Public key
62  int_t slot; ///<Private key slot
64 
65 
66 /**
67  * @brief Message chunk descriptor
68  **/
69 
70 typedef struct
71 {
72  const void *buffer;
73  size_t length;
75 
76 
77 //EdDSA related functions
80 
83 
84 error_t eddsaGenerateKeyPair(const PrngAlgo *prngAlgo, void *prngContext,
85  const EcCurveInfo *curveInfo, EddsaPrivateKey *privateKey,
86  EddsaPublicKey *publicKey);
87 
88 error_t eddsaGeneratePrivateKey(const PrngAlgo *prngAlgo, void *prngContext,
89  const EcCurveInfo *curveInfo, EddsaPrivateKey *privateKey);
90 
92  const EddsaPrivateKey *privateKey, EddsaPublicKey *publicKey);
93 
94 //C++ guard
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 //Ed25519 supported?
100 #if (ED25519_SUPPORT == ENABLED)
101  #include "ecc/ed25519.h"
102 #endif
103 
104 //Ed448 supported?
105 #if (ED448_SUPPORT == ENABLED)
106  #include "ecc/ed448.h"
107 #endif
108 
109 #endif
signed int int_t
Definition: compiler_port.h:49
General definitions for cryptographic algorithms.
#define PrngAlgo
Definition: crypto.h:917
ECC (Elliptic Curve Cryptography)
Ed25519 elliptic curve (constant-time implementation)
Ed448 elliptic curve (constant-time implementation)
error_t eddsaGeneratePublicKey(const EcCurveInfo *curveInfo, const EddsaPrivateKey *privateKey, EddsaPublicKey *publicKey)
Derive the public key from an EdDSA private key.
Definition: eddsa.c:200
void eddsaFreePrivateKey(EddsaPrivateKey *key)
Release an EdDSA private key.
Definition: eddsa.c:89
error_t eddsaGeneratePrivateKey(const PrngAlgo *prngAlgo, void *prngContext, const EcCurveInfo *curveInfo, EddsaPrivateKey *privateKey)
EdDSA private key generation.
Definition: eddsa.c:138
void eddsaInitPublicKey(EddsaPublicKey *key)
Initialize an EdDSA public key.
Definition: eddsa.c:49
void eddsaFreePublicKey(EddsaPublicKey *key)
Release an EdDSA public key.
Definition: eddsa.c:61
void eddsaInitPrivateKey(EddsaPrivateKey *key)
Initialize an EdDSA private key.
Definition: eddsa.c:73
error_t eddsaGenerateKeyPair(const PrngAlgo *prngAlgo, void *prngContext, const EcCurveInfo *curveInfo, EddsaPrivateKey *privateKey, EddsaPublicKey *publicKey)
EdDSA key pair generation.
Definition: eddsa.c:107
error_t
Error codes.
Definition: error.h:43
Elliptic curve parameters.
Definition: ec_curves.h:295
Message chunk descriptor.
Definition: eddsa.h:71
const void * buffer
Definition: eddsa.h:72
size_t length
Definition: eddsa.h:73
EdDSA private key.
Definition: eddsa.h:59
int_t slot
Private key slot.
Definition: eddsa.h:62
Mpi q
Public key.
Definition: eddsa.h:61
Mpi d
Private key.
Definition: eddsa.h:60
EdDSA public key.
Definition: eddsa.h:49
Mpi q
Public key.
Definition: eddsa.h:50
Arbitrary precision integer.
Definition: mpi.h:80