onmyway133 / Arcane

:trident: CommonCrypto in Swift, and more
https://onmyway133.github.io/
Other
283 stars 22 forks source link

Adds keySize parameter to AES functions #18

Closed james-rant closed 6 years ago

james-rant commented 6 years ago

Adds a keySize parameter to each of the AES encryption/decryption functions. The parameter defaults to kCCKeySizeAES128, which is what was being used previously. Also creates appropriately sized hashedKeyData and ivData based on the specified key size.

I believe the previous code was incorrectly creating a 256-bit key data, when only specifying 128-bit key size in the CCCrypt() options, as I raised in issue: #17. I appreciate that I may be wrong on this point, and I'm open to being educated further on the matter.

onmyway133 commented 6 years ago

@james-rantmedia Hi, sharp eyes. I don't have strong opinion about this. My approach was to just hash something and use that to get a random enough key and iv. Maybe CommonCrypto has special checking of key size to make it work, but I think your PR is good in making this matter clearer 🚀