wolfssl: Support OAEP labels

This commit is contained in:
Andreas Steffen
2021-11-10 20:03:22 +01:00
parent 6adb543341
commit 9cfdc32597
2 changed files with 15 additions and 2 deletions
@@ -247,6 +247,12 @@ METHOD(private_key_t, decrypt, bool,
{
int padding, mgf, len;
enum wc_HashType hash;
chunk_t label = chunk_empty;
if (params)
{
label = *(chunk_t *)params;
}
switch (scheme)
{
@@ -300,7 +306,8 @@ METHOD(private_key_t, decrypt, bool,
len = wc_RsaEncryptSize(&this->rsa);
*plain = chunk_alloc(len);
len = wc_RsaPrivateDecrypt_ex(crypto.ptr, crypto.len, plain->ptr, len,
&this->rsa, padding, hash, mgf, NULL, 0);
&this->rsa, padding, hash, mgf,
label.ptr, label.len);
if (len < 0)
{
DBG1(DBG_LIB, "RSA decryption failed");
@@ -222,6 +222,12 @@ METHOD(public_key_t, encrypt, bool,
{
int padding, mgf, len;
enum wc_HashType hash;
chunk_t label = chunk_empty;
if (params)
{
label = *(chunk_t *)params;
}
switch (scheme)
{
@@ -276,7 +282,7 @@ METHOD(public_key_t, encrypt, bool,
*crypto = chunk_alloc(len);
len = wc_RsaPublicEncrypt_ex(plain.ptr, plain.len, crypto->ptr, len,
&this->rsa, &this->rng, padding, hash, mgf,
NULL, 0);
label.ptr, label.len);
if (len < 0)
{
DBG1(DBG_LIB, "RSA encryption failed");