BeeCrypt 4.2.1
rsa.h File Reference

RSA algorithm. More...

#include "beecrypt/rsakp.h"
Include dependency graph for rsa.h:

Go to the source code of this file.

Functions

int rsapub (const mpbarrett *n, const mpnumber *e, const mpnumber *m, mpnumber *c)
 This function performs a raw RSA public key operation.
int rsapri (const mpbarrett *n, const mpnumber *d, const mpnumber *c, mpnumber *m)
 This function performs a raw RSA private key operation.
int rsapricrt (const mpbarrett *n, const mpbarrett *p, const mpbarrett *q, const mpnumber *dp, const mpnumber *dq, const mpnumber *qi, const mpnumber *c, mpnumber *m)
 This function performs a raw RSA private key operation, with application of the Chinese Remainder Theorem.
int rsavrfy (const mpbarrett *n, const mpnumber *e, const mpnumber *m, const mpnumber *c)
 This function performs a raw RSA verification.

Detailed Description

Function Documentation

◆ rsapri()

int rsapri ( const mpbarrett * n,
const mpnumber * d,
const mpnumber * c,
mpnumber * m )

This function performs a raw RSA private key operation.

This function can be used for decryption and signing.

It performs the operation:

  • $m=c^{d}\ \textrm{mod}\ n$
Parameters
nThe modulus.
dThe private exponent.
cThe ciphertext.
mThe message.
Return values
0on success.
-1on failure.

References BEECRYPTAPI.

◆ rsapricrt()

int rsapricrt ( const mpbarrett * n,
const mpbarrett * p,
const mpbarrett * q,
const mpnumber * dp,
const mpnumber * dq,
const mpnumber * qi,
const mpnumber * c,
mpnumber * m )

This function performs a raw RSA private key operation, with application of the Chinese Remainder Theorem.

It performs the operation:

  • $j_1=c^{dp}\ \textrm{mod}\ p$
  • $j_2=c^{dq}\ \textrm{mod}\ q$
  • $h=qi \cdot (j_1-j_2)\ \textrm{mod}\ p$
  • $m=j_2+hq$
Parameters
nThe modulus.
pThe first prime factor.
qThe second prime factor.
dpThe private exponent d mod (p-1).
dqThe private exponent d (q-1).
qiThe inverse of q mod p.
cThe ciphertext.
mThe message.
Return values
0on success.
-1on failure.

References BEECRYPTAPI.

◆ rsapub()

int rsapub ( const mpbarrett * n,
const mpnumber * e,
const mpnumber * m,
mpnumber * c )

This function performs a raw RSA public key operation.

This function can be used for encryption and verifying.

It performs the following operation:

  • $c=m^{e}\ \textrm{mod}\ n$
Parameters
nThe RSA modulus.
eThe RSA public exponent.
mThe message.
cThe ciphertext.
Return values
0on success.
-1on failure.

References BEECRYPTAPI.

◆ rsavrfy()

int rsavrfy ( const mpbarrett * n,
const mpnumber * e,
const mpnumber * m,
const mpnumber * c )

This function performs a raw RSA verification.

It verifies if ciphertext c was encrypted from cleartext m with the private key matching the given public key (n, e).

Parameters
nThe modulus.
eThe public exponent.
mThe cleartext message.
cThe ciphertext message.
Return values
1on success.
0on failure.