Package dev.dsf.bpe.v2.service
Interface CryptoService.Kem
- Enclosing interface:
CryptoService
public static interface CryptoService.Kem
Key encapsulation mechanism with encrypt and decrypt methods.
-
Method Summary
Modifier and TypeMethodDescriptiondefault byte[]decrypt(byte[] encrypted, PrivateKey privateKey) decrypt(InputStream encrypted, PrivateKey privateKey) default byte[]Encrypts the givenInputStreamwith an AES session key calculated by KEM for the givenPublicKey.encrypt(InputStream data, PublicKey publicKey) Encrypts the givenInputStreamwith an AES session key calculated by KEM for the givenPublicKey.
-
Method Details
-
encrypt
default byte[] encrypt(byte[] data, PublicKey publicKey) throws IOException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, InvalidAlgorithmParameterException Encrypts the givenInputStreamwith an AES session key calculated by KEM for the givenPublicKey. The returnedInputStreamhas the form [encapsulation length (big-endian, 2 bytes), encapsulation, AES initialization vector (12 bytes), AES encrypted data].- Parameters:
data- notnullpublicKey- notnull- Returns:
- byte array of [encapsulation length (big-endian, 2 bytes), encapsulation, iv (12 bytes), encrypted data]
- Throws:
IOExceptionNoSuchAlgorithmExceptionInvalidKeyExceptionNoSuchPaddingExceptionInvalidAlgorithmParameterException
-
encrypt
InputStream encrypt(InputStream data, PublicKey publicKey) throws IOException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, InvalidAlgorithmParameterException Encrypts the givenInputStreamwith an AES session key calculated by KEM for the givenPublicKey. The returnedInputStreamhas the form [encapsulation length (big-endian, 2 bytes), encapsulation, AES initialization vector (12 bytes), AES encrypted data].- Parameters:
data- notnullpublicKey- notnull- Returns:
InputStreamof [encapsulation length (big-endian, 2 bytes), encapsulation, iv (12 bytes), encrypted data]- Throws:
IOExceptionNoSuchAlgorithmExceptionInvalidKeyExceptionNoSuchPaddingExceptionInvalidAlgorithmParameterException
-
decrypt
default byte[] decrypt(byte[] encrypted, PrivateKey privateKey) throws IOException, NoSuchAlgorithmException, InvalidKeyException, DecapsulateException, NoSuchPaddingException, InvalidAlgorithmParameterException - Parameters:
encrypted- notnull,InputStreamof [encapsulation length (big-endian, 2 bytes), encapsulation, iv (12 bytes), encrypted data]privateKey- notnull- Returns:
- decrypted data
- Throws:
IOExceptionNoSuchAlgorithmExceptionInvalidKeyExceptionDecapsulateExceptionNoSuchPaddingExceptionInvalidAlgorithmParameterException
-
decrypt
InputStream decrypt(InputStream encrypted, PrivateKey privateKey) throws IOException, NoSuchAlgorithmException, InvalidKeyException, DecapsulateException, NoSuchPaddingException, InvalidAlgorithmParameterException - Parameters:
encrypted- notnull,InputStreamof [encapsulation length (big-endian, 2 bytes), encapsulation, iv (12 bytes), encrypted data]privateKey- notnull- Returns:
- decrypted data
- Throws:
IOExceptionNoSuchAlgorithmExceptionInvalidKeyExceptionDecapsulateExceptionNoSuchPaddingExceptionInvalidAlgorithmParameterException
-