Skip to content

Commit

Permalink
Remove 'withUnsafeBytes' deprecated method warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrbrowne committed Apr 18, 2019
1 parent d008042 commit 119368b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/JWA/HMAC/HMACCommonCrypto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ extension HMACAlgorithm: SignAlgorithm, VerifyAlgorithm {
let context = UnsafeMutablePointer<CCHmacContext>.allocate(capacity: 1)
defer { context.deallocate() }

key.withUnsafeBytes() { (buffer: UnsafePointer<UInt8>) in
CCHmacInit(context, hash.commonCryptoAlgorithm, buffer, size_t(key.count))
key.withUnsafeBytes { ptr in
let buffer = ptr.baseAddress?.assumingMemoryBound(to: UInt8.self)
CCHmacInit(context, hash.commonCryptoAlgorithm, buffer, size_t(key.count))
}

message.withUnsafeBytes { (buffer: UnsafePointer<UInt8>) in
CCHmacUpdate(context, buffer, size_t(message.count))
message.withUnsafeBytes { ptr in
let buffer = ptr.baseAddress?.assumingMemoryBound(to: UInt8.self)
CCHmacUpdate(context, buffer, size_t(message.count))
}

var hmac = Array<UInt8>(repeating: 0, count: Int(hash.commonCryptoDigestLength))
Expand Down

0 comments on commit 119368b

Please sign in to comment.