forked from wolfSSL/wolfssl
Allow reading ENC EC PRIVATE KEY as well via wolfSSL_PEM_read_bio_ECPrivateKey (#6055)
* fix qt qsslkey unit test
This commit is contained in:
13
src/pk.c
13
src/pk.c
@ -12121,7 +12121,7 @@ WOLFSSL_EC_KEY* wolfSSL_PEM_read_bio_ECPrivateKey(WOLFSSL_BIO* bio,
|
|||||||
DerBuffer* der = NULL;
|
DerBuffer* der = NULL;
|
||||||
int keyFormat = 0;
|
int keyFormat = 0;
|
||||||
|
|
||||||
WOLFSSL_ENTER("wolfSSL_PEM_read_bio_EC_PUBKEY");
|
WOLFSSL_ENTER("wolfSSL_PEM_read_bio_ECPrivateKey");
|
||||||
|
|
||||||
/* Validate parameters. */
|
/* Validate parameters. */
|
||||||
if (bio == NULL) {
|
if (bio == NULL) {
|
||||||
@ -12135,11 +12135,18 @@ WOLFSSL_EC_KEY* wolfSSL_PEM_read_bio_ECPrivateKey(WOLFSSL_BIO* bio,
|
|||||||
err = 1;
|
err = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Read a PEM key in to a new DER buffer. */
|
/* Read a PEM key in to a new DER buffer.
|
||||||
if ((!err) && (pem_read_bio_key(bio, cb, pass, ECC_PRIVATEKEY_TYPE,
|
* To check ENC EC PRIVATE KEY, it uses PRIVATEKEY_TYPE to call
|
||||||
|
* pem_read_bio_key(), and then check key format if it is EC.
|
||||||
|
*/
|
||||||
|
if ((!err) && (pem_read_bio_key(bio, cb, pass, PRIVATEKEY_TYPE,
|
||||||
&keyFormat, &der) <= 0)) {
|
&keyFormat, &der) <= 0)) {
|
||||||
err = 1;
|
err = 1;
|
||||||
}
|
}
|
||||||
|
if (keyFormat != ECDSAk) {
|
||||||
|
WOLFSSL_ERROR_MSG("Error not EC key format");
|
||||||
|
err = 1;
|
||||||
|
}
|
||||||
/* Load the EC key with the private key from the DER encoding. */
|
/* Load the EC key with the private key from the DER encoding. */
|
||||||
if ((!err) && (wolfSSL_EC_KEY_LoadDer_ex(ec, der->buffer, der->length,
|
if ((!err) && (wolfSSL_EC_KEY_LoadDer_ex(ec, der->buffer, der->length,
|
||||||
WOLFSSL_EC_KEY_LOAD_PRIVATE) != 1)) {
|
WOLFSSL_EC_KEY_LOAD_PRIVATE) != 1)) {
|
||||||
|
Reference in New Issue
Block a user