STCRYPTOLIB_RSA_ALT

MBEDTLS IMPLEMENTATION STCRYPTOLIB RSA ALT FUNCTIONS

group MBEDTLS_IMPLEMENTATION_STCRYPTOLIB_RSA_ALT_FUNCTIONS

Public API functions for STCRYPTOLIB RSA alternate implementation.

Functions

int mbedtls_rsa_import ( mbedtls_rsa_context * ctx , const mbedtls_mpi * N , const mbedtls_mpi * P , const mbedtls_mpi * Q , const mbedtls_mpi * D , const mbedtls_mpi * E )
int mbedtls_rsa_import_raw ( mbedtls_rsa_context * ctx , unsigned char const * N , size_t N_len , unsigned char const * P , size_t P_len , unsigned char const * Q , size_t Q_len , unsigned char const * D , size_t D_len , unsigned char const * E , size_t E_len )
int mbedtls_rsa_complete ( mbedtls_rsa_context * ctx )
int mbedtls_rsa_export_raw ( const mbedtls_rsa_context * ctx , unsigned char * N , size_t N_len , unsigned char * P , size_t P_len , unsigned char * Q , size_t Q_len , unsigned char * D , size_t D_len , unsigned char * E , size_t E_len )
int mbedtls_rsa_export ( const mbedtls_rsa_context * ctx , mbedtls_mpi * N , mbedtls_mpi * P , mbedtls_mpi * Q , mbedtls_mpi * D , mbedtls_mpi * E )
int mbedtls_rsa_export_crt ( const mbedtls_rsa_context * ctx , mbedtls_mpi * DP , mbedtls_mpi * DQ , mbedtls_mpi * QP )

Export CRT parameters.

This must also be implemented if CRT is not used, in order to be able to write DER encoded RSA keys. The helper function mbedtls_rsa_deduce_crt can be used in this case.

void mbedtls_rsa_init ( mbedtls_rsa_context * ctx )

Initialize an RSA context.

int mbedtls_rsa_set_padding ( mbedtls_rsa_context * ctx , int padding , mbedtls_md_type_t hash_id )

Set padding for an existing RSA context.

int mbedtls_rsa_get_padding_mode ( const mbedtls_rsa_context * ctx )

Get padding mode of initialized RSA context.

int mbedtls_rsa_get_md_alg ( const mbedtls_rsa_context * ctx )

Get hash identifier of mbedtls_md_type_t type.

size_t mbedtls_rsa_get_bitlen ( const mbedtls_rsa_context * ctx )

Get length in bits of RSA modulus.

size_t mbedtls_rsa_get_len ( const mbedtls_rsa_context * ctx )

Get length in bytes of RSA modulus.

int mbedtls_rsa_gen_key ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , unsigned int nbits , int exponent )

Generate an RSA key pair.

This generation method follows the RSA key pair generation procedure of FIPS 186-4 if 2^16 < exponent < 2^256 and nbits = 2048 or nbits = 3072.

int mbedtls_rsa_check_pubkey ( const mbedtls_rsa_context * ctx )

Check a public RSA key.

int mbedtls_rsa_check_privkey ( const mbedtls_rsa_context * ctx )

Check for the consistency of all fields in an RSA private key context.

int mbedtls_rsa_check_pub_priv ( const mbedtls_rsa_context * pub , const mbedtls_rsa_context * prv )

Check if contexts holding a public and private key match.

int mbedtls_rsa_rsaes_oaep_encrypt ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , const unsigned char * label , size_t label_len , size_t ilen , const unsigned char * input , unsigned char * output )

Implementation of the PKCS#1 v2.1 RSAES-OAEP-ENCRYPT function.

int mbedtls_rsa_rsaes_pkcs1_v15_encrypt ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , size_t ilen , const unsigned char * input , unsigned char * output )

Implementation of the PKCS#1 v2.1 RSAES-PKCS1-V1_5-ENCRYPT function.

int mbedtls_rsa_pkcs1_encrypt ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , size_t ilen , const unsigned char * input , unsigned char * output )

Add the message padding, then do an RSA operation.

int mbedtls_rsa_rsaes_oaep_decrypt ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , const unsigned char * label , size_t label_len , size_t * olen , const unsigned char * input , unsigned char * output , size_t output_max_len )

Implementation of the PKCS#1 v2.1 RSAES-OAEP-DECRYPT function.

int mbedtls_rsa_rsaes_pkcs1_v15_decrypt ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , size_t * olen , const unsigned char * input , unsigned char * output , size_t output_max_len )

Implementation of the PKCS#1 v2.1 RSAES-PKCS1-V1_5-DECRYPT function.

int mbedtls_rsa_pkcs1_decrypt ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , size_t * olen , const unsigned char * input , unsigned char * output , size_t output_max_len )

Do an RSA operation, then remove the message padding.

int mbedtls_rsa_rsassa_pss_sign_no_mode_check ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , unsigned char * sig )
int mbedtls_rsa_rsassa_pss_sign_ext ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , int saltlen , unsigned char * sig )

Implementation of the PKCS#1 v2.1 RSASSA-PSS-SIGN function with the option to pass in the salt length.

int mbedtls_rsa_rsassa_pss_sign ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , unsigned char * sig )

Implementation of the PKCS#1 v2.1 RSASSA-PSS-SIGN function.

int mbedtls_rsa_rsassa_pkcs1_v15_sign ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , unsigned char * sig )

Do an RSA operation to sign the message digest.

int mbedtls_rsa_pkcs1_sign ( mbedtls_rsa_context * ctx , int ( * f_rng ) ( void * , unsigned char * , size_t ) , void * p_rng , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , unsigned char * sig )

Do an RSA operation to sign the message digest.

int mbedtls_rsa_rsassa_pss_verify_ext ( mbedtls_rsa_context * ctx , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , mbedtls_md_type_t mgf1_hash_id , int expected_salt_len , const unsigned char * sig )

Implementation of the PKCS#1 v2.1 RSASSA-PSS-VERIFY function.

int mbedtls_rsa_rsassa_pss_verify ( mbedtls_rsa_context * ctx , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , const unsigned char * sig )

Simplified PKCS#1 v2.1 RSASSA-PSS-VERIFY function.

int mbedtls_rsa_rsassa_pkcs1_v15_verify ( mbedtls_rsa_context * ctx , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , const unsigned char * sig )

Implementation of the PKCS#1 v2.1 RSASSA-PKCS1-v1_5-VERIFY function.

int mbedtls_rsa_pkcs1_verify ( mbedtls_rsa_context * ctx , mbedtls_md_type_t md_alg , unsigned int hashlen , const unsigned char * hash , const unsigned char * sig )

Do an RSA operation and check the message digest.

int mbedtls_rsa_copy ( mbedtls_rsa_context * dst , const mbedtls_rsa_context * src )

Copy the components of an RSA key.

void mbedtls_rsa_free ( mbedtls_rsa_context * ctx )

Free the components of an RSA key.

MBEDTLS IMPLEMENTATION STCRYPTOLIB RSA ALT TYPES

group MBEDTLS_IMPLEMENTATION_STCRYPTOLIB_RSA_ALT_TYPES

The RSA context structure.

RSA context structure definitions for STCRYPTOLIB.

Note

Direct manipulation of the members of this structure is deprecated. All manipulation must instead be done through the public interface functions.

struct mbedtls_rsa_context
#include <hal_rsa_alt.h>

Public Members

int ver

Always 0.

size_t len

The size of N in Bytes.

mbedtls_mpi N

The public modulus.

mbedtls_mpi E

The public exponent.

mbedtls_mpi D

The private exponent.

mbedtls_mpi P

The first prime factor.

mbedtls_mpi Q

The second prime factor.

mbedtls_mpi Phi

The Euler tolient function.

mbedtls_mpi DP

D % (P - 1).

mbedtls_mpi DQ

D % (Q - 1).

mbedtls_mpi QP

1 / (Q % P).

mbedtls_mpi RN

cached R^2 mod N.

mbedtls_mpi RP

cached R^2 mod P.

mbedtls_mpi RQ

cached R^2 mod Q.

mbedtls_mpi Vi

The cached blinding value.

mbedtls_mpi Vf

The cached un-blinding value.

int padding

Selects padding mode: #MBEDTLS_RSA_PKCS_V15 for 1.5 padding and #MBEDTLS_RSA_PKCS_V21 for OAEP or PSS.

int hash_id

Hash identifier of mbedtls_md_type_t type, as specified in md.h for use in the MGF mask generating function used in the EME-OAEP and EMSA-PSS encodings.

mbedtls_threading_mutex_t mutex

Thread-safety mutex.

cmox_rsa_handle_t rsa_ctx

ptr on rsa generic ctx