allow cert signing w/o Cert object, buffer only

pull/1/head
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)
return -407;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, &rng);
certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, &rng);
if (certSz < 0)
return -408;
@ -2891,7 +2892,8 @@ int rsa_test(void)
if (certSz < 0)
return -456;
certSz = SignCert(&myCert, derCert, FOURK_BUF, &caKey, &rng);
certSz = SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF,
&caKey, &rng);
if (certSz < 0)
return -457;

View File

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

View File

@ -4592,25 +4592,24 @@ int MakeNtruCert(Cert* cert, byte* derBuffer, word32 derSz,
#endif /* HAVE_NTRU */
int SignCert(Cert* cert, byte* buffer, word32 buffSz, RsaKey* rsaKey,
ecc_key* eccKey, RNG* rng)
int SignCert(int requestSz, int sigType, byte* buffer, word32 buffSz,
RsaKey* rsaKey, ecc_key* eccKey, RNG* rng)
{
byte sig[MAX_ENCODED_SIG_SZ];
int sigSz;
int bodySz = cert->bodySz;
if (bodySz < 0)
return bodySz;
if (requestSz < 0)
return requestSz;
sigSz = MakeSignature(buffer, bodySz, sig, sizeof(sig), rsaKey, eccKey,
rng, cert->sigType);
sigSz = MakeSignature(buffer, requestSz, sig, sizeof(sig), rsaKey, eccKey,
rng, sigType);
if (sigSz < 0)
return sigSz;
if (bodySz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz)
if (requestSz + MAX_SEQ_SZ * 2 + sigSz > (int)buffSz)
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)
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)
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)
return -408;
@ -2890,7 +2891,8 @@ int rsa_test(void)
if (certSz < 0)
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)
return -5408;
@ -3002,7 +3004,8 @@ int rsa_test(void)
if (certSz < 0)
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)
return -457;

View File

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