psa_cryptocell_310_ecc_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "psa/crypto.h"
28 
29 #include "sns_silib.h"
30 #include "crys_ecpki_build.h"
31 #include "crys_ecpki_ecdsa.h"
32 #include "crys_ecpki_kg.h"
33 #include "crys_ecpki_domain.h"
34 
40 #define MAP_PSA_HASH_TO_CRYS_HASH_AFTER(hash) \
41  ((hash == PSA_ALG_SHA_1) ? CRYS_ECPKI_AFTER_HASH_SHA1_mode : \
42  (hash == PSA_ALG_SHA_224) ? CRYS_ECPKI_AFTER_HASH_SHA224_mode : \
43  (hash == PSA_ALG_SHA_256) ? CRYS_ECPKI_AFTER_HASH_SHA256_mode : \
44  (hash == PSA_ALG_SHA_384) ? CRYS_ECPKI_AFTER_HASH_SHA384_mode : \
45  (hash == PSA_ALG_SHA_512) ? CRYS_ECPKI_AFTER_HASH_SHA512_mode : \
46  0)
47 
53 #define MAP_PSA_HASH_TO_CRYS_HASH_BEFORE(hash) \
54  ((hash == PSA_ALG_SHA_1) ? CRYS_ECPKI_HASH_SHA1_mode : \
55  (hash == PSA_ALG_SHA_224) ? CRYS_ECPKI_HASH_SHA224_mode : \
56  (hash == PSA_ALG_SHA_256) ? CRYS_ECPKI_HASH_SHA256_mode : \
57  (hash == PSA_ALG_SHA_384) ? CRYS_ECPKI_HASH_SHA384_mode : \
58  (hash == PSA_ALG_SHA_512) ? CRYS_ECPKI_HASH_SHA512_mode : \
59  0)
60 
72  uint8_t *pub_key_buffer,
73  uint32_t *priv_key_buffer_length,
74  uint32_t *pub_key_buffer_length,
75  CRYS_ECPKI_DomainID_t domain);
76 
88  uint8_t *pub_key_buffer,
89  uint32_t priv_key_buffer_length,
90  uint32_t *pub_key_buffer_length,
91  CRYS_ECPKI_DomainID_t domain);
92 
107  uint32_t priv_key_size,
108  const uint8_t *input,
109  size_t input_length,
110  uint8_t *signature,
111  size_t *signature_length,
112  CRYS_ECPKI_HASH_OpMode_t hash_mode,
113  CRYS_ECPKI_DomainID_t domain);
114 
130  size_t pub_key_size,
131  const uint8_t *input,
132  size_t input_length,
133  const uint8_t *signature,
134  size_t signature_length,
135  CRYS_ECPKI_HASH_OpMode_t hash_mode,
136  CRYS_ECPKI_DomainID_t domain);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
Function declarations for PSA Crypto.
int32_t psa_status_t
Status code type used for all PSA Certified APIs.
Definition: error.h:40
psa_status_t cryptocell_310_common_ecc_generate_key_pair(uint8_t *priv_key_buffer, uint8_t *pub_key_buffer, uint32_t *priv_key_buffer_length, uint32_t *pub_key_buffer_length, CRYS_ECPKI_DomainID_t domain)
Common ECC key generation function.
psa_status_t cryptocell_310_common_ecc_sign(const uint8_t *priv_key, uint32_t priv_key_size, const uint8_t *input, size_t input_length, uint8_t *signature, size_t *signature_length, CRYS_ECPKI_HASH_OpMode_t hash_mode, CRYS_ECPKI_DomainID_t domain)
Common ECC signature function.
psa_status_t cryptocell_310_common_ecc_derive_pub_key(const uint8_t *priv_key_buffer, uint8_t *pub_key_buffer, uint32_t priv_key_buffer_length, uint32_t *pub_key_buffer_length, CRYS_ECPKI_DomainID_t domain)
Common ECC public key derivation function (not supported)
psa_status_t cryptocell_310_common_ecc_verify(const uint8_t *pub_key, size_t pub_key_size, const uint8_t *input, size_t input_length, const uint8_t *signature, size_t signature_length, CRYS_ECPKI_HASH_OpMode_t hash_mode, CRYS_ECPKI_DomainID_t domain)
Common ECC verification function.