Crypto: Align to PSA Crypto headers 0.1.0a
This patch updates the PSA Crypto API headers to version
0.1.0a. The Crypto service implementation is updated when
needed to make sure the service is buildable and functional.
Change-Id: I63709db0d87f449012d0c8355658f1af1583b3ab
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
diff --git a/secure_fw/services/crypto/crypto_alloc.c b/secure_fw/services/crypto/crypto_alloc.c
index c7ffec3..5ccd33c 100644
--- a/secure_fw/services/crypto/crypto_alloc.c
+++ b/secure_fw/services/crypto/crypto_alloc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -25,10 +25,7 @@
#include "psa_crypto.h"
#include "tfm_crypto_api.h"
-/* The file "psa_crypto_struct.h" contains definitions for
- * implementation-specific structs that are declared in "psa_crypto.h".
- */
-#include "psa_crypto_struct.h"
+#include "tfm_crypto_struct.h"
/**
* \brief This value defines the maximum number of simultaneous operations
@@ -46,9 +43,9 @@
uint32_t in_use; /*!< Indicates if the operation is in use */
enum tfm_crypto_operation_type type; /*!< Type of the operation */
union {
- struct psa_cipher_operation_s cipher; /*!< Cipher operation context */
- struct psa_mac_operation_s mac; /*!< MAC operation context */
- struct psa_hash_operation_s hash; /*!< Hash operation context */
+ struct tfm_cipher_operation_s cipher; /*!< Cipher operation context */
+ struct tfm_mac_operation_s mac; /*!< MAC operation context */
+ struct tfm_hash_operation_s hash; /*!< Hash operation context */
} operation;
};
@@ -62,13 +59,13 @@
switch(operation[index].type) {
case TFM_CRYPTO_CIPHER_OPERATION:
- mem_size = sizeof(struct psa_cipher_operation_s);
+ mem_size = sizeof(struct tfm_cipher_operation_s);
break;
case TFM_CRYPTO_MAC_OPERATION:
- mem_size = sizeof(struct psa_mac_operation_s);
+ mem_size = sizeof(struct tfm_mac_operation_s);
break;
case TFM_CRYPTO_HASH_OPERATION:
- mem_size = sizeof(struct psa_hash_operation_s);
+ mem_size = sizeof(struct tfm_hash_operation_s);
break;
case TFM_CRYPTO_OPERATION_NONE:
default:
@@ -101,7 +98,7 @@
return TFM_CRYPTO_ERR_PSA_SUCCESS;
}
}
-
+ *handle = INVALID_HANDLE;
return TFM_CRYPTO_ERR_PSA_ERROR_NOT_PERMITTED;
}
@@ -124,15 +121,13 @@
enum tfm_crypto_err_t tfm_crypto_operation_lookup(
enum tfm_crypto_operation_type type,
- uint32_t *handle,
+ uint32_t handle,
void **oper)
{
- uint32_t i = *handle;
-
- if ( (i<TFM_CRYPTO_CONC_OPER_NUM) &&
- (operation[i].in_use == TFM_CRYPTO_IN_USE) &&
- (operation[i].type == type) ) {
- *oper = (void *) &(operation[i].operation);
+ if ( (handle<TFM_CRYPTO_CONC_OPER_NUM) &&
+ (operation[handle].in_use == TFM_CRYPTO_IN_USE) &&
+ (operation[handle].type == type) ) {
+ *oper = (void *) &(operation[handle].operation);
return TFM_CRYPTO_ERR_PSA_SUCCESS;
}