<< NL_S_RSAKeys NL_S: Security NL_S_ShiftRows >>

NARVAL >> NL_S: Security > NL_S_RSAKeysE

NL_S_RSAKeysE

Perform the public and private keys of the RSA algorithm (additional input E).

Calling Sequence

[N,D] = NL_S_RSAKeysE(P,Q,E)

Arguments

P :

Prime number.

Q :

Prime number.

E :

Public exponent.

N :

Modulus.

D :

Private exponent.

Description

NL_S_RSAKeysE performs the public and private keys of the RSA algorithm (WIKIPEDIA). RSA involves a public key and a private key. The public key can be known by everyone and it is used for encrypting messages. Messages encrypted with the public key can only be decrypted using the private key. The public key consists of the modulus N and the public (or encryption) exponent E. The private key consists of the modulus N and the private (or decryption) exponent D which must be kept secret.

Pseudo-Code (Wikipedia)

1) Choose two distinct prime numbers p and q.
    For security purposes, the integers p and q should be chosen at random, and should be of similar bit-length. Prime integers can be efficiently found using a primality test.
2) Compute n = pq.
    n is used as the modulus for both the public and private keys
3) Compute phi(n) = (p1)(q1), where phi is Euler's totient function.
4) Choose an integer e such that 1 < e < phi(n) and greatest common divisor of (e, phi(n)) = 1; i.e., e and phi(n) are coprime.
    e is released as the public key exponent.
    e having a short bit-length and small Hamming weight results in more efficient encryption - most commonly 0x10001 = 65,537. However, small values of e (such as 3) have been shown to be less secure in some settings.
5) Determine d as:
    d = e^{-1} (mod phi(n))
    i.e., d is the multiplicative inverse of e mod phi(n).
        This is more clearly stated as solve for d given (de) mod phi(n) = 1
        This is often computed using the extended Euclidean algorithm.
        d is kept as the private key exponent.

Examples

p=61;//integer
q=53;//integer
e=17;//public exponent
[n,d]=NL_S_RSAKeysE(p,q,e);//application of NL_S_RSAKeysE
//public key
[n e]
//private key
[n d]

Dependency

NL_S_Prime, NL_S_GCDExtended

Report an issue
<< NL_S_RSAKeys NL_S: Security NL_S_ShiftRows >>