Class RsaCipher
- java.lang.Object
- 
- org.activecomponents.udp.asymciphers.RsaCipher
 
- 
- All Implemented Interfaces:
- IAsymCipher
 
 public class RsaCipher extends java.lang.Object implements IAsymCipher 
- 
- 
Field SummaryFields Modifier and Type Field Description protected org.bouncycastle.crypto.params.AsymmetricKeyParameterforeignpublicPublic key of the communication partner.protected org.bouncycastle.crypto.AsymmetricCipherKeyPairkeypairKeypairprotected org.bouncycastle.crypto.AsymmetricBlockCipheroaeprsaOAEP engine.protected org.bouncycastle.crypto.SignerpssrsaPSS engine.
 - 
Constructor SummaryConstructors Constructor Description RsaCipher(RsaKeyProvider kp)RsaCipher(org.bouncycastle.crypto.AsymmetricCipherKeyPair keypair)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.bouncycastle.crypto.params.AsymmetricKeyParameterbyteArrayToKey(byte[] enckey)Converts a key from binary form.byte[]decrypt(byte[] ciphertext)Decrypts a message.byte[]decryptAndVerify(byte[] ciphertext, boolean verifywithforeign)Decrypts a message and verifies the signature.byte[]encrypt(byte[] plain, boolean foreign)Encrypts a message using a public key.byte[]keyToByteArray(org.bouncycastle.crypto.params.AsymmetricKeyParameter key)Converts a key to binary form.static voidmain(java.lang.String[] args)booleansetForeign(byte[] foreignpublic)Sets the public key of the communication partner.byte[]sign(byte[] msg)Signs a message.byte[]signAndEncrypt(byte[] msg, boolean encryptwithforeign)Signs a message and encrypts a message.byte[]verify(byte[] msgwithsig, boolean foreign)Verifies a message.
 
- 
- 
- 
Field Detail- 
keypairprotected org.bouncycastle.crypto.AsymmetricCipherKeyPair keypair Keypair
 - 
foreignpublicprotected org.bouncycastle.crypto.params.AsymmetricKeyParameter foreignpublic Public key of the communication partner.
 - 
pssrsaprotected org.bouncycastle.crypto.Signer pssrsa PSS engine.
 - 
oaeprsaprotected org.bouncycastle.crypto.AsymmetricBlockCipher oaeprsa OAEP engine.
 
- 
 - 
Constructor Detail- 
RsaCipherpublic RsaCipher(RsaKeyProvider kp) 
 - 
RsaCipherpublic RsaCipher(org.bouncycastle.crypto.AsymmetricCipherKeyPair keypair) 
 
- 
 - 
Method Detail- 
mainpublic static void main(java.lang.String[] args) 
 - 
setForeignpublic boolean setForeign(byte[] foreignpublic) Sets the public key of the communication partner.- Specified by:
- setForeignin interface- IAsymCipher
- Parameters:
- foreignpublic- The public key.
- Returns:
- False, if the key was invalid.
 
 - 
encryptpublic byte[] encrypt(byte[] plain, boolean foreign)Encrypts a message using a public key.- Parameters:
- plain- The plain text.
- foreign- True, if the foreign public key should be used, false, if the innate one should be used.
- Returns:
- The cipher text.
 
 - 
decryptpublic byte[] decrypt(byte[] ciphertext) Decrypts a message.- Parameters:
- ciphertext- The cipher text.
- Returns:
- The plain text or null if decryption failed.
 
 - 
signpublic byte[] sign(byte[] msg) Signs a message.- Parameters:
- msg- The message.
- Returns:
- The message with signature.
 
 - 
verifypublic byte[] verify(byte[] msgwithsig, boolean foreign)Verifies a message.- Parameters:
- msg- The message with signature.
- foreign- True, if the foreign public key should be used, false, if the innate one should be used.
- Returns:
- The message or null if the verification failed.
 
 - 
signAndEncryptpublic byte[] signAndEncrypt(byte[] msg, boolean encryptwithforeign)Signs a message and encrypts a message.- Specified by:
- signAndEncryptin interface- IAsymCipher
- Parameters:
- msg- The message.
- encryptwithforeign- True, if the foreign public key should be used for encryption, false, if the innate one should be used.
- Returns:
- The message with signature, encrypted.
 
 - 
decryptAndVerifypublic byte[] decryptAndVerify(byte[] ciphertext, boolean verifywithforeign)Decrypts a message and verifies the signature.- Specified by:
- decryptAndVerifyin interface- IAsymCipher
- Parameters:
- msg- The signed and encrypted message.
- encryptwithforeign- True, if the foreign public key should be used for verification, false, if the innate one should be used.
- Returns:
- The message, null if verification failed.
 
 - 
keyToByteArraypublic byte[] keyToByteArray(org.bouncycastle.crypto.params.AsymmetricKeyParameter key) Converts a key to binary form.- Specified by:
- keyToByteArrayin interface- IAsymCipher
- Parameters:
- key- The key.
- Returns:
- The binary form of the key.
 
 - 
byteArrayToKeypublic org.bouncycastle.crypto.params.AsymmetricKeyParameter byteArrayToKey(byte[] enckey) Converts a key from binary form.- Specified by:
- byteArrayToKeyin interface- IAsymCipher
- Parameters:
- enckey- The encoded key.
- Returns:
- The key.
 
 
- 
 
-