metadata = extractEncryptionMetadata(encryptedRecord); } catch (IOException | ClassNotFoundException e) { final String msg = "Encountered an error reading the encryption metadata: "; logger.debug("Decrypting provenance record " + recordId + " with key ID " + metadata.keyId); EncryptionMethod method = EncryptionMethod.forAlgorithm(metadata.algorithm); Cipher cipher = initCipher(method, Cipher.DECRYPT_MODE, keyProvider.getKey(metadata.keyId), metadata.ivBytes); byte[] cipherBytes = extractCipherBytes(encryptedRecord, metadata);
try { logger.debug("Encrypting provenance record " + recordId + " with key ID " + keyId); Cipher cipher = initCipher(EncryptionMethod.AES_GCM, Cipher.ENCRYPT_MODE, keyProvider.getKey(keyId), ivBytes); ivBytes = cipher.getIV(); byte[] serializedEncryptionMetadata = serializeEncryptionMetadata(metadata);
keyProvider = buildKeyProvider(); provenanceEventEncryptor = new AESProvenanceEventEncryptor(); provenanceEventEncryptor.initialize(keyProvider); } catch (KeyManagementException e) {
metadata = extractEncryptionMetadata(encryptedRecord); } catch (IOException | ClassNotFoundException e) { final String msg = "Encountered an error reading the encryption metadata: "; logger.debug("Decrypting provenance record " + recordId + " with key ID " + metadata.keyId); EncryptionMethod method = EncryptionMethod.forAlgorithm(metadata.algorithm); Cipher cipher = initCipher(method, Cipher.DECRYPT_MODE, keyProvider.getKey(metadata.keyId), metadata.ivBytes); byte[] cipherBytes = extractCipherBytes(encryptedRecord, metadata);
try { logger.debug("Encrypting provenance record " + recordId + " with key ID " + keyId); Cipher cipher = initCipher(EncryptionMethod.AES_GCM, Cipher.ENCRYPT_MODE, keyProvider.getKey(keyId), ivBytes); ivBytes = cipher.getIV(); byte[] serializedEncryptionMetadata = serializeEncryptionMetadata(metadata);