decentralized-identity / veramo

A JavaScript Framework for Verifiable Data
https://veramo.io
Apache License 2.0
414 stars 130 forks source link

DIDComm unpack fail with authcrypt envelope #1375

Open veromassera opened 2 months ago

veromassera commented 2 months ago

Bug severity 4

Describe the bug The packed text is made with the authcrypt envelope, 'alg: ECDH-1PU+A256KW' and 'enc: A256CBC-HS512'.

One difference I noticed between the Veramo pack results and other libraries is that the Veramo result does not have the 'apu' and 'apv' fields in the 'protected' header (according to my understanding of the DIF standard, they should be mandatory https://identity.foundation/didcomm-messaging/spec/#ecdh-1pu-key-wrapping-and-common-protected-headers).

I am using Veramo version 6.0.0 and these libraries to generate the packaging:

https://github.com/beatt83/peerdid-swift https://github.com/beatt83/didcomm-swift

I also did other tests to rule out the possibility that the problem is with these libraries.

I performed this test:

Packaged with: https://github.com/beatt83/peerdid-swift https://github.com/beatt83/didcomm-swift

Unpacked with this example: https://github.com/sicpa-dlab/didcomm-demo It worked without problems, but I couldn't get it to work with Veramo.

Could this be the reason for the problem? Do you have any suggestions or comments that could help me?

To Reproduce Steps to reproduce the behaviour: 1.Create a did:peer recipient (hereinafter referred to as did:peer:recipient) in Veramo. 2.Create a did:peer sender (hereinafter referred to as did:peer:sender) outside of Veramo, for example you can follow the demo https://github.com/decentralized-identity/didcomm-messaging 3.Pack some text outside of Veramo with the following characteristics: Sender: did:peer:sender Recipient: did:peer:recipient Envelope: authcrypt alg: ECDH-1PU+A256KW enc: A256CBC-HS512 4.Take the packed text and unpack it in Veramo. 5.It should decrypt and verify it without problems but it fails.

Observed behaviour The unpack process throws this high-level error: "unable to decrypt DIDComm message with any of the locally managed keys" However, the initial innerError is: "AESKW: integrity check failed"

Expected behaviour I expected the unpack inside Veramo to work correctly and decrypt and verify the text packed by the sender.

Details

image

Succession of errors from lowest to highest level:

Additional context Perhaps the error has something to do with the apv and apu header fields

Versions (please complete the following information):

stale[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.