crm_pk_constraints Struct

C

struct crm_pk_constraints {
   /** Maximum simultaneous requests any application can configure. */
    int maxpending;
};

Description

CryptoPK and hardware constraints

crm_pk_capabilities Struct

C

struct crm_pk_capabilities {
   /** Maximum pending requests at any time. */
   int maxpending;
   /** Maximum operand size for prime field operands. 0 when not supported. */
   int max_gfp_opsz;
   /** Maximum operand size for elliptic curve operands. 0 when not supported. */
   int max_ecc_opsz;
   /** Maximum operand size for binary field operands. 0 when not supported. */
   int max_gfb_opsz;
   /** Operand size for IK operands. 0 when not supported. */
   int ik_opsz;
};

Description

Description of the (hardware) accelerator capabilities and features

crm_pk_config Struct

C

struct crm_pk_config {
    /** Maximum simultaneous requests the application will start.
     *
     * Set to 0 to use library default.
     */
    int maxpending;

    /** Device index to use.
     *
     * For special use cases with multiple independent hardware
     * accelerators. In case of doubt, leave to 0.
     */
    int devidx;

    /** User memory */
    long long *usrmem;

    /** Size of user provided memory */
    size_t usrmemsz;

    /** Personalization string for IK */
    uint32_t *personalization;

    /** Personalization string size in 32 bit words
     *
     * If the size is 0 the personalization string
     * is considered NULL and will not be used.
     */
    int personalization_sz;
};

Description

Library configuration for CRM_PK_OPEN()

crm_pk_dreq Struct

C

struct crm_pk_dreq
{
   /** The acquired acceleration request **/
   crm_pk_accel *req;
   /** The status of CRM_PK_ACQUIRE_REQ() **/
   int status;
};

Description

Encapsulated acceleration request

PK_OP_FLAGS_EDDSA_AX_LSB Macro

C

#define PK_OP_FLAGS_EDDSA_AX_LSB (1 << 29)

Description

Least significant bit of Ax is 1 (flag A)

PK_OP_FLAGS_EDDSA_RX_LSB Macro

C

#define PK_OP_FLAGS_EDDSA_RX_LSB (1 << 30)

Description

Least significant bit of Rx is 1 (flag B)

crm_pk_slot Struct

C

struct crm_pk_slot
{
   /** Memory address of the operand slot **/
   char *addr;
};

Description

Operand slot structure

crm_pk_dblslot Struct

C

struct crm_pk_dblslot
{
   /** First slot **/
   struct crm_pk_slot a;
   /** Second slot **/
   struct crm_pk_slot b;
};

Description

Pair of slots. Used to store large values

crm_pk_ecurve Struct

C

struct crm_pk_ecurve {
    uint32_t curveflags;
    int sz;
    const char *params;
    int offset;
    struct crm_pk_cnx *cnx;
};

Description

Elliptic curve configuration and parameters.To be used only via the functions in ec_curves.h The internal members of the structure should not be accessed directly

CRM_PK_LIST_CONSTRAINTS

C

typedef struct crm_pk_constraints (*FUNC_CRM_PK_LIST_CONSTRAINTS)(int index, int usermemsz);
#define CRM_PK_LIST_CONSTRAINTS         ((FUNC_CRM_PK_LIST_CONSTRAINTS)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_LIST_CONSTRAINTS)))

Description

Return CryptoPK constraints If maxpending in crm_pk_constraints is 0, than CryptoPK cannot be used with the given environment.

Parameters

ParamDescription
indexindex should always be 0
usermemszUser memory size provided in bytes. Should be non zero with no static memory

Returns

Constraints of CryptoPK

CRM_PK_FETCH_CAPABILITIES

C

typedef const struct crm_pk_capabilities *(*FUNC_CRM_PK_FETCH_CAPABILITIES)(struct crm_pk_cnx *cnx);
#define CRM_PK_FETCH_CAPABILITIES         ((FUNC_CRM_PK_FETCH_CAPABILITIES)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_FETCH_CAPABILITIES)))

Description

Return the crypto acceleration capabilities and features

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup

Returns

Returns Capabilities of the accelator on success

CRM_PK_OPEN

C

typedef struct crm_pk_cnx *(*FUNC_CRM_PK_OPEN)(struct crm_pk_config *cfg);
#define CRM_PK_OPEN         ((FUNC_CRM_PK_OPEN)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_OPEN)))

Description

Open CryptoPK and related hardware and allocate internal resources

Parameters

ParamDescription
cfgConfiguration to customize CryptoPK to application specific needs

Returns

NULL on failure Connection structure for future CryptoPK calls on success. Can be used with CryptoPK functions to run operations.

##SEE

CRM_PK_CLOSE()

CRM_PK_CLOSE

C

typedef void (*FUNC_CRM_PK_CLOSE)(struct crm_pk_cnx *cnx);
#define CRM_PK_CLOSE         ((FUNC_CRM_PK_CLOSE)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_CLOSE)))

Description

Finish using any public key acceleration. No other hardware acceleration function can be called after this.

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup

Returns

None

CRM_PK_ACQUIRE_REQ

C

typedef struct crm_pk_dreq (*FUNC_CRM_PK_ACQUIRE_REQ)(struct crm_pk_cnx *cnx, const struct crm_pk_cmd_def *cmd);
#define CRM_PK_ACQUIRE_REQ         ((FUNC_CRM_PK_ACQUIRE_REQ)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_ACQUIRE_REQ)))

Description

Get a CryptoPK request instance locked to perform the given operation. The returned crm_pk_dreq structure contains a status and a pointer to a reserved hardware accelerator instance. That pointer is only valid and usable if status is non-zero.

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
cmdThe command definition (for example ::CRM_PK_CMD_MOD_EXP)

Returns

None

##SEE CRM_PK_RELEASE_REQ()

CRM_PK_GET_REQ_ID

C

typedef unsigned int (*FUNC_CRM_PK_GET_REQ_ID)(crm_pk_accel *req);
#define CRM_PK_GET_REQ_ID         ((FUNC_CRM_PK_GET_REQ_ID)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_GET_REQ_ID

Description

Return the instance number of the hardware accelerator for this request

Parameters

ParamDescription
reqThe acceleration request obtained through CRM_PK_ACQUIRE_REQ()

| cmd | The command definition (for example ::CRM_PK_CMD_MOD_EXP) |

Returns

Instance number of the hardware accelerator for this request

CRM_PK_SET_USER_CONTEXT

C

typedef void (*FUNC_CRM_PK_SET_USER_CONTEXT)(crm_pk_accel *req, void *context);
#define CRM_PK_SET_USER_CONTEXT         ((FUNC_CRM_PK_SET_USER_CONTEXT)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_SET_USER_CONTEXT)))

Description

Add the context pointer to an acceleration request. The attached pointer can be retrieved by CRM_PK_GET_USER_CONTEXT(). After CRM_PK_RELEASE_REQ(), the context pointer is not available anymore. The context can represent any content the user may associate with the PK request.

Parameters

ParamDescription
reqThe acquired acceleration request

Returns

Context pointer from an acceleration request

SEE

CRM_PK_GET_USER_CONTEXT()

CRM_PK_GET_USER_CONTEXT

C

typedef void *(*FUNC_CRM_PK_GET_USER_CONTEXT)(crm_pk_accel *req);
#define CRM_PK_GET_USER_CONTEXT         ((FUNC_CRM_PK_GET_USER_CONTEXT)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_GET_USER_CONTEXT)))

Description

Get the context pointer from an acceleration request

Parameters

ParamDescription
reqThe acquired acceleration request

Returns

None

SEE

CRM_PK_SET_USER_CONTEXT()

CRM_PK_GET_OPSIZE

C

typedef int (*FUNC_CRM_PK_GET_OPSIZE)(crm_pk_accel *req);
#define CRM_PK_GET_OPSIZE         ((FUNC_CRM_PK_GET_OPSIZE)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_GET_OPSIZE)))

Description

Return the global operands size detected for the request

Parameters

ParamDescription
reqThe acquired acceleration request

Returns

Operand size for the request

CRM_PK_LIST_ECC_INSLOTS

C

typedef int (*FUNC_CRM_PK_LIST_ECC_INSLOTS)(crm_pk_accel *req, const struct crm_pk_ecurve *curve, int flags, struct crm_pk_slot *inputs);
#define CRM_PK_LIST_ECC_INSLOTS         ((FUNC_CRM_PK_LIST_ECC_INSLOTS)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_LIST_ECC_INSLOTS)))

Description

List slots for input operands for an ECC operation. Once the function completes with ::CRM_OK, write each operand to the address found in the corresponding slot. That applies to all ECC operations.

Parameters

ParamDescription
reqThe acquired acceleration request through CRM_PK_ACQUIRE_REQ()
curveThe curve used for that ECC operation
flagsOperation specific flags
inputsList of input slots that will be filled in

Returns

CRM_OK CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_BUSY

CRM_PK_LIST_GFP_INSLOTS

C

typedef int (*FUNC_CRM_PK_LIST_GFP_INSLOTS)(crm_pk_accel *req, const int *opsizes, struct crm_pk_slot *inputs);
#define CRM_PK_LIST_GFP_INSLOTS         ((FUNC_CRM_PK_LIST_GFP_INSLOTS)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_LIST_GFP_INSLOTS)))

Description

List slots for input operands for an GF(p) modular operation. Once the function completes with ::CRM_OK, write each operands to the address found in the corresponding slot. That applies to all operation except ECC.

Parameters

ParamDescription
reqThe acquired acceleration request through CRM_PK_ACQUIRE_REQ()
opsizesList of operand sizes
inputsList of input slots that will be filled in

Returns

CRM_OK CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_BUSY

CRM_PK_RUN

C

typedef void (*FUNC_CRM_PK_RUN)(crm_pk_accel *req);
#define CRM_PK_RUN         ((FUNC_CRM_PK_RUN)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_RUN)))

Description

Run the operation request in hardware

PRE

To be called after all operands have been written in the slots obtainded with CRM_PK_LIST_ECC_INSLOTS() or CRM_PK_LIST_GFP_INSLOTS(). After that the acceleration request is pending.

POST

The caller should wait until the operation finishes with CRM_PK_WAIT() or do polling by using crm_pk_has_finished().

Parameters

ParamDescription
reqThe acquired acceleration request through CRM_PK_ACQUIRE_REQ()

Returns

None

CRM_PK_WAIT

C

typedef int (*FUNC_CRM_PK_WAIT)(crm_pk_accel *req);
#define CRM_PK_WAIT         ((FUNC_CRM_PK_WAIT)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_WAIT)))

Description

Wait until the current operation finishes. After the operation finishes, return the operation status code.

Parameters

ParamDescription
reqThe acquired acceleration request through CRM_PK_ACQUIRE_REQ()

Returns

Any \ref CRM_PK_STATUS "status code"

CRM_PK_CLEARIRQ

C

typedef void (*FUNC_CRM_PK_CLEAR_IRQ)(void);
#define CRM_PK_CLEARIRQ     ((FUNC_CRM_PK_CLEAR_IRQ)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_CLEARIRQ)))

Description

Clear the interrupt request signal

Parameters

None

Returns

None

CRM_PK_ACCEL

C

typedef crm_pk_accel *(*FUNC_CRM_PK_POP_FINISHED_REQ)(struct crm_pk_cnx *cnx);
#define CRM_PK_POP_FINISHED_REQ         ((FUNC_CRM_PK_POP_FINISHED_REQ)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_POP_FINISHED_REQ)))

Description

Return the public key acceleration request which finished its operation. If no public key accelerator finished or none has an operation, return NULL. The results from the returned crm_pk_accel should be used as soon as possible and the instances given back with CRM_PK_RELEASE_REQ().

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup

Returns

NULL when no public key accelerator finished The acceleration request which finished its operation

CRM_PK_GET_GLOBAL_NOTIFICATION_ID

C

typedef int (*FUNC_CRM_PK_GET_GLOBAL_NOTIFICATION_ID)(struct crm_pk_cnx *cnx);
#define CRM_PK_GET_GLOBAL_NOTIFICATION_ID         ((FUNC_CRM_PK_GET_GLOBAL_NOTIFICATION_ID)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_GET_GLOBAL_NOTIFICATION_ID)))

Description

Return a platform notification that notifies when a request completed. The platform notification id is:

  • -1 if not available
  • a fd on POSIX systems
  • an interrupt line number

When a request completes the notification will activate. The fd will become readable and the interrupt line will generate an interrupt. The returned platform notification can be used once. After the platform notification or after CRM_PK_POP_FINISHED_REQ(), the notification id shall not be used anymore. May not be used in combination with CRM_PK_WAIT().

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup

Returns

Platform notification id

CRM_PK_GET_REQ_COMPLETION_ID

C

typedef int (*FUNC_CRM_PK_GET_REQ_COMPLETION_ID)(crm_pk_accel *req);
#define CRM_PK_GET_REQ_COMPLETION_ID         ((FUNC_CRM_PK_GET_REQ_COMPLETION_ID)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_GET_REQ_COMPLETION_ID)))

Description

Return a platform notification that notifies when a request completed. The platform notification id is:

  • -1 if not available
  • a fd on POSIX systems
  • an interrupt line number

When a request completes the notification will activate. The fd will become readable and the interrupt line will generate an interrupt.After it was used or after CRM_PK_POP_FINISHED_REQ(), the fd or interrupt line shall not be used anymore. May not be used in combination with CRM_PK_WAIT().

Parameters

ParamDescription
reqThe acceleration request obtained through CRM_PK_ACQUIRE_REQ

Returns

Platform notification id

CRM_PK_GET_OUTPUT_OPS

C

typedef const char **(*FUNC_CRM_PK_GET_OUTPUT_OPS)(crm_pk_accel *req);
#define CRM_PK_GET_OUTPUT_OPS         ((FUNC_CRM_PK_GET_OUTPUT_OPS)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_GET_OUTPUT_OPS)))

Description

Fetch array of addresses to output operands

Parameters

ParamDescription
reqThe acceleration request obtained through CRM_PK_ACQUIRE_REQ

Returns

Array of addresses to output operands

CRM_PK_RELEASE_REQ

C

typedef void (*FUNC_CRM_PK_RELEASE_REQ)(crm_pk_accel *req);
#define CRM_PK_RELEASE_REQ         ((FUNC_CRM_PK_RELEASE_REQ)(*(uint32_t *)(API_TABLE_BASE_ADDRESS + ATO_CRM_PK_RELEASE_REQ)))

Description

Give back the public key acceleration request. Release the reserved resources

PRE

CRM_PK_ACQUIRE_REQ() should have been called before this function is called and not being in use by the hardware

Parameters

ParamDescription
reqThe acceleration request obtained through CRM_PK_ACQUIRE_REQ() operation has finished

Returns

None