Class EciesEncryptor
java.lang.Object
io.getlime.security.powerauth.crypto.lib.encryptor.ecies.EciesEncryptor
Class implementing an ECIES encryptor.
- Author:
- Petr Dvorak, petr@wultra.com, Roman Strobl, roman.strobl@wultra.com
-
Constructor Summary
ConstructorsConstructorDescriptionEciesEncryptor(EciesEnvelopeKey envelopeKey, byte[] sharedInfo2) Construct an encryptor from existing ECIES envelope key and sharedInfo2 parameter.EciesEncryptor(ECPublicKey publicKey) Construct a new encryptor with null sharedInfo1 and sharedInfo2.EciesEncryptor(ECPublicKey publicKey, byte[] sharedInfo1, byte[] sharedInfo2) Construct a new encryptor with provided sharedInfo1 and sharedInfo2. -
Method Summary
Modifier and TypeMethodDescriptionencrypt(byte[] data, boolean useIv, boolean useTimestamp, byte[] associatedData) Encrypt data.encrypt(byte[] data, EciesParameters eciesParameters) Encrypt data with provided ECIES parameters.Get ECIES envelope key.byte[]Get parameter sharedInfo2 for ECIES.voidinitEnvelopeKey(byte[] ephemeralPublicKeyBytes) Initialize envelope key for encryptor using provided ephemeral public key.
-
Constructor Details
-
EciesEncryptor
Construct a new encryptor with null sharedInfo1 and sharedInfo2.- Parameters:
publicKey- Public key used for encryption.
-
EciesEncryptor
Construct a new encryptor with provided sharedInfo1 and sharedInfo2.- Parameters:
publicKey- Public key used for encryption.sharedInfo1- Additional shared information used during key derivation.sharedInfo2- Additional shared information used during decryption.
-
EciesEncryptor
Construct an encryptor from existing ECIES envelope key and sharedInfo2 parameter. The derivation of envelope key is skipped. The privateKey and sharedInfo1 values are unknown.- Parameters:
envelopeKey- ECIES envelope key.sharedInfo2- Parameter sharedInfo2 for ECIES.
-
-
Method Details
-
initEnvelopeKey
Initialize envelope key for encryptor using provided ephemeral public key. This method is used when the encryptor parameters are transported over network and the encryptor is reconstructed on another server using envelope key and sharedInfo2 parameter.- Parameters:
ephemeralPublicKeyBytes- Ephemeral public key for ECIES.- Throws:
EciesException- In case envelope key initialization fails.
-
encrypt
public EciesPayload encrypt(byte[] data, boolean useIv, boolean useTimestamp, byte[] associatedData) throws EciesException Encrypt data.- Parameters:
data- Request data.useIv- Controls whether encryption uses non-zero initialization vector for protocol V3.1+.useTimestamp- Controls whether encryption uses timestamp for protocol V3.2+.associatedData- Associated data for protocol V3.2+ or null for previous protocol versions.- Returns:
- ECIES payload.
- Throws:
EciesException- In case encryption fails.
-
encrypt
Encrypt data with provided ECIES parameters.- Parameters:
data- Request data.eciesParameters- ECIES parameters.- Returns:
- ECIES payload.
- Throws:
EciesException- In case encryption fails.
-
getEnvelopeKey
Get ECIES envelope key.- Returns:
- ECIES envelope key.
-