mirror of https://github.com/wolfSSL/wolfssl.git
Added function to flatten the RSA public key to a pair of byte arrays
parent
8bb52380a8
commit
1a88e9fbdc
|
@ -469,6 +469,33 @@ int RsaEncryptSize(RsaKey* key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int RsaFlattenPublicKey(RsaKey* key, byte* e, word32* eSz, byte* n, word32* nSz)
|
||||||
|
{
|
||||||
|
int sz, ret;
|
||||||
|
|
||||||
|
if (key == NULL || e == NULL || eSz == NULL || n == NULL || nSz == NULL)
|
||||||
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
|
sz = mp_unsigned_bin_size(&key->e);
|
||||||
|
if ((word32)sz > *nSz)
|
||||||
|
return RSA_BUFFER_E;
|
||||||
|
ret = mp_to_unsigned_bin(&key->e, e);
|
||||||
|
if (ret != MP_OKAY)
|
||||||
|
return ret;
|
||||||
|
*eSz = (word32)sz;
|
||||||
|
|
||||||
|
sz = mp_unsigned_bin_size(&key->n);
|
||||||
|
if ((word32)sz > *nSz)
|
||||||
|
return RSA_BUFFER_E;
|
||||||
|
ret = mp_to_unsigned_bin(&key->n, n);
|
||||||
|
if (ret != MP_OKAY)
|
||||||
|
return ret;
|
||||||
|
*nSz = (word32)sz;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CYASSL_KEY_GEN
|
#ifdef CYASSL_KEY_GEN
|
||||||
|
|
||||||
static const int USE_BBS = 1;
|
static const int USE_BBS = 1;
|
||||||
|
|
|
@ -82,6 +82,8 @@ CYASSL_API int RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
|
||||||
word32);
|
word32);
|
||||||
CYASSL_API int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
|
CYASSL_API int RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey*,
|
||||||
word32);
|
word32);
|
||||||
|
CYASSL_API int RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*, word32*);
|
||||||
|
|
||||||
#ifdef CYASSL_KEY_GEN
|
#ifdef CYASSL_KEY_GEN
|
||||||
CYASSL_API int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng);
|
CYASSL_API int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng);
|
||||||
CYASSL_API int RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
|
CYASSL_API int RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
|
||||||
|
|
Loading…
Reference in New Issue