apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.47k stars 166 forks source link

Making ivBytes accessible for _CBC.IV #260

Closed maschall closed 2 months ago

maschall commented 2 months ago

Checklist

Motivation:

Right now, we're using CommonCrypto and would like to switch to Crypto instead. However, the requirement we need is that we send the data for IV to the server for them to verify the signature we are sending them. Similarly, they send us their IV and we verify the signature of other data. (Which is supported currently)

Modifications:

By making ivBytes public, we can access the randomly generated salt for our cipher.

Result:

I can replace CommonCrypto code in my repo with Crypto instead :)

Lukasa commented 2 months ago

Thanks for this, this is a change we're generally happy to make. Can I make a few requests?

Firstly, let's prefer to offer an API that exposes an Array. That will generally be more useful than the tuple we have here.

Secondly, can you add a unit test that drives that API? It'll help us avoid regressing it.

maschall commented 2 months ago

That is interesting about the [UInt8] because that is how I use it in my code, and had to repeat a lot of ivBytes.0, 1, 2,...

So I'm happy to expose and API and unit tests

maschall commented 2 months ago

Closing in favor of #261