1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 #include "tomcrypt_private.h"
4 
5 /**
6   @file rsa_sign_saltlen_get.c
7   Retrieve the maximum size of the salt, Steffen Jaeckel.
8 */
9 
10 #ifdef LTC_MRSA
11 
12 /**
13   Retrieve the maximum possible size of the salt when creating a PKCS#1 PSS signature.
14   @param padding    Type of padding (LTC_PKCS_1_PSS only)
15   @param hash_idx   The index of the desired hash
16   @param key        The RSA key
17   @return The maximum salt length in bytes or INT_MAX on error.
18 */
rsa_sign_saltlen_get_max_ex(int padding,int hash_idx,const rsa_key * key)19 int rsa_sign_saltlen_get_max_ex(int padding, int hash_idx, const rsa_key *key)
20 {
21   int ret = INT_MAX;
22   LTC_ARGCHK(key != NULL);
23 
24   if ((hash_is_valid(hash_idx) == CRYPT_OK) &&
25       (padding == LTC_PKCS_1_PSS))
26   {
27     ret = rsa_get_size(key);
28     if (ret < INT_MAX)
29     {
30       ret -= (hash_descriptor[hash_idx]->hashsize + 2);
31     } /* if */
32   } /* if */
33 
34   return ret;
35 }
36 
37 #endif
38