
Description
I am given an assignment on RSA Implementation using OpenSSL. Need to submit a detailed report with appropriate solutions as asked in the file attached.
Unformatted Attachment Preview
Purchase answer to see full attachment

Explanation & Answer

Hello, here's the complete fileSorry for delay though
Openssl cryptographic library implement the RSA public key encryption
Scheme
Program to generate prime numbers p, and q, calculating the
values of n, e and private key d. The value of e should be chosen randomly.
import pyasn1.codec.der.encoder
import pyasn1.type.univ
def pempriv(n, e, d, p, q, dP, dQ, qInv):
template = '-----BEGIN RSA PRIVATE KEY-----\n{}-----END RSA PRIVATE KEY----\n'
seq = pyasn1.type.univ.Sequence()
for x in [0, n, e, d, p, q, dP, dQ, qInv]:
seq.setComponentByPosition(len(seq), pyasn1.type.univ.Integer(x))
der = pyasn1.codec.der.encoder.encode(seq)
return template.format(base64.encodestring(der).decode('ascii'))=
n = p * q
phi = (p -1)*(q-1)
d = modinv(e, phi)
dp = modinv(e,(p-1))
dq = modinv(e,(q-1))
qi = modinv(q,p)
key = pempriv(n, e, d, p, q, dp, dq, qi)
f = open(output_file,"w")
f.write(key)
f.close()
Program
#include
#ifdef OPENSSL_NO_RSA
NON_EMPTY_TRANSLATION_UNIT
#else
# include
# include
# include
# include
# include "apps.h"
# include "progs.h"
# include
# include
# include
Your Last Name 2
# include
# include
# include
# include
typedef enum OPTION_choice {
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_IN, OPT_OUT,
OPT_PUBIN, OPT_PUBOUT, OPT_PASSOUT, OPT_PASSIN,
OPT_RSAPUBKEY_IN, OPT_RSAPUBKEY_OUT,
/* Do not change the order here; see case statements below */
OPT_PVK_NONE, OPT_PVK_WEAK, OPT_PVK_STRONG,
OPT_NOOUT, OPT_TEXT, OPT_MODULUS, OPT_CHECK, OPT_CIPHER
} OPTION_CHOICE;
const OPTIONS rsa_o...
