crm_async_mod_single_op_cmd_go

C

struct crm_pk_dreq crm_async_mod_single_op_cmd_go(
      struct crm_pk_cnx *cnx,
      const struct crm_pk_cmd_def *cmd,
      const crm_op *modulo,
      const crm_op *b)

Description

Asynchronous (non-blocking) Primitive modular operation with 1 operand Start a primitive modular operation with 1 operand on the accelerator and return immediately. When the operation finishes on the accelerator, call crm_async_finish_single()

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
cmdcmd Command definition. Should be a primitive modular operation with 1 operands. For example: CRM_PK_CMD_ODD_MOD_INV, CRM_PK_CMD_ODD_MOD_REDUCE, CRM_PK_CMD_EVEN_MOD_INV, CRM_PK_CMD_EVEN_MOD_REDUCE
moduloModulus operand. Must be odd if using CRM_PK_CMD_ODD_MOD_INV or CRM_PK_CMD_ODD_MOD_REDUCE command and even when using CRM_PK_CMD_EVEN_MOD_INV or CRM_PK_CMD_EVEN_MOD_REDUCE command
bOperand of modular operation

Returns

Acquired acceleration request for this operation

crm_mod_single_op_cmd

C

int crm_mod_single_op_cmd(
      struct crm_pk_cnx *cnx,
      const struct crm_pk_cmd_def *cmd,
      const crm_op *modulo,
      const crm_op *b,
      crm_op *result)```

## Description

Compute single operand modular operation
 - result = b mod modulo for CRM_PK_CMD_ODD_MOD_REDUCE, CRM_PK_CMD_EVEN_MOD_REDUCE
 - result = 1 / b mod modulo for CRM_PK_CMD_ODD_MOD_INV, CRM_PK_CMD_EVEN_MOD_INV

## Parameters

| Param | Description |
|:----- |:----------- |
| cnx |  Connection structure obtained through CRM_PK_OPEN() at startup |
| cmd | cmd Command definition. Should be a primitive modular operation with 1 operands. For example: CRM_PK_CMD_ODD_MOD_REDUCE, CRM_PK_CMD_ODD_MOD_INV, CRM_PK_CMD_EVEN_MOD_REDUCE, CRM_PK_CMD_EVEN_MOD_INV |
| modulo | modulo Modulus operand. Must be odd if using CRM_PK_CMD_ODD_MOD_INV or CRM_PK_CMD_ODD_MOD_REDUCE command and even when using CRM_PK_CMD_EVEN_MOD_INV or CRM_PK_CMD_EVEN_MOD_REDUCE command |
| b | Operand of modular operation |
| result | Result Operand |

## See
crm_async_mod_single_op_cmd_go() and crm_async_finish_single() for an asynchronous version

## Returns
CRM_OK
CRM_ERR_INVALID_PARAM
CRM_ERR_NOT_INVERTIBLE
CRM_ERR_UNKNOWN_ERROR
CRM_ERR_BUSY
CRM_ERR_NOT_IMPLEMENTED
CRM_ERR_OPERAND_TOO_LARGE
CRM_ERR_PLATFORM_ERROR
CRM_ERR_EXPIRED

# crm_async_mod_cmd_go

## C

```c
struct crm_pk_dreq crm_async_mod_cmd_go(
      struct crm_pk_cnx *cnx,
      const struct crm_pk_cmd_def *cmd,
      const crm_op *modulo,
      const crm_op *a,
      const crm_op *b)

Description

Asynchronous (non-blocking) Primitive modular operation with 2 operands Start a primitive modular operation with 2 operands on the accelerator and return immediately. When the operation finishes on the accelerator, call crm_async_finish_single()

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
cmdcmd Command definition. Should be a primitive modular operation with 2 operands. For example: CRM_PK_CMD_MOD_ADD, CRM_PK_CMD_SUB, CRM_PK_CMD_ODD_MOD_MULT, CRM_PK_CMD_ODD_MOD_DIV
moduloModulus operand.
aFirst Operand of modular operation
bSecond Operand of modular operation

See

crm_mod_primitive_cmd() for a synchronous version

Returns

Acquired acceleration request for this operation

crm_mod_primitive_cmd

C

int crm_mod_primitive_cmd(
      struct crm_pk_cnx *cnx,
      const struct crm_pk_cmd_def *cmd,
      const crm_op *modulo,
      const crm_op *a,
      const crm_op *b,
      crm_op *result)

Description

Primitive modular operation with 2 operands

  • result = a + b mod modulo for ::CRM_PK_CMD_MOD_ADD
  • result = a - b mod modulo for ::CRM_PK_CMD_MOD_SUB
  • result = ab mod modulo for ::CRM_PK_CMD_ODD_MOD_MULT with odd modulus
  • result = a / b mod modulo for ::CRM_PK_CMD_ODD_MOD_DIV with odd modulus Perform a modular addition or subtraction or odd modular multiplication or odd modular division.

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
cmdcmd Command definition. Should be a primitive modular operation with 2 operands
moduloModulus operand.
aFirst Operand of modular operation
bSecond Operand of modular operation
resultResult Operand

See

crm_async_mod_cmd_go() and crm_async_finish_single for an asynchronous version

Returns

CRM_OK CRM_ERR_NOT_INVERTIBLE CRM_ERR_INVALID_PARAM CRM_ERR_UNKNOWN_ERROR CRM_ERR_BUSY CRM_ERR_NOT_IMPLEMENTED CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_PLATFORM_ERROR CRM_ERR_EXPIRED

crm_async_mod_inv_go

C

struct crm_pk_dreq crm_async_mod_inv_go(
      struct crm_pk_cnx *cnx,
      const crm_op *modulo,
      const crm_op *b)

Description

Asynchronous (non-blocking) mod inversion. Start a modular inversion on the accelerator and return immediately. When the operation finishes on the accelerator, call crm_async_finish_single()

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
moduloModulus operand
bOperand to inverse

See

crm_async_finish_single(), crm_mod_inv()

Returns

Acquired acceleration request for this operation

crm_mod_inv

C

int crm_mod_inv(
      struct crm_pk_cnx *cnx,
      const crm_op *modulo,
      const crm_op *b,
      crm_op *result)

Description

Compute modular inversion result = 1/b mod modulo

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
moduloModulus operand
bOperand to inverse
resultResult operand of the modular inversion

See

crm_async_mod_inv_go() for an asynchronous version

Returns

CRM_OK CRM_ERR_NOT_INVERTIBLE CRM_ERR_INVALID_PARAM CRM_ERR_UNKNOWN_ERROR CRM_ERR_BUSY CRM_ERR_NOT_IMPLEMENTED CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_PLATFORM_ERROR CRM_ERR_EXPIRED

crm_async_mod_exp_go

C

struct crm_pk_dreq crm_async_mod_exp_go(
      struct crm_pk_cnx *cnx,
      const crm_op *input,
      const crm_op *exp,
      const crm_op *m)

Description

Asynchronous (non-blocking) modular exponentiation. Start a modular exponentiation on the accelerator and return immediately. When the operation finishes on the accelerator, call crm_async_mod_exp_end()

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
inputBase operand for modular exponentiation
expExponent operand
mModulus operand

See

crm_mod_exp() for a synchronous version

Returns

Acquired acceleration request for this operation

crm_async_mod_exp_end

C

void crm_async_mod_exp_end(
      crm_pk_accel *req,
      crm_op *result)

Description

Finish asynchronous (non-blocking) modular exponentiation. Get the output operand of the modular exponentiation and release the accelerator. The operation on the accelerator must be finished before calling this function.

Parameters

ParamDescription
reqThe pewviously acquired acceleration request for this operation
resultResult operand

See

crm_async_mod_exp_go() and crm_mod_exp()

Returns

None

crm_mod_exp

C

int crm_mod_exp(
        struct crm_pk_cnx *cnx,
        const crm_op *input,
        const crm_op *exp,
        const crm_op *m,
        crm_op *result)

Description

Compute modular exponentiation. result = input ^ exp mod m

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
inputBase operand
expExponent operand
mModulus operand
resultResult operand

See

crm_async_mod_exp_go(), crm_async_mod_exp_end() for an asynchronous version

Returns

CRM_OK CRM_ERR_INVALID_PARAM CRM_ERR_UNKNOWN_ERROR CRM_ERR_BUSY CRM_ERR_NOT_IMPLEMENTED CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_PLATFORM_ERROR CRM_ERR_EXPIRED

crm_async_crt_mod_exp_go

C

struct crm_pk_dreq crm_async_crt_mod_exp_go(
      struct crm_pk_cnx *cnx,
      const crm_op *in,
      const crm_op *p,
      const crm_op *q,
      const crm_op *dp,
      const crm_op *dq,
      const crm_op *qinv)

Description

Asynchronous (non-blocking) modular exponentiation with CRT. Start a modular exponentiation with CRT on the accelerator and return immediately. When the operation finishes on the accelerator, call crm_async_crt_mod_exp_end()

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
inInput
pprime number P
qprime number q
dpd mod (p-1), with d the private key
dqd mod (q-1), with d the private key
qinvq^(-1) mod p

See

crm_async_crt_mod_exp_end()

Returns

Acquired acceleration request for this operation

crm_async_crt_mod_exp_end

C

void crm_async_crt_mod_exp_end(
      crm_pk_accel *req,
      crm_op *result)

Description

Finish asynchronous (non-blocking) modular exponentiation with CRT. Get the output operand of the modular exponentiation with CRT and release the reserved resources. The operation on the accelerator must be finished before calling this function.

Parameters

ParamDescription
reqThe previously acquired acceleration request for this operation
resultResult

See

crm_async_crt_mod_exp_go()

Returns

None

crm_crt_mod_exp

C

int crm_crt_mod_exp(
        struct crm_pk_cnx *cnx,
        const crm_op *in,
        const crm_op *p,
        const crm_op *q,
        const crm_op *dp,
        const crm_op *dq,
        const crm_op *qinv,
        crm_op *result)

Description

Compute modular exponentiation with CRT Compute (result = in ^ db mod m) with those steps:

vp = in dp mod p vq = in dq mod q u = (vp -vq)qinv mod p result = vq + uq

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
inInput
pprime number P
qprime number q
dpd mod (p-1), with d the private key
dqd mod (q-1), with d the private key
qinvq^(-1) mod p
resultResult of modular exponentiation with CRT

See

crm_async_crt_mod_exp_go(), crm_async_crt_mod_exp_end() for an asynchronous version

Returns

CRM_OK CRM_ERR_INVALID_PARAM CRM_ERR_UNKNOWN_ERROR CRM_ERR_BUSY CRM_ERR_NOT_IMPLEMENTED CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_PLATFORM_ERROR CRM_ERR_EXPIRED

crm_async_rsa_keygen_go

C

struct crm_pk_dreq crm_async_rsa_keygen_go(struct crm_pk_cnx *cnx,
   const crm_op *p, const crm_op *q, const crm_op *public_expo)

Description

Asynchronous (non-blocking) RSA private key generation. Start an RSA private key generation on the accelerator and return immediately. When the operation finishes on the accelerator, call crm_async_rsa_keygen_end()

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
pprime number P
qprime number q
public_expoPublic exponent operand

Returns

Acquired acceleration request for this operation

crm_async_rsa_keygen_end

C

void crm_async_rsa_keygen_end(crm_pk_accel *req, crm_op *n, crm_op *lambda_n, crm_op *privkey)

Description

Finish asynchronous (non-blocking) RSA private key generation. Get the output operands of the RSA private key generation and release the reserved resources. The operation on the accelerator must be finished before calling this function

Parameters

ParamDescription
reqThe previously acquired acceleration request for this operation
nMultiple of 2 primes p and q
lambda_nLeast common multiple of p-1 and q-1
privkeyPrivate Key

Returns

None

crm_rsa_keygen

C

int crm_rsa_keygen(struct crm_pk_cnx *cnx,
     const crm_op *p, const crm_op *q, const crm_op *public_expo,
     crm_op *n, crm_op *lambda_n, crm_op *privkey)

Description

Compute RSA private key and lambda_n from primes p and q. The private key is generated with the following steps:

  1. n = pq
  2. lambda_n = lcm(p-1,q-1)
  3. d = e^-1 % lambda_n Where d is the private key (privkey).

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
pPrime value P
qPrime value q
public_expoPublic exponent operand
nResulting operand
lambda_nResulting lambda_n operand
privkeyResulting Private Key operand

See

crm_async_rsa_keygen_go(), crm_async_rsa_keygen_end() for an asynchronous version

Returns

CRM_OK CRM_ERR_INVALID_PARAM CRM_ERR_UNKNOWN_ERROR CRM_ERR_BUSY CRM_ERR_NOT_IMPLEMENTED CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_PLATFORM_ERROR CRM_ERR_EXPIRED

crm_async_rsa_crt_keyparams_go

C

struct crm_pk_dreq crm_async_rsa_crt_keyparams_go(
   struct crm_pk_cnx *cnx, const crm_op *p, const crm_op *q,
   const crm_op *privkey)

Description

Asynchronous (non-blocking) RSA CRT private key parameters. Start a RSA CRT private key generation on the accelerator and return immediately. When the operation finishes on the accelerator, call crm_async_rsa_crt_keyparams_end()

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
pPrime operand p
qPrime operand q
privkeyResulting Private Key operand

See

crm_async_rsakeyparams_end() and crm_async_rsa_crt_keyparams()

Returns

Acquired acceleration request for this operation

crm_async_rsa_crt_keyparams_end

C

void crm_async_rsa_crt_keyparams_end(crm_pk_accel *req,
                             crm_op *dp, crm_op *dq, crm_op *qinv)

Description

Finish asynchronous (non-blocking) RSA CRT private key parameters. Get the output operands of the RSA CRT private key parameters and release the reserved resources. The operation on the accelerator must be finished before calling this function.

Parameters

ParamDescription
reqThe previously acquired acceleration request for this operation
dpd mod (p-1)
dqd moe (q-1)
qinvq ^ -1 mod p

See

crm_async_rsa_crt_keyparams_go() and crm_rsa_crt_keyparams()

Returns

None

crm_async_rsa_crt_keyparams_end

C

int crm_rsa_crt_keyparams(struct crm_pk_cnx *cnx,
     const crm_op *p, const crm_op *q, const crm_op *privkey,
     crm_op *dp, crm_op *dq, crm_op *qinv)

Description

Compute RSA CRT private key parameters. Computes the following parameters: dp = d mod (p - 1) dq = d mod (q - 1) qinv = q ^ -1 mod p where d is the private key and the pair p and q are the secret primes used to create the RSA private key.

Parameters

ParamDescription
cnxConnection structure obtained through CRM_PK_OPEN() at startup
pPrime value p
qPrime value q
privkeyPrivate key operand
dpd mod (p-1)
dqd moe (q-1)
qinvq ^ -1 mod p

See

crm_async_rsa_crt_keyparams_go(), crm_async_rsa_crt_keyparams_end() for an asynchronous version

Returns

CRM_OK CRM_ERR_NOT_INVERTIBLE CRM_ERR_OUT_OF_RANGE CRM_ERR_INVALID_PARAM CRM_ERR_UNKNOWN_ERROR CRM_ERR_BUSY CRM_ERR_NOT_IMPLEMENTED CRM_ERR_OPERAND_TOO_LARGE CRM_ERR_PLATFORM_ERROR CRM_ERR_EXPIRED