I am storing SymmetricKey in Keychain which is shared between App and App Share Extension. When I run the app encryption/decryption happens properly using the key, however, when I do decryption of text from App Extension using same key it throws following error
CryptoKit.CryptoKitError.authenticationFailure
decryption logic
func decrypt(_ value : Any?) -> Data? {
let value = value as! any DataProtocol
do {
let sealedBox = try ChaChaPoly.SealedBox(combined: value)
let data = try ChaChaPoly.open(sealedBox, using: self.symmetricKey!)
return data
} catch {
print(error.localizedDescription)
}
return nil
}
Any help would be appreciated.