Predefined and custom elliptic curve definitions

@file

EC_CURVES_HEADER_FILE Macro

C

#define EC_CURVES_HEADER_FILE
# sx_curve_slots Struct

## C

```c
struct sx_curve_slots {
    struct sx_pk_slot p; /**< Field size of curve **/
    struct sx_pk_slot n; /**< Order of curve **/
    struct sx_pk_slot gx; /**< x-coordinate of generator point of curve **/
    struct sx_pk_slot gy; /**< y-coordinate of generator point of curve **/
    struct sx_pk_slot a; /**< Curve parameter a **/
    struct sx_pk_slot b; /**< Curve parameter b **/
};

Description

Slots to write custom curve parameters into

SX_PK_CREATE_ECP_CURVE

C

typedef void (*FUNC_SX_PK_CREATE_ECP_CURVE)( struct sx_pk_cnx *cnx, struct sx_pk_ecurve *curve, char *mem, int sz, struct sx_curve_slots *slots);
#define SX_PK_CREATE_ECP_CURVE         ((FUNC_SX_PK_CREATE_ECP_CURVE)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_CREATE_ECP_CURVE)))

Description

Create a prime elliptic curve When this function returns, copy the paramters of the curve into the slots returned in 'slots'. After that, you can use the prime elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup
curveCurve to initialise as a prime elliptic curve
memMemory for the parameters of the curve. The size of the memory should be 6 time sz as there are 6 curve parameters of size sz
slotsSlots for the curve parameters

SEE

SX_PK_CREATE_ECB_CURVE() and SX_PK_DESTROY_EC_CURVE()

Returns

None

SX_PK_CREATE_ECB_CURVE

C

typedef void (*FUNC_SX_PK_CREATE_ECB_CURVE)(struct sx_pk_cnx *cnx, struct sx_pk_ecurve *curve, char *mem, int sz, struct sx_curve_slots *slots);
#define SX_PK_CREATE_ECB_CURVE         ((FUNC_SX_PK_CREATE_ECB_CURVE)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_CREATE_ECB_CURVE)))

Description

Create a binary elliptic curve When this function returns, copy the paramters of the curve into the slots returned in 'slots'. After that, you can use the binary elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup
curveCurve to initialise as a binary elliptic curve
memMemory for the parameters of the curve. The size of the memory should be 6 time sz as there are 6 curve parameters of size sz
slotsSlots for the curve parameters

SEE

SX_PK_CREATE_ECP_CURVE() and SX_PK_DESTROY_EC_CURVE()

Returns

None

SX_PK_DESTROY_EC_CURVE

C

typedef void (*FUNC_SX_PK_DESTROY_EC_CURVE)(struct sx_pk_ecurve *curve);
#define SX_PK_DESTROY_EC_CURVE         ((FUNC_SX_PK_DESTROY_EC_CURVE)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_DESTROY_EC_CURVE)))

Description

Destroy a custom ecp or ecb curve. Destroy a curve created previously by SX_PK_CREATE_ECP_CURVE() or SX_PK_CREATE_ECB_CURVE().

Parameters

ParamDescription
curveCurve initialized to destroy

Returns

None

SX_PK_GET_CURVE_NISTP192

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_NISTP192)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_NISTP192         ((FUNC_SX_PK_GET_CURVE_NISTP192)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP192)))

Description

Get a reference to the predefined NIST P192 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for P192 curve

SX_PK_GET_CURVE_NISTP256

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_NISTP256)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_NISTP256         ((FUNC_SX_PK_GET_CURVE_NISTP256)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP256)))

Description

Get a reference to the predefined NIST P256 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for P256 curve

SX_PK_GET_CURVE_NISTP384

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_NISTP384)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_NISTP384         ((FUNC_SX_PK_GET_CURVE_NISTP384)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP384)))

Description

Get a reference to the predefined NIST P384 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for P384 curve

SX_PK_GET_CURVE_NISTP521

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_NISTP521)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_NISTP521         ((FUNC_SX_PK_GET_CURVE_NISTP521)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP521)))

Description

Get a reference to the predefined NIST P521 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for P521 curve

SX_PK_GET_CURVE_ED25519

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_ED25519)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_ED25519         ((FUNC_SX_PK_GET_CURVE_ED25519)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_ED25519)))

Description

Get a reference to the predefined ED25519 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for ED25510 curve

SX_PK_GET_CURVE_ED448

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_ED448)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_ED448         ((FUNC_SX_PK_GET_CURVE_ED448)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_ED448)))

Description

Get a reference to the predefined ED448 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for ED448 curve

SX_PK_GET_CURVE_X25519

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_X25519)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_X25519         ((FUNC_SX_PK_GET_CURVE_X25519)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_X25519)))

Description

Get a reference to the predefined X25519 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for X25519 curve

SX_PK_GET_CURVE_X448

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_X448)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_X448         ((FUNC_SX_PK_GET_CURVE_X448)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_X448)))

Description

Get a reference to the predefined X448 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for X448 curve

SX_PK_GET_CURVE_SECP256K1

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_SECP256K1)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_SECP256K1         ((FUNC_SX_PK_GET_CURVE_SECP256K1)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_SECP256K1)))

Description

Get a reference to the predefined SEC p256k1 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for SEC p256k1 curve

SX_PK_GET_CURVE_FP256

C

typedef struct sx_pk_ecurve (*FUNC_SX_PK_GET_CURVE_FP256)(struct sx_pk_cnx *cnx);
#define SX_PK_GET_CURVE_FP256         ((FUNC_SX_PK_GET_CURVE_FP256)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_FP256)))

Description

Get a reference to the predefined fp256 elliptic curve

Parameters

ParamDescription
cnxConnection structure obtained through SX_PK_OPEN() at startup

Returns

Curve structure for fp256 curve (used in SM2)

SX_PK_WRITE_CURVE_GEN

C

typedef void (*FUNC_SX_PK_WRITE_CURVE_GEN)(sx_pk_accel *pk, const struct sx_pk_ecurve *curve, struct sx_pk_slot px, struct sx_pk_slot py);
#define SX_PK_WRITE_CURVE_GEN         ((FUNC_SX_PK_WRITE_CURVE_GEN)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_AEAD_CREATE_AESGCM_ENC)))

Description

Write the generator point of the curve into the slots (internal). Write the parameter gx & gy from curve to px.addr & py.addr respectively

Parameters

ParamDescription
pkThe accelerator request
curveInitialised curve to get generator point from
pxx-coordinate slot of generator point. The curve generator (x-coordinate) will be written to this address
pyy-coordinate slot of generator point. The curve generator (y-coordinate) will be written to this address

Returns

None

C SX_PK_CURVE_OPSIZE

typedef int (*FUNC_SX_PK_CURVE_OPSIZE)(const struct sx_pk_ecurve *curve);
#define SX_PK_CURVE_OPSIZE         ((FUNC_SX_PK_CURVE_OPSIZE)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_SX_PK_CURVE_OPSIZE)))

Description

Return the operand size in bytes for the given curve

Parameters

ParamDescription
curveCurve initialized to get operand size from

SEE

SX_PK_CREATE_ECP_CURVE() and SX_PK_DESTROY_EC_CURVE()

Returns

Operand size in bytes for the given curve

/
 Copyright (c) 2018-2020 Silex Insight sa
 Copyright (c) 2018-2020 Beerten Engineering scs
 SPDX-License-Identifier: BSD-3-Clause



# int Function

## C

```c
typedef int (*FUNC_SX_PK_CURVE_OPSIZE)(const struct sx_pk_ecurve *curve);

@addtogroup SX_PK_CURVES

@{

Slots to write custom curve parameters into. */

struct sx_curve_slots { struct sx_pk_slot p; /< Field size of curve / struct sx_pk_slot n; /< Order of curve / struct sx_pk_slot gx; /< x-coordinate of generator point of curve / struct sx_pk_slot gy; /< y-coordinate of generator point of curve / struct sx_pk_slot a; /< Curve parameter a / struct sx_pk_slot b; /< Curve parameter b / };

Create a prime elliptic curve

SX_PK_CREATE_ECP_CURVE Macro

C

typedef void (FUNC_SX_PK_CREATE_ECP_CURVE)( struct sx_pk_cnx cnx, struct sx_pk_ecurve curve, char mem, int sz, struct sx_curve_slots slots);
#define SX_PK_CREATE_ECP_CURVE ((FUNC_SX_PK_CREATE_ECP_CURVE)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_CREATE_ECP_CURVE)))

@remark When this function returns, copy the paramters of the curve into the slots returned in 'slots'. After that, you can use the prime elliptic curve

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup

Parameters

curve Curve to initialise as a prime elliptic curve

Parameters

mem Memory for the parameters of the curve. The size of the memory should be 6 time sz as there are 6 curve parameters of size sz

Parameters

sz Size of the curve in bytes

Parameters

slots Slots for the curve parameters @see SX_PK_CREATE_ECB_CURVE() and SX_PK_DESTROY_EC_CURVE()

Create a binary elliptic curve

SX_PK_CREATE_ECB_CURVE Macro

C

typedef void (FUNC_SX_PK_CREATE_ECB_CURVE)(struct sx_pk_cnx cnx, struct sx_pk_ecurve curve, char mem, int sz, struct sx_curve_slots slots);
#define SX_PK_CREATE_ECB_CURVE ((FUNC_SX_PK_CREATE_ECB_CURVE)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_CREATE_ECB_CURVE)))

@remark When this function returns, copy the paramters of the curve into the slots returned in 'slots'. After that, you can use the binary elliptic curve

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup

Parameters

curve Curve to initialise as a binary elliptic curve

Parameters

mem Memory for the parameters of the curve. The size of the memory should be 6 time sz as there are 6 curve parameters of size sz

Parameters

sz Size of the curve in bytes

Parameters

slots Slots for the curve parameters @see SX_PK_CREATE_ECP_CURVE() and SX_PK_DESTROY_EC_CURVE()

Destroy a custom ecp or ecb curve

SX_PK_DESTROY_EC_CURVE Macro

C

typedef void (FUNC_SX_PK_DESTROY_EC_CURVE)(struct sx_pk_ecurve curve);
#define SX_PK_DESTROY_EC_CURVE ((FUNC_SX_PK_DESTROY_EC_CURVE)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_DESTROY_EC_CURVE)))

Destroy a curve created previously by SX_PK_CREATE_ECP_CURVE() or SX_PK_CREATE_ECB_CURVE().

Parameters

curve Initialised curve to destroy

Get a reference to the predefined NIST P192 elliptic curve

SX_PK_GET_CURVE_NISTP192 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_NISTP192)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_NISTP192 ((FUNC_SX_PK_GET_CURVE_NISTP192)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP192)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for P192 curve

Get a reference to the predefined NIST P256 elliptic curve

SX_PK_GET_CURVE_NISTP256 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_NISTP256)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_NISTP256 ((FUNC_SX_PK_GET_CURVE_NISTP256)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP256)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for P256 curve

Get a reference to the predefined NIST P384 elliptic curve

SX_PK_GET_CURVE_NISTP384 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_NISTP384)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_NISTP384 ((FUNC_SX_PK_GET_CURVE_NISTP384)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP384)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for P384 curve

Get a reference to the predefined NIST P521 elliptic curve

SX_PK_GET_CURVE_NISTP521 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_NISTP521)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_NISTP521 ((FUNC_SX_PK_GET_CURVE_NISTP521)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_NISTP521)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for P521 curve

Get a reference to the predefined ED25519 elliptic curve

SX_PK_GET_CURVE_ED25519 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_ED25519)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_ED25519 ((FUNC_SX_PK_GET_CURVE_ED25519)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_ED25519)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for ED25519 curve

Get a reference to the predefined ED448 elliptic curve

SX_PK_GET_CURVE_ED448 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_ED448)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_ED448 ((FUNC_SX_PK_GET_CURVE_ED448)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_ED448)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for ED448 curve

Get a reference to the predefined X25519 elliptic curve

SX_PK_GET_CURVE_X25519 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_X25519)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_X25519 ((FUNC_SX_PK_GET_CURVE_X25519)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_X25519)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for X25519 curve

Get a reference to the predefined X448 elliptic curve

SX_PK_GET_CURVE_X448 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_X448)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_X448 ((FUNC_SX_PK_GET_CURVE_X448)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_X448)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for X448 curve

Get a reference to the predefined SEC p256k1 elliptic curve

SX_PK_GET_CURVE_SECP256K1 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_SECP256K1)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_SECP256K1 ((FUNC_SX_PK_GET_CURVE_SECP256K1)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_SECP256K1)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for SEC p256k1 curve

Get a reference to the predefined fp256 elliptic curve

SX_PK_GET_CURVE_FP256 Macro

C

typedef struct sx_pk_ecurve (FUNC_SX_PK_GET_CURVE_FP256)(struct sx_pk_cnx cnx);
#define SX_PK_GET_CURVE_FP256 ((FUNC_SX_PK_GET_CURVE_FP256)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_GET_CURVE_FP256)))

Parameters

cnx Connection structure obtained through SX_PK_OPEN() at startup @return Curve structure for fp256 curve (used in SM2)

Write the generator point of the curve into the slots (internal)

SX_PK_WRITE_CURVE_GEN Macro

C

typedef void (FUNC_SX_PK_WRITE_CURVE_GEN)(sx_pk_accel pk, const struct sx_pk_ecurve curve, struct sx_pk_slot px, struct sx_pk_slot py);
#define SX_PK_WRITE_CURVE_GEN ((FUNC_SX_PK_WRITE_CURVE_GEN)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_AEAD_CREATE_AESGCM_ENC)))

Write the parameter gx & gy from curve to px.addr & py.addr respectively

Parameters

pk The accelerator request

Parameters

curve Initialised curve to get generator point from.

Parameters

px x-coordinate slot of generator point. The curve generator (x-coordinate) will be written to this address

Parameters

py y-coordinate slot of generator point. The curve generator (y-coordinate) will be written to this address

Return the operand size in bytes for the given curve

SX_PK_CURVE_OPSIZE Macro

C

typedef int (FUNC_SX_PK_CURVE_OPSIZE)(const struct sx_pk_ecurve curve);
#define SX_PK_CURVE_OPSIZE ((FUNC_SX_PK_CURVE_OPSIZE)((uint32_t )(API_TABLE_BASE_ADDRESS + ATO_SX_PK_CURVE_OPSIZE)))

Parameters

curve Initialised curve to get operand size from @return Operand size in bytes for the given curve

}