truncatedASN1Field Error

Hello,

I am encountering truncatedASN1Field issue while decrypting encrypted data with P256 private key. I am using Base64 format to exchange the encrypted data between the clients. I have no idea what's exactly going on here. Please help me to resolve the issue.

Thanks in Advance.

while decrypting encrypted data with P256 private key

Apple CryptoKit does not directly support encryption with P256. Consider this page: Your choices are either KeyAgreement or Signing. So how have you layered this encryption on top of that?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Space

Ah, you’re using Security framework not Apple CryptoKit. That explains my confusion. I’ve changed the tags on your thread to reflect that.

As to your main problem, you wrote:

I am trying to decrypt in the same way.

I’d like to clarify this setup. Based on this and your earlier post I think you’re doing this:

  1. On {mac,i,tv,watch}OS device A, you call SecKeyCreateEncryptedData to encrypt some data.

  2. You then passing that data to {mac,i,tv,watch}OS device B.

  3. On device B you call SecKeyCreateDecryptedData to decrypt that data.

Is that correct?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It’s best to put your replies in the Your Reply field. I don’t get notified when you add a comment.

Transferring encrypted data from an Apple device to another Apple device using .eciesEncryptionStandardX963SHA512AESGCM should be pretty straightforward. This error suggests that the data hasn’t arrived intact. I recommend that you confirm this in two ways:

  • First do a local test. Generate a key pair, then encrypt some data using the public key and decrypt it using the private key. That should just work.

  • Next repeat this test across the network. To confirm that the data is transfered correctly, print a hex dump of it on both the send side and another on the receive side.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you very much, it helped me to understand the problem better I was using different way of representing the data. It solved the current issue.

truncatedASN1Field Error
 
 
Q