Skip to content

Commit

Permalink
5.4.2: fix auth tag size calculation (#222)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Michael Dietrich <[email protected]>
  • Loading branch information
JesusMcCloud and md4096 authored Feb 19, 2025
1 parent e818e5d commit 264f02d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

Release 5.4.2:
- Fix auth tag size calculation

Release 5.4.1:
- Fix encoding `dcql_query` in authentication request, it is now a string
- Provide default values for RQES data classes
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin.mpp.enableCInteropCommonization=true
kotlin.mpp.stability.nowarn=true
kotlin.native.ignoreDisabledTargets=true

artifactVersion = 5.4.1
artifactVersion = 5.4.2
jdk.version=17


Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ actual open class PlatformCryptoShim actual constructor(actual val keyMaterial:
}
}.doFinal(input)
if (algorithm.isAuthenticatedEncryption) {
val ciphertext = jcaCiphertext.dropLast(algorithm.ivLengthBits / 8).toByteArray()
val authtag = jcaCiphertext.takeLast(algorithm.ivLengthBits / 8).toByteArray()
//FOR AES AEAD it is always block size
val ciphertext = jcaCiphertext.dropLast(128/ 8).toByteArray()
val authtag = jcaCiphertext.takeLast(128 / 8).toByteArray()
AuthenticatedCiphertext(ciphertext, authtag)
} else {
AuthenticatedCiphertext(jcaCiphertext, byteArrayOf())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ actual open class PlatformCryptoShim actual constructor(actual val keyMaterial:
}
}.doFinal(input)
if (algorithm.isAuthenticatedEncryption) {
val ciphertext = jcaCiphertext.dropLast(algorithm.ivLengthBits / 8).toByteArray()
val authtag = jcaCiphertext.takeLast(algorithm.ivLengthBits / 8).toByteArray()
//FOR AES AEAD it is always block size
val ciphertext = jcaCiphertext.dropLast(128/ 8).toByteArray()
val authtag = jcaCiphertext.takeLast(128 / 8).toByteArray()
AuthenticatedCiphertext(ciphertext, authtag)
} else {
AuthenticatedCiphertext(jcaCiphertext, byteArrayOf())
Expand Down

0 comments on commit 264f02d

Please sign in to comment.