SemiDrive SSDK Appication Program Interface PTG3.0
Functions
sdrv_crypto_rsapadding.h File Reference
#include <sdrv_crypto_mailbox_common.h>
#include <sdrv_crypto_mailbox_trng.h>
#include <sdrv_crypto_mailbox_hash.h>
#include <sdrv_crypto_sharemem.h>
#include <armv7-r/cache.h>

Go to the source code of this file.

Functions

sdrv_crypto_error_status_e rsa_pad_eme_oaep_encode (uint32_t k, uint32_t hash_alg, uint8_t *EM, uint8_t *message, uint32_t mLen)
 
sdrv_crypto_error_status_e rsa_pad_eme_oaep_decode (uint32_t k, uint32_t hash_alg, uint8_t *EM, uint8_t **message, uint32_t *mLen)
 
sdrv_crypto_error_status_e rsa_pad_eme_pkcs_encode (uint32_t k, uint8_t *EM, uint8_t *message, uint32_t mLen)
 
sdrv_crypto_error_status_e rsa_pad_eme_pkcs_decode (uint32_t k, uint8_t *EM, uint8_t **message, uint32_t *mLen)
 
sdrv_crypto_error_status_e rsa_pad_emsa_pkcs_encode (uint32_t emLen, uint32_t hash_type, uint8_t *EM, uint8_t *hash)
 
sdrv_crypto_error_status_e rsa_pad_emsa_pss_encode (uint32_t emLen, uint32_t hash_alg, uint8_t *EM, uint8_t *hash, uint32_t n0, uint32_t sLen)
 
sdrv_crypto_error_status_e rsa_pad_emsa_pss_decode (uint32_t emLen, uint32_t hash_alg, uint8_t *EM, uint8_t *hash, uint32_t sLen, uint32_t n0)
 
void rsa_pad_zeros (uint8_t *EM, uint32_t emLen, uint8_t *hash, uint32_t hashLen)
 

Detailed Description

Macro Definition Documentation

◆ MAC_BUFF_MAX_SIZE

#define MAC_BUFF_MAX_SIZE   (4096/8)

◆ MAX_BLOCKSIZE

#define MAX_BLOCKSIZE   SHA512_BLOCKSIZE

◆ MAX_DIGESTSIZE

#define MAX_DIGESTSIZE   SHA512_DIGESTSIZE

◆ MD5_BLOCKSIZE

#define MD5_BLOCKSIZE   64

◆ MD5_DIGESTSIZE

#define MD5_DIGESTSIZE   16

◆ MD5_INITSIZE

#define MD5_INITSIZE   16

◆ RSA_MAX_SIZE

#define RSA_MAX_SIZE   (4096/8)

◆ SEIP_CACHE_ALIGN_32BYTE_ADDR_MASK

#define SEIP_CACHE_ALIGN_32BYTE_ADDR_MASK   (0x1F)

◆ SHA1_BLOCKSIZE

#define SHA1_BLOCKSIZE   64

◆ SHA1_DIGESTSIZE

#define SHA1_DIGESTSIZE   20

◆ SHA1_INITSIZE

#define SHA1_INITSIZE   20

◆ SHA224_BLOCKSIZE

#define SHA224_BLOCKSIZE   64

◆ SHA224_DIGESTSIZE

#define SHA224_DIGESTSIZE   28

◆ SHA224_INITSIZE

#define SHA224_INITSIZE   32

◆ SHA256_BLOCKSIZE

#define SHA256_BLOCKSIZE   64

◆ SHA256_DIGESTSIZE

#define SHA256_DIGESTSIZE   32

◆ SHA256_INITSIZE

#define SHA256_INITSIZE   32

◆ SHA384_BLOCKSIZE

#define SHA384_BLOCKSIZE   128

◆ SHA384_DIGESTSIZE

#define SHA384_DIGESTSIZE   48

◆ SHA384_INITSIZE

#define SHA384_INITSIZE   64

◆ SHA512_BLOCKSIZE

#define SHA512_BLOCKSIZE   128

◆ SHA512_DIGESTSIZE

#define SHA512_DIGESTSIZE   64

◆ SHA512_INITSIZE

#define SHA512_INITSIZE   64

◆ SM3_BLOCKSIZE

#define SM3_BLOCKSIZE   64

◆ SM3_DIGESTSIZE

#define SM3_DIGESTSIZE   32

◆ SM3_INITSIZE

#define SM3_INITSIZE   32

Enumeration Type Documentation

◆ rsa_padding_mode_e

CRYPTO mode of rsa padding.

Enumerator
CRYPTO_ALGOMODE_RSAES_OAEP 
CRYPTO_ALGOMODE_RSAES_PKCS1_v1_5 
CRYPTO_ALGOMODE_RSASSA_PSS 
CRYPTO_ALGOMODE_RSASSA_PKCS1_v1_5 
CRYPTO_ALGOMODE_RSA_NO_PAD 

Function Documentation

◆ rsa_pad_eme_oaep_decode()

sdrv_crypto_error_status_e rsa_pad_eme_oaep_decode ( uint32_t  k,
uint32_t  hash_alg,
uint8_t *  EM,
uint8_t **  message,
uint32_t *  mLen 
)

Decode a message using OEAP

Parameters
kRSA parameter length in bytes
hashTypethe hash function to use
EMPointer to the encoded message (EM) buffer
messageOutput: Pointer to the decoded message. The decoding is done in place within the limits of the EM buffer.
mLenOutput: Length of the decoded message
Returns
E_OK when no error occurs

◆ rsa_pad_eme_oaep_encode()

sdrv_crypto_error_status_e rsa_pad_eme_oaep_encode ( uint32_t  k,
uint32_t  hash_alg,
uint8_t *  EM,
uint8_t *  message,
uint32_t  mLen 
)

Encode a message using OAEP

Parameters
kRSA parameter length in bytes
hashTypeThe hash function to use
EMPointer to the encoded message (EM) buffer
messageBlock containing address of the message to encode
mLenLength of the message to be encoded (bytes)
rngRandom number generator to use
Returns
E_OK when no error occurs

◆ rsa_pad_eme_pkcs_decode()

sdrv_crypto_error_status_e rsa_pad_eme_pkcs_decode ( uint32_t  k,
uint8_t *  EM,
uint8_t **  message,
uint32_t *  mLen 
)

Decodes encoded message using PKCS. message will point to the decoded message in EM

Parameters
kRSA param length in bytes
EMPointer to the encoded message (EM) buffer
messageOutput: Pointer to the decoded message in EM. The decoding is done in place within the limits of the EM buffer.
mLenOutput: Length of the decoded message (bytes)
Returns
E_OK when no error occurs

◆ rsa_pad_eme_pkcs_encode()

sdrv_crypto_error_status_e rsa_pad_eme_pkcs_encode ( uint32_t  k,
uint8_t *  EM,
uint8_t *  message,
uint32_t  mLen 
)

Encode message using PKCS

Parameters
kRSA parameter length in bytes
EMPointer to the encoded message (EM) buffer
messageBlock containing address of the message to encode
mLenLen of the message to be encoded (bytes)
rngrandom number generator to use
Returns
E_OK when no error occurs

◆ rsa_pad_emsa_pkcs_encode()

sdrv_crypto_error_status_e rsa_pad_emsa_pkcs_encode ( uint32_t  emLen,
uint32_t  hash_type,
uint8_t *  EM,
uint8_t *  hash 
)

Encode hash using PKCS

Parameters
emLenLength of encoded message (EM) buffer (RSA parameter length in bytes)
hashypeHash function used for hashing hash (also used for the PKCS algorithm)
EMOutput: Pointer to the encoded message buffer
hashInput: Hash to encode
Returns
E_OK if no error occurs

◆ rsa_pad_emsa_pss_decode()

sdrv_crypto_error_status_e rsa_pad_emsa_pss_decode ( uint32_t  emLen,
uint32_t  hash_alg,
uint8_t *  EM,
uint8_t *  hash,
uint32_t  sLen,
uint32_t  n0 
)

Decode encoded message using PSS and compares hash to the decoded hash

Parameters
emLenLength of encoded message (EM) buffer (RSA parameter length in bytes)
hashTypeHash function used for hasing hash
EMInput: Pointer to the encoded message buffer
hashHash to compare with
sLenIntended length of the salt
n0MSB of the modulus (for masking in order to match the modulus size)
Returns
E_OK if no error occurs and hash is valid

◆ rsa_pad_emsa_pss_encode()

sdrv_crypto_error_status_e rsa_pad_emsa_pss_encode ( uint32_t  emLen,
uint32_t  hash_alg,
uint8_t *  EM,
uint8_t *  hash,
uint32_t  n0,
uint32_t  sLen 
)

Encode hash using PSS. This function uses a salt length equal to the hash digest length.

Parameters
emLenLength of encoded message (EM) buffer (RSA parameter length in bytes)
hashTypeHash function used for hashing hash (also used for PKCS algorithm)
EMOutput: Pointer to the encoded message buffer
hashInput: Hash to encode
n0MSB of the modulus (for masking in order to match the modulus size)
sLenIntended length of the salt
rngRandom number generator to use
Returns
E_OK if no error occurs

◆ rsa_pad_zeros()

void rsa_pad_zeros ( uint8_t *  EM,
uint32_t  emLen,
uint8_t *  hash,
uint32_t  hashLen 
)

Pads the hash of hashLen to EM of emLen. MSBs are set to 0.

Warning
There should not be overlapping between EM and hash !
Parameters
EMDestination buffer (pointer)
emLenLength of the destination buffer (bytes)
hashInput to pad
hashLenLength of the input