Mistake on this page?
Report an issue in GitHub or email us
TARGET_TFM/TARGET_TFM_V1_1/include/psa/crypto_extra.h
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 /**
8  * \file psa/crypto_extra.h
9  *
10  * \brief PSA cryptography module: vendor extensions
11  *
12  * \note This file may not be included directly. Applications must
13  * include psa/crypto.h.
14  *
15  * This file is reserved for vendor-specific definitions.
16  */
17 
18 #ifndef PSA_CRYPTO_EXTRA_H
19 #define PSA_CRYPTO_EXTRA_H
20 
21 #include "psa/crypto_compat.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /** \addtogroup crypto_types
28  * @{
29  */
30 
31 /** DSA public key.
32  *
33  * The import and export format is the
34  * representation of the public key `y = g^x mod p` as a big-endian byte
35  * string. The length of the byte string is the length of the base prime `p`
36  * in bytes.
37  */
38 #define PSA_KEY_TYPE_DSA_PUBLIC_KEY ((psa_key_type_t)0x60020000)
39 
40 /** DSA key pair (private and public key).
41  *
42  * The import and export format is the
43  * representation of the private key `x` as a big-endian byte string. The
44  * length of the byte string is the private key size in bytes (leading zeroes
45  * are not stripped).
46  *
47  * Determinstic DSA key derivation with psa_generate_derived_key follows
48  * FIPS 186-4 §B.1.2: interpret the byte string as integer
49  * in big-endian order. Discard it if it is not in the range
50  * [0, *N* - 2] where *N* is the boundary of the private key domain
51  * (the prime *p* for Diffie-Hellman, the subprime *q* for DSA,
52  * or the order of the curve's base point for ECC).
53  * Add 1 to the resulting integer and use this as the private key *x*.
54  *
55  */
56 #define PSA_KEY_TYPE_DSA_KEY_PAIR ((psa_key_type_t)0x70020000)
57 
58 /**@}*/
59 
60 /** \brief Declare the enrollment algorithm for a key.
61  *
62  * An operation on a key may indifferently use the algorithm set with
63  * psa_set_key_algorithm() or with this function.
64  *
65  * \param[out] attributes The attribute structure to write to.
66  * \param alg2 A second algorithm that the key may be used
67  * for, in addition to the algorithm set with
68  * psa_set_key_algorithm().
69  *
70  * \warning Setting an enrollment algorithm is not recommended, because
71  * using the same key with different algorithms can allow some
72  * attacks based on arithmetic relations between different
73  * computations made with the same key, or can escalate harmless
74  * side channels into exploitable ones. Use this function only
75  * if it is necessary to support a protocol for which it has been
76  * verified that the usage of the key with multiple algorithms
77  * is safe.
78  */
79 static inline void psa_set_key_enrollment_algorithm(
80  psa_key_attributes_t *attributes,
81  psa_algorithm_t alg2)
82 {
83  attributes->alg2 = alg2;
84 }
85 
86 /** Retrieve the enrollment algorithm policy from key attributes.
87  *
88  * \param[in] attributes The key attribute structure to query.
89  *
90  * \return The enrollment algorithm stored in the attribute structure.
91  */
93  const psa_key_attributes_t *attributes)
94 {
95  return attributes->alg2;
96 }
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* PSA_CRYPTO_EXTRA_H */
static void psa_set_key_enrollment_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg2)
Declare the enrollment algorithm for a key.
static psa_algorithm_t psa_get_key_enrollment_algorithm(const psa_key_attributes_t *attributes)
Retrieve the enrollment algorithm policy from key attributes.
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.