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


API Reference


Brew Release
Brew MP 1.0.2
See Also
IPubKey_Encrypt(), IPubKey_SetParam()

Call this method to perform decryption using a private key. The data in the input buffer is decrypted, padding is removed and the result is placed in the output buffer.

Many of the details depend on the algorithm, the implementation, and the cryptographic standard (e.g. RSA using PKCS1). These details are documented with each specific implementation using this interface.

Note that decryption is usually the exact reverse of encryption for a given padding mode and encryption standard, but not always. See implementation documentation.
Pointer to the IPubKey interface
[in] pointer to buffer of data to decrypt
[in] length of input buffer
[out] Pointer to buffer to store encrpypted data, caller allocated
[in/out] Length of output buffer on input, length of data on output
[in] Type of padding to use
[out] Result code
[in] Pointer to callback record (called when async operation completes) Return
Decrypt successful
Output buffer to small
Private key not set, SetParam not called
Padding type given was wrong
After decryption, padding decoding failed (probably means decryption was with wrong key or otherwise failed)
nInBufLen is not equal to the modulus size or pucInBuf is bigger than the modulus
If Decryption is not supported by this implementation
Ran out of memory while processing
Other error codes as returned by engine
  •    void IPubKey_Decrypt
          IPubKey *pif,
          const uint8 * pucInBuf,
          int nInBufLen,
          uint8 *pucOutBuf,
          int *pnOutBufLen,
          int nPadType,
          int *pnResult,
          AEECallback *pCB
Side Effect
  • None
The key used to decrypt must have been set before the operation is attempted. It is usually set by calling IPubKey_SetParam(), but it may be pre set in some implementations such as hardware key stores. It is also usually the private key of the key pair. The specific parameter IDs depend on the algorithm and implementation. A typical RSA implementation will require the parameter IDs IPUBKEY_PARAM_RSA_PRIV_EXPONENT and IPUBKEY_PARAM_RSA_MODULUS to be set as they make up the public key. The input data, pucInBuf, must be valid until the operation completes. The data is not copied. The input buffer and output buffer cannot be the same. Decryption is not in place. The nPadType parameter specifies the padding type expected after decryption. The padding is usually removed. The possible padding types depends on the implementation. See the specific implementation documentation. Note that with the RSA algorithm private key operations with some implementations, usually software only, are very slow. Five error codes listed above, AEESEC_CRYPT_BUFFER_TOO_SMALL through AEESEC_CRYPT_INVALID_SIZE, result only from bad input, either a bad key or bad padding or such in the input buffer. Usually these inputs come from external sources like a server. All the other errors are hard errors that result from resource issues like lack of memory or from incorrect calling. If a hard error occurs there is no point in calling IPubKey_Decrypt() again even with a different input as it will fail for the same reason. See the general comments on the IPubkey interface for more details on this error convention.