exporting pkCurve info to ctx and ssl

This commit is contained in:
Moisés Guimarães
2014-01-14 14:20:34 -03:00
parent 70e3d6ddb0
commit de6a537896
4 changed files with 13 additions and 6 deletions

View File

@ -1522,7 +1522,6 @@ static int GetKey(DecodedCert* cert)
#ifdef HAVE_ECC #ifdef HAVE_ECC
case ECDSAk: case ECDSAk:
{ {
word32 oid = 0;
int oidSz = 0; int oidSz = 0;
byte b = cert->source[cert->srcIdx++]; byte b = cert->source[cert->srcIdx++];
@ -1533,12 +1532,10 @@ static int GetKey(DecodedCert* cert)
return ASN_PARSE_E; return ASN_PARSE_E;
while(oidSz--) while(oidSz--)
oid += cert->source[cert->srcIdx++]; cert->pkCurveOID += cert->source[cert->srcIdx++];
if (CheckCurve(oid) < 0)
if (CheckCurve(cert->pkCurveOID) < 0)
return ECC_CURVE_OID_E; return ECC_CURVE_OID_E;
#ifdef OPENSSL_EXTRA
cert->pkCurveOID = oid;
#endif /* OPENSSL_EXTRA */
/* key header */ /* key header */
b = cert->source[cert->srcIdx++]; b = cert->source[cert->srcIdx++];

View File

@ -1230,6 +1230,7 @@ struct CYASSL_CTX {
word32 timeout; /* session timeout */ word32 timeout; /* session timeout */
#ifdef HAVE_ECC #ifdef HAVE_ECC
word16 eccTempKeySz; /* in octets 20 - 66 */ word16 eccTempKeySz; /* in octets 20 - 66 */
word32 pkCurveOID; /* curve Ecc_Sum */
#endif #endif
#ifndef NO_PSK #ifndef NO_PSK
byte havePSK; /* psk key set by user */ byte havePSK; /* psk key set by user */
@ -1849,6 +1850,7 @@ struct CYASSL {
ecc_key* eccTempKey; /* private ECDHE key */ ecc_key* eccTempKey; /* private ECDHE key */
ecc_key* eccDsaKey; /* private ECDSA key */ ecc_key* eccDsaKey; /* private ECDSA key */
word16 eccTempKeySz; /* in octets 20 - 66 */ word16 eccTempKeySz; /* in octets 20 - 66 */
word32 pkCurveOID; /* curve Ecc_Sum */
byte peerEccKeyPresent; byte peerEccKeyPresent;
byte peerEccDsaKeyPresent; byte peerEccDsaKeyPresent;
byte eccTempKeyPresent; byte eccTempKeyPresent;

View File

@ -1400,6 +1400,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx)
#ifdef HAVE_ECC #ifdef HAVE_ECC
ssl->eccTempKeySz = ctx->eccTempKeySz; ssl->eccTempKeySz = ctx->eccTempKeySz;
ssl->pkCurveOID = ctx->pkCurveOID;
ssl->peerEccKeyPresent = 0; ssl->peerEccKeyPresent = 0;
ssl->peerEccDsaKeyPresent = 0; ssl->peerEccDsaKeyPresent = 0;
ssl->eccDsaKeyPresent = 0; ssl->eccDsaKeyPresent = 0;

View File

@ -2137,6 +2137,13 @@ int CyaSSL_Init(void)
break; break;
} }
#ifdef HAVE_ECC
if (ctx)
ctx->pkCurveOID = cert.pkCurveOID;
if (ssl)
ssl->pkCurveOID = cert.pkCurveOID;
#endif
FreeDecodedCert(&cert); FreeDecodedCert(&cert);
} }