TEE_Result TEE_DigestDoFinal(TEE_OperationHandle operation, void *chunk, uint32_t chunkLen, void *hash, uint32_t *hashLen) { TEE_Result res; uint64_t hl; if ((operation == TEE_HANDLE_NULL) || (!chunk && chunkLen) || !hash || !hashLen || (operation->info.operationClass != TEE_OPERATION_DIGEST)) { res = TEE_ERROR_BAD_PARAMETERS; goto out; } hl = *hashLen; res = utee_hash_final(operation->state, chunk, chunkLen, hash, &hl); *hashLen = hl; if (res != TEE_SUCCESS) goto out; /* Reset operation state */ init_hash_operation(operation, NULL, 0); operation->operationState = TEE_OPERATION_STATE_INITIAL; out: if (res != TEE_SUCCESS && res != TEE_ERROR_SHORT_BUFFER) TEE_Panic(0); return res; }
TEE_Result TEE_DigestDoFinal(TEE_OperationHandle operation, const void *chunk, size_t chunkLen, void *hash, size_t *hashLen) { if (operation == TEE_HANDLE_NULL || (chunk == NULL && chunkLen != 0) || hash == NULL || hashLen == NULL) TEE_Panic(0); if (operation->info.operationClass != TEE_OPERATION_DIGEST) TEE_Panic(0); return utee_hash_final(operation->state, chunk, chunkLen, hash, hashLen); }
TEE_Result TEE_MACComputeFinal(TEE_OperationHandle operation, void *message, uint32_t messageLen, void *mac, uint32_t *macLen) { TEE_Result res; uint64_t ml; if (operation == TEE_HANDLE_NULL || (message == NULL && messageLen != 0) || mac == NULL || macLen == NULL) { res = TEE_ERROR_BAD_PARAMETERS; goto out; } if (operation->info.operationClass != TEE_OPERATION_MAC) { res = TEE_ERROR_BAD_PARAMETERS; goto out; } if ((operation->info.handleState & TEE_HANDLE_FLAG_INITIALIZED) == 0) { res = TEE_ERROR_BAD_PARAMETERS; goto out; } if (operation->operationState != TEE_OPERATION_STATE_ACTIVE) { res = TEE_ERROR_BAD_PARAMETERS; goto out; } ml = *macLen; res = utee_hash_final(operation->state, message, messageLen, mac, &ml); *macLen = ml; if (res != TEE_SUCCESS) goto out; operation->info.handleState &= ~TEE_HANDLE_FLAG_INITIALIZED; operation->operationState = TEE_OPERATION_STATE_INITIAL; out: if (res != TEE_SUCCESS && res != TEE_ERROR_SHORT_BUFFER) TEE_Panic(res); return res; }
TEE_Result TEE_MACComputeFinal(TEE_OperationHandle op, const void *message, size_t messageLen, void *mac, size_t *macLen) { TEE_Result res; if (op == TEE_HANDLE_NULL || (message == NULL && messageLen != 0) || mac == NULL || macLen == NULL) TEE_Panic(0); if (op->info.operationClass != TEE_OPERATION_MAC) TEE_Panic(0); if ((op->info.handleState & TEE_HANDLE_FLAG_INITIALIZED) == 0) TEE_Panic(0); res = utee_hash_final(op->state, message, messageLen, mac, macLen); op->info.handleState &= ~TEE_HANDLE_FLAG_INITIALIZED; return res; }