Validate attachment key size.

This commit is contained in:
Greyson Parrelli
2025-10-23 12:00:51 -04:00
committed by jeffrey-signal
parent c268625f52
commit 123b88e032

View File

@@ -362,7 +362,11 @@ object AttachmentCipherInputStream {
private class CombinedKeyMaterial(val aesKey: ByteArray, val macKey: ByteArray) { private class CombinedKeyMaterial(val aesKey: ByteArray, val macKey: ByteArray) {
companion object { companion object {
@Throws(InvalidMessageException::class)
fun from(combinedKeyMaterial: ByteArray): CombinedKeyMaterial { fun from(combinedKeyMaterial: ByteArray): CombinedKeyMaterial {
if (combinedKeyMaterial.size != CIPHER_KEY_SIZE + MAC_KEY_SIZE) {
throw InvalidMessageException("Invalid combined key material size: ${combinedKeyMaterial.size}")
}
val parts = Util.split(combinedKeyMaterial, CIPHER_KEY_SIZE, MAC_KEY_SIZE) val parts = Util.split(combinedKeyMaterial, CIPHER_KEY_SIZE, MAC_KEY_SIZE)
return CombinedKeyMaterial(parts[0], parts[1]) return CombinedKeyMaterial(parts[0], parts[1])
} }