API Reference | developer.brewmp.com API Reference | developer.brewmp.com

Developer

API Reference

IRSA_ENCRYPT()

Brew Release
Brew MP 1.0.2
See Also
Error Codes IRSA
Description
This routine encrypts given data, which must be less than the size of the modulus specified in the IRSA object. It pads the data with the specified padding type provided in the ePadType parameter, and encrypts it using the modululs and exponent the user set up the IRSA object with in a previous call to IRSA_Init.
If padding type is AEE_RSA_NO_PADDING, the cbIn must be of the same size as the modulus. For other padding types, the input length must be less than the block size. For the padding types provided, there must be atleast 11 spare bytes below the block size (ie for 512 bit(64byte) modulus, the data must be <= 53 (64-11) bytes).
Use this function with a private key for the signing operation.
Params
pIRSA
[]:
pointer to the IRSA interface.
pbIn
[]:
[in] pointer to buffer of data to encrypt.
cbIn
[]:
[in] length of input buffer.
pbOut
[]:
[out] pointer to buffer to store encrpypted data, caller allocated.
pcbOut
[]:
[in/out] length of output buffer on input, length of data on output.
ePadType
[]:
[in] type of padding to use.
pdwResult
[]:
[out] result code.
pCB
[]:
[in] completion callback.
Interface
Prototype
  •    void IRSA_Encrypt
       (
          IRSA* pIRSA, 
          const byte* pbIn, 
          int cbIn, 
          byte* pbOut, 
          int *pcbOut, 
          int ePadType, 
          uint32* pdwResult, 
          AEECallback *pCB
       );
    
Return
  • None. The result code is passed back in the pdwResult parameter.
    AEE_SUCCESS: if task is successful AEESEC_CRYPT_INVALID_KEY: key not set, Init not called AEESEC_CRYPT_INVALID_SIZE: cbIn is not equal to the modulus size or pbIn is bigger than the modulus (in the case where ePadType is AEE_RSA_NO_PADDING). AEE_ENOMEMORY: ran out of memory while processing AEE_CRYPT_BUFFER_TOO_SMALL: output buffer to small AEE_CRYPT_INVALID_PADTYPE: padding type given was wrong AEE_ECLASSNOTSUPPORT: internal depedency failure, unable to instantiate an object of class implementing hash function needed to complete the operation.
    This function can return errors returned by CreateInstance of internal dependency classes.
Side Effect
  • None
Comments
This routine does a private or public encrypt based on how the caller has configured the IRSA object beforehand and the padding type the user specifies. The input data, pbIn, must be valid until the callback is called. The data is not copied. ePadType must be one of the following: AEE_RSA_PKCS1TYPE1_PADDING - PKCS #1 v1.5 padding. This currently is the most widely used mode. AEE_RSA_PKCS1TYPE2_PADDING - PKCS #1 v2.0 padding. This currently is the most widely used mode. AEE_RSA_SSLV23_PADDING - PKCS #1 v1.5 padding with an SSL-specific modification that denotes that the server is SSL3 capable AEE_RSA_PKCS1_OAEP_SHA1_MGF1_PADDING - PKCS #1 v2.1 padding with OAEP - This padding type added in Brew 3.1.4 AEE_RSA_NO_PADDING - No padding used. Application should only use cryptographically sound padding modes The operation may be cancelled by calling CALLBACK_Cancel on pCB.