I am new in cryptography and I am facing some complications in encryption-decryption. I am trying to use AES-GCM with a 256-bit AES key and a 96-bit nonce. I use an open source project (Vault) to create the encryption keys. Vault can encrypt/decrypt using the generated key.

The question is what should I have to encrypt data in a different application using the key generated by Vault (so Vault can decrypt afterward)? Is having only the encryption key enough, or should I export more data from Vault such as IV?

Thanks in advance if you have some advice and hope my question is clear

New contributor
houssein is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
up vote 1 down vote accepted

Exporting the key is sufficient.

With GCM (and block modes in general), the key and the nonce play very different roles.

The key is secret; it is known by the encryptor and the decryptor and no one else. And, you can use the same key to encrypt multiple messages.

The nonce (or IV) need not be secret; common practice is to send it along with the encrypted message. However, one limitation with GCM is that, while you can encrypt multiple messages with the same key, you must use a different nonce for each message that you encrypt with that same key. And, typically, the encryptor selects the nonce when it encrypts the message.

Because of this, it doesn't make sense to ask Vault which nonce it expects to use to decrypt; the encryptor selects it (and if Vault will be able to decrypt several messages with the same key, it'll have to use different nonces anyways).

  • your answer is really helpful. But just to clarify, the encryptor should choose the nonces and send them to the decryptor with the encrypted data right?. Is there any free program or a website that can encrypt using AES-256 specified key and give you back the used nonce? – houssein Sep 14 at 13:34
  • @houssein: I believe OpenSSL can do that. As for a website, would you really want to give your keys to a third party website? – poncho Sep 14 at 13:41
  • It is just for testing. I will delete the key right away after the test. I tried to encrypt online but Vault couldn't decrypt. maybe because I gave vault only the encrypted data. The website I used don't give back the nonces. thanks for your answer – houssein Sep 14 at 13:56

Your Answer

houssein is a new contributor. Be nice, and check out our Code of Conduct.
 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.