move signature algo types to public header and have test cert gen use SHA256wRSA as example
This commit is contained in:
parent
42b7eefbee
commit
d3bb4bf4d4
@ -6,7 +6,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
AC_INIT([cyassl],[2.0.0rc3b],[http://www.yassl.com])
|
||||
AC_INIT([cyassl],[2.0.0rc3c],[http://www.yassl.com])
|
||||
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
|
||||
|
@ -1681,17 +1681,17 @@ static word32 SetAlgoID(int algoOID, byte* output, int type)
|
||||
}
|
||||
else if (type == sigType) { /* sigType */
|
||||
switch (algoOID) {
|
||||
case MD5wRSA:
|
||||
case CTC_MD5wRSA:
|
||||
algoSz = sizeof(md5wRSA_AlgoID);
|
||||
algoName = md5wRSA_AlgoID;
|
||||
break;
|
||||
|
||||
case SHAwRSA:
|
||||
case CTC_SHAwRSA:
|
||||
algoSz = sizeof(shawRSA_AlgoID);
|
||||
algoName = shawRSA_AlgoID;
|
||||
break;
|
||||
|
||||
case SHA256wRSA:
|
||||
case CTC_SHA256wRSA:
|
||||
algoSz = sizeof(sha256wRSA_AlgoID);
|
||||
algoName = sha256wRSA_AlgoID;
|
||||
break;
|
||||
@ -1761,7 +1761,7 @@ static int ConfirmSignature(DecodedCert* cert, const byte* key, word32 keySz,
|
||||
#endif
|
||||
int typeH, digestSz, ret;
|
||||
|
||||
if (cert->signatureOID == MD5wRSA) {
|
||||
if (cert->signatureOID == CTC_MD5wRSA) {
|
||||
Md5 md5;
|
||||
InitMd5(&md5);
|
||||
Md5Update(&md5, cert->source + cert->certBegin,
|
||||
@ -1770,8 +1770,9 @@ static int ConfirmSignature(DecodedCert* cert, const byte* key, word32 keySz,
|
||||
typeH = MD5h;
|
||||
digestSz = MD5_DIGEST_SIZE;
|
||||
}
|
||||
else if (cert->signatureOID == SHAwRSA || cert->signatureOID == SHAwDSA ||
|
||||
cert->signatureOID == SHAwECDSA) {
|
||||
else if (cert->signatureOID == CTC_SHAwRSA ||
|
||||
cert->signatureOID == CTC_SHAwDSA ||
|
||||
cert->signatureOID == CTC_SHAwECDSA) {
|
||||
Sha sha;
|
||||
InitSha(&sha);
|
||||
ShaUpdate(&sha, cert->source + cert->certBegin,
|
||||
@ -1781,8 +1782,8 @@ static int ConfirmSignature(DecodedCert* cert, const byte* key, word32 keySz,
|
||||
digestSz = SHA_DIGEST_SIZE;
|
||||
}
|
||||
#ifndef NO_SHA256
|
||||
else if (cert->signatureOID == SHA256wRSA ||
|
||||
cert->signatureOID == SHA256wECDSA) {
|
||||
else if (cert->signatureOID == CTC_SHA256wRSA ||
|
||||
cert->signatureOID == CTC_SHA256wECDSA) {
|
||||
Sha256 sha256;
|
||||
InitSha256(&sha256);
|
||||
Sha256Update(&sha256, cert->source + cert->certBegin,
|
||||
@ -2430,7 +2431,7 @@ int RsaKeyToDer(RsaKey* key, byte* output, word32 inLen)
|
||||
void InitCert(Cert* cert)
|
||||
{
|
||||
cert->version = 2; /* version 3 is hex 2 */
|
||||
cert->sigType = SHAwRSA;
|
||||
cert->sigType = CTC_SHAwRSA;
|
||||
cert->daysValid = 500;
|
||||
cert->selfSigned = 1;
|
||||
cert->isCA = 0;
|
||||
@ -3044,7 +3045,7 @@ static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz,
|
||||
byte encSig[MAX_ENCODED_DIG_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ];
|
||||
int encSigSz, digestSz, typeH;
|
||||
|
||||
if (sigAlgoType == MD5wRSA) {
|
||||
if (sigAlgoType == CTC_MD5wRSA) {
|
||||
Md5 md5;
|
||||
InitMd5(&md5);
|
||||
Md5Update(&md5, buffer, sz);
|
||||
@ -3052,7 +3053,7 @@ static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz,
|
||||
digestSz = MD5_DIGEST_SIZE;
|
||||
typeH = MD5h;
|
||||
}
|
||||
else if (sigAlgoType == SHAwRSA) {
|
||||
else if (sigAlgoType == CTC_SHAwRSA) {
|
||||
Sha sha;
|
||||
InitSha(&sha);
|
||||
ShaUpdate(&sha, buffer, sz);
|
||||
@ -3060,7 +3061,7 @@ static int MakeSignature(const byte* buffer, int sz, byte* sig, int sigSz,
|
||||
digestSz = SHA_DIGEST_SIZE;
|
||||
typeH = SHAh;
|
||||
}
|
||||
else if (sigAlgoType == SHA256wRSA) {
|
||||
else if (sigAlgoType == CTC_SHA256wRSA) {
|
||||
Sha256 sha256;
|
||||
InitSha256(&sha256);
|
||||
Sha256Update(&sha256, buffer, sz);
|
||||
|
@ -1227,7 +1227,8 @@ int rsa_test()
|
||||
strncpy(myCert.subject.unit, "Development", CTC_NAME_SIZE);
|
||||
strncpy(myCert.subject.commonName, "www.yassl.com", CTC_NAME_SIZE);
|
||||
strncpy(myCert.subject.email, "info@yassl.com", CTC_NAME_SIZE);
|
||||
myCert.isCA = 1;
|
||||
myCert.isCA = 1;
|
||||
myCert.sigType = CTC_SHA256wRSA;
|
||||
|
||||
certSz = MakeSelfCert(&myCert, derCert, sizeof(derCert), &key, &rng);
|
||||
if (certSz < 0)
|
||||
|
@ -135,16 +135,6 @@ enum Oid_Types {
|
||||
};
|
||||
|
||||
|
||||
enum Sig_Sum {
|
||||
SHAwDSA = 517,
|
||||
MD2wRSA = 646,
|
||||
MD5wRSA = 648,
|
||||
SHAwRSA = 649,
|
||||
SHAwECDSA = 520,
|
||||
SHA256wRSA = 655,
|
||||
SHA256wECDSA = 524
|
||||
};
|
||||
|
||||
enum Hash_Sum {
|
||||
MD2h = 646,
|
||||
MD5h = 649,
|
||||
@ -152,6 +142,7 @@ enum Hash_Sum {
|
||||
SHA256h = 414
|
||||
};
|
||||
|
||||
|
||||
enum Key_Sum {
|
||||
DSAk = 515,
|
||||
RSAk = 645,
|
||||
@ -159,6 +150,7 @@ enum Key_Sum {
|
||||
ECDSAk = 518
|
||||
};
|
||||
|
||||
|
||||
enum Ecc_Sum {
|
||||
ECC_256R1 = 526,
|
||||
ECC_384R1 = 210,
|
||||
|
@ -41,12 +41,25 @@ enum CertType {
|
||||
CA_TYPE
|
||||
};
|
||||
|
||||
|
||||
/* Signature type, by OID sum */
|
||||
enum Ctc_SigType {
|
||||
CTC_SHAwDSA = 517,
|
||||
CTC_MD2wRSA = 646,
|
||||
CTC_MD5wRSA = 648,
|
||||
CTC_SHAwRSA = 649,
|
||||
CTC_SHAwECDSA = 520,
|
||||
CTC_SHA256wRSA = 655,
|
||||
CTC_SHA256wECDSA = 524
|
||||
};
|
||||
|
||||
|
||||
#ifdef CYASSL_CERT_GEN
|
||||
|
||||
enum Ctc_Misc {
|
||||
CTC_NAME_SIZE = 64,
|
||||
CTC_MAX_ALT_SIZE = 512,
|
||||
CTC_SERIAL_SIZE = 8
|
||||
CTC_NAME_SIZE = 64,
|
||||
CTC_MAX_ALT_SIZE = 512,
|
||||
CTC_SERIAL_SIZE = 8
|
||||
};
|
||||
|
||||
typedef struct CertName {
|
||||
@ -84,7 +97,7 @@ typedef struct Cert {
|
||||
/* Initialize and Set Certficate defaults:
|
||||
version = 3 (0x2)
|
||||
serial = 0 (Will be randomly generated)
|
||||
sigType = MD5_WITH_RSA
|
||||
sigType = SHA_WITH_RSA
|
||||
issuer = blank
|
||||
daysValid = 500
|
||||
selfSigned = 1 (true) use subject as issuer
|
||||
|
Loading…
Reference in New Issue
Block a user