gcrypt: Add support for static salts when signing with RSA-PSS
authorTobias Brunner <tobias@strongswan.org>
Tue, 26 Sep 2017 14:44:44 +0000 (16:44 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 8 Nov 2017 15:48:10 +0000 (16:48 +0100)
src/libstrongswan/plugins/gcrypt/gcrypt_rsa_private_key.c

index 5dc0bfd..c06f433 100644 (file)
@@ -177,14 +177,25 @@ static bool sign_pkcs1(private_gcrypt_rsa_private_key_t *this,
 
        if (pss)
        {
-               u_int slen = hasher_hash_size(hash_algorithm);
-               if (pss->salt_len > RSA_PSS_SALT_LEN_DEFAULT)
+               if (pss->salt.len)
                {
-                       slen = pss->salt_len;
+                       err = gcry_sexp_build(&in, NULL,
+                                                       "(data(flags pss)(salt-length %u)"
+                                                       "(random-override %b)(hash %s %b))",
+                                                       pss->salt.len, pss->salt.len, pss->salt.ptr,
+                                                       hash_name, hash.len, hash.ptr);
+               }
+               else
+               {
+                       u_int slen = hasher_hash_size(hash_algorithm);
+                       if (pss->salt_len > RSA_PSS_SALT_LEN_DEFAULT)
+                       {
+                               slen = pss->salt_len;
+                       }
+                       err = gcry_sexp_build(&in, NULL,
+                                                       "(data(flags pss)(salt-length %u)(hash %s %b))",
+                                                       slen, hash_name, hash.len, hash.ptr);
                }
-               err = gcry_sexp_build(&in, NULL,
-                                                         "(data(flags pss)(salt-length %u)(hash %s %b))",
-                                                         slen, hash_name, hash.len, hash.ptr);
        }
        else
        {