Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ecdsa.h Source File

ecdsa.h

Go to the documentation of this file.
00001 /**
00002  * @file ecdsa.h
00003  * @brief ECDSA (Elliptic Curve Digital Signature Algorithm)
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneCrypto Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _ECDSA_H
00030 #define _ECDSA_H
00031 
00032 //Dependencies
00033 #include "crypto.h"
00034 #include "ec.h"
00035 
00036 
00037 /**
00038  * @brief ECDSA signature
00039  **/
00040 
00041 typedef struct
00042 {
00043    Mpi r;
00044    Mpi s;
00045 } EcdsaSignature;
00046 
00047 
00048 //ECDSA related constants
00049 extern const uint8_t ECDSA_WITH_SHA1_OID[7];
00050 extern const uint8_t ECDSA_WITH_SHA224_OID[8];
00051 extern const uint8_t ECDSA_WITH_SHA256_OID[8];
00052 extern const uint8_t ECDSA_WITH_SHA384_OID[8];
00053 extern const uint8_t ECDSA_WITH_SHA512_OID[8];
00054 extern const uint8_t ECDSA_WITH_SHA3_224_OID[9];
00055 extern const uint8_t ECDSA_WITH_SHA3_256_OID[9];
00056 extern const uint8_t ECDSA_WITH_SHA3_384_OID[9];
00057 extern const uint8_t ECDSA_WITH_SHA3_512_OID[9];
00058 
00059 //ECDSA related functions
00060 void ecdsaInitSignature(EcdsaSignature *signature);
00061 void ecdsaFreeSignature(EcdsaSignature *signature);
00062 
00063 error_t ecdsaWriteSignature(const EcdsaSignature *signature, uint8_t *data, size_t *length);
00064 error_t ecdsaReadSignature(const uint8_t *data, size_t length, EcdsaSignature *signature);
00065 
00066 error_t ecdsaGenerateSignature(const EcDomainParameters *params,
00067    const PrngAlgo *prngAlgo, void *prngContext, const Mpi *privateKey,
00068    const uint8_t *digest, size_t digestLength, EcdsaSignature *signature);
00069 
00070 error_t ecdsaVerifySignature(const EcDomainParameters *params, const EcPoint *publicKey,
00071    const uint8_t *digest, size_t digestLength, const EcdsaSignature *signature);
00072 
00073 #endif
00074