Skip to content
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

AES-256 generating a 64 byte key? #624

Closed
thomasmost opened this issue Sep 4, 2024 · 4 comments
Closed

AES-256 generating a 64 byte key? #624

thomasmost opened this issue Sep 4, 2024 · 4 comments

Comments

@thomasmost
Copy link

Hi, I'm developing a protocol that requires interoperability between clients written in different languages using the AES encryption algorithm. Our first clients were in Rust, and I'm working on a Java implementation now. Basically we want a Java client to be able to encrypt a payload, send it to the Rust client, and have the Rust client decrypt it. Not rocket science.

In the process of testing, I'm generating a key in Rust, like so:

pub fn generate_key() -> Vec<u8> {
  let bytekey = Aes256SivAead::generate_key(&mut OsRng);
  bytekey.to_vec()
}

...but when I try to use this key to decrypt in Java, I get this error:
Invalid AES key length: 64 bytes

Sure enough... it looks like the bytekey vector length (Vec) is 64. I would have expected it to be 32! Can someone help me understand what I'm missing?

Potentially relevant: I'm base64 encoding the key rather than sending it as raw bytes

@tarcieri
Copy link
Member

tarcieri commented Sep 4, 2024

AES-SIV uses keys which are twice the size of the corresponding AES key.

Are you sure you're actually using AES-SIV on the Java side of things?

@tarcieri tarcieri closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
@thomasmost
Copy link
Author

That sounds like the missing piece! Thanks very much @tarcieri

@tarcieri
Copy link
Member

tarcieri commented Sep 4, 2024

Also note that AES-SIV is largely obsoleted by AES-GCM-SIV

@thomasmost
Copy link
Author

got it, I'll migrate the services to that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants