Part Number: CC2745R10-Q1
Tool/software:
Hello,
My environment is as follows:
Board: CC2745R10-Q1
Debugger: XDS110
SDK: SimpleLink Lowpower f3 ver.9.10.00.83
IDE: IAR Embedded Workbench for ARM 9.60.3.7274
PSA API is basically recognized as a synchronous API, but what if you want to use asynchronous processing or callbacks?
Is it possible to achieve the following sample code example [Single call CBC decryption with plaintext CryptoKey in callback return mode] using the PSA API?
ti/simplelink_lowpower_f3_sdk_9_10_00_83/docs/secure_drivers/doxygen/html/_a_e_s_c_b_c_8h.html
#include <ti/drivers/AESCBC.h>
#include <ti/drivers/cryptoutils/cryptokey/CryptoKeyPlaintext.h>
...
// Test vector 0 from NIST CAPV set CBCMMT256
uint8_t iv[16] = {0xdd, 0xbb, 0xb0, 0x17, 0x3f, 0x1e, 0x2d, 0xeb,
0x23, 0x94, 0xa6, 0x2a, 0xa2, 0xa0, 0x24, 0x0e};
uint8_t ciphertext[16] = {0xd5, 0x1d, 0x19, 0xde, 0xd5, 0xca, 0x4a, 0xe1,
0x4b, 0x2b, 0x20, 0xb0, 0x27, 0xff, 0xb0, 0x20};
uint8_t keyingMaterial[32] = {0x43, 0xe9, 0x53, 0xb2, 0xae, 0xa0, 0x8a, 0x3a,
0xd5, 0x2d, 0x18, 0x2f, 0x58, 0xc7, 0x2b, 0x9c,
0x60, 0xfb, 0xe4, 0xa9, 0xca, 0x46, 0xa3, 0xcb,
0x89, 0xe3, 0x86, 0x38, 0x45, 0xe2, 0x2c, 0x9e};
uint8_t plaintext[sizeof(ciphertext)];
// The plaintext should be the following after the decryption operation:
// 0x07, 0x27, 0x0d, 0x0e, 0x63, 0xaa, 0x36, 0xda
// 0xed, 0x8c, 0x6a, 0xde, 0x13, 0xac, 0x1a, 0xf1
void cbcCallback(AESCBC_Handle handle,
int_fast16_t returnValue,
AESCBC_OperationUnion *operation,
AESCBC_OperationType operationType) {
if (returnValue != AESCBC_STATUS_SUCCESS) {
// handle error
}
if (operationType == AESCBC_OPERATION_TYPE_DECRYPT ||
operationType == AESCBC_OPERATION_TYPE_ENCRYPT) {
// do something with operation->oneStepOperation
} else {
// do something with operation->segmentedOperation
}
}
AESCBC_OneStepOperation operation;
void cbcStartFunction(void) {
AESCBC_Handle handle;
AESCBC_Params params;
CryptoKey cryptoKey;
int_fast16_t decryptionResult;
AESCBC_Params_init(¶ms);
params.returnBehavior = AESCBC_RETURN_BEHAVIOR_CALLBACK;
params.callbackFxn = cbcCallback;
handle = AESCBC_open(0, ¶ms);
if (handle == NULL) {
// handle error
}
CryptoKeyPlaintext_initKey(&cryptoKey, keyingMaterial, sizeof(keyingMaterial));
AESCBC_OneStepOperation_init(&operation);
operation.key = &cryptoKey;
operation.input = ciphertext;
operation.output = plaintext;
operation.inputLength = sizeof(ciphertext);
operation.iv = iv;
decryptionResult = AESCBC_oneStepDecrypt(handle, &operation);
if (decryptionResult != AESCBC_STATUS_SUCCESS) {
// handle error
}
// do other things while CBC operation completes in the background
}
Best,
