Questions tagged [cryptokit]

6 questions
2
votes
1 answer

How can I compute the SHA512/256 hash in Swift?

I'm familiar with CryptoKit and the SHA512 implementation, which is super easy to use. let digest = SHA512.hash(data: Data("".utf8)) However, I can't seem to find how to compute SHA512/256 (the truncated version of SHA512) anywhere in the Apple…
Morgan Wilde
  • 16,795
  • 10
  • 53
  • 99
1
vote
2 answers

Getting Authentcationfailure with nonce and tag using CryptoKit

What am I doing wrong here? It throws below error while decrypting (at second last line) Fatal error: 'try!' expression unexpectedly raised an error: CryptoKit.CryptoKitError.authenticationFailure func encryptDecryptWithNonceTag(){ let secret…
nirav dinmali
  • 197
  • 11
1
vote
0 answers

How to sign a hash in Swift with CryptoKit

I'm trying to port this code from Node.js to Swift using CryptoKit. const sign = crypto.createSign('sha256'); sign.write(hashString); sign.end(); const signature = sign.sign({ key: privateKey, // read from a .pem file passphrase:…
Berry Blue
  • 15,330
  • 18
  • 62
  • 113
0
votes
0 answers

underlyingCoreCryptoError(error: -1) while verify signature

getting error while verifying private key signature using cryptokit What i tried: func signMessage(_ message: String, withPrivateKey privateKey: Data) -> Data { do{ let key = try P256.Signing.PrivateKey(rawRepresentation: privateKey) //…
Jatin
  • 92
  • 7
0
votes
2 answers

Decrypt PHP ChaChaPoly encrypted data in Swift

I am trying to decrypt data with Swift CryptoKit that I have encrypted with php using openssl_encrypt() chacha20-poly1305. Encrypting works, but when decrypting I get the error: incorrectParameterSize (Swift: error 1, line 10). PHP encryption using…
0
votes
1 answer

Swift AES GCM encryptor and Java decryption - Padding issues

I have a swift function to encrypt a string. When I give it "abc" it creates a ciphertext without padding. When I give it "a" it creates a ciphertext with padding "==". This behavior is understood. The problem is I need to decrypt the string in…
nirav dinmali
  • 197
  • 11