Webserver+3d print
cyclone_crypto/ecdsa.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file ecdsa.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief ECDSA (Elliptic Curve Digital Signature Algorithm) |
Sergunb | 0:8918a71cdbe9 | 4 | * |
Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
Sergunb | 0:8918a71cdbe9 | 6 | * |
Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
Sergunb | 0:8918a71cdbe9 | 8 | * |
Sergunb | 0:8918a71cdbe9 | 9 | * This file is part of CycloneCrypto Open. |
Sergunb | 0:8918a71cdbe9 | 10 | * |
Sergunb | 0:8918a71cdbe9 | 11 | * This program is free software; you can redistribute it and/or |
Sergunb | 0:8918a71cdbe9 | 12 | * modify it under the terms of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 13 | * as published by the Free Software Foundation; either version 2 |
Sergunb | 0:8918a71cdbe9 | 14 | * of the License, or (at your option) any later version. |
Sergunb | 0:8918a71cdbe9 | 15 | * |
Sergunb | 0:8918a71cdbe9 | 16 | * This program is distributed in the hope that it will be useful, |
Sergunb | 0:8918a71cdbe9 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Sergunb | 0:8918a71cdbe9 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Sergunb | 0:8918a71cdbe9 | 19 | * GNU General Public License for more details. |
Sergunb | 0:8918a71cdbe9 | 20 | * |
Sergunb | 0:8918a71cdbe9 | 21 | * You should have received a copy of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 22 | * along with this program; if not, write to the Free Software Foundation, |
Sergunb | 0:8918a71cdbe9 | 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
Sergunb | 0:8918a71cdbe9 | 24 | * |
Sergunb | 0:8918a71cdbe9 | 25 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
Sergunb | 0:8918a71cdbe9 | 26 | * @version 1.7.6 |
Sergunb | 0:8918a71cdbe9 | 27 | **/ |
Sergunb | 0:8918a71cdbe9 | 28 | |
Sergunb | 0:8918a71cdbe9 | 29 | #ifndef _ECDSA_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _ECDSA_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "crypto.h" |
Sergunb | 0:8918a71cdbe9 | 34 | #include "ec.h" |
Sergunb | 0:8918a71cdbe9 | 35 | |
Sergunb | 0:8918a71cdbe9 | 36 | |
Sergunb | 0:8918a71cdbe9 | 37 | /** |
Sergunb | 0:8918a71cdbe9 | 38 | * @brief ECDSA signature |
Sergunb | 0:8918a71cdbe9 | 39 | **/ |
Sergunb | 0:8918a71cdbe9 | 40 | |
Sergunb | 0:8918a71cdbe9 | 41 | typedef struct |
Sergunb | 0:8918a71cdbe9 | 42 | { |
Sergunb | 0:8918a71cdbe9 | 43 | Mpi r; |
Sergunb | 0:8918a71cdbe9 | 44 | Mpi s; |
Sergunb | 0:8918a71cdbe9 | 45 | } EcdsaSignature; |
Sergunb | 0:8918a71cdbe9 | 46 | |
Sergunb | 0:8918a71cdbe9 | 47 | |
Sergunb | 0:8918a71cdbe9 | 48 | //ECDSA related constants |
Sergunb | 0:8918a71cdbe9 | 49 | extern const uint8_t ECDSA_WITH_SHA1_OID[7]; |
Sergunb | 0:8918a71cdbe9 | 50 | extern const uint8_t ECDSA_WITH_SHA224_OID[8]; |
Sergunb | 0:8918a71cdbe9 | 51 | extern const uint8_t ECDSA_WITH_SHA256_OID[8]; |
Sergunb | 0:8918a71cdbe9 | 52 | extern const uint8_t ECDSA_WITH_SHA384_OID[8]; |
Sergunb | 0:8918a71cdbe9 | 53 | extern const uint8_t ECDSA_WITH_SHA512_OID[8]; |
Sergunb | 0:8918a71cdbe9 | 54 | extern const uint8_t ECDSA_WITH_SHA3_224_OID[9]; |
Sergunb | 0:8918a71cdbe9 | 55 | extern const uint8_t ECDSA_WITH_SHA3_256_OID[9]; |
Sergunb | 0:8918a71cdbe9 | 56 | extern const uint8_t ECDSA_WITH_SHA3_384_OID[9]; |
Sergunb | 0:8918a71cdbe9 | 57 | extern const uint8_t ECDSA_WITH_SHA3_512_OID[9]; |
Sergunb | 0:8918a71cdbe9 | 58 | |
Sergunb | 0:8918a71cdbe9 | 59 | //ECDSA related functions |
Sergunb | 0:8918a71cdbe9 | 60 | void ecdsaInitSignature(EcdsaSignature *signature); |
Sergunb | 0:8918a71cdbe9 | 61 | void ecdsaFreeSignature(EcdsaSignature *signature); |
Sergunb | 0:8918a71cdbe9 | 62 | |
Sergunb | 0:8918a71cdbe9 | 63 | error_t ecdsaWriteSignature(const EcdsaSignature *signature, uint8_t *data, size_t *length); |
Sergunb | 0:8918a71cdbe9 | 64 | error_t ecdsaReadSignature(const uint8_t *data, size_t length, EcdsaSignature *signature); |
Sergunb | 0:8918a71cdbe9 | 65 | |
Sergunb | 0:8918a71cdbe9 | 66 | error_t ecdsaGenerateSignature(const EcDomainParameters *params, |
Sergunb | 0:8918a71cdbe9 | 67 | const PrngAlgo *prngAlgo, void *prngContext, const Mpi *privateKey, |
Sergunb | 0:8918a71cdbe9 | 68 | const uint8_t *digest, size_t digestLength, EcdsaSignature *signature); |
Sergunb | 0:8918a71cdbe9 | 69 | |
Sergunb | 0:8918a71cdbe9 | 70 | error_t ecdsaVerifySignature(const EcDomainParameters *params, const EcPoint *publicKey, |
Sergunb | 0:8918a71cdbe9 | 71 | const uint8_t *digest, size_t digestLength, const EcdsaSignature *signature); |
Sergunb | 0:8918a71cdbe9 | 72 | |
Sergunb | 0:8918a71cdbe9 | 73 | #endif |
Sergunb | 0:8918a71cdbe9 | 74 |