Question: Generate your RSA key pair using keytool -genkey option. Export your public certificate using -exportcert option. You will need to lookup keytool documentation. Encrypt your

Generate your RSA key pair using keytool -genkey option. Export your public certificate using -exportcert option. You will need to lookup keytool documentation. Encrypt your name using your private key and encryption mode "RSA/ECB/NoPadding". Submit your certificate and the binary file containing encrypted version of your name.

Example to generate a RSA key pair:

keytool -genkey -alias cs166 -keystore mystore.jks

Example to export certificate:

keytool -export -alias cs166 -keystore mystore.jks -file .cer

Example code to Base64 decode a byte array: (JDK1.8)

byte[] bt = Files.readAllBytes( "hw4.rsa") ;

byte[] btDecoded = java.util.Base64.getDecoder().decode(bt) ;

Example sample code to get RSA public key from a certificate:

static PublicKey getPublicKey() throws Exception { InputStream inStream = new FileInputStream("s166teacher.cer"); CertificateFactory cf = CertificateFactory.getInstance("X.509"); X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream); PublicKey pk = cert.getPublicKey(); return pk; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!