============================================================================
This file contains a common definition for elliptic curve structures used throughout the ECC based drivers. Not all devices support every curve.
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <ti/drivers/cryptoutils/cryptokey/CryptoKey.h>
#include <ti/devices/DeviceFamily.h>
Go to the source code of this file.
Data Structures | |
struct | ECCParams_CurveParams |
A structure containing the parameters of an elliptic curve. More... | |
union | ECC_NISTP256_Param |
Union to access ECC_NISTP256 curve params in bytes or words. More... | |
union | ECC_Curve25519_Param |
Union to access ECC_Curve25519 curve params in bytes or words. More... | |
Macros | |
#define | ECCParams_STATUS_SUCCESS (0) |
Successful status code. More... | |
#define | ECCParams_STATUS_ERROR (-1) |
Generic error status code. More... | |
#define | ECCParams_CURVE_TYPE_NONE 0U |
#define | ECCParams_CURVE_TYPE_SHORT_WEIERSTRASS_AN3 1U |
#define | ECCParams_CURVE_TYPE_SHORT_WEIERSTRASS_GEN 2U |
#define | ECCParams_CURVE_TYPE_MONTGOMERY 3U |
#define | ECCParams_CURVE_TYPE_EDWARDS 4U |
#define | ECC_LENGTH_PREFIX_BYTES 4 |
Number of bytes for the length word prepended before all parameters passed into the ECC SW library functions. More... | |
#define | ECCParams_NISTP256_LENGTH 32 |
Length of NIST P256 curve parameters in bytes. More... | |
#define | ECC_NISTP256_PARAM_LENGTH_WITH_PREFIX_BYTES (ECCParams_NISTP256_LENGTH + ECC_LENGTH_PREFIX_BYTES) |
Length in bytes of NISTP256 curve parameters including the prepended length word. More... | |
#define | ECCParams_CURVE25519_LENGTH 32 |
Length of Curve25519 curve parameters in bytes. More... | |
#define | ECC_CURVE25519_LENGTH_WITH_PREFIX_BYTES (ECCParams_CURVE25519_LENGTH + ECC_LENGTH_PREFIX_BYTES) |
Length in bytes of Curve25519 curve parameters including the prepended length word. More... | |
#define | ECCParams_FormatCurve25519PrivateKey ECCParams_formatCurve25519PrivateKey |
Typedefs | |
typedef uint32_t | ECCParams_CurveType |
Enumeration of curve equations supported. More... | |
typedef struct ECCParams_CurveParams | ECCParams_CurveParams |
A structure containing the parameters of an elliptic curve. More... | |
Enumerations | |
enum | ECCParams_SecureCurve { ECCParams_SecureCurve_NISTP224 = 0, ECCParams_SecureCurve_NISTP256, ECCParams_SecureCurve_NISTP384, ECCParams_SecureCurve_NISTP521, ECCParams_SecureCurve_BrainpoolP256R1, ECCParams_SecureCurve_BrainpoolP384R1, ECCParams_SecureCurve_BrainpoolP512R1, ECCParams_SecureCurve_Curve25519, ECCParams_SecureCurve_Ed25519, ECCParams_SecureCurve_Wei25519, ECCParams_SecureCurve_COUNT } |
Enumeration of ECC curve names supported by TF-M. More... | |
Functions | |
int_fast16_t | ECCParams_formatCurve25519PrivateKey (CryptoKey *myPrivateKey) |
Formats a CryptoKey to conform to Curve25519 private key requirements. More... | |
int_fast16_t | ECCParams_getUncompressedGeneratorPoint (const ECCParams_CurveParams *curveParams, uint8_t *buffer, size_t length) |
Extracts the curve generator point from an ecliptic curve description. More... | |
Variables | |
const ECCParams_CurveParams | ECCParams_NISTP224 |
The NISTP224 curve in short Weierstrass form. More... | |
const ECCParams_CurveParams | ECCParams_NISTP256 |
The NISTP256 curve in short Weierstrass form. More... | |
const ECCParams_CurveParams | ECCParams_NISTP384 |
The NISTP384 curve in short Weierstrass form. More... | |
const ECCParams_CurveParams | ECCParams_NISTP521 |
The NISTP521 curve in short Weierstrass form. More... | |
const ECCParams_CurveParams | ECCParams_BrainpoolP256R1 |
The BrainpoolP256R1 curve in short Weierstrass form. More... | |
const ECCParams_CurveParams | ECCParams_BrainpoolP384R1 |
The BrainpoolP384R1 curve in short Weierstrass form. More... | |
const ECCParams_CurveParams | ECCParams_BrainpoolP512R1 |
The BrainpoolP512R1 curve in short Weierstrass form. More... | |
const ECCParams_CurveParams | ECCParams_Wei25519 |
A short Weierstrass equivalent representation of Ed25519. More... | |
const ECCParams_CurveParams | ECCParams_Curve25519 |
The Curve25519 curve in Montgomery form. More... | |
const ECCParams_CurveParams | ECCParams_Ed25519 |
The Ed25519 curve in Edwards form. More... | |
const ECC_NISTP256_Param | ECC_NISTP256_generatorX |
X coordinate of the generator point of the ECC_NISTP256 curve. More... | |
const ECC_NISTP256_Param | ECC_NISTP256_generatorY |
Y coordinate of the generator point of the ECC_NISTP256 curve. More... | |
const ECC_NISTP256_Param | ECC_NISTP256_prime |
Prime of the generator point of the ECC_NISTP256 curve. More... | |
const ECC_NISTP256_Param | ECC_NISTP256_a |
'a' constant of the ECC_NISTP256 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b). More... | |
const ECC_NISTP256_Param | ECC_NISTP256_b |
'b' constant of the ECC_NISTP256 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b). More... | |
const ECC_NISTP256_Param | ECC_NISTP256_order |
Order of the generator point of the ECC_NISTP256 curve. More... | |
const ECC_NISTP256_Param | ECC_NISTP256_k_mont |
'k' in Montgomery domain of the ECC_NISTP256 curve. More... | |
const ECC_NISTP256_Param | ECC_NISTP256_a_mont |
'a' in Montgomery domain of the ECC_NISTP256 curve. More... | |
const ECC_NISTP256_Param | ECC_NISTP256_b_mont |
'b' in Montgomery domain of the ECC_NISTP256 curve. More... | |
const ECC_Curve25519_Param | ECC_Curve25519_generatorX |
X coordinate of the generator point of the ECC_Curve25519 curve. More... | |
const ECC_Curve25519_Param | ECC_Curve25519_generatorY |
Y coordinate of the generator point of the ECC_Curve25519 curve. More... | |
const ECC_Curve25519_Param | ECC_Curve25519_prime |
Prime of the generator point of the ECC_Curve25519 curve. More... | |
const ECC_Curve25519_Param | ECC_Curve25519_a |
'a' constant of the ECC_Curve25519 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b). More... | |
const ECC_Curve25519_Param | ECC_Curve25519_b |
'b' constant of the ECC_Curve25519 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b). More... | |
const ECC_Curve25519_Param | ECC_Curve25519_order |
Order of the generator point of the ECC_Curve25519 curve. More... | |
#define ECCParams_STATUS_SUCCESS (0) |
Successful status code.
Function return ECCParams_STATUS_SUCCESS if the control code was executed successfully.
#define ECCParams_STATUS_ERROR (-1) |
Generic error status code.
Functions return ECCParams_STATUS_ERROR if the control code was not executed successfully.
#define ECCParams_CURVE_TYPE_NONE 0U |
#define ECCParams_CURVE_TYPE_SHORT_WEIERSTRASS_AN3 1U |
#define ECCParams_CURVE_TYPE_SHORT_WEIERSTRASS_GEN 2U |
#define ECCParams_CURVE_TYPE_MONTGOMERY 3U |
#define ECCParams_CURVE_TYPE_EDWARDS 4U |
#define ECC_LENGTH_PREFIX_BYTES 4 |
Number of bytes for the length word prepended before all parameters passed into the ECC SW library functions.
#define ECCParams_CURVE25519_LENGTH 32 |
Length of Curve25519 curve parameters in bytes.
#define ECCParams_FormatCurve25519PrivateKey ECCParams_formatCurve25519PrivateKey |
typedef uint32_t ECCParams_CurveType |
Enumeration of curve equations supported.
Elliptic curves can be expressed using multiple equations of polynomials over finite fields. All forms can be converted to one another using parameter substitution. Each curve has a default curve equations it was designed to use.
Some curve implementations have restrictions on which algorithms and schemes they work with. For example, Curve25519 was explicitely designed with ECDH in mind. It only uses and yields the X coordinate of a point on the elliptic curve in common implementations. Some implementations do provide X and Y affine coordinates but most do not. Therefore, ECDSA and ECJPAKE do not have compatible implementations for Curve25519 on some devices as the Y coordinate is required by them.
Check the header files of each device-specific implementation for information regarding curve-support for specific schemes on a device.
Name | Equation |
---|---|
Short Weierstrass | y^3 = x^2 + a*x + b mod p |
Montgomery | By^2 = x^3 + Ax^2 + x mod p |
Edwards | x^2 + y^2 = 1 + dx^2y^2 mod p |
typedef struct ECCParams_CurveParams ECCParams_CurveParams |
A structure containing the parameters of an elliptic curve.
Elliptical Curve Cryptography (ECC) prime curve parameters.
Enumeration of ECC curve names supported by TF-M.
int_fast16_t ECCParams_formatCurve25519PrivateKey | ( | CryptoKey * | myPrivateKey | ) |
Formats a CryptoKey to conform to Curve25519 private key requirements.
Curve25519 has specific private key requirements specified by the curve definition. Specifically, the bottom three and the top bit may not be set and the second to last bit must be set.
myPrivateKey | An initialized CryptoKey describing the entropy for a Curve25519 private key. Platform-specific restrictions for the location of the keying material apply. Some implementations do not support modifying keying material in flash for example. |
int_fast16_t ECCParams_getUncompressedGeneratorPoint | ( | const ECCParams_CurveParams * | curveParams, |
uint8_t * | buffer, | ||
size_t | length | ||
) |
Extracts the curve generator point from an ecliptic curve description.
The curve parameters ECCParams_CurveParams::generatorX and ECCParams_CurveParams::generatorY are extracted from curveParams
and written as a concatenated octet string in big endian order to buffer
. The format is defined in SEC 1: Elliptic Curve Cryptography section 2.3.3.
The curve point has the format 0x04 || X || Y
and the length is 2 * size_of_x_or_y + 1
where 0x04
specifies octet string format. If the buffer length
exceeds the curve point length, the remaining buffer space is zeroed.
curveParams | Points to the input curve parameters |
buffer | Points to the destination where the generator point will be written to. Make sure that buffer is large enough to hold |
length | Maximum length of buffer in bytes. |
ECCParams_STATUS_SUCCESS | on success, ECCParams_STATUS_ERROR if the provided buffer length is insufficient to hold the curve point. |
const ECCParams_CurveParams ECCParams_NISTP224 |
The NISTP224 curve in short Weierstrass form.
const ECCParams_CurveParams ECCParams_NISTP256 |
The NISTP256 curve in short Weierstrass form.
const ECCParams_CurveParams ECCParams_NISTP384 |
The NISTP384 curve in short Weierstrass form.
const ECCParams_CurveParams ECCParams_NISTP521 |
The NISTP521 curve in short Weierstrass form.
const ECCParams_CurveParams ECCParams_BrainpoolP256R1 |
The BrainpoolP256R1 curve in short Weierstrass form.
const ECCParams_CurveParams ECCParams_BrainpoolP384R1 |
The BrainpoolP384R1 curve in short Weierstrass form.
const ECCParams_CurveParams ECCParams_BrainpoolP512R1 |
The BrainpoolP512R1 curve in short Weierstrass form.
const ECCParams_CurveParams ECCParams_Wei25519 |
A short Weierstrass equivalent representation of Ed25519.
const ECCParams_CurveParams ECCParams_Curve25519 |
The Curve25519 curve in Montgomery form.
const ECCParams_CurveParams ECCParams_Ed25519 |
The Ed25519 curve in Edwards form.