]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
wolfssl: Support OAEP labels
authorAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 8 Nov 2021 18:29:28 +0000 (19:29 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 10 Nov 2021 19:03:22 +0000 (20:03 +0100)
src/libstrongswan/plugins/wolfssl/wolfssl_rsa_private_key.c
src/libstrongswan/plugins/wolfssl/wolfssl_rsa_public_key.c

index 03b6c9326f0792baab6abdfbc2dd1c12f71d29d7..c279169799f01f3578d4387a26517cba36345515 100644 (file)
@@ -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");
index 5329b59539470a10f58dd1f8a4583c116e179ed5..72df115fe907ab06f992da9615d46738b2f5116b 100644 (file)
@@ -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");