swift-crypto icon indicating copy to clipboard operation
swift-crypto copied to clipboard

Why is `ivBytes` not publicly accessible on `AES._CBC.IV`?

Open wnagrodzki opened this issue 5 months ago • 1 comments

Question Checklist

Question Subject

Why ivBytes is not a public property on AES._CBC.IV?

Question Description

I would expect ivBytes to be public which would enable me to encode it to an external representation. There is a workaround for this issue:

var copy = iv
let ivData = withUnsafeBytes(of: &copy) { Data($0) }

wnagrodzki avatar Jul 29 '25 06:07 wnagrodzki

The answer is basically by analogy to the nonces in Crypto, however a piece of code is missing. The CBC IV should conform to at least Sequence though, if not Collection, which would let you do what you're trying to do. I'd welcome a patch that adds that conformance.

Lukasa avatar Jul 29 '25 09:07 Lukasa