CryptoSwift
CryptoSwift copied to clipboard
Use BlockCipher.blockSize as a result length in randomIV helper
Checklist:
- [ ] Correct file headers (see CONTRIBUTING.md) (not needed).
- [x] Formatted with SwiftFormat.
- [x] Tests added.
Changes proposed in this pull request:
Use BlockCipher.blockSize as a result length in randomIV helper. This should help to avoid two mistakes when randomIV helper is used:
- Passing of invalid array length for IV generation.
- Usage of
randomIVhelper for a key generation. Because it usesSwift.SystemRandomNumberGenerator, depending on the platform the result might be not cryptographically secure to be used as a key.Security.SecRandomCopyBytesshould be preferred to generate a key on Apple platforms.
@krzyzanowskim any feedback for this?