aerogear-crypto 0.1.0

org.jboss.aerogear.crypto
Class CryptoBox

java.lang.Object
  extended by org.jboss.aerogear.crypto.CryptoBox

public class CryptoBox
extends Object

Class responsible for box and unbox crypto messages given the key


Field Summary
private  byte[] authData
           
private  org.bouncycastle.crypto.modes.AEADBlockCipher cipher
           
private  byte[] key
           
 
Constructor Summary
CryptoBox(byte[] key)
          Initializes the box providing the secret key
CryptoBox(PrivateKey key)
          Initializes the box providing the secret key
CryptoBox(PrivateKey privateKey, PublicKey publicKey)
          Initializes the box providing the key pair for asymmetric encryption
CryptoBox(String key, Encoder encoder)
          Initializes the box providing the secret key and encoder
 
Method Summary
 byte[] decrypt(byte[] IV, byte[] cipherText)
          Given the IV, decrypt the provided data
 byte[] decrypt(String IV, String cipherText, Encoder encoder)
          Given the IV, decrypt the provided data
 byte[] encrypt(byte[] IV, byte[] message)
          Given the IV, encrypt the provided data
 byte[] encrypt(String IV, String message, Encoder encoder)
          Given the IV, encrypt and encode the provided data
private  byte[] generateSecret(PrivateKey privateKey, PublicKey publicKey)
           
 void updateAAD(byte[] authData)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

private byte[] key

cipher

private org.bouncycastle.crypto.modes.AEADBlockCipher cipher

authData

private byte[] authData
Constructor Detail

CryptoBox

public CryptoBox(byte[] key)
Initializes the box providing the secret key

Parameters:
key - byte array

CryptoBox

public CryptoBox(PrivateKey key)
Initializes the box providing the secret key

Parameters:
key - reference to the PrivateKey

CryptoBox

public CryptoBox(String key,
                 Encoder encoder)
Initializes the box providing the secret key and encoder

Parameters:
key -
encoder -

CryptoBox

public CryptoBox(PrivateKey privateKey,
                 PublicKey publicKey)
Initializes the box providing the key pair for asymmetric encryption

Parameters:
privateKey -
publicKey -
Method Detail

generateSecret

private byte[] generateSecret(PrivateKey privateKey,
                              PublicKey publicKey)

encrypt

public byte[] encrypt(byte[] IV,
                      byte[] message)
               throws RuntimeException
Given the IV, encrypt the provided data

Parameters:
IV - initialization vector
message - data to be encrypted
Returns:
byte array with the cipher text
Throws:
RuntimeException

encrypt

public byte[] encrypt(String IV,
                      String message,
                      Encoder encoder)
Given the IV, encrypt and encode the provided data

Parameters:
IV - initialization vector
message - data to be encrypted
encoder - encoder provided RAW or HEX
Returns:
byte array with the cipher text

decrypt

public byte[] decrypt(byte[] IV,
                      byte[] cipherText)
               throws RuntimeException
Given the IV, decrypt the provided data

Parameters:
IV - initialization vector
cipherText - data to be decrypted
Returns:
byte array with the plain text
Throws:
RuntimeException

decrypt

public byte[] decrypt(String IV,
                      String cipherText,
                      Encoder encoder)
Given the IV, decrypt the provided data

Parameters:
IV - initialization vector
cipherText - data to be decrypted
encoder - encoder provided RAW or HEX
Returns:
byte array with the plain text

updateAAD

public void updateAAD(byte[] authData)

aerogear-crypto 0.1.0

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.