sx_async_mod_single_op_cmd_go
C
struct sx_pk_dreq sx_async_mod_single_op_cmd_go(
struct sx_pk_cnx *cnx,
const struct sx_pk_cmd_def *cmd,
const sx_op *modulo,
const sx_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 sx_async_finish_single()
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
cmd | cmd Command definition. Should be a primitive modular operation with 1 operands. For example: SX_PK_CMD_ODD_MOD_INV, SX_PK_CMD_ODD_MOD_REDUCE, SX_PK_CMD_EVEN_MOD_INV, SX_PK_CMD_EVEN_MOD_REDUCE |
modulo | Modulus operand. Must be odd if using SX_PK_CMD_ODD_MOD_INV or SX_PK_CMD_ODD_MOD_REDUCE command and even when using SX_PK_CMD_EVEN_MOD_INV or SX_PK_CMD_EVEN_MOD_REDUCE command |
b | Operand of modular operation |
Returns
Acquired acceleration request for this operation
sx_mod_single_op_cmd
C
int sx_mod_single_op_cmd( struct sx_pk_cnx *cnx, const struct sx_pk_cmd_def *cmd, const sx_op *modulo, const sx_op *b, sx_op *result)``` ## Description Compute single operand modular operation - result = b mod modulo for SX_PK_CMD_ODD_MOD_REDUCE, SX_PK_CMD_EVEN_MOD_REDUCE - result = 1 / b mod modulo for SX_PK_CMD_ODD_MOD_INV, SX_PK_CMD_EVEN_MOD_INV ## Parameters | Param | Description | |:----- |:----------- | | cnx | Connection structure obtained through SX_PK_OPEN() at startup | | cmd | cmd Command definition. Should be a primitive modular operation with 1 operands. For example: SX_PK_CMD_ODD_MOD_REDUCE, SX_PK_CMD_ODD_MOD_INV, SX_PK_CMD_EVEN_MOD_REDUCE, SX_PK_CMD_EVEN_MOD_INV | | modulo | modulo Modulus operand. Must be odd if using SX_PK_CMD_ODD_MOD_INV or SX_PK_CMD_ODD_MOD_REDUCE command and even when using SX_PK_CMD_EVEN_MOD_INV or SX_PK_CMD_EVEN_MOD_REDUCE command | | b | Operand of modular operation | | result | Result Operand | ## See sx_async_mod_single_op_cmd_go() and sx_async_finish_single() for an asynchronous version ## Returns SX_OK SX_ERR_INVALID_PARAM SX_ERR_NOT_INVERTIBLE SX_ERR_UNKNOWN_ERROR SX_ERR_BUSY SX_ERR_NOT_IMPLEMENTED SX_ERR_OPERAND_TOO_LARGE SX_ERR_PLATFORM_ERROR SX_ERR_EXPIRED # sx_async_mod_cmd_go ## C ```c struct sx_pk_dreq sx_async_mod_cmd_go( struct sx_pk_cnx *cnx, const struct sx_pk_cmd_def *cmd, const sx_op *modulo, const sx_op *a, const sx_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 sx_async_finish_single()
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
cmd | cmd Command definition. Should be a primitive modular operation with 2 operands. For example: SX_PK_CMD_MOD_ADD, SX_PK_CMD_SUB, SX_PK_CMD_ODD_MOD_MULT, SX_PK_CMD_ODD_MOD_DIV |
modulo | Modulus operand. |
a | First Operand of modular operation |
b | Second Operand of modular operation |
See
sx_mod_primitive_cmd() for a synchronous version
Returns
Acquired acceleration request for this operation
sx_mod_primitive_cmd
C
int sx_mod_primitive_cmd(
struct sx_pk_cnx *cnx,
const struct sx_pk_cmd_def *cmd,
const sx_op *modulo,
const sx_op *a,
const sx_op *b,
sx_op *result)
Description
Primitive modular operation with 2 operands
- result = a + b mod modulo for ::SX_PK_CMD_MOD_ADD
- result = a - b mod modulo for ::SX_PK_CMD_MOD_SUB
- result = ab mod modulo for ::SX_PK_CMD_ODD_MOD_MULT with odd modulus
- result = a / b mod modulo for ::SX_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 SX_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
sx_async_mod_cmd_go() and sx_async_finish_single for an asynchronous version
Returns
SX_OK SX_ERR_NOT_INVERTIBLE SX_ERR_INVALID_PARAM SX_ERR_UNKNOWN_ERROR SX_ERR_BUSY SX_ERR_NOT_IMPLEMENTED SX_ERR_OPERAND_TOO_LARGE SX_ERR_PLATFORM_ERROR SX_ERR_EXPIRED
sx_async_mod_inv_go
C
struct sx_pk_dreq sx_async_mod_inv_go(
struct sx_pk_cnx *cnx,
const sx_op *modulo,
const sx_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 sx_async_finish_single()
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
modulo | Modulus operand |
b | Operand to inverse |
See
sx_async_finish_single(), sx_mod_inv()
Returns
Acquired acceleration request for this operation
sx_mod_inv
C
int sx_mod_inv(
struct sx_pk_cnx *cnx,
const sx_op *modulo,
const sx_op *b,
sx_op *result)
Description
Compute modular inversion result = 1/b mod modulo
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
modulo | Modulus operand |
b | Operand to inverse |
result | Result operand of the modular inversion |
See
sx_async_mod_inv_go() for an asynchronous version
Returns
SX_OK SX_ERR_NOT_INVERTIBLE SX_ERR_INVALID_PARAM SX_ERR_UNKNOWN_ERROR SX_ERR_BUSY SX_ERR_NOT_IMPLEMENTED SX_ERR_OPERAND_TOO_LARGE SX_ERR_PLATFORM_ERROR SX_ERR_EXPIRED
sx_async_mod_exp_go
C
struct sx_pk_dreq sx_async_mod_exp_go(
struct sx_pk_cnx *cnx,
const sx_op *input,
const sx_op *exp,
const sx_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 sx_async_mod_exp_end()
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
input | Base operand for modular exponentiation |
exp | Exponent operand |
m | Modulus operand |
See
sx_mod_exp() for a synchronous version
Returns
Acquired acceleration request for this operation
sx_async_mod_exp_end
C
void sx_async_mod_exp_end(
sx_pk_accel *req,
sx_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
sx_async_mod_exp_go() and sx_mod_exp()
Returns
None
sx_mod_exp
C
int sx_mod_exp(
struct sx_pk_cnx *cnx,
const sx_op *input,
const sx_op *exp,
const sx_op *m,
sx_op *result)
Description
Compute modular exponentiation. result = input ^ exp mod m
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
input | Base operand |
exp | Exponent operand |
m | Modulus operand |
result | Result operand |
See
sx_async_mod_exp_go(), sx_async_mod_exp_end() for an asynchronous version
Returns
SX_OK SX_ERR_INVALID_PARAM SX_ERR_UNKNOWN_ERROR SX_ERR_BUSY SX_ERR_NOT_IMPLEMENTED SX_ERR_OPERAND_TOO_LARGE SX_ERR_PLATFORM_ERROR SX_ERR_EXPIRED
sx_async_crt_mod_exp_go
C
struct sx_pk_dreq sx_async_crt_mod_exp_go(
struct sx_pk_cnx *cnx,
const sx_op *in,
const sx_op *p,
const sx_op *q,
const sx_op *dp,
const sx_op *dq,
const sx_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 sx_async_crt_mod_exp_end()
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_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
sx_async_crt_mod_exp_end()
Returns
Acquired acceleration request for this operation
sx_async_crt_mod_exp_end
C
void sx_async_crt_mod_exp_end(
sx_pk_accel *req,
sx_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
sx_async_crt_mod_exp_go()
Returns
None
sx_crt_mod_exp
C
int sx_crt_mod_exp(
struct sx_pk_cnx *cnx,
const sx_op *in,
const sx_op *p,
const sx_op *q,
const sx_op *dp,
const sx_op *dq,
const sx_op *qinv,
sx_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 SX_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
sx_async_crt_mod_exp_go(), sx_async_crt_mod_exp_end() for an asynchronous version
Returns
SX_OK SX_ERR_INVALID_PARAM SX_ERR_UNKNOWN_ERROR SX_ERR_BUSY SX_ERR_NOT_IMPLEMENTED SX_ERR_OPERAND_TOO_LARGE SX_ERR_PLATFORM_ERROR SX_ERR_EXPIRED
sx_async_rsa_keygen_go
C
struct sx_pk_dreq sx_async_rsa_keygen_go(struct sx_pk_cnx *cnx,
const sx_op *p, const sx_op *q, const sx_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 sx_async_rsa_keygen_end()
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
p | prime number P |
q | prime number q |
public_expo | Public exponent operand |
Returns
Acquired acceleration request for this operation
sx_async_rsa_keygen_end
C
void sx_async_rsa_keygen_end(sx_pk_accel *req, sx_op *n, sx_op *lambda_n, sx_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
sx_rsa_keygen
C
int sx_rsa_keygen(struct sx_pk_cnx *cnx,
const sx_op *p, const sx_op *q, const sx_op *public_expo,
sx_op *n, sx_op *lambda_n, sx_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 SX_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
sx_async_rsa_keygen_go(), sx_async_rsa_keygen_end() for an asynchronous version
Returns
SX_OK SX_ERR_INVALID_PARAM SX_ERR_UNKNOWN_ERROR SX_ERR_BUSY SX_ERR_NOT_IMPLEMENTED SX_ERR_OPERAND_TOO_LARGE SX_ERR_PLATFORM_ERROR SX_ERR_EXPIRED
sx_async_rsa_crt_keyparams_go
C
struct sx_pk_dreq sx_async_rsa_crt_keyparams_go(
struct sx_pk_cnx *cnx, const sx_op *p, const sx_op *q,
const sx_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 sx_async_rsa_crt_keyparams_end()
Parameters
Param | Description |
---|---|
cnx | Connection structure obtained through SX_PK_OPEN() at startup |
p | Prime operand p |
q | Prime operand q |
privkey | Resulting Private Key operand |
See
sx_async_rsakeyparams_end() and sx_async_rsa_crt_keyparams()
Returns
Acquired acceleration request for this operation
sx_async_rsa_crt_keyparams_end
C
void sx_async_rsa_crt_keyparams_end(sx_pk_accel *req,
sx_op *dp, sx_op *dq, sx_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
sx_async_rsa_crt_keyparams_go() and sx_rsa_crt_keyparams()
Returns
None
sx_async_rsa_crt_keyparams_end
C
int sx_rsa_crt_keyparams(struct sx_pk_cnx *cnx,
const sx_op *p, const sx_op *q, const sx_op *privkey,
sx_op *dp, sx_op *dq, sx_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 SX_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
sx_async_rsa_crt_keyparams_go(), sx_async_rsa_crt_keyparams_end() for an asynchronous version
Returns
SX_OK SX_ERR_NOT_INVERTIBLE SX_ERR_OUT_OF_RANGE SX_ERR_INVALID_PARAM SX_ERR_UNKNOWN_ERROR SX_ERR_BUSY SX_ERR_NOT_IMPLEMENTED SX_ERR_OPERAND_TOO_LARGE SX_ERR_PLATFORM_ERROR SX_ERR_EXPIRED