org.bouncycastle.crypto.engines
Class RSABlindingEngine

java.lang.Object
  extended by org.bouncycastle.crypto.engines.RSABlindingEngine
All Implemented Interfaces:
AsymmetricBlockCipher

public class RSABlindingEngine
extends java.lang.Object
implements AsymmetricBlockCipher

This does your basic RSA Chaum's blinding and unblinding as outlined in "Handbook of Applied Cryptography", page 475. You need to use this if you are trying to get another party to generate signatures without them being aware of the message they are signing.


Field Summary
private  java.math.BigInteger blindingFactor
           
private  RSACoreEngine core
           
private  boolean forEncryption
           
private  RSAKeyParameters key
           
 
Constructor Summary
RSABlindingEngine()
           
 
Method Summary
private  java.math.BigInteger blindMessage(java.math.BigInteger msg)
           
 int getInputBlockSize()
          Return the maximum size for an input block to this engine.
 int getOutputBlockSize()
          Return the maximum size for an output block to this engine.
 void init(boolean forEncryption, CipherParameters param)
          Initialise the blinding engine.
 byte[] processBlock(byte[] in, int inOff, int inLen)
          Process a single block using the RSA blinding algorithm.
private  java.math.BigInteger unblindMessage(java.math.BigInteger blindedMsg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

core

private RSACoreEngine core

key

private RSAKeyParameters key

blindingFactor

private java.math.BigInteger blindingFactor

forEncryption

private boolean forEncryption
Constructor Detail

RSABlindingEngine

public RSABlindingEngine()
Method Detail

init

public void init(boolean forEncryption,
                 CipherParameters param)
Initialise the blinding engine.

Specified by:
init in interface AsymmetricBlockCipher
Parameters:
forEncryption - true if we are encrypting (blinding), false otherwise.
param - the necessary RSA key parameters.

getInputBlockSize

public int getInputBlockSize()
Return the maximum size for an input block to this engine. For RSA this is always one byte less than the key size on encryption, and the same length as the key size on decryption.

Specified by:
getInputBlockSize in interface AsymmetricBlockCipher
Returns:
maximum size for an input block.

getOutputBlockSize

public int getOutputBlockSize()
Return the maximum size for an output block to this engine. For RSA this is always one byte less than the key size on decryption, and the same length as the key size on encryption.

Specified by:
getOutputBlockSize in interface AsymmetricBlockCipher
Returns:
maximum size for an output block.

processBlock

public byte[] processBlock(byte[] in,
                           int inOff,
                           int inLen)
Process a single block using the RSA blinding algorithm.

Specified by:
processBlock in interface AsymmetricBlockCipher
Parameters:
in - the input array.
inOff - the offset into the input buffer where the data starts.
inLen - the length of the data to be processed.
Returns:
the result of the RSA process.
Throws:
DataLengthException - the input block is too large.

blindMessage

private java.math.BigInteger blindMessage(java.math.BigInteger msg)

unblindMessage

private java.math.BigInteger unblindMessage(java.math.BigInteger blindedMsg)