allow cert signing w/o Cert object, buffer only

This commit is contained in:
toddouska
2013-11-19 16:56:49 -08:00
parent 74c9ddcffb
commit 7585e92fee
5 changed files with 25 additions and 19 deletions

View File

@@ -2779,7 +2779,8 @@ int rsa_test(void)
if (certSz < 0) if (certSz < 0)
return -407; return -407;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, &rng); certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, &rng);
if (certSz < 0) if (certSz < 0)
return -408; return -408;
@@ -2891,7 +2892,8 @@ int rsa_test(void)
if (certSz < 0) if (certSz < 0)
return -456; return -456;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, &rng); certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, &rng);
if (certSz < 0) if (certSz < 0)
return -457; return -457;

View File

@@ -2550,7 +2550,8 @@ int rsa_test(void)
if (certSz < 0) if (certSz < 0)
return -407; return -407;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, &rng); certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, &rng);
if (certSz < 0) if (certSz < 0)
return -408; return -408;
@@ -2662,7 +2663,8 @@ int rsa_test(void)
if (certSz < 0) if (certSz < 0)
return -456; return -456;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, &rng); certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, &rng);
if (certSz < 0) if (certSz < 0)
return -457; return -457;

View File

@@ -4592,25 +4592,24 @@ int MakeNtruCert(Cert* cert, byte* derBuffer, word32 derSz,
#endif /* HAVE_NTRU */ #endif /* HAVE_NTRU */
int SignCert(Cert* cert, byte* buffer, word32 buffSz, RsaKey* rsaKey, int SignCert(int requestSz, int sigType, byte* buffer, word32 buffSz,
ecc_key* eccKey, RNG* rng) RsaKey* rsaKey, ecc_key* eccKey, RNG* rng)
{ {
byte sig[MAX_ENCODED_SIG_SZ]; byte sig[MAX_ENCODED_SIG_SZ];
int sigSz; int sigSz;
int bodySz = cert->bodySz;
if (bodySz < 0) if (requestSz < 0)
return bodySz; return requestSz;
sigSz = MakeSignature(buffer, bodySz, sig, sizeof(sig), rsaKey, eccKey, sigSz = MakeSignature(buffer, requestSz, sig, sizeof(sig), rsaKey, eccKey,
rng, cert->sigType); rng, sigType);
if (sigSz < 0) if (sigSz < 0)
return sigSz; return sigSz;
if (bodySz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz) if (requestSz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz)
return BUFFER_E; return BUFFER_E;
return AddSignature(buffer, bodySz, sig, sigSz, cert->sigType); return AddSignature(buffer, requestSz, sig, sigSz, sigType);
} }
@@ -4621,7 +4620,7 @@ int MakeSelfCert(Cert* cert, byte* buffer, word32 buffSz, RsaKey* key, RNG* rng)
if (ret < 0) if (ret < 0)
return ret; return ret;
return SignCert(cert, buffer, buffSz, key, NULL, rng); return SignCert(cert->bodySz, cert->sigType, buffer, buffSz, key, NULL,rng);
} }

View File

@@ -2802,7 +2802,8 @@ int rsa_test(void)
if (certSz < 0) if (certSz < 0)
return -407; return -407;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, NULL, &rng); certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, NULL, &rng);
if (certSz < 0) if (certSz < 0)
return -408; return -408;
@@ -2890,7 +2891,8 @@ int rsa_test(void)
if (certSz < 0) if (certSz < 0)
return -5407; return -5407;
certSz = SignCert(&myCert, derCert, FOURK_BUF, NULL, &caKey, &rng); certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
NULL, &caKey, &rng);
if (certSz < 0) if (certSz < 0)
return -5408; return -5408;
@@ -3002,7 +3004,8 @@ int rsa_test(void)
if (certSz < 0) if (certSz < 0)
return -456; return -456;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, NULL, &rng); certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, NULL, &rng);
if (certSz < 0) if (certSz < 0)
return -457; return -457;

View File

@@ -127,8 +127,8 @@ typedef struct Cert {
CYASSL_API void InitCert(Cert*); CYASSL_API void InitCert(Cert*);
CYASSL_API int MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, CYASSL_API int MakeCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
ecc_key*, RNG*); ecc_key*, RNG*);
CYASSL_API int SignCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, CYASSL_API int SignCert(int requestSz, int sigType, byte* derBuffer,
ecc_key*, RNG*); word32 derSz, RsaKey*, ecc_key*, RNG*);
CYASSL_API int MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*, CYASSL_API int MakeSelfCert(Cert*, byte* derBuffer, word32 derSz, RsaKey*,
RNG*); RNG*);
CYASSL_API int SetIssuer(Cert*, const char*); CYASSL_API int SetIssuer(Cert*, const char*);