Some tweaks added to IESEngine to conform to the Ethereum encryption approach.
| Modifier and Type | Class and Description |
|---|---|
| public static class | EthereumIESEngine.
Basic KDF generator for derived keys and ivs as defined by IEEE P1363a/ISO 18033 This implementation is based on ISO 18033/P1363a. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv BasicAgreement | |
| pack-priv BufferedBlockCipher | |
| pack-priv byte[] | |
| pack-priv boolean | |
| private byte[] | |
| pack-priv DerivationFunction | |
| private EphemeralKeyPairGenerator | |
| private KeyParser | |
| pack-priv Mac | |
| pack-priv byte[] | |
| pack-priv IESParameters | |
| pack-priv CipherParameters | |
| pack-priv CipherParameters | |
| pack-priv byte[] |
| Access | Constructor and Description |
|---|---|
| public | EthereumIESEngine(BasicAgreement
the key agreement used as the basis for the encryption agree, DerivationFunction the key derivation function used for byte generation kdf, Mac the message authentication code generator for the message mac, byte[] the common MAC bytes to append to the mac commonMac)Set up for use with stream mode, where the key derivation function is used to provide a stream of bytes to xor with the message. |
| public | EthereumIESEngine(BasicAgreement
the key agreement used as the basis for the encryption agree, DerivationFunction the key derivation function used for byte generation kdf, Mac the message authentication code generator for the message mac, byte[] the common MAC bytes to append to the mac commonMac, BufferedBlockCipher the cipher to used for encrypting the message cipher)Set up for use in conjunction with a block cipher to handle the message. |
| Modifier and Type | Method and Description |
|---|---|
| private byte[] | |
| private byte[] | |
| private void | |
| public BufferedBlockCipher | |
| protected byte[] | |
| public Mac | |
| public void | init(boolean
whether or not this is encryption/decryption. forEncryption, CipherParameters our private key parameters privParam, CipherParameters the recipient's/sender's public key parameters pubParam, CipherParameters encoding and derivation parameters, may be wrapped to include an IV for an underlying block cipher. params)Initialise the encryptor. |
| public void | init(AsymmetricKeyParameter
the recipient's/sender's public key parameters publicKey, CipherParameters encoding and derivation parameters, may be wrapped to include an IV for an underlying block cipher. params, EphemeralKeyPairGenerator the ephemeral key pair generator to use. ephemeralKeyPairGenerator)Initialise the decryptor. |
| public void | init(AsymmetricKeyParameter
the recipient's private key. privateKey, CipherParameters encoding and derivation parameters, may be wrapped to include an IV for an underlying block cipher. params, KeyParser the parser for reading the ephemeral public key. publicKeyParser)Initialise the encryptor. |
| public byte[] |
| agree | back to summary |
|---|---|
| pack-priv BasicAgreement agree | |
| cipher | back to summary |
|---|---|
| pack-priv BufferedBlockCipher cipher | |
| commonMac | back to summary |
|---|---|
| pack-priv byte[] commonMac | |
| forEncryption | back to summary |
|---|---|
| pack-priv boolean forEncryption | |
| IV | back to summary |
|---|---|
| private byte[] IV | |
| kdf | back to summary |
|---|---|
| pack-priv DerivationFunction kdf | |
| keyPairGenerator | back to summary |
|---|---|
| private EphemeralKeyPairGenerator keyPairGenerator | |
| keyParser | back to summary |
|---|---|
| private KeyParser keyParser | |
| mac | back to summary |
|---|---|
| pack-priv Mac mac | |
| macBuf | back to summary |
|---|---|
| pack-priv byte[] macBuf | |
| param | back to summary |
|---|---|
| pack-priv IESParameters param | |
| privParam | back to summary |
|---|---|
| pack-priv CipherParameters privParam | |
| pubParam | back to summary |
|---|---|
| pack-priv CipherParameters pubParam | |
| V | back to summary |
|---|---|
| pack-priv byte[] V | |
| EthereumIESEngine | back to summary |
|---|---|
| public EthereumIESEngine(BasicAgreement agree, DerivationFunction kdf, Mac mac, byte[] commonMac) Set up for use with stream mode, where the key derivation function is used to provide a stream of bytes to xor with the message.
| |
| EthereumIESEngine | back to summary |
|---|---|
| public EthereumIESEngine(BasicAgreement agree, DerivationFunction kdf, Mac mac, byte[] commonMac, BufferedBlockCipher cipher) Set up for use in conjunction with a block cipher to handle the message. It is strongly recommended that the cipher is not in ECB mode.
| |
| decryptBlock | back to summary |
|---|---|
| private byte[] decryptBlock(byte[] in_enc, int inOff, int inLen) throws InvalidCipherTextException | |
| encryptBlock | back to summary |
|---|---|
| private byte[] encryptBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException | |
| extractParams | back to summary |
|---|---|
| private void extractParams(CipherParameters params) | |
| getCipher | back to summary |
|---|---|
| public BufferedBlockCipher getCipher() | |
| getLengthTag | back to summary |
|---|---|
| protected byte[] getLengthTag(byte[] p2) | |
| getMac | back to summary |
|---|---|
| public Mac getMac() | |
| init | back to summary |
|---|---|
| public void init(boolean forEncryption, CipherParameters privParam, CipherParameters pubParam, CipherParameters params) Initialise the encryptor.
| |
| init | back to summary |
|---|---|
| public void init(AsymmetricKeyParameter publicKey, CipherParameters params, EphemeralKeyPairGenerator ephemeralKeyPairGenerator) Initialise the decryptor.
| |
| init | back to summary |
|---|---|
| public void init(AsymmetricKeyParameter privateKey, CipherParameters params, KeyParser publicKeyParser) Initialise the encryptor.
| |
| processBlock | back to summary |
|---|---|
| public byte[] processBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException | |
This class has been adapted from the BaseKDFBytesGenerator implementation of Bouncy Castle. Only one change is present specifically for Ethereum.
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private Digest | |
| private byte[] | |
| private byte[] |
| Access | Constructor and Description |
|---|---|
| public | HandshakeKDFFunction(int
value of counter. counterStart, Digest the digest to be used as the source of derived keys. digest)Construct a KDF Parameters generator. |
| Modifier and Type | Method and Description |
|---|---|
| public int | generateBytes(byte[] out, int outOff, int len)
Implements org. fill len bytes of the output buffer with bytes generated from the derivation function. |
| public Digest | getDigest()
Implements org. return the underlying digest. |
| public void |
| counterStart | back to summary |
|---|---|
| private int counterStart | |
| digest | back to summary |
|---|---|
| private Digest digest | |
| iv | back to summary |
|---|---|
| private byte[] iv | |
| shared | back to summary |
|---|---|
| private byte[] shared | |
| HandshakeKDFFunction | back to summary |
|---|---|
| public HandshakeKDFFunction(int counterStart, Digest digest) Construct a KDF Parameters generator.
| |
| generateBytes | back to summary |
|---|---|
| public int generateBytes(byte[] out, int outOff, int len) throws DataLengthException, IllegalArgumentException Implements org. fill len bytes of the output buffer with bytes generated from the derivation function.
| |
| getDigest | back to summary |
|---|---|
| public Digest getDigest() Implements org. return the underlying digest. | |
| init | back to summary |
|---|---|
| public void init(DerivationParameters param) Implements org. | |