Fixed GCM reuse error
This commit is contained in:
parent
28570d92e9
commit
aa3540a8bb
@ -70,7 +70,6 @@ internal class CryptoManagement(val logger: KLogger,
|
|||||||
val secureRandom = SecureRandom(settingsStore.getSalt())
|
val secureRandom = SecureRandom(settingsStore.getSalt())
|
||||||
|
|
||||||
private val iv = ByteArray(GCM_IV_LENGTH)
|
private val iv = ByteArray(GCM_IV_LENGTH)
|
||||||
private val gcmParameterSpec = GCMParameterSpec(GCM_TAG_LENGTH * 8, iv)
|
|
||||||
val cryptOutput = AeronOutput()
|
val cryptOutput = AeronOutput()
|
||||||
val cryptInput = AeronInput()
|
val cryptInput = AeronInput()
|
||||||
|
|
||||||
@ -192,6 +191,7 @@ internal class CryptoManagement(val logger: KLogger,
|
|||||||
|
|
||||||
val secretKeySpec = generateAesKey(clientPublicKeyBytes, clientPublicKeyBytes, publicKeyBytes)
|
val secretKeySpec = generateAesKey(clientPublicKeyBytes, clientPublicKeyBytes, publicKeyBytes)
|
||||||
secureRandom.nextBytes(iv)
|
secureRandom.nextBytes(iv)
|
||||||
|
val gcmParameterSpec = GCMParameterSpec(GCM_TAG_LENGTH * 8, iv)
|
||||||
aesCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, gcmParameterSpec)
|
aesCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, gcmParameterSpec)
|
||||||
|
|
||||||
// now create the byte array that holds all our data
|
// now create the byte array that holds all our data
|
||||||
@ -224,6 +224,7 @@ internal class CryptoManagement(val logger: KLogger,
|
|||||||
|
|
||||||
|
|
||||||
// now decrypt the data
|
// now decrypt the data
|
||||||
|
val gcmParameterSpec = GCMParameterSpec(GCM_TAG_LENGTH * 8, iv)
|
||||||
aesCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, gcmParameterSpec)
|
aesCipher.init(Cipher.DECRYPT_MODE, secretKeySpec, gcmParameterSpec)
|
||||||
|
|
||||||
cryptInput.buffer = aesCipher.doFinal(secretBytes)
|
cryptInput.buffer = aesCipher.doFinal(secretBytes)
|
||||||
|
Loading…
Reference in New Issue
Block a user