Open ghost opened 5 years ago
This chunk of code doesn't work:
func verify(_ input : Data, signature : Data) -> Bool {
let signedDataHash = Data(referencing: (input as NSData).digest(withSize: self.hashFunction.rawValue))
let padding = paddingForHashFunction(self.hashFunction)
let result: OSStatus = signature.withUnsafeBytes { (signatureRawPointer: UnsafeRawBufferPointer) in
signedDataHash.withUnsafeBytes { (signedHashRawPointer: UnsafeRawBufferPointer) in
guard let signtureAddress = signatureRawPointer.baseAddress, signatureRawPointer.count > 0,
let hashAddress = signedHashRawPointer.baseAddress, signedHashRawPointer.count > 0 else {
return -4 // OSStatus.errSecUnimplemented
}
return SecKeyRawVerify(
key.value,
padding,
signtureAddress.assumingMemoryBound(to: UInt8.self),
signedDataHash.count,
hashAddress.assumingMemoryBound(to: UInt8.self),
signature.count
)
}
}
switch result {
case errSecSuccess:
return true
default:
return false
}
}
I haven't had time to investigate this but the committed method above causes JWT verification to fail.
changes in code and project settings for building the project on Xcode 10.2 with swift5