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.4
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 //EdDSA related functions
69 
72 
73 error_t eddsaGenerateKeyPair(const PrngAlgo *prngAlgo, void *prngContext,
74  const EcCurveInfo *curveInfo, EddsaPrivateKey *privateKey,
75  EddsaPublicKey *publicKey);
76 
77 error_t eddsaGeneratePrivateKey(const PrngAlgo *prngAlgo, void *prngContext,
78  const EcCurveInfo *curveInfo, EddsaPrivateKey *privateKey);
79 
81  const EddsaPrivateKey *privateKey, EddsaPublicKey *publicKey);
82 
83 //C++ guard
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 //Ed25519 supported?
89 #if (ED25519_SUPPORT == ENABLED)
90  #include "ecc/ed25519.h"
91 #endif
92 
93 //Ed448 supported?
94 #if (ED448_SUPPORT == ENABLED)
95  #include "ecc/ed448.h"
96 #endif
97 
98 #endif
Ed25519 elliptic curve (constant-time implementation)
Arbitrary precision integer.
Definition: mpi.h:80
signed int int_t
Definition: compiler_port.h:49
#define PrngAlgo
Definition: crypto.h:938
void eddsaFreePublicKey(EddsaPublicKey *key)
Release an EdDSA public key.
Definition: eddsa.c:61
Elliptic curve parameters.
Definition: ec_curves.h:302
error_t eddsaGeneratePrivateKey(const PrngAlgo *prngAlgo, void *prngContext, const EcCurveInfo *curveInfo, EddsaPrivateKey *privateKey)
EdDSA private key generation.
Definition: eddsa.c:138
error_t eddsaGeneratePublicKey(const EcCurveInfo *curveInfo, const EddsaPrivateKey *privateKey, EddsaPublicKey *publicKey)
Derive the public key from an EdDSA private key.
Definition: eddsa.c:200
error_t
Error codes.
Definition: error.h:43
Mpi q
Public key.
Definition: eddsa.h:50
EdDSA public key.
Definition: eddsa.h:49
void eddsaInitPublicKey(EddsaPublicKey *key)
Initialize an EdDSA public key.
Definition: eddsa.c:49
int_t slot
Private key slot.
Definition: eddsa.h:62
Mpi q
Public key.
Definition: eddsa.h:61
General definitions for cryptographic algorithms.
EdDSA private key.
Definition: eddsa.h:59
Mpi d
Private key.
Definition: eddsa.h:60
void eddsaFreePrivateKey(EddsaPrivateKey *key)
Release an EdDSA private key.
Definition: eddsa.c:89
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
ECC (Elliptic Curve Cryptography)
Ed448 elliptic curve (constant-time implementation)