-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with ECDH-1PU-A256KW key agreement algorithm #1
Comments
I think that the problem is with the |
The key management algorithm, To resolve this, you have two options: Option 1: Switch to using
Option 2: Opt out of AES key wrapping:
|
Thank you a lot for your answer I'm sorry for one more question. I'm new to cryptography, so if anything you just can tell that this question is bullshit )))) I see that during the using
Shouldn't And also i looked into the implementation of this Here you can see that even with using And here i can see that they are using func encrypt(_ plaintext: Data, additionalAuthenticatedData: Data) throws -> ContentEncryptionContext Default Implementation of key generating func retrieveKeys(from inputKey: Data) throws -> (hmacKey: Data, encryptionKey: Data) {
switch self {
case .A256CBCHS512:
guard checkKeyLength(for: inputKey) else {
throw JWEError.keyLengthNotSatisfied
}
return (inputKey.subdata(in: 0..<32), inputKey.subdata(in: 32..<64))
case .A128CBCHS256:
guard checkKeyLength(for: inputKey) else {
throw JWEError.keyLengthNotSatisfied
}
return (inputKey.subdata(in: 0..<16), inputKey.subdata(in: 16..<32))
}
} I just want to understand witch approach is right... |
The confusion is understandable, cryptography can be a complex field! To start with, it's important to note that the key used for AES Key Wrapping and the encryption key used for the content encryption process are not the same. When using AES Key Wrap, you're wrapping (encrypting) the content encryption key (CEK). The wrapped CEK is then transported securely to the recipient, who unwraps it (decrypts it) to recover the original CEK. This CEK is what's used for encrypting and decrypting the content. Now, coming to your question about the The function you referred to in the jose swift library is used to generate the MAC_KEY and ENC_KEY from the provided input key (the CEK). This is done after the CEK has been unwrapped. The key for AES Key Wrap (the key encryption key, or KEK) comes from the key agreement process ( The observation you made about the jose swift library using ENC_KEY for key wrapping appears to be a misunderstanding. The key wrapping process should be using the KEK derived from the key agreement process, not the ENC_KEY. In summary, the approach where a 512-bit key is split into two 256-bit halves, one for MAC and one for encryption, is correct. The important thing to remember is that the keys for AES Key Wrap and content encryption are derived from different processes and serve different purposes. I hope this helps to clarify things! |
Hello |
Hello We have the problem with this function So the problem is with the
It should be equal to 256 because of A256KW... we should take the "enc" key length only for "ECDH-1PU" |
Hi there. :) I had the same problem and actually was checking a few things, I noticed that there is actually a bug in this key management algorithm, in the This is documented in the ECDH-1PU draft rfc https://datatracker.ietf.org/doc/html/draft-madden-jose-ecdh-1pu-04#section-2.3 |
Hello
I tried version from main branch
And got an error during encryption process
Code
We got this issue here
encryptedKey = try AES.KeyWrap.wrap(.init(data: contentEncryptionKey), using: .init(data: keyEncryptionKey))
When we are trying to create
encryptedKey
for receiver.The text was updated successfully, but these errors were encountered: