What would be the best way of encrypting small mesasages to be stored in encrypted form? (This sounds like somthing a textbook would cover, but I haven't found any references).
Let's say I have many systems producing messages (log-lines) which I would like to transfer and store centrally in a secure manner. Using off-the-shelf products I could secure the transfer and storing of these messages independently, but I would like to investigate another approach: encrypting each message at the sendig system with the public key of the reciever, so that the messages can be stored as-is, and thus provide end-to-end encryption from the sender down to the storage medium.
First some definitions:
- RSA(PublicKey, Message) means: RSA-encrypt Message with the given Key
- AES(Key, IV, Message) means: AES-encrypt Message in CBC-mode with the given Key and IV
- Message = gzip(plaintext)
I have come up with the following options:
I can encrypt each message with RSA:
- Ciphertext = RSA(PublicKey, Message)
However, this would fail of the message is too long.
Or I could create a random AES-key for each message (and also use this as IV):
- Key = Random()
- EncryptedSessionKey = RSA(PublicKey, Key)
- Ciphertext =EncryptedSessionKey, AES(Key, EncryptedSessionKey, Message)
However, RSA-computation is heavy and I probably cannot afford to do this for every message. Thus, I can re-use the key for, say, 100 messages and do:
- Key = Random() (re-key every 100 messages)
- EncryptedSessionKey = RSA(PublicKey, Key)
- IV = Random() (new IV for each message)
- Ciphertext = EncryptedSessionKey, AES(Key, IV, Message)
The last one seems to be both secure and efficient. However, I really don't want to invent a system like this myself. Is there any best practices, research or textbook-examples I should look into?
RSA-encrypt
is not well defined; one should hardly ever use textbook RSA, see PKCS#1, and its two variants of RSAES. RSA encryption is not very heavy with short $e$ (decryption is). Use ofIV=EncryptedSessionKey
is needlessly complicated: when key is single use, IV can be 0. I let others answer the question. $\endgroup$