add rsa_sign_saltlen_get_max_ex()
This commit is contained in:
parent
73c201da1f
commit
aacfec441e
@ -72,6 +72,9 @@ void rsa_free(rsa_key *key);
|
||||
#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_idx, _saltlen, _stat, _key) \
|
||||
rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key)
|
||||
|
||||
#define rsa_sign_saltlen_get_max(_hash_idx, _key) \
|
||||
rsa_sign_saltlen_get_max_ex(LTC_PKCS_1_PSS, _hash_idx, _key)
|
||||
|
||||
/* These can be switched between LTC_PKCS #1 v2.x and LTC_PKCS #1 v1.5 paddings */
|
||||
int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
@ -97,6 +100,8 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
|
||||
int hash_idx, unsigned long saltlen,
|
||||
int *stat, rsa_key *key);
|
||||
|
||||
int rsa_sign_saltlen_get_max_ex(int padding, int hash_idx, rsa_key *key);
|
||||
|
||||
/* LTC_PKCS #1 import/export */
|
||||
int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key);
|
||||
int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
|
||||
|
49
src/pk/rsa/rsa_sign_saltlen_get.c
Normal file
49
src/pk/rsa/rsa_sign_saltlen_get.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*
|
||||
* http://libtom.org
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file rsa_sign_saltlen_get_ex.c
|
||||
Retrieve the maximum size of the salt, Steffen Jaeckel.
|
||||
*/
|
||||
|
||||
#ifdef LTC_MRSA
|
||||
|
||||
/**
|
||||
Retrieve the maximum possible size of the salt when creating a PKCS#1 PSS signature.
|
||||
@param padding Type of padding (LTC_PKCS_1_PSS only)
|
||||
@param hash_idx The index of the desired hash
|
||||
@param key The RSA key
|
||||
@return The maximum salt length in bytes or INT_MAX on error.
|
||||
*/
|
||||
int rsa_sign_saltlen_get_max_ex(int padding, int hash_idx, rsa_key *key)
|
||||
{
|
||||
int ret = INT_MAX;
|
||||
LTC_ARGCHKVD(key != NULL);
|
||||
|
||||
if (hash_is_valid(hash_idx) &&
|
||||
(padding == LTC_PKCS_1_PSS))
|
||||
{
|
||||
ret = rsa_get_size(key);
|
||||
if (ret < INT_MAX)
|
||||
{
|
||||
ret -= (hash_descriptor[hash_idx].hashsize + 2);
|
||||
} /* if */
|
||||
} /* if */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* $Source$ */
|
||||
/* $Revision$ */
|
||||
/* $Date$ */
|
Loading…
Reference in New Issue
Block a user