Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
dsa.h
00001 /** 00002 * @file dsa.h 00003 * @brief DSA (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 _DSA_H 00030 #define _DSA_H 00031 00032 //Dependencies 00033 #include "crypto.h" 00034 #include "mpi.h" 00035 00036 00037 /** 00038 * @brief DSA public key 00039 **/ 00040 00041 typedef struct 00042 { 00043 Mpi p; ///<Prime modulus 00044 Mpi q; ///<Prime divisor 00045 Mpi g; ///<Generator of the subgroup 00046 Mpi y; ///<Public key 00047 } DsaPublicKey; 00048 00049 00050 /** 00051 * @brief DSA private key 00052 **/ 00053 00054 typedef struct 00055 { 00056 Mpi p; ///<Prime modulus 00057 Mpi q; ///<<Prime divisor 00058 Mpi g; ///<Generator of the subgroup 00059 Mpi x; ///<Private key 00060 } DsaPrivateKey; 00061 00062 00063 /** 00064 * @brief DSA signature 00065 **/ 00066 00067 typedef struct 00068 { 00069 Mpi r; 00070 Mpi s; 00071 } DsaSignature; 00072 00073 00074 //DSA related constants 00075 extern const uint8_t DSA_OID[7]; 00076 extern const uint8_t DSA_WITH_SHA1_OID[7]; 00077 extern const uint8_t DSA_WITH_SHA224_OID[9]; 00078 extern const uint8_t DSA_WITH_SHA256_OID[9]; 00079 extern const uint8_t DSA_WITH_SHA384_OID[9]; 00080 extern const uint8_t DSA_WITH_SHA512_OID[9]; 00081 extern const uint8_t DSA_WITH_SHA3_224_OID[9]; 00082 extern const uint8_t DSA_WITH_SHA3_256_OID[9]; 00083 extern const uint8_t DSA_WITH_SHA3_384_OID[9]; 00084 extern const uint8_t DSA_WITH_SHA3_512_OID[9]; 00085 00086 //DSA related functions 00087 void dsaInitPublicKey(DsaPublicKey *key); 00088 void dsaFreePublicKey(DsaPublicKey *key); 00089 00090 void dsaInitPrivateKey(DsaPrivateKey *key); 00091 void dsaFreePrivateKey(DsaPrivateKey *key); 00092 00093 void dsaInitSignature(DsaSignature *signature); 00094 void dsaFreeSignature(DsaSignature *signature); 00095 00096 error_t dsaWriteSignature(const DsaSignature *signature, uint8_t *data, size_t *length); 00097 error_t dsaReadSignature(const uint8_t *data, size_t length, DsaSignature *signature); 00098 00099 error_t dsaGenerateSignature(const PrngAlgo *prngAlgo, void *prngContext, 00100 const DsaPrivateKey *key, const uint8_t *digest, size_t digestLength, 00101 DsaSignature *signature); 00102 00103 error_t dsaVerifySignature(const DsaPublicKey *key, 00104 const uint8_t *digest, size_t digestLength, const DsaSignature *signature); 00105 00106 #endif 00107
Generated on Tue Jul 12 2022 17:10:13 by
