Skip to content

Commit

Permalink
Add envelope key initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
romanstrobl committed Jul 11, 2023
1 parent 14b8da1 commit 16cdb59
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ public EciesEncryptor(final EciesEnvelopeKey envelopeKey, final byte[] sharedInf
this.canEncryptData = true;
}

/**
* 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.
*
* @param ephemeralPublicKeyBytes Ephemeral public key for ECIES.
* @throws EciesException In case envelope key initialization fails.
*/
public void initEnvelopeKey(byte[] ephemeralPublicKeyBytes) throws EciesException {
envelopeKey = EciesEnvelopeKey.fromPublicKey(publicKey, sharedInfo1);
// Invalidate this encryptor for encryption
canEncryptData = false;
}

/**
* Encrypt data.
*
Expand Down

0 comments on commit 16cdb59

Please sign in to comment.