demo
Class RSA

java.lang.Object
  |
  +--demo.RSA

public class RSA
extends Object

This class tests the RSA cipher implementation.

IAIK-JCE allows to use the javax.crypto.Cipher class for working with RSA ciphers. Creating a RSA cipher is done in the same way as creating a, for instance, DES or IDEA cipher by calling a proper getInstance factory method, e.g.:

Cipher rsa = Cipher.getInstance("RSA", "IAIK");

The supplied transformation string may be expanded to perform block formatting according to PKCS#1 with block type 1 or blocktype 2, i.e.:

 Cipher rsa = Cipher.getInstance("RSA/ECB/PKCS1Padding", "IAIK");
 

If you want to use OAEP es encryption scheme you have to specify "OAEP" as padding scheme when instantiating the cipher object:

 Cipher rsa = Cipher.getInstance("RSA/ECB/OAEP");
 
The further proceeding uses cipher initialization, cipher update and cipher finishing as used with any other cipher, e.g.:

 rsa.init(Cipher.ENCRYPT_MODE, public_key);
 byte[] encrypted = rsa.doFinal(plain_data);
 

Version:
File Revision 23

Constructor Summary
RSA()
          Default constructor.
 
Method Summary
static void main(String[] argv)
          Starts the RSA cipher implementation test.
 void rsa(String transformation)
          RSA cipher test.
 void start()
          Performs the RSA cipher implementation test.
 void testOAEPParametersCreate()
          Test of OAEP parameter creation.
 void testOAEPParametersParse()
          Test of OAEP parameter parsing.
 void testOAEPPSourceParameters()
          Test of OAEP PSourceAlgorithm parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RSA

public RSA()
Default constructor. Inits the keys.
Method Detail

start

public void start()
Performs the RSA cipher implementation test.

rsa

public void rsa(String transformation)
RSA cipher test.
Parameters:
transformation - the Cipher transformation string (e.g. "RSA/ECB/OAEP");

testOAEPParametersParse

public void testOAEPParametersParse()
Test of OAEP parameter parsing. This method first uses a "RSA/ECB/OAEPWithMD5AndMGF1Padding" cipher to encrypt some data and then inits a "RSA/ECB/OAEP" cipher with the parameters from the first cipher to decrypt the encrypted data.

testOAEPParametersCreate

public void testOAEPParametersCreate()
Test of OAEP parameter creation. This method first uses a "RSA/ECB/OAEP" cipher and inits it with OAEP paramaters to encrypt some data and then uses a "RSA/ECB/OAEPWithMD5AndMGF1Padding" cipher to decrypt the encrypted data.

testOAEPPSourceParameters

public void testOAEPPSourceParameters()
Test of OAEP PSourceAlgorithm parameters. This method first uses a "RSA/ECB/OAEPWithSHA1AndMGF1Padding" cipher and inits it with PSourceAlgorithm parameters only to encrypt some data and then inits a "RSA/ECB/OAEP" cipher with the parameters from the first cipher to decrypt the encrypted data.

main

public static void main(String[] argv)
Starts the RSA cipher implementation test.

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK