HMAC.swift's fromNative lookup table maps native CCHmacAlgorithm constants back to HMAC.Algorithm cases:
static let fromNative: [CCHmacAlgorithm: Algorithm] = [
CCHmacAlgorithm(kCCHmacAlgSHA1): .sha1,
CCHmacAlgorithm(kCCHmacAlgSHA1): .md5, // should be kCCHmacAlgMD5
...
]
kCCHmacAlgSHA1 is used as the key for both .sha1 and .md5 — the .md5 entry should use kCCHmacAlgMD5. Since Swift dictionary
literals fatal-error on duplicate keys, any access to fromNative (e.g. via fromNativeValue(nativeAlg:)) traps at runtime with
Fatal error: Dictionary literal contains duplicate keys.
Both members are internal, so this isn't reachable by consumers of the library today, and there's no existing test coverage for
fromNativeValue at all — likely why this has gone unnoticed.
Fix: use kCCHmacAlgMD5 for the .md5 entry, plus a regression test that round-trips every Algorithm case through nativeValue() →
fromNativeValue().
HMAC.swift'sfromNativelookup table maps nativeCCHmacAlgorithmconstants back toHMAC.Algorithmcases:kCCHmacAlgSHA1 is used as the key for both .sha1 and .md5 — the .md5 entry should use kCCHmacAlgMD5. Since Swift dictionary
literals fatal-error on duplicate keys, any access to fromNative (e.g. via fromNativeValue(nativeAlg:)) traps at runtime with
Fatal error: Dictionary literal contains duplicate keys.
Both members are internal, so this isn't reachable by consumers of the library today, and there's no existing test coverage for
fromNativeValue at all — likely why this has gone unnoticed.
Fix: use kCCHmacAlgMD5 for the .md5 entry, plus a regression test that round-trips every Algorithm case through nativeValue() →
fromNativeValue().