Lines Matching refs:object

110 static inline int_fast16_t AESCCMLPF3_finishTag(AESCCMLPF3_Object *object, AESCCM_Mode direction);
114 static int_fast16_t AESCCMLPF3_performFinalizeChecks(const AESCCMLPF3_Object *object,
127 static inline int_fast16_t AESCCMLPF3_processOneStepDecryptPolling(AESCCMLPF3_Object *object,
129 static inline int_fast16_t AESCCMLPF3_processOneStepEncryptPolling(AESCCMLPF3_Object *object,
131 static int_fast16_t AESCCMLPF3_setupSegmentedOperation(AESCCMLPF3_Object *object,
138 static int_fast16_t AESCCMLPF3_processSegmentedCBCMAC(AESCCMLPF3_Object *object,
142 static int_fast16_t AESCCMLPF3_processSegmentedCTR(AESCCMLPF3_Object *object, size_t dataSegmentLen…
143 static void AESCCMLPF3_processTagCTR(AESCCMLPF3_Object *object);
144 static int_fast16_t AESCCMLPF3_waitForDMA(const AESCCMLPF3_Object *object);
169 static int_fast16_t AESCCMLPF3HSM_performFinalizeChecks(const AESCCMLPF3_Object *object,
171 static int_fast16_t AESCCMLPF3HSM_setupSegmentedOperation(AESCCMLPF3_Object *object,
186 AESCCMLPF3_Object *object = (AESCCMLPF3_Object *)handle->object; in AESCCMLPF3_getObject() local
187 DebugP_assert(object); in AESCCMLPF3_getObject()
189 return object; in AESCCMLPF3_getObject()
204 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3_hwiFxn() local
212 AESCommonLPF3_cleanupHwi(&object->common); in AESCCMLPF3_hwiFxn()
216 if ((object->operationType == AESCCM_OP_TYPE_ONESTEP_DECRYPT) || in AESCCMLPF3_hwiFxn()
217 (object->operationType == AESCCM_OP_TYPE_DATA_DECRYPT) || in AESCCMLPF3_hwiFxn()
218 (object->operationType == AESCCM_OP_TYPE_FINALIZE_DECRYPT)) in AESCCMLPF3_hwiFxn()
227 const uint8_t *plainText = object->input; in AESCCMLPF3_hwiFxn()
230 plainText = object->output; in AESCCMLPF3_hwiFxn()
236 if (object->inputCBCMACLengthRemaining > 0U) in AESCCMLPF3_hwiFxn()
238 size_t inputCBCMACLengthRemaining = object->inputCBCMACLengthRemaining; in AESCCMLPF3_hwiFxn()
240 … AESCCMLPF3_processCBCMACFinalBlock(&plainText[object->inputLength - inputCBCMACLengthRemaining], in AESCCMLPF3_hwiFxn()
243 object->totalCBCMACLengthRemaining -= inputCBCMACLengthRemaining; in AESCCMLPF3_hwiFxn()
244 object->inputCBCMACLengthRemaining = 0U; in AESCCMLPF3_hwiFxn()
248 AESCMACLPF3_readTag((uint32_t *)&object->intermediateTag[0]); in AESCCMLPF3_hwiFxn()
250 if (object->totalCBCMACLengthRemaining == 0U) in AESCCMLPF3_hwiFxn()
252 object->common.returnStatus = AESCCMLPF3_finishTag(object, direction); in AESCCMLPF3_hwiFxn()
261object->common.returnStatus = AESCCMLPF3_processSegmentedCTR(object, object->inputLength); in AESCCMLPF3_hwiFxn()
264 if (object->inputLength < AESCCMLPF3_DMA_SIZE_THRESHOLD) in AESCCMLPF3_hwiFxn()
278 if (object->inputCTRLengthRemaining > 0U) in AESCCMLPF3_hwiFxn()
280 size_t inputCTRLengthRemaining = object->inputCTRLengthRemaining; in AESCCMLPF3_hwiFxn()
282 AESCTRLPF3_processData(&object->input[object->inputLength - inputCTRLengthRemaining], in AESCCMLPF3_hwiFxn()
283 &object->output[object->inputLength - inputCTRLengthRemaining], in AESCCMLPF3_hwiFxn()
287 object->totalCTRLengthRemaining -= inputCTRLengthRemaining; in AESCCMLPF3_hwiFxn()
288 object->inputCTRLengthRemaining = 0U; in AESCCMLPF3_hwiFxn()
291 if (object->totalCTRLengthRemaining > 0U) in AESCCMLPF3_hwiFxn()
294 AESCTRLPF3_readCounter((uint32_t *)&object->intermediateCounter[0]); in AESCCMLPF3_hwiFxn()
303 object->common.returnStatus = AESCCMLPF3_processSegmentedCBCMAC(object, in AESCCMLPF3_hwiFxn()
305 object->inputLength, in AESCCMLPF3_hwiFxn()
309 if (object->inputLength < AESCCMLPF3_DMA_SIZE_THRESHOLD) in AESCCMLPF3_hwiFxn()
321 size_t totalLengthRemaining = object->totalCTRLengthRemaining; in AESCCMLPF3_hwiFxn()
322 totalLengthRemaining += object->totalCBCMACLengthRemaining; in AESCCMLPF3_hwiFxn()
326 AESCommonLPF3_clearOperationInProgress(&object->common); in AESCCMLPF3_hwiFxn()
330 AESCommonLPF3_cleanup(&object->common); in AESCCMLPF3_hwiFxn()
332 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_BLOCKING) in AESCCMLPF3_hwiFxn()
340object->callbackFxn(handle, object->common.returnStatus, object->operation, object->operationType); in AESCCMLPF3_hwiFxn()
348 static inline int_fast16_t AESCCMLPF3_finishTag(AESCCMLPF3_Object *object, AESCCM_Mode direction) in AESCCMLPF3_finishTag() argument
352 AESCCMLPF3_processTagCTR(object); in AESCCMLPF3_finishTag()
354 if (object->mac != NULL) in AESCCMLPF3_finishTag()
358 … (void)memcpy((void *)&object->mac[0], (void *)&object->intermediateTag[0], object->macLength); in AESCCMLPF3_finishTag()
363 …bool macValid = CryptoUtils_buffersMatch(object->intermediateTag, object->mac, (size_t)object->mac… in AESCCMLPF3_finishTag()
378 static int_fast16_t AESCCMLPF3_waitForDMA(const AESCCMLPF3_Object *object) in AESCCMLPF3_waitForDMA() argument
382 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_BLOCKING) in AESCCMLPF3_waitForDMA()
396 status = object->common.returnStatus; in AESCCMLPF3_waitForDMA()
427 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_construct() local
437 object->hsmStatus = HSMLPF3_STATUS_ERROR; in AESCCM_construct()
441 object->hsmStatus = HSMLPF3_STATUS_SUCCESS; in AESCCM_construct()
443 object->segmentedOperationInProgress = false; in AESCCM_construct()
455 object->callbackFxn = params->callbackFxn; in AESCCM_construct()
457 …status = AESCommonLPF3_construct(&object->common, (AES_ReturnBehavior)params->returnBehavior, para… in AESCCM_construct()
474 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_close() local
476 AESCommonLPF3_close(&object->common); in AESCCM_close()
754 static inline int_fast16_t AESCCMLPF3_processOneStepEncryptPolling(AESCCMLPF3_Object *object, in AESCCMLPF3_processOneStepEncryptPolling() argument
758 …AESCCMLPF3_processOneStepCBCMACPolling(operation, (uint32_t *)&object->intermediateTag[0], AESCCM_… in AESCCMLPF3_processOneStepEncryptPolling()
761 AESCCMLPF3_processOneStepCTRPolling(operation, (uint32_t *)&object->intermediateTag[0]); in AESCCMLPF3_processOneStepEncryptPolling()
763 …(void)memcpy((void *)&operation->mac[0], (void *)&object->intermediateTag[0], operation->macLength… in AESCCMLPF3_processOneStepEncryptPolling()
772 static inline int_fast16_t AESCCMLPF3_processOneStepDecryptPolling(AESCCMLPF3_Object *object, in AESCCMLPF3_processOneStepDecryptPolling() argument
782 mac = (uint32_t *)&object->intermediateCounter[0]; in AESCCMLPF3_processOneStepDecryptPolling()
791 …AESCCMLPF3_processOneStepCBCMACPolling(operation, (uint32_t *)&object->intermediateTag[0], AESCCM_… in AESCCMLPF3_processOneStepDecryptPolling()
794 macValid = CryptoUtils_buffersMatch(object->intermediateTag, mac, (size_t)operation->macLength); in AESCCMLPF3_processOneStepDecryptPolling()
824 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3_oneStepOperation() local
848 if ((object->common.returnBehavior != AES_RETURN_BEHAVIOR_POLLING) && in AESCCMLPF3_oneStepOperation()
857 status = AESCommonLPF3_setOperationInProgress(&object->common); in AESCCMLPF3_oneStepOperation()
864 if (!CryptoResourceLPF3_acquireLock(object->common.semaphoreTimeout)) in AESCCMLPF3_oneStepOperation()
866 AESCommonLPF3_clearOperationInProgress(&object->common); in AESCCMLPF3_oneStepOperation()
870 object->common.cryptoResourceLocked = true; in AESCCMLPF3_oneStepOperation()
871 object->common.returnStatus = AESCCM_STATUS_SUCCESS; in AESCCMLPF3_oneStepOperation()
878 if ((object->common.returnBehavior == AES_RETURN_BEHAVIOR_POLLING) || in AESCCMLPF3_oneStepOperation()
883 status = AESCCMLPF3_processOneStepEncryptPolling(object, operation); in AESCCMLPF3_oneStepOperation()
887 status = AESCCMLPF3_processOneStepDecryptPolling(object, operation); in AESCCMLPF3_oneStepOperation()
892 object->operation = (AESCCM_OperationUnion *)operation; in AESCCMLPF3_oneStepOperation()
893 object->operationType = operationType; in AESCCMLPF3_oneStepOperation()
896 object->input = operation->input; in AESCCMLPF3_oneStepOperation()
897 object->output = operation->output; in AESCCMLPF3_oneStepOperation()
898 object->mac = operation->mac; in AESCCMLPF3_oneStepOperation()
899 object->aad = operation->aad; in AESCCMLPF3_oneStepOperation()
900 object->nonce = operation->nonce; in AESCCMLPF3_oneStepOperation()
903 object->nonceLength = operation->nonceLength; in AESCCMLPF3_oneStepOperation()
904 object->totalAADLength = operation->aadLength; in AESCCMLPF3_oneStepOperation()
905 object->totalDataLength = operation->inputLength; in AESCCMLPF3_oneStepOperation()
906 object->totalCBCMACLengthRemaining = operation->inputLength; in AESCCMLPF3_oneStepOperation()
907 object->totalCTRLengthRemaining = operation->inputLength; in AESCCMLPF3_oneStepOperation()
908 object->macLength = operation->macLength; in AESCCMLPF3_oneStepOperation()
911 object->aadBytesProcessed = 0U; in AESCCMLPF3_oneStepOperation()
912 object->bufferedAADLength = (uint8_t)0U; in AESCCMLPF3_oneStepOperation()
928 status = AESCCMLPF3_processSegmentedCBCMAC(object, operation->aadLength, 0, direction); in AESCCMLPF3_oneStepOperation()
941 AESCommonLPF3_clearOperationInProgress(&object->common); in AESCCMLPF3_oneStepOperation()
944 AESCommonLPF3_cleanup(&object->common); in AESCCMLPF3_oneStepOperation()
946 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCMLPF3_oneStepOperation()
948 object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, operationType); in AESCCMLPF3_oneStepOperation()
1009 static int_fast16_t AESCCMLPF3_setupSegmentedOperation(AESCCMLPF3_Object *object, in AESCCMLPF3_setupSegmentedOperation() argument
1017 int_fast16_t status = AESCommonLPF3_setupSegmentedOperation(&object->common, key); in AESCCMLPF3_setupSegmentedOperation()
1024 object->totalAADLength = totalAADLength; in AESCCMLPF3_setupSegmentedOperation()
1025 object->totalDataLength = totalDataLength; in AESCCMLPF3_setupSegmentedOperation()
1026 object->macLength = (uint8_t)macLength; in AESCCMLPF3_setupSegmentedOperation()
1028 object->totalCTRLengthRemaining = totalDataLength; in AESCCMLPF3_setupSegmentedOperation()
1029 object->totalCBCMACLengthRemaining = totalDataLength; in AESCCMLPF3_setupSegmentedOperation()
1030 object->aadBytesProcessed = 0U; in AESCCMLPF3_setupSegmentedOperation()
1031 object->bufferedAADLength = (uint8_t)0U; in AESCCMLPF3_setupSegmentedOperation()
1036 object->mac = NULL; in AESCCMLPF3_setupSegmentedOperation()
1041 object->operation = NULL; in AESCCMLPF3_setupSegmentedOperation()
1057 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_setupEncrypt() local
1066 int_fast16_t status = AESCCMLPF3_setupSegmentedOperation(object, in AESCCM_setupEncrypt()
1073 object->operationType = AESCCM_OPERATION_TYPE_ENCRYPT; in AESCCM_setupEncrypt()
1090 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_setupDecrypt() local
1099 int_fast16_t status = AESCCMLPF3_setupSegmentedOperation(object, in AESCCM_setupDecrypt()
1106 object->operationType = AESCCM_OPERATION_TYPE_DECRYPT; in AESCCM_setupDecrypt()
1119 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_setLengths() local
1122 DebugP_assert(object->operationType == AESCCM_OPERATION_TYPE_DECRYPT || in AESCCM_setLengths()
1123 object->operationType == AESCCM_OPERATION_TYPE_ENCRYPT); in AESCCM_setLengths()
1128 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCM_setLengths()
1130 return object->common.returnStatus; in AESCCM_setLengths()
1139 object->totalAADLength = aadLength; in AESCCM_setLengths()
1140 object->totalDataLength = plaintextLength; in AESCCM_setLengths()
1141 object->totalCBCMACLengthRemaining = plaintextLength; in AESCCM_setLengths()
1142 object->totalCTRLengthRemaining = plaintextLength; in AESCCM_setLengths()
1143 object->macLength = (uint8_t)macLength; in AESCCM_setLengths()
1156 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_setNonce() local
1159 DebugP_assert((object->operationType == AESCCM_OPERATION_TYPE_DECRYPT) || in AESCCM_setNonce()
1160 (object->operationType == AESCCM_OPERATION_TYPE_ENCRYPT)); in AESCCM_setNonce()
1165 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCM_setNonce()
1167 return object->common.returnStatus; in AESCCM_setNonce()
1176 object->nonce = nonce; in AESCCM_setNonce()
1177 object->nonceLength = (uint8_t)nonceLength; in AESCCM_setNonce()
1199 static int_fast16_t AESCCMLPF3_processSegmentedCBCMAC(AESCCMLPF3_Object *object, in AESCCMLPF3_processSegmentedCBCMAC() argument
1212 …if ((object->aadBytesProcessed == 0U) && (object->totalCBCMACLengthRemaining == object->totalDataL… in AESCCMLPF3_processSegmentedCBCMAC()
1217 AESCCMLPF3_processB0(object->nonce, in AESCCMLPF3_processSegmentedCBCMAC()
1218 object->nonceLength, in AESCCMLPF3_processSegmentedCBCMAC()
1219 object->totalAADLength, in AESCCMLPF3_processSegmentedCBCMAC()
1220 object->totalDataLength, in AESCCMLPF3_processSegmentedCBCMAC()
1221 object->macLength); in AESCCMLPF3_processSegmentedCBCMAC()
1226 AESWriteTag32((uint32_t *)&object->intermediateTag[0]); in AESCCMLPF3_processSegmentedCBCMAC()
1237 if (object->aadBytesProcessed == 0U) in AESCCMLPF3_processSegmentedCBCMAC()
1240 object->aadBytesProcessed = AESCCMLPF3_processB1withAAD(object->aad, in AESCCMLPF3_processSegmentedCBCMAC()
1242 object->totalAADLength); in AESCCMLPF3_processSegmentedCBCMAC()
1243 aadBytesRemaining -= object->aadBytesProcessed; in AESCCMLPF3_processSegmentedCBCMAC()
1253 if (object->bufferedAADLength > (uint8_t)0U) in AESCCMLPF3_processSegmentedCBCMAC()
1263 aadBlock.bytes[0] = object->bufferedAAD[0]; in AESCCMLPF3_processSegmentedCBCMAC()
1264 aadBlock.bytes[1] = object->bufferedAAD[1]; in AESCCMLPF3_processSegmentedCBCMAC()
1267 const uint8_t *newAAD = &object->aad[aadSegmentLength - aadBytesRemaining]; in AESCCMLPF3_processSegmentedCBCMAC()
1276 object->aadBytesProcessed += AES_BLOCK_SIZE; in AESCCMLPF3_processSegmentedCBCMAC()
1285 object->aadBytesProcessed += (aadBytesRemaining + AESCCMLPF3_AAD_BUFFER_SIZE); in AESCCMLPF3_processSegmentedCBCMAC()
1291 object->bufferedAADLength = (uint8_t)0U; in AESCCMLPF3_processSegmentedCBCMAC()
1298 AESCMACLPF3_processBlocks(&object->aad[aadSegmentLength - aadBytesRemaining], in AESCCMLPF3_processSegmentedCBCMAC()
1301 object->aadBytesProcessed += blockSizeAlignedAADLength; in AESCCMLPF3_processSegmentedCBCMAC()
1307 if ((object->aadBytesProcessed + aadBytesRemaining) == object->totalAADLength) in AESCCMLPF3_processSegmentedCBCMAC()
1309 … AESCCMLPF3_processCBCMACFinalBlock(&object->aad[aadSegmentLength - aadBytesRemaining], in AESCCMLPF3_processSegmentedCBCMAC()
1311 object->aadBytesProcessed += aadBytesRemaining; in AESCCMLPF3_processSegmentedCBCMAC()
1316 … const uint8_t *aadRemaining = &object->aad[aadSegmentLength - AESCCMLPF3_AAD_BUFFER_SIZE]; in AESCCMLPF3_processSegmentedCBCMAC()
1317 object->bufferedAAD[0] = *aadRemaining; in AESCCMLPF3_processSegmentedCBCMAC()
1318 object->bufferedAAD[1] = *(aadRemaining + 1U); in AESCCMLPF3_processSegmentedCBCMAC()
1319 object->bufferedAADLength = (uint8_t)AESCCMLPF3_AAD_BUFFER_SIZE; in AESCCMLPF3_processSegmentedCBCMAC()
1343 const uint8_t *plainText = object->input; in AESCCMLPF3_processSegmentedCBCMAC()
1346 plainText = object->output; in AESCCMLPF3_processSegmentedCBCMAC()
1351 if ((object->common.returnBehavior == AES_RETURN_BEHAVIOR_POLLING) || in AESCCMLPF3_processSegmentedCBCMAC()
1368 object->inputCBCMACLengthRemaining -= dataSegmentLength; in AESCCMLPF3_processSegmentedCBCMAC()
1369 object->totalCBCMACLengthRemaining -= dataSegmentLength; in AESCCMLPF3_processSegmentedCBCMAC()
1377 AESCommonLPF3_setupDMA(&object->common, AESCBCMACLPF3_DMA_CONFIG); in AESCCMLPF3_processSegmentedCBCMAC()
1384 object->inputCBCMACLengthRemaining -= blockSizeAlignedDataRemaining; in AESCCMLPF3_processSegmentedCBCMAC()
1385 object->totalCBCMACLengthRemaining -= blockSizeAlignedDataRemaining; in AESCCMLPF3_processSegmentedCBCMAC()
1396 status = AESCCMLPF3_waitForDMA(object); in AESCCMLPF3_processSegmentedCBCMAC()
1401 AESCMACLPF3_readTag((uint32_t *)&object->intermediateTag[0]); in AESCCMLPF3_processSegmentedCBCMAC()
1455 static void AESCCMLPF3_processTagCTR(AESCCMLPF3_Object *object) in AESCCMLPF3_processTagCTR() argument
1464 AESCCMLPF3_processCTRCounterBlock(object->nonce, object->nonceLength, (uint8_t)0U); in AESCCMLPF3_processTagCTR()
1467 AESWriteTXTXOR32((uint32_t *)&object->intermediateTag[0]); in AESCCMLPF3_processTagCTR()
1470 AESReadTag32((uint32_t *)&object->intermediateTag[0]); in AESCCMLPF3_processTagCTR()
1476 static int_fast16_t AESCCMLPF3_processSegmentedCTR(AESCCMLPF3_Object *object, size_t dataSegmentLen… in AESCCMLPF3_processSegmentedCTR() argument
1482 if (object->totalCTRLengthRemaining == object->totalDataLength) in AESCCMLPF3_processSegmentedCTR()
1489 if ((object->common.returnBehavior != AES_RETURN_BEHAVIOR_POLLING) && in AESCCMLPF3_processSegmentedCTR()
1494 …bytesProcessed = AESCTRLPF3_configDataDMA(&object->common, object->input, object->output, dataSegm… in AESCCMLPF3_processSegmentedCTR()
1496 object->totalCTRLengthRemaining -= bytesProcessed; in AESCCMLPF3_processSegmentedCTR()
1497 object->inputCTRLengthRemaining -= bytesProcessed; in AESCCMLPF3_processSegmentedCTR()
1506 AESCCMLPF3_processCTRCounterBlock(object->nonce, object->nonceLength, (uint8_t)1U); in AESCCMLPF3_processSegmentedCTR()
1511 AESCTRLPF3_writeCounter((uint32_t *)&object->intermediateCounter[0]); in AESCCMLPF3_processSegmentedCTR()
1516 status = AESCCMLPF3_waitForDMA(object); in AESCCMLPF3_processSegmentedCTR()
1521 AESCTRLPF3_processData(object->input, object->output, dataSegmentLength, false); in AESCCMLPF3_processSegmentedCTR()
1523 object->totalCTRLengthRemaining -= dataSegmentLength; in AESCCMLPF3_processSegmentedCTR()
1526 AESCTRLPF3_readCounter((uint32_t *)&object->intermediateCounter[0]); in AESCCMLPF3_processSegmentedCTR()
1540 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_addAAD() local
1543 if (object->common.key.encoding == CryptoKey_PLAINTEXT_HSM) in AESCCM_addAAD()
1551 object->operation = (AESCCM_OperationUnion *)operation; in AESCCM_addAAD()
1556 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCM_addAAD()
1558 return object->common.returnStatus; in AESCCM_addAAD()
1562 DebugP_assert((object->operationType == AESCCM_OPERATION_TYPE_DECRYPT) || in AESCCM_addAAD()
1563 (object->operationType == AESCCM_OPERATION_TYPE_ENCRYPT) || in AESCCM_addAAD()
1564 (object->operationType == AESCCM_OP_TYPE_AAD_DECRYPT) || in AESCCM_addAAD()
1565 (object->operationType == AESCCM_OP_TYPE_AAD_ENCRYPT)); in AESCCM_addAAD()
1567 …size_t calcAADLen = object->aadBytesProcessed + (size_t)object->bufferedAADLength + operation->aad… in AESCCM_addAAD()
1573 …((AES_NON_BLOCK_SIZE_MULTIPLE_LENGTH(operation->aadLength) > 0U) && (calcAADLen != object->totalAA… in AESCCM_addAAD()
1581 if (calcAADLen > object->totalAADLength) in AESCCM_addAAD()
1589 if ((object->operationType == AESCCM_OPERATION_TYPE_DECRYPT) || in AESCCM_addAAD()
1590 (object->operationType == AESCCM_OP_TYPE_AAD_DECRYPT)) in AESCCM_addAAD()
1596 if (!CryptoResourceLPF3_acquireLock(object->common.semaphoreTimeout)) in AESCCM_addAAD()
1601 object->common.cryptoResourceLocked = true; in AESCCM_addAAD()
1606 AESCommonLPF3_loadKey(&object->common.key); in AESCCM_addAAD()
1608 object->operationType = operationType; in AESCCM_addAAD()
1609 object->aad = operation->aad; in AESCCM_addAAD()
1618 status = AESCCMLPF3_processSegmentedCBCMAC(object, operation->aadLength, 0, direction); in AESCCM_addAAD()
1620 if ((status == AESCCM_STATUS_SUCCESS) && (object->totalDataLength == 0U) && in AESCCM_addAAD()
1621 (object->aadBytesProcessed == object->totalAADLength)) in AESCCM_addAAD()
1623 AESCCMLPF3_processTagCTR(object); in AESCCM_addAAD()
1627 AESCommonLPF3_cleanup(&object->common); in AESCCM_addAAD()
1629 object->common.returnStatus = status; in AESCCM_addAAD()
1631 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCM_addAAD()
1633 object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, operationType); in AESCCM_addAAD()
1647 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3_addDataDMA() local
1650 object->inputLength = inputLength; in AESCCMLPF3_addDataDMA()
1651 object->inputCBCMACLengthRemaining = inputLength; in AESCCMLPF3_addDataDMA()
1653 object->inputLength = inputLength; in AESCCMLPF3_addDataDMA()
1654 object->inputCTRLengthRemaining = inputLength; in AESCCMLPF3_addDataDMA()
1666 status = AESCCMLPF3_processSegmentedCBCMAC(object, 0U, inputLength, AESCCM_MODE_ENCRYPT); in AESCCMLPF3_addDataDMA()
1670 status = AESCCMLPF3_processSegmentedCTR(object, inputLength); in AESCCMLPF3_addDataDMA()
1687 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3_addData() local
1689 if (!CryptoResourceLPF3_acquireLock(object->common.semaphoreTimeout)) in AESCCMLPF3_addData()
1694 object->common.cryptoResourceLocked = true; in AESCCMLPF3_addData()
1699 AESCommonLPF3_loadKey(&object->common.key); in AESCCMLPF3_addData()
1701 object->operationType = operationType; in AESCCMLPF3_addData()
1702 object->operation = operation; in AESCCMLPF3_addData()
1704 object->input = input; in AESCCMLPF3_addData()
1705 object->output = output; in AESCCMLPF3_addData()
1709 if ((object->operationType == AESCCM_OP_TYPE_DATA_DECRYPT) || in AESCCMLPF3_addData()
1710 (object->operationType == AESCCM_OP_TYPE_FINALIZE_DECRYPT)) in AESCCMLPF3_addData()
1718 …if ((object->common.returnBehavior == AES_RETURN_BEHAVIOR_POLLING) || (inputLength < AESCCMLPF3_DM… in AESCCMLPF3_addData()
1722 status = AESCCMLPF3_processSegmentedCBCMAC(object, 0, inputLength, AESCCM_MODE_ENCRYPT); in AESCCMLPF3_addData()
1727 status = AESCCMLPF3_processSegmentedCTR(object, inputLength); in AESCCMLPF3_addData()
1732 … status = AESCCMLPF3_processSegmentedCBCMAC(object, 0U, inputLength, AESCCM_MODE_DECRYPT); in AESCCMLPF3_addData()
1735 if ((object->totalCBCMACLengthRemaining == 0U) && (status == AESCCM_STATUS_SUCCESS)) in AESCCMLPF3_addData()
1737 AESCCMLPF3_processTagCTR(object); in AESCCMLPF3_addData()
1740 object->common.returnStatus = status; in AESCCMLPF3_addData()
1743 AESCommonLPF3_cleanup(&object->common); in AESCCMLPF3_addData()
1751 object->common.returnStatus = status; in AESCCMLPF3_addData()
1754 AESCommonLPF3_cleanup(&object->common); in AESCCMLPF3_addData()
1769 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_addData() local
1773 DebugP_assert((object->operationType == AESCCM_OP_TYPE_AAD_ENCRYPT) || in AESCCM_addData()
1774 (object->operationType == AESCCM_OP_TYPE_DATA_ENCRYPT)); in AESCCM_addData()
1776 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCM_addData()
1778 return object->common.returnStatus; in AESCCM_addData()
1790 if (object->common.key.encoding == CryptoKey_PLAINTEXT_HSM) in AESCCM_addData()
1796 … (operation->inputLength != object->totalDataLengthRemaining))) in AESCCM_addData()
1804 if (operation->inputLength > object->totalDataLengthRemaining) in AESCCM_addData()
1816 … (operation->inputLength != object->totalCBCMACLengthRemaining))) in AESCCM_addData()
1824 if (operation->inputLength > object->totalCBCMACLengthRemaining) in AESCCM_addData()
1834 if (object->aadBytesProcessed != object->totalAADLength in AESCCM_addData()
1836 …&& (object->common.key.encoding == CryptoKey_PLAINTEXT || object->common.key.encoding == CryptoKey… in AESCCM_addData()
1844 if ((object->common.returnBehavior != AES_RETURN_BEHAVIOR_POLLING) && in AESCCM_addData()
1852 if ((object->operationType == AESCCM_OPERATION_TYPE_DECRYPT) || in AESCCM_addData()
1853 …(object->operationType == AESCCM_OP_TYPE_AAD_DECRYPT) || (object->operationType == AESCCM_OP_TYPE_… in AESCCM_addData()
1858 …if (object->common.key.encoding == CryptoKey_PLAINTEXT || object->common.key.encoding == CryptoKey… in AESCCM_addData()
1868 else if (object->common.key.encoding == CryptoKey_PLAINTEXT_HSM) in AESCCM_addData()
1884 if ((object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) && in AESCCM_addData()
1887 object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, operationType); in AESCCM_addData()
1904 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_finalizeEncrypt() local
1907 if (object->common.key.encoding == CryptoKey_PLAINTEXT_HSM) in AESCCM_finalizeEncrypt()
1915 status = AESCCMLPF3_performFinalizeChecks(object, operation); in AESCCM_finalizeEncrypt()
1924 object->mac = operation->mac; in AESCCM_finalizeEncrypt()
1925 object->macLength = operation->macLength; in AESCCM_finalizeEncrypt()
1940 if ((object->common.returnBehavior == AES_RETURN_BEHAVIOR_POLLING) || in AESCCM_finalizeEncrypt()
1945 … (void)memcpy(operation->mac, (uint32_t *)&object->intermediateTag[0], operation->macLength); in AESCCM_finalizeEncrypt()
1949 object->common.returnStatus = status; in AESCCM_finalizeEncrypt()
1952 AESCommonLPF3_clearOperationInProgress(&object->common); in AESCCM_finalizeEncrypt()
1954 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCM_finalizeEncrypt()
1956object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, AESCCM_OP_TYPE_FINALIZE_EN… in AESCCM_finalizeEncrypt()
1974 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_finalizeDecrypt() local
1977 if (object->common.key.encoding == CryptoKey_PLAINTEXT_HSM) in AESCCM_finalizeDecrypt()
1985 status = AESCCMLPF3_performFinalizeChecks(object, operation); in AESCCM_finalizeDecrypt()
1994 object->mac = operation->mac; in AESCCM_finalizeDecrypt()
1995 object->macLength = operation->macLength; in AESCCM_finalizeDecrypt()
2005 if ((object->common.returnBehavior == AES_RETURN_BEHAVIOR_POLLING) || in AESCCM_finalizeDecrypt()
2011 bool macValid = CryptoUtils_buffersMatch(object->intermediateTag, in AESCCM_finalizeDecrypt()
2022 object->common.returnStatus = status; in AESCCM_finalizeDecrypt()
2025 AESCommonLPF3_clearOperationInProgress(&object->common); in AESCCM_finalizeDecrypt()
2027 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCM_finalizeDecrypt()
2029object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, AESCCM_OP_TYPE_FINALIZE_DE… in AESCCM_finalizeDecrypt()
2042 static int_fast16_t AESCCMLPF3_performFinalizeChecks(const AESCCMLPF3_Object *object, in AESCCMLPF3_performFinalizeChecks() argument
2046 DebugP_assert((object->operationType == AESCCM_OP_TYPE_AAD_ENCRYPT) || in AESCCMLPF3_performFinalizeChecks()
2047 (object->operationType == AESCCM_OP_TYPE_DATA_ENCRYPT)); in AESCCMLPF3_performFinalizeChecks()
2052 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCMLPF3_performFinalizeChecks()
2054 return object->common.returnStatus; in AESCCMLPF3_performFinalizeChecks()
2066 if (object->aadBytesProcessed != object->totalAADLength) in AESCCMLPF3_performFinalizeChecks()
2072 if (operation->inputLength != object->totalCBCMACLengthRemaining) in AESCCMLPF3_performFinalizeChecks()
2078 if ((object->common.returnBehavior != AES_RETURN_BEHAVIOR_POLLING) && in AESCCMLPF3_performFinalizeChecks()
2094 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCM_cancelOperation() local
2097 if (object->common.returnBehavior != AES_RETURN_BEHAVIOR_CALLBACK) in AESCCM_cancelOperation()
2109 … if (((object->common.key.encoding & CRYPTOKEY_HSM) == 0) && (!object->common.operationInProgress)) in AESCCM_cancelOperation()
2111 if (!object->common.operationInProgress) in AESCCM_cancelOperation()
2123 AESCommonLPF3_cancelOperation(&object->common, true); in AESCCM_cancelOperation()
2131 object->segmentedOperationInProgress = false; in AESCCM_cancelOperation()
2143 …if ((object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) && (object->operation != NULL)) in AESCCM_cancelOperation()
2146object->callbackFxn(handle, AESCCM_STATUS_CANCELED, object->operation, object->operationType); in AESCCM_cancelOperation()
2150 (void)memset(object->output, 0, object->totalDataLength); in AESCCM_cancelOperation()
2152 object->aad = NULL; in AESCCM_cancelOperation()
2153 object->input = NULL; in AESCCM_cancelOperation()
2154 object->output = NULL; in AESCCM_cancelOperation()
2155 object->nonce = NULL; in AESCCM_cancelOperation()
2156 object->mac = NULL; in AESCCM_cancelOperation()
2157 object->operation = NULL; in AESCCM_cancelOperation()
2159 object->inputLength = 0; in AESCCM_cancelOperation()
2160 object->totalCBCMACLengthRemaining = 0; in AESCCM_cancelOperation()
2161 object->totalCTRLengthRemaining = 0; in AESCCM_cancelOperation()
2162 object->totalAADLength = 0; in AESCCM_cancelOperation()
2163 object->totalDataLength = 0; in AESCCM_cancelOperation()
2164 object->aadBytesProcessed = 0; in AESCCM_cancelOperation()
2166 object->macLength = 0; in AESCCM_cancelOperation()
2167 object->nonceLength = 0; in AESCCM_cancelOperation()
2182 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_setMac() local
2185 DebugP_assert((object->operationType == AESCCM_OPERATION_TYPE_DECRYPT) || in AESCCMLPF3HSM_setMac()
2186 (object->operationType == AESCCM_OPERATION_TYPE_ENCRYPT)); in AESCCMLPF3HSM_setMac()
2191 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCMLPF3HSM_setMac()
2193 return object->common.returnStatus; in AESCCMLPF3HSM_setMac()
2196 object->mac = (uint8_t *)mac; in AESCCMLPF3HSM_setMac()
2197 object->macLength = (uint8_t)macLength; in AESCCMLPF3HSM_setMac()
2208 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_createAssetPostProcessing() local
2214 object->tempAssetID = HSMLPF3_getResultAssetID(); in AESCCMLPF3HSM_createAssetPostProcessing()
2218 object->common.returnStatus = status; in AESCCMLPF3HSM_createAssetPostProcessing()
2232 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_createTempAssetID() local
2272 status = object->common.returnStatus; in AESCCMLPF3HSM_createTempAssetID()
2291 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_oneStepPostProcessing() local
2292 AESCCM_OneStepOperation *oneStepOperation = (AESCCM_OneStepOperation *)object->operation; in AESCCMLPF3HSM_oneStepPostProcessing()
2307 if (object->operationType == AESCCM_OP_TYPE_ONESTEP_ENCRYPT) in AESCCMLPF3HSM_oneStepPostProcessing()
2314 else if ((object->operationType == AESCCM_OP_TYPE_ONESTEP_DECRYPT) || in AESCCMLPF3HSM_oneStepPostProcessing()
2320 object->common.returnStatus = status; in AESCCMLPF3HSM_oneStepPostProcessing()
2326 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCMLPF3HSM_oneStepPostProcessing()
2328object->callbackFxn(handle, object->common.returnStatus, object->operation, object->operationType); in AESCCMLPF3HSM_oneStepPostProcessing()
2339 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_processOneStepOperation() local
2348 HSMLPF3_constructAESCCMOneStepPhysicalToken(object); in AESCCMLPF3HSM_processOneStepOperation()
2350 hsmRetval = HSMLPF3_submitToken((HSMLPF3_ReturnBehavior)object->common.returnBehavior, in AESCCMLPF3HSM_processOneStepOperation()
2359 status = object->common.returnStatus; in AESCCMLPF3HSM_processOneStepOperation()
2392 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_oneStepOperation() local
2401 if (object->hsmStatus != HSMLPF3_STATUS_SUCCESS) in AESCCMLPF3HSM_oneStepOperation()
2413 if (object->segmentedOperationInProgress) in AESCCMLPF3HSM_oneStepOperation()
2418 object->common.returnStatus = AESCCM_STATUS_SUCCESS; in AESCCMLPF3HSM_oneStepOperation()
2420 object->operation = (AESCCM_OperationUnion *)operation; in AESCCMLPF3HSM_oneStepOperation()
2421 object->operationType = operationType; in AESCCMLPF3HSM_oneStepOperation()
2423 object->common.key = *(operation->key); in AESCCMLPF3HSM_oneStepOperation()
2424 object->input = operation->input; in AESCCMLPF3HSM_oneStepOperation()
2425 object->output = operation->output; in AESCCMLPF3HSM_oneStepOperation()
2426 object->mac = operation->mac; in AESCCMLPF3HSM_oneStepOperation()
2427 object->aad = operation->aad; in AESCCMLPF3HSM_oneStepOperation()
2428 object->nonce = operation->nonce; in AESCCMLPF3HSM_oneStepOperation()
2430 object->inputLength = operation->inputLength; in AESCCMLPF3HSM_oneStepOperation()
2431 object->totalDataLength = operation->inputLength; in AESCCMLPF3HSM_oneStepOperation()
2432 object->macLength = operation->macLength; in AESCCMLPF3HSM_oneStepOperation()
2433 object->aadLength = object->totalAADLength; in AESCCMLPF3HSM_oneStepOperation()
2434 object->totalAADLength = operation->aadLength; in AESCCMLPF3HSM_oneStepOperation()
2435 object->nonceLength = operation->nonceLength; in AESCCMLPF3HSM_oneStepOperation()
2437 object->totalDataLengthRemaining = object->totalDataLength; in AESCCMLPF3HSM_oneStepOperation()
2438 object->totalAADLengthRemaining = object->totalAADLength; in AESCCMLPF3HSM_oneStepOperation()
2440 object->tempAssetID = 0U; in AESCCMLPF3HSM_oneStepOperation()
2451 static int_fast16_t AESCCMLPF3HSM_setupSegmentedOperation(AESCCMLPF3_Object *object, in AESCCMLPF3HSM_setupSegmentedOperation() argument
2460 if (object->hsmStatus != HSMLPF3_STATUS_SUCCESS) in AESCCMLPF3HSM_setupSegmentedOperation()
2466 if (object->segmentedOperationInProgress) in AESCCMLPF3HSM_setupSegmentedOperation()
2472 object->common.key = *key; in AESCCMLPF3HSM_setupSegmentedOperation()
2475 object->common.returnStatus = AES_STATUS_SUCCESS; in AESCCMLPF3HSM_setupSegmentedOperation()
2477 object->segmentedOperationInProgress = true; in AESCCMLPF3HSM_setupSegmentedOperation()
2482 object->totalAADLength = totalAADLength; in AESCCMLPF3HSM_setupSegmentedOperation()
2483 object->totalDataLength = totalDataLength; in AESCCMLPF3HSM_setupSegmentedOperation()
2484 object->macLength = (uint8_t)macLength; in AESCCMLPF3HSM_setupSegmentedOperation()
2486 object->totalCTRLengthRemaining = totalDataLength; in AESCCMLPF3HSM_setupSegmentedOperation()
2487 object->totalCBCMACLengthRemaining = totalDataLength; in AESCCMLPF3HSM_setupSegmentedOperation()
2488 object->aadBytesProcessed = 0U; in AESCCMLPF3HSM_setupSegmentedOperation()
2489 object->bufferedAADLength = (uint8_t)0U; in AESCCMLPF3HSM_setupSegmentedOperation()
2491 object->totalDataLengthRemaining = totalDataLength; in AESCCMLPF3HSM_setupSegmentedOperation()
2492 object->totalAADLengthRemaining = totalAADLength; in AESCCMLPF3HSM_setupSegmentedOperation()
2493 object->inputLength = 0U; in AESCCMLPF3HSM_setupSegmentedOperation()
2494 object->aadLength = 0U; in AESCCMLPF3HSM_setupSegmentedOperation()
2499 object->mac = NULL; in AESCCMLPF3HSM_setupSegmentedOperation()
2504 object->operation = NULL; in AESCCMLPF3HSM_setupSegmentedOperation()
2520 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_setupEncrypt() local
2522 …status = AESCCMLPF3HSM_setupSegmentedOperation(object, key, totalAADLength, totalPlaintextLength, … in AESCCMLPF3HSM_setupEncrypt()
2525 object->operationType = AESCCM_OPERATION_TYPE_ENCRYPT; in AESCCMLPF3HSM_setupEncrypt()
2543 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_setupDecrypt() local
2545 …status = AESCCMLPF3HSM_setupSegmentedOperation(object, key, totalAADLength, totalPlaintextLength, … in AESCCMLPF3HSM_setupDecrypt()
2548 object->operationType = AESCCM_OPERATION_TYPE_DECRYPT; in AESCCMLPF3HSM_setupDecrypt()
2561 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_SegmentedPostProcessing() local
2570 if ((tokenResult == EIP130TOKEN_RESULT_INVALID_LENGTH) && (object->macLength == 0U)) in AESCCMLPF3HSM_SegmentedPostProcessing()
2575 if ((object->operationType == AESCCM_OP_TYPE_DATA_DECRYPT) || in AESCCMLPF3HSM_SegmentedPostProcessing()
2576 (object->operationType == AESCCM_OP_TYPE_FINALIZE_DECRYPT)) in AESCCMLPF3HSM_SegmentedPostProcessing()
2581 …if ((object->operationType == AESCCM_OP_TYPE_AAD_ENCRYPT) || (object->operationType == AESCCM_OP_T… in AESCCMLPF3HSM_SegmentedPostProcessing()
2585 object->totalAADLengthRemaining -= object->aadLength; in AESCCMLPF3HSM_SegmentedPostProcessing()
2586 object->aadLength = 0U; in AESCCMLPF3HSM_SegmentedPostProcessing()
2595 object->totalAADLengthRemaining -= object->aadLength; in AESCCMLPF3HSM_SegmentedPostProcessing()
2596 object->totalDataLengthRemaining -= object->inputLength; in AESCCMLPF3HSM_SegmentedPostProcessing()
2600 HSMLPF3_getAESEncryptTag((uint8_t *)&object->intermediateTag[0]); in AESCCMLPF3HSM_SegmentedPostProcessing()
2602 if ((object->operationType == AESCCM_OP_TYPE_FINALIZE_ENCRYPT) && in AESCCMLPF3HSM_SegmentedPostProcessing()
2603 … ((object->totalDataLengthRemaining == 0U) && (object->totalAADLengthRemaining == 0U))) in AESCCMLPF3HSM_SegmentedPostProcessing()
2605 … (void)memcpy((void *)&object->mac[0], (void *)&object->intermediateTag[0], object->macLength); in AESCCMLPF3HSM_SegmentedPostProcessing()
2612 (object->operationType == AESCCM_OP_TYPE_FINALIZE_DECRYPT)) in AESCCMLPF3HSM_SegmentedPostProcessing()
2614 object->totalAADLengthRemaining -= object->aadLength; in AESCCMLPF3HSM_SegmentedPostProcessing()
2615 object->totalDataLengthRemaining -= object->inputLength; in AESCCMLPF3HSM_SegmentedPostProcessing()
2625 if ((object->operationType == AESCCM_OP_TYPE_FINALIZE_ENCRYPT) || in AESCCMLPF3HSM_SegmentedPostProcessing()
2626 (object->operationType == AESCCM_OP_TYPE_FINALIZE_DECRYPT)) in AESCCMLPF3HSM_SegmentedPostProcessing()
2630 object->segmentedOperationInProgress = false; in AESCCMLPF3HSM_SegmentedPostProcessing()
2633 object->common.returnStatus = status; in AESCCMLPF3HSM_SegmentedPostProcessing()
2635 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCMLPF3HSM_SegmentedPostProcessing()
2637 object->callbackFxn(handle, status, object->operation, object->operationType); in AESCCMLPF3HSM_SegmentedPostProcessing()
2649 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_addAAD() local
2653 object->operation = (AESCCM_OperationUnion *)operation; in AESCCMLPF3HSM_addAAD()
2655 if (object->totalAADLengthRemaining == object->totalAADLength) in AESCCMLPF3HSM_addAAD()
2657 object->aad = operation->aad; in AESCCMLPF3HSM_addAAD()
2663 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCMLPF3HSM_addAAD()
2665 return object->common.returnStatus; in AESCCMLPF3HSM_addAAD()
2669 if (object->hsmStatus != HSMLPF3_STATUS_SUCCESS) in AESCCMLPF3HSM_addAAD()
2682 DebugP_assert((object->operationType == AESCCM_OPERATION_TYPE_DECRYPT) || in AESCCMLPF3HSM_addAAD()
2683 (object->operationType == AESCCM_OPERATION_TYPE_ENCRYPT) || in AESCCMLPF3HSM_addAAD()
2684 (object->operationType == AESCCM_OP_TYPE_AAD_DECRYPT) || in AESCCMLPF3HSM_addAAD()
2685 (object->operationType == AESCCM_OP_TYPE_AAD_ENCRYPT)); in AESCCMLPF3HSM_addAAD()
2687 uint8_t aadBytesProcessed = object->totalAADLength - object->totalAADLengthRemaining; in AESCCMLPF3HSM_addAAD()
2693 if (calcAADLen > object->totalAADLength) in AESCCMLPF3HSM_addAAD()
2709 if ((object->operationType == AESCCM_OPERATION_TYPE_DECRYPT) || in AESCCMLPF3HSM_addAAD()
2710 (object->operationType == AESCCM_OP_TYPE_AAD_DECRYPT)) in AESCCMLPF3HSM_addAAD()
2715 object->operationType = operationType; in AESCCMLPF3HSM_addAAD()
2725 if (aadBytesProcessed + aadBytesToProcess == object->totalAADLength) in AESCCMLPF3HSM_addAAD()
2730 object->aadLength = aadBytesToProcess; in AESCCMLPF3HSM_addAAD()
2731 object->inputLength = 0U; in AESCCMLPF3HSM_addAAD()
2735 HSMLPF3_constructAESCCMSegmentedAADPhysicalToken(object); in AESCCMLPF3HSM_addAAD()
2737 hsmRetval = HSMLPF3_submitToken((HSMLPF3_ReturnBehavior)object->common.returnBehavior, in AESCCMLPF3HSM_addAAD()
2746 status = object->common.returnStatus; in AESCCMLPF3HSM_addAAD()
2757 object->common.returnStatus = status; in AESCCMLPF3HSM_addAAD()
2765 object->common.returnStatus = status; in AESCCMLPF3HSM_addAAD()
2767 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCMLPF3HSM_addAAD()
2769 object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, operationType); in AESCCMLPF3HSM_addAAD()
2791 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_addData() local
2795 if (object->hsmStatus != HSMLPF3_STATUS_SUCCESS) in AESCCMLPF3HSM_addData()
2807 object->operationType = operationType; in AESCCMLPF3HSM_addData()
2808 object->operation = operation; in AESCCMLPF3HSM_addData()
2810 if (object->totalDataLengthRemaining == object->totalDataLength) in AESCCMLPF3HSM_addData()
2812 object->input = segmentedOperation->input; in AESCCMLPF3HSM_addData()
2813 object->output = segmentedOperation->output; in AESCCMLPF3HSM_addData()
2816 object->aadLength = object->totalAADLengthRemaining; in AESCCMLPF3HSM_addData()
2817 object->inputLength = inputLength; in AESCCMLPF3HSM_addData()
2819 HSMLPF3_constructAESCCMSegmentedDataPhysicalToken(object); in AESCCMLPF3HSM_addData()
2821 hsmRetval = HSMLPF3_submitToken((HSMLPF3_ReturnBehavior)object->common.returnBehavior, in AESCCMLPF3HSM_addData()
2830 status = object->common.returnStatus; in AESCCMLPF3HSM_addData()
2841 object->common.returnStatus = status; in AESCCMLPF3HSM_addData()
2852 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_freeAssetPostProcessing() local
2858 object->tempAssetID = 0; in AESCCMLPF3HSM_freeAssetPostProcessing()
2862 object->common.returnStatus = status; in AESCCMLPF3HSM_freeAssetPostProcessing()
2864 if ((HSMLPF3_ReturnBehavior)object->common.returnBehavior == HSMLPF3_RETURN_BEHAVIOR_POLLING) in AESCCMLPF3HSM_freeAssetPostProcessing()
2877 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_freeTempAssetID() local
2881 if (object->tempAssetID != 0) in AESCCMLPF3HSM_freeTempAssetID()
2883 … if ((HSMLPF3_ReturnBehavior)object->common.returnBehavior == HSMLPF3_RETURN_BEHAVIOR_POLLING) in AESCCMLPF3HSM_freeTempAssetID()
2892 HSMLPF3_constructDeleteAssetToken(object->tempAssetID); in AESCCMLPF3HSM_freeTempAssetID()
2903 status = object->common.returnStatus; in AESCCMLPF3HSM_freeTempAssetID()
2908 … if (((HSMLPF3_ReturnBehavior)object->common.returnBehavior == HSMLPF3_RETURN_BEHAVIOR_POLLING) && in AESCCMLPF3HSM_freeTempAssetID()
2927 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_finalizeEncrypt() local
2930 status = AESCCMLPF3HSM_performFinalizeChecks(object, operation); in AESCCMLPF3HSM_finalizeEncrypt()
2937 if (object->totalDataLengthRemaining == object->totalDataLength) in AESCCMLPF3HSM_finalizeEncrypt()
2939 object->input = operation->input; in AESCCMLPF3HSM_finalizeEncrypt()
2940 object->output = operation->output; in AESCCMLPF3HSM_finalizeEncrypt()
2943 object->mac = operation->mac; in AESCCMLPF3HSM_finalizeEncrypt()
2944 object->macLength = operation->macLength; in AESCCMLPF3HSM_finalizeEncrypt()
2946 if ((operation->inputLength > 0U) || (object->totalAADLengthRemaining > 0)) in AESCCMLPF3HSM_finalizeEncrypt()
2957 (void)memcpy(operation->mac, (uint32_t *)&object->intermediateTag[0], operation->macLength); in AESCCMLPF3HSM_finalizeEncrypt()
2961 object->segmentedOperationInProgress = false; in AESCCMLPF3HSM_finalizeEncrypt()
2963 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCMLPF3HSM_finalizeEncrypt()
2965object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, AESCCM_OP_TYPE_FINALIZE_EN… in AESCCMLPF3HSM_finalizeEncrypt()
2979 AESCCMLPF3_Object *object = AESCCMLPF3_getObject(handle); in AESCCMLPF3HSM_finalizeDecrypt() local
2982 status = AESCCMLPF3HSM_performFinalizeChecks(object, operation); in AESCCMLPF3HSM_finalizeDecrypt()
2989 if (object->totalDataLengthRemaining == object->totalDataLength) in AESCCMLPF3HSM_finalizeDecrypt()
2991 object->input = operation->input; in AESCCMLPF3HSM_finalizeDecrypt()
2992 object->output = operation->output; in AESCCMLPF3HSM_finalizeDecrypt()
2995 object->mac = operation->mac; in AESCCMLPF3HSM_finalizeDecrypt()
2996 object->macLength = operation->macLength; in AESCCMLPF3HSM_finalizeDecrypt()
2998 if ((operation->inputLength > 0U) || (object->totalAADLengthRemaining > 0U)) in AESCCMLPF3HSM_finalizeDecrypt()
3011 object->segmentedOperationInProgress = false; in AESCCMLPF3HSM_finalizeDecrypt()
3013 if (object->common.returnBehavior == AES_RETURN_BEHAVIOR_CALLBACK) in AESCCMLPF3HSM_finalizeDecrypt()
3015object->callbackFxn(handle, status, (AESCCM_OperationUnion *)operation, AESCCM_OP_TYPE_FINALIZE_DE… in AESCCMLPF3HSM_finalizeDecrypt()
3025 static int_fast16_t AESCCMLPF3HSM_performFinalizeChecks(const AESCCMLPF3_Object *object, in AESCCMLPF3HSM_performFinalizeChecks() argument
3029 DebugP_assert((object->operationType == AESCCM_OP_TYPE_AAD_ENCRYPT) || in AESCCMLPF3HSM_performFinalizeChecks()
3030 (object->operationType == AESCCM_OP_TYPE_DATA_ENCRYPT)); in AESCCMLPF3HSM_performFinalizeChecks()
3035 if (object->common.returnStatus != AESCCM_STATUS_SUCCESS) in AESCCMLPF3HSM_performFinalizeChecks()
3037 return object->common.returnStatus; in AESCCMLPF3HSM_performFinalizeChecks()
3041 if (object->hsmStatus != HSMLPF3_STATUS_SUCCESS) in AESCCMLPF3HSM_performFinalizeChecks()
3047 if (operation->inputLength != object->totalDataLengthRemaining) in AESCCMLPF3HSM_performFinalizeChecks()