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


1 Answer 1


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).

  • $\begingroup$ 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? $\endgroup$
    – hff
    Commented Sep 14, 2018 at 13:34
  • $\begingroup$ @houssein: I believe OpenSSL can do that. As for a website, would you really want to give your keys to a third party website? $\endgroup$
    – poncho
    Commented Sep 14, 2018 at 13:41
  • $\begingroup$ 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 $\endgroup$
    – hff
    Commented Sep 14, 2018 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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