ecdsa.h
Go to the documentation of this file.
1 /**
2  * @file ecdsa.h
3  * @brief ECDSA (Elliptic Curve Digital Signature Algorithm)
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneCrypto Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _ECDSA_H
30 #define _ECDSA_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 #include "ecc/ec.h"
35 
36 //C++ guard
37 #ifdef __cplusplus
38  extern "C" {
39 #endif
40 
41 
42 /**
43  * @brief ECDSA signature
44  **/
45 
46 typedef struct
47 {
48  Mpi r;
49  Mpi s;
51 
52 
53 //ECDSA related constants
54 extern const uint8_t ECDSA_WITH_SHA1_OID[7];
55 extern const uint8_t ECDSA_WITH_SHA224_OID[8];
56 extern const uint8_t ECDSA_WITH_SHA256_OID[8];
57 extern const uint8_t ECDSA_WITH_SHA384_OID[8];
58 extern const uint8_t ECDSA_WITH_SHA512_OID[8];
59 extern const uint8_t ECDSA_WITH_SHA3_224_OID[9];
60 extern const uint8_t ECDSA_WITH_SHA3_256_OID[9];
61 extern const uint8_t ECDSA_WITH_SHA3_384_OID[9];
62 extern const uint8_t ECDSA_WITH_SHA3_512_OID[9];
63 
64 //ECDSA related functions
67 
69  size_t *length);
70 
71 error_t ecdsaReadSignature(const uint8_t *data, size_t length,
73 
75  const PrngAlgo *prngAlgo, void *prngContext, Mpi *privateKey,
76  EcPoint *publicKey);
77 
79  const PrngAlgo *prngAlgo, void *prngContext, const Mpi *privateKey,
80  const uint8_t *digest, size_t digestLen, EcdsaSignature *signature);
81 
83  const EcPoint *publicKey, const uint8_t *digest, size_t digestLen,
84  const EcdsaSignature *signature);
85 
86 //C++ guard
87 #ifdef __cplusplus
88  }
89 #endif
90 
91 #endif
ECC (Elliptic Curve Cryptography)
EC domain parameters.
Definition: ec.h:61
const uint8_t ECDSA_WITH_SHA512_OID[8]
Definition: ecdsa.c:51
Arbitrary precision integer.
Definition: mpi.h:67
const uint8_t ECDSA_WITH_SHA224_OID[8]
Definition: ecdsa.c:45
General definitions for cryptographic algorithms.
error_t ecdsaWriteSignature(const EcdsaSignature *signature, uint8_t *data, size_t *length)
Encode ECDSA signature using ASN.1.
Definition: ecdsa.c:96
const uint8_t ECDSA_WITH_SHA3_512_OID[9]
Definition: ecdsa.c:59
const uint8_t ECDSA_WITH_SHA3_256_OID[9]
Definition: ecdsa.c:55
void ecdsaFreeSignature(EcdsaSignature *signature)
Release an ECDSA signature.
Definition: ecdsa.c:80
void ecdsaInitSignature(EcdsaSignature *signature)
Initialize an ECDSA signature.
Definition: ecdsa.c:67
Elliptic curve point.
Definition: ec.h:49
error_t ecdsaGenerateKeyPair(const EcDomainParameters *params, const PrngAlgo *prngAlgo, void *prngContext, Mpi *privateKey, EcPoint *publicKey)
ECDSA key pair generation.
Definition: ecdsa.c:353
ECDSA signature.
Definition: ecdsa.h:46
error_t ecdsaVerifySignature(const EcDomainParameters *params, const EcPoint *publicKey, const uint8_t *digest, size_t digestLen, const EcdsaSignature *signature)
ECDSA signature verification.
Definition: ecdsa.c:524
const uint8_t ECDSA_WITH_SHA3_384_OID[9]
Definition: ecdsa.c:57
error_t ecdsaReadSignature(const uint8_t *data, size_t length, EcdsaSignature *signature)
Read an ASN.1 encoded ECDSA signature.
Definition: ecdsa.c:253
const uint8_t ECDSA_WITH_SHA384_OID[8]
Definition: ecdsa.c:49
uint8_t signature
Definition: tls.h:1364
error_t ecdsaGenerateSignature(const EcDomainParameters *params, const PrngAlgo *prngAlgo, void *prngContext, const Mpi *privateKey, const uint8_t *digest, size_t digestLen, EcdsaSignature *signature)
ECDSA signature generation.
Definition: ecdsa.c:409
error_t
Error codes.
Definition: error.h:40
uint8_t data[]
Definition: dtls_misc.h:167
const uint8_t ECDSA_WITH_SHA256_OID[8]
Definition: ecdsa.c:47
Common interface for pseudo-random number generators.
Definition: crypto.h:1091
const uint8_t ECDSA_WITH_SHA1_OID[7]
Definition: ecdsa.c:43
uint8_t length
Definition: dtls_misc.h:140
const uint8_t ECDSA_WITH_SHA3_224_OID[9]
Definition: ecdsa.c:53