public class AESUtils extends Object
Utility class to provide the following to BRIT API:
Modifier and Type | Field and Description |
---|---|
static int |
BLOCK_LENGTH
The size of an AES block in bytes.
|
static int |
KEY_LENGTH
Key length in bytes.
|
Modifier and Type | Method and Description |
---|---|
static org.bouncycastle.crypto.params.KeyParameter |
createAESKey(byte[] seed,
byte[] salt)
Create an AES 256 key given 20 bytes of entropy (e.g.
|
static byte[] |
decrypt(byte[] encryptedBytes,
org.bouncycastle.crypto.params.KeyParameter aesKey,
byte[] initialisationVector)
Decrypt bytes previously encrypted with this class.
|
static byte[] |
encrypt(byte[] plainBytes,
org.bouncycastle.crypto.params.KeyParameter aesKey,
byte[] initialisationVector)
Password based encryption using AES - CBC 256 bits.
|
static byte[] |
generate160BitsOfEntropy(byte[] seed,
byte[] salt)
Generate 160 bits of entropy from the seed bytes.
|
public static final int KEY_LENGTH
public static final int BLOCK_LENGTH
public static byte[] encrypt(byte[] plainBytes, org.bouncycastle.crypto.params.KeyParameter aesKey, byte[] initialisationVector) throws org.bitcoinj.crypto.KeyCrypterException
plainBytes
- The unencrypted bytes for encryptionaesKey
- The AES key to use for encryptioninitialisationVector
- The initialisationVector to use whilst encryptingorg.bitcoinj.crypto.KeyCrypterException
public static byte[] decrypt(byte[] encryptedBytes, org.bouncycastle.crypto.params.KeyParameter aesKey, byte[] initialisationVector) throws org.bitcoinj.crypto.KeyCrypterException
encryptedBytes
- The encrypted bytes required to decryptaesKey
- The AES key to use for decryptioninitialisationVector
- The initialisationVector to use whilst decryptingorg.bitcoinj.crypto.KeyCrypterException
- if bytes could not be decoded to a valid keypublic static byte[] generate160BitsOfEntropy(byte[] seed, byte[] salt)
seed
- seed bytes to use as 'credentials'/ initial valuesalt
- salt value used to customise trapdoor functionspublic static org.bouncycastle.crypto.params.KeyParameter createAESKey(byte[] seed, byte[] salt) throws NoSuchAlgorithmException
seed
- entropy, typically a wallet id or a credentials as bytessalt
- bytes, used as saltNoSuchAlgorithmException
Copyright © 2015–2018. All rights reserved.