forked from wolfSSL/wolfssl
add RsaPublicKeyDecodeRaw() to load key from existing n, e
This commit is contained in:
@ -1237,6 +1237,36 @@ int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e, word32 eSz,
|
||||
RsaKey* key)
|
||||
{
|
||||
if (n == NULL || e == NULL || key == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
key->type = RSA_PUBLIC;
|
||||
|
||||
if (mp_init(&key->n) != MP_OKAY)
|
||||
return MP_INIT_E;
|
||||
|
||||
if (mp_read_unsigned_bin(&key->n, n, nSz) != 0) {
|
||||
mp_clear(&key->n);
|
||||
return ASN_GETINT_E;
|
||||
}
|
||||
|
||||
if (mp_init(&key->e) != MP_OKAY) {
|
||||
mp_clear(&key->n);
|
||||
return MP_INIT_E;
|
||||
}
|
||||
|
||||
if (mp_read_unsigned_bin(&key->e, e, eSz) != 0) {
|
||||
mp_clear(&key->n);
|
||||
mp_clear(&key->e);
|
||||
return ASN_GETINT_E;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NO_DH
|
||||
|
@ -82,6 +82,8 @@ CYASSL_API int RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
|
||||
word32);
|
||||
CYASSL_API int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
|
||||
word32);
|
||||
CYASSL_API int RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
|
||||
word32 eSz, RsaKey* key);
|
||||
CYASSL_API int RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*, word32*);
|
||||
|
||||
#ifdef CYASSL_KEY_GEN
|
||||
|
Reference in New Issue
Block a user