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

index e24fda8..aca232c 100644 (file)
@@ -380,7 +380,11 @@ static bool build_emsa_pss_signature(private_gmp_rsa_private_key_t *this,
        }
 
        salt.len = hash.len;
-       if (params->salt_len > RSA_PSS_SALT_LEN_DEFAULT)
+       if (params->salt.len)
+       {
+               salt = params->salt;
+       }
+       else if (params->salt_len > RSA_PSS_SALT_LEN_DEFAULT)
        {
                salt.len = params->salt_len;
        }
@@ -388,7 +392,7 @@ static bool build_emsa_pss_signature(private_gmp_rsa_private_key_t *this,
        {       /* too long */
                goto error;
        }
-       if (salt.len)
+       if (salt.len && !params->salt.len)
        {
                salt = chunk_alloca(salt.len);
                rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);