I'm having a lot of trouble trying to understand how to implement AES-GCM.
My usecase: Person A sent me a file with a gauranteed unique name. I want to be assured it was from person A, and that no one saw the contents, and that it wasn't tampered with.
I figured that I would do the following:
- Person A would give me a public key offline to which only they have the private key
- Person A would encrypt the file with AES-GCM. They would then encrypt the AES-GCM key+nonce+aad with their private key. They would then send me two files: the cipher and the encrypted key+nonce+aad combo.
- I would decrypt the key+nonce+aad with their public key, then I would decrypt the AES-GCM cipher using those values.
I figured that I would use these values:
- Key: random
- Nonce: file name
- AAD: file name
I know this is probably a terrible way to do things. It seems overly complicated to me, but I'm not sure how else to achieve my usecase. I have no idea if these are the right values to use for the encryption/decryption, and I have no idea what should be kept secret and what shouldn't be kept secret.
Any guidance would be greatly appreciated. If it helps, it looks like the GSM encryption/decryption will happen in Python.