forked from wolfSSL/wolfssl
Improve "keyFormat" to always set based on "algId" and let the later key parsing code produce failure.
This commit is contained in:
17
src/ssl.c
17
src/ssl.c
@@ -5635,22 +5635,7 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
|
|||||||
}
|
}
|
||||||
else if (type == PRIVATEKEY_TYPE && format != WOLFSSL_FILETYPE_RAW) {
|
else if (type == PRIVATEKEY_TYPE && format != WOLFSSL_FILETYPE_RAW) {
|
||||||
#if defined(WOLFSSL_ENCRYPTED_KEYS) || defined(HAVE_PKCS8)
|
#if defined(WOLFSSL_ENCRYPTED_KEYS) || defined(HAVE_PKCS8)
|
||||||
#ifndef NO_DSA
|
keyFormat = algId;
|
||||||
if (algId == DSAk)
|
|
||||||
keyFormat = DSAk;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ECC
|
|
||||||
if (algId == ECDSAk)
|
|
||||||
keyFormat = ECDSAk;
|
|
||||||
#endif
|
|
||||||
#ifndef NO_DH
|
|
||||||
if (algId == DHk)
|
|
||||||
keyFormat = DHk;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ED25519
|
|
||||||
if (algId == ED25519k)
|
|
||||||
keyFormat = ED25519k;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = ProcessBufferTryDecode(ctx, ssl, der, &keySz, &idx, &resetSuites,
|
ret = ProcessBufferTryDecode(ctx, ssl, der, &keySz, &idx, &resetSuites,
|
||||||
|
@@ -10331,22 +10331,7 @@ int PemToDer(const unsigned char* buff, long longSz, int type,
|
|||||||
if ((ret = ToTraditional_ex(der->buffer, der->length, &algId)) > 0) {
|
if ((ret = ToTraditional_ex(der->buffer, der->length, &algId)) > 0) {
|
||||||
der->length = ret;
|
der->length = ret;
|
||||||
if (keyFormat) {
|
if (keyFormat) {
|
||||||
#ifndef NO_DSA
|
*keyFormat = algId;
|
||||||
if (algId == DSAk)
|
|
||||||
*keyFormat = DSAk;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ECC
|
|
||||||
if (algId == ECDSAk)
|
|
||||||
*keyFormat = ECDSAk;
|
|
||||||
#endif
|
|
||||||
#ifndef NO_DH
|
|
||||||
if (algId == DHk)
|
|
||||||
*keyFormat = DHk;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ED25519
|
|
||||||
if (algId == ED25519k)
|
|
||||||
*keyFormat = ED25519k;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -10392,22 +10377,7 @@ int PemToDer(const unsigned char* buff, long longSz, int type,
|
|||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
der->length = ret;
|
der->length = ret;
|
||||||
if (keyFormat) {
|
if (keyFormat) {
|
||||||
#ifndef NO_DSA
|
*keyFormat = algId;
|
||||||
if (algId == DSAk)
|
|
||||||
*keyFormat = DSAk;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ECC
|
|
||||||
if (algId == ECDSAk)
|
|
||||||
*keyFormat = ECDSAk;
|
|
||||||
#endif
|
|
||||||
#ifndef NO_DH
|
|
||||||
if (algId == DHk)
|
|
||||||
*keyFormat = DHk;
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ED25519
|
|
||||||
if (algId == ED25519k)
|
|
||||||
*keyFormat = ED25519k;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user