This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Need support for RSA crypto algorithm for Digital Signature

Hi Team,

For our development we are using the nRF52840 soc, We need the some example code or some project which will explains the Usage of RSA algorithm and supported API's for Digital Signature generation and Verification.

Currently we have Crypto backend (CC310, uECC, Oberon, mbed TLS) examples programs which is covering the ECC(ECDSA, ECDH) with supported ECC Curves. We need the some example code which supports the RSA.

It would be more helpful to us if we have any reference projest on RSA.

Regards,

Srinivas.V

  • Hi Einar,

    Thanks for your reply. I have cross checked in code for the buffer size. we are allocating the size which is given example project like 256

    Is there  any other things we need to take care.

    #define TST_MAX_PRVT_EXP_SIZE_IN_BYTES                              256
    
    typedef struct rsaSignVerifyDataStuct
    {	
        char				        rsaSignVerify_Name[MAX_TEST_DATA_SIZE];
        uint8_t 		                        rsaSignVerify_PrivetExponent_D[TST_MAX_PRVT_EXP_SIZE_IN_BYTES];
        uint8_t					rsaSignVerify_PublicExponent_E[TST_MAX_PRVT_EXP_SIZE_IN_BYTES];
        uint8_t					rsaSignVerify_Modulus_N[TST_MAX_MOD_SIZE_IN_BYTES];
        uint8_t					rsaSignVerify_P[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2]; 
        uint8_t					rsaSignVerify_Q[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2];  	   
        uint8_t					rsaSignVerify_dP[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2];
        uint8_t					rsaSignVerify_dQ[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2];
        uint8_t					rsaSignVerify_Qinv[TST_MAX_PRVT_EXP_SIZE_IN_BYTES/2];		  	
        uint16_t					rsaSignVerify_KeySize;
        uint16_t					rsaSignVerify_DPSize;
        uint16_t					rsaSignVerify_PubExponentSize; 
        uint16_t					rsaSignVerify_SaltLength;
        uint8_t 					rsaSignVerify_input_data[TST_MAX_SIGN_VERIFY_DATA_IN_BYTES];
        uint16_t 					rsaSignVerify_input_dataSize;
        uint8_t 					rsaSignVerify_output_signiture[TST_MAX_PRVT_EXP_SIZE_IN_BYTES];	
        uint8_t                   	                rsaSignVerify_hash_SHA1[CRYS_HASH_SHA1_DIGEST_SIZE_IN_BYTES];
        uint8_t                   	                rsaSignVerify_hash_SHA256[CRYS_HASH_SHA256_DIGEST_SIZE_IN_BYTES];
        uint8_t                   	                rsaSignVerify_hash_SHA512[CRYS_HASH_SHA512_DIGEST_SIZE_IN_BYTES];
        
    } rsaSignVerifyDataStuct;
    
    uint8_trsaSignVerify_output_signiture[TST_MAX_PRVT_EXP_SIZE_IN_BYTES];	

    Regards,

    Srinivas.V

  • Hi Srinivas,

    Srinivas V said:

    Thanks for your reply. I have cross checked in code for the buffer size. we are allocating the size which is given example project like 256

    Is there  any other things we need to take care.

    I have checked the implementation in the runtime library, and a too small buffer is the only explanation for this. But please note that the library has no idea about the buffer size other than what you tell it. So I assume you pass the wrong length. I cannot say for sure without seeing more of your code, but my guess is that referring to the code in this post, you have the wrong value of ActualSignatureSize. This is a in/out variable, where you populate it with the buffer size before the call to CRYS_RSA_PSS_Sign(), and as an output it has the actual signature size.

    Einar

Related