org.clazzes.optional.sec.rsa
Class OAEP

java.lang.Object
  extended by org.clazzes.optional.sec.rsa.OAEP

public class OAEP
extends java.lang.Object

OAEP algorithm as defined in Section 7.1 of RFC 3447.


Constructor Summary
OAEP(Digest digest, MGF mgf, RandomGenerator randomGenerator)
           
 
Method Summary
 int decrypt(byte[] in, int keyLen, byte[] label, byte[] out, int outOff)
          Prepare the given input data for RSA encryption.
 int decryptRSA(byte[] in, RSAPrivKey privKey, byte[] label, byte[] out, int outOff)
          Decrypt and unpad the given input data using RSA decryption.
 void encrypt(byte[] in, int inOff, int inLen, byte[] label, byte[] out)
          Prepare the given input data for RSA encryption.
 byte[] encryptRSA(byte[] in, int inOff, int inLen, RSAPubKey pubKey, byte[] label)
          Pad an encrypt the given input data using RSA encryption.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OAEP

public OAEP(Digest digest,
            MGF mgf,
            RandomGenerator randomGenerator)
Method Detail

encrypt

public void encrypt(byte[] in,
                    int inOff,
                    int inLen,
                    byte[] label,
                    byte[] out)
Prepare the given input data for RSA encryption.

Parameters:
in - The input buffer
inOff - The offset of the data to be encrypted.
inLen - The length of the data to be encrypted.
label - The encryption label used as additional seed material.
out - The output buffer. The length of the output buffer is the size of the RSA modulus used.

encryptRSA

public byte[] encryptRSA(byte[] in,
                         int inOff,
                         int inLen,
                         RSAPubKey pubKey,
                         byte[] label)
Pad an encrypt the given input data using RSA encryption.

Parameters:
in - The input buffer
inOff - The offset of the data to be encrypted.
inLen - The length of the data to be encrypted.
pubKey - The RSA public key used to encrypt.
label - The encryption label used as additional seed material.

decrypt

public int decrypt(byte[] in,
                   int keyLen,
                   byte[] label,
                   byte[] out,
                   int outOff)
Prepare the given input data for RSA encryption.

Parameters:
in - The input buffer, which not longer than keyLen.
keyLen - The length of the RSA modulus. THe length of in may be less than keyLen, because in is the magnitude of a big integer, which might have contained leading zero bytes. Hence, if in is shorter than keyLen, the missing parts are interpreted as leading zero bytes.
label - The encryption label used as additional seed material.
out - The output buffer. The length of the output buffer must be at least the size of the RSA modulus used.
outOff - The offset at which the result is stored in out.
Returns:
The number of bytes stored to out.

decryptRSA

public int decryptRSA(byte[] in,
                      RSAPrivKey privKey,
                      byte[] label,
                      byte[] out,
                      int outOff)
Decrypt and unpad the given input data using RSA decryption.

Parameters:
in - The input buffer, which not longer than keyLen.
privKey - The RAS private key used for the plain RSA operation.
label - The encryption label used as additional seed material.
out - The output buffer. The length of the output buffer must be at least the size of the RSA modulus used.
outOff - The offset at which the result is stored in out.
Returns:
The number of bytes stored to out.


Copyright © 2010. All Rights Reserved.