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
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_INV, CRM_PK_CMD_ODD_MOD_REDUCE, CRM_PK_CMD_EVEN_MOD_INV, CRM_PK_CMD_EVEN_MOD_REDUCE |
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 |
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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
cmd | cmd 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 |
modulo | Modulus operand. |
a | First Operand of modular operation |
b | Second 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
cmd | cmd Command definition. Should be a primitive modular operation with 2 operands |
modulo | Modulus operand. |
a | First Operand of modular operation |
b | Second Operand of modular operation |
result | Result 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
modulo | Modulus operand |
b | Operand 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
modulo | Modulus operand |
b | Operand to inverse |
result | Result 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
input | Base operand for modular exponentiation |
exp | Exponent operand |
m | Modulus 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
Param | Description |
---|---|
req | The pewviously acquired acceleration request for this operation |
result | Result 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
input | Base operand |
exp | Exponent operand |
m | Modulus operand |
result | Result 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
in | Input |
p | prime number P |
q | prime number q |
dp | d mod (p-1), with d the private key |
dq | d mod (q-1), with d the private key |
qinv | q^(-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
Param | Description |
---|---|
req | The previously acquired acceleration request for this operation |
result | Result |
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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
in | Input |
p | prime number P |
q | prime number q |
dp | d mod (p-1), with d the private key |
dq | d mod (q-1), with d the private key |
qinv | q^(-1) mod p |
result | Result 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
p | prime number P |
q | prime number q |
public_expo | Public 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
Param | Description |
---|---|
req | The previously acquired acceleration request for this operation |
n | Multiple of 2 primes p and q |
lambda_n | Least common multiple of p-1 and q-1 |
privkey | Private 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:
- n = pq
- lambda_n = lcm(p-1,q-1)
- d = e^-1 % lambda_n Where d is the private key (privkey).
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
p | Prime value P |
q | Prime value q |
public_expo | Public exponent operand |
n | Resulting operand |
lambda_n | Resulting lambda_n operand |
privkey | Resulting 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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
p | Prime operand p |
q | Prime operand q |
privkey | Resulting 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
Param | Description |
---|---|
req | The previously acquired acceleration request for this operation |
dp | d mod (p-1) |
dq | d moe (q-1) |
qinv | q ^ -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
Param | Description |
---|---|
cnx | Connection structure obtained through CRM_PK_OPEN() at startup |
p | Prime value p |
q | Prime value q |
privkey | Private key operand |
dp | d mod (p-1) |
dq | d moe (q-1) |
qinv | q ^ -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