mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
### Motivation: We have some helper functions to zero out memory after use. One of these helper functions provides a `zeroize()` method on `UnsafeMutablePointer`, which has a subtle bug. It zeros out `MemoryLayout.size(ofValue: Pointee.self)` instead of `MemoryLayout<Pointee>.size`, so only the first 8 bytes get zeroed. This bug is duplicated in CryptoExtras too in a fileprivate helper. ### Modifications: - Zero the entire pointee in UnsafeMutablePointer.zeroize - Copy Zeroization helpers from Crypto to CryptoExtras (without the `#if canImport(CryptoKit)` guard) ### Result: All the memory that should be zeroed by this helper is actually zeroed.