mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-24 22:05:40 +00:00

All identifiers, regardless of use, that start with two underscores are reserved. This means they can't be used in header guards. The style that this project is now to use the full name of the file in capital letters followed by 'H'. For example, for a file called "uart_example.h", the header guard is UART_EXAMPLE_H. The exceptions are files that are imported from other projects: - CryptoCell driver - dt-bindings folders - zlib headers Change-Id: I50561bf6c88b491ec440d0c8385c74650f3c106e Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
62 lines
1.8 KiB
C
62 lines
1.8 KiB
C
/*
|
|
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef CRYPTO_MOD_H
|
|
#define CRYPTO_MOD_H
|
|
|
|
/* Return values */
|
|
enum crypto_ret_value {
|
|
CRYPTO_SUCCESS = 0,
|
|
CRYPTO_ERR_INIT,
|
|
CRYPTO_ERR_HASH,
|
|
CRYPTO_ERR_SIGNATURE,
|
|
CRYPTO_ERR_UNKNOWN
|
|
};
|
|
|
|
/*
|
|
* Cryptographic library descriptor
|
|
*/
|
|
typedef struct crypto_lib_desc_s {
|
|
const char *name;
|
|
|
|
/* Initialize library. This function is not expected to fail. All errors
|
|
* must be handled inside the function, asserting or panicing in case of
|
|
* a non-recoverable error */
|
|
void (*init)(void);
|
|
|
|
/* Verify a digital signature. Return one of the
|
|
* 'enum crypto_ret_value' options */
|
|
int (*verify_signature)(void *data_ptr, unsigned int data_len,
|
|
void *sig_ptr, unsigned int sig_len,
|
|
void *sig_alg, unsigned int sig_alg_len,
|
|
void *pk_ptr, unsigned int pk_len);
|
|
|
|
/* Verify a hash. Return one of the 'enum crypto_ret_value' options */
|
|
int (*verify_hash)(void *data_ptr, unsigned int data_len,
|
|
void *digest_info_ptr, unsigned int digest_info_len);
|
|
} crypto_lib_desc_t;
|
|
|
|
/* Public functions */
|
|
void crypto_mod_init(void);
|
|
int crypto_mod_verify_signature(void *data_ptr, unsigned int data_len,
|
|
void *sig_ptr, unsigned int sig_len,
|
|
void *sig_alg_ptr, unsigned int sig_alg_len,
|
|
void *pk_ptr, unsigned int pk_len);
|
|
int crypto_mod_verify_hash(void *data_ptr, unsigned int data_len,
|
|
void *digest_info_ptr, unsigned int digest_info_len);
|
|
|
|
/* Macro to register a cryptographic library */
|
|
#define REGISTER_CRYPTO_LIB(_name, _init, _verify_signature, _verify_hash) \
|
|
const crypto_lib_desc_t crypto_lib_desc = { \
|
|
.name = _name, \
|
|
.init = _init, \
|
|
.verify_signature = _verify_signature, \
|
|
.verify_hash = _verify_hash \
|
|
}
|
|
|
|
extern const crypto_lib_desc_t crypto_lib_desc;
|
|
|
|
#endif /* CRYPTO_MOD_H */
|