Package org.iqtig.packer.shared.crypto
Klasse CryptographySupportShared
java.lang.Object
org.iqtig.packer.shared.crypto.CryptographySupportShared
-
Verschachtelte Klassen - Übersicht
Verschachtelte Klassen -
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungcheckEncryptionType(InputStream inputStream) byte[]voiddecrypt(InputStream inputStream, OutputStream outputStream, Function<byte[], SecretKey> secretKeyUnwrapper) Entschlüsselt den eigenhenden InputStream und schreibt das Resultat auf den gegebenen OutputStream.voiddecrypt(InputStream inputStream, OutputStream outputStream, SecretKey secretKey) byte[]decryptWithPassword(byte[] payload, String password) byte[]voidencrypt(InputStream inputstream, OutputStream outputStream, SecretKey secretKey) voidencrypt(InputStream inputStream, OutputStream outputStream, SecretKey secretKey, Function<SecretKey, byte[]> secredKeyWrapper) Verschlüsselt den Inhalt eines eingehenden InputStreams und schreibt das Resultat auf den gegebenen OutputStream.byte[]encryptWithPassword(byte[] payload, String password) getKeyFromBytesForAES(byte[] keyBytes) readPrivateKeyFromKeyStore(InputStream keyStoreStream, String keystorePassword, String keyAlias, String keyentryPassword) readPrivateKeyFromPem(InputStream inputStream) readPublicKeyFromKeyStore(InputStream keyStoreStream, String keystorePassword, String keyAlias) readPublicKeyFromPem(InputStream inputStream) readX509Certificate(InputStream certificateInputStream) unwrapSecretKey(byte[] wrappedSecretKey, PrivateKey privateKey) byte[]wrapSecretKey(SecretKey secretKey, PublicKey publicKey)
-
Felddetails
-
FILE_TYPE_IDENTIFIER_OLD
- Siehe auch:
-
FILE_TYPE_IDENTIFIER_NEW
- Siehe auch:
-
FILE_TYPE_IDENTIFIER_LENGTH
public static final int FILE_TYPE_IDENTIFIER_LENGTH- Siehe auch:
-
FILE_TYPE_IDENTIFIER_CHARSET
- Siehe auch:
-
-
Konstruktordetails
-
CryptographySupportShared
public CryptographySupportShared()
-
-
Methodendetails
-
createRandomAESSessionKey
- Löst aus:
CryptoException
-
createRandomAESSessionKey256Bit
- Löst aus:
CryptoException
-
getKeyFromBytesForAES
-
readPrivateKeyFromPem
- Löst aus:
CryptoException
-
readPrivateKeyFromKeyStore
public PrivateKey readPrivateKeyFromKeyStore(InputStream keyStoreStream, String keystorePassword, String keyAlias, String keyentryPassword) throws CryptoException - Löst aus:
CryptoException
-
readPublicKeyFromKeyStore
public PublicKey readPublicKeyFromKeyStore(InputStream keyStoreStream, String keystorePassword, String keyAlias) throws CryptoException - Löst aus:
CryptoException
-
readPublicKeyFromPem
- Löst aus:
CryptoException
-
readX509Certificate
public X509Certificate readX509Certificate(InputStream certificateInputStream) throws CryptoException - Löst aus:
CryptoException
-
wrapSecretKey
- Löst aus:
CryptoException
-
unwrapSecretKey
public SecretKey unwrapSecretKey(byte[] wrappedSecretKey, PrivateKey privateKey) throws CryptoException - Löst aus:
CryptoException
-
encryptWithPassword
public byte[] encryptWithPassword(byte[] payload, String password) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException -
decryptWithPassword
public byte[] decryptWithPassword(byte[] payload, String password) throws NoSuchAlgorithmException, InvalidKeySpecException -
encrypt
-
decrypt
-
encrypt
public void encrypt(InputStream inputstream, OutputStream outputStream, SecretKey secretKey) throws CryptoException - Löst aus:
CryptoException
-
decrypt
public void decrypt(InputStream inputStream, OutputStream outputStream, SecretKey secretKey) throws CryptoException - Löst aus:
CryptoException
-
encrypt
public void encrypt(InputStream inputStream, OutputStream outputStream, SecretKey secretKey, Function<SecretKey, byte[]> secredKeyWrapper) throws CryptoExceptionVerschlüsselt den Inhalt eines eingehenden InputStreams und schreibt das Resultat auf den gegebenen OutputStream. Es wird eine symmetrische Verschlüsselung (AES) durchgeführt. Als Betriebsmodus wird GCM (Galois Counter Mode) verwendet.Vor das Chiffrat werden das Salt und die IV gehangen. In alternativen Implementierungen könnte man über eine Base64 Kodierung des Salt und der IV nachdenken. Das ist hier aber unnötig. Salt+IV+Cipher
Zum Entschlüsseln müssen zuerst das Salt und die IV gelesen werden.
- Parameter:
inputStream- die zu verschlüsselnden Daten als InputStreamoutputStream- der OutputStream auf den das Verschlüsselungsergebnis geschrieben werden sollsecretKey- derSecretKeyder zur Anwendung kommtsecredKeyWrapper- eine Function, die das Wrapping des SecretKeys umsetzt- Löst aus:
CryptoException
-
decrypt
public void decrypt(InputStream inputStream, OutputStream outputStream, Function<byte[], SecretKey> secretKeyUnwrapper) throws CryptoExceptionEntschlüsselt den eigenhenden InputStream und schreibt das Resultat auf den gegebenen OutputStream.- Parameter:
inputStream- die verschlüsselten Daten als InputStreamoutputStream- der OutputStream auf den das Entschlüsselungsergebnis geschrieben werden sollsecretKeyUnwrapper- Function die den extrahierten SecretKey unwrapped- Löst aus:
CryptoException
-
createRandomIV
- Löst aus:
CryptoException
-
checkEncryptionType
-