[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: C_Decrypt / C_DecryptFinal behavior
1.ÂÂÂÂÂIfÂpBufÂis NULL_PTR, then all that the function does is return (in *pulBufLen) a number of bytes which would suffice to hold the cryptographic output produced from the input to the function. This number may somewhat exceed the precise number of bytes needed, but should not exceed it by a large amount. CKR_OK is returned by the function.
2.ÂÂÂÂÂIfÂpBufÂis not NULL_PTR, then *pulBufLenÂMUST contain the size in bytes of the buffer pointed to byÂpBuf. If that buffer is large enough to hold the cryptographic output produced from the input to the function, then that cryptographic output is placed there, and CKR_OK is returned by the function. If the buffer is not large enough, then CKR_BUFFER_TOO_SMALL is returned. In either case, *pulBufLenÂis set to hold theÂexactÂnumber of bytes needed to hold the cryptographic output produced from the input to the function.
CK_BYTE ciphertext[AES_BLOCK_LEN * 4000] = { â };CK_BYTE_PTR *plaintext;CK_ULONG len;CK_MECHANISM mech = { CKM_AES_CBC_PAD, iv, ivlen };/* Note that plaintext is << ciphertext */plaintext = malloc(AES_BLOCK_LEN * 2);len = AES_BLOCK_LEN * 2;C_DecryptInit(handle, &mech, keyHandle);/*Â* This should return CKR_BUFFER_TOO_SMALL, however to set len appropriately,Â* the entire contents of ciphertext must be decrypted, and the resulting ciphertextÂ* must be saved internally as part of the operation, or the decryption operation stateÂ* must support some sort of rollback or snapshot to perform the full decryptionÂ* each time C_Decrypt() is called without the current operation terminating.Â*/C_Decrypt(hSession, ciphertext, sizeof (ciphertext), plaintext, &len);
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]