mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-27 22:42:21 +01:00
Merge pull request #6078 from SparkiDev/rsapss_openssl_compat
X509 RSA PSS: fixes for OpenSSL compat layer
This commit is contained in:
@@ -9360,7 +9360,6 @@ int wc_RsaPublicKeyDecode_ex(const byte* input, word32* inOutIdx, word32 inSz,
|
||||
int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
|
||||
word32 inSz)
|
||||
{
|
||||
#ifndef WOLFSSL_ASN_TEMPLATE
|
||||
int ret;
|
||||
const byte *n = NULL, *e = NULL;
|
||||
word32 nSz = 0, eSz = 0;
|
||||
@@ -9374,44 +9373,6 @@ int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
|
||||
}
|
||||
|
||||
return ret;
|
||||
#else
|
||||
DECL_ASNGETDATA(dataASN, rsaPublicKeyASN_Length);
|
||||
int ret = 0;
|
||||
|
||||
/* Check validity of parameters. */
|
||||
if ((input == NULL) || (inOutIdx == NULL) || (key == NULL)) {
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
CALLOC_ASNGETDATA(dataASN, rsaPublicKeyASN_Length, ret, NULL);
|
||||
|
||||
if (ret == 0) {
|
||||
/* Set mp_ints to fill with modulus and exponent data. */
|
||||
GetASN_MP(&dataASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_N], &key->n);
|
||||
GetASN_MP(&dataASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_E], &key->e);
|
||||
/* Try decoding PKCS #1 public key by ignoring rest of ASN.1. */
|
||||
ret = GetASN_Items(&rsaPublicKeyASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_SEQ],
|
||||
&dataASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_SEQ],
|
||||
(int)(rsaPublicKeyASN_Length - RSAPUBLICKEYASN_IDX_PUBKEY_RSA_SEQ),
|
||||
0, input, inOutIdx, inSz);
|
||||
if (ret != 0) {
|
||||
mp_free(&key->n);
|
||||
mp_free(&key->e);
|
||||
|
||||
/* Didn't work - try whole SubjectKeyInfo instead. */
|
||||
/* Set the OID to expect. */
|
||||
GetASN_ExpBuffer(&dataASN[RSAPUBLICKEYASN_IDX_ALGOID_OID],
|
||||
keyRsaOid, sizeof(keyRsaOid));
|
||||
/* Decode SubjectKeyInfo. */
|
||||
ret = GetASN_Items(rsaPublicKeyASN, dataASN,
|
||||
rsaPublicKeyASN_Length, 1, input, inOutIdx,
|
||||
inSz);
|
||||
}
|
||||
}
|
||||
|
||||
FREE_ASNGETDATA(dataASN, NULL);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* import RSA public key elements (n, e) into RsaKey structure (key) */
|
||||
|
||||
Reference in New Issue
Block a user