5
$\begingroup$

In Envelope encryption a symmetric secret key is used to sign the data and then another key is used to encrypt the secret to produce an encrypted secret key. The encrypted messages is packaged with the encrypted secret key and sent to the client/consumer which then decrypted the encrypted secret key to get the secret key, which in turn is used to decrypt the message

There are 2 ways to implement it:

  1. Asymmetric encryption: The producer encrypts the secret key(s) with the consumers public key. The consumer uses a private key to decrypted the encrypted secret
  2. KMS (such as AWS KMS): The secret key is encrypted by the KMS, and client that needs access to the secret key has to ask the KMS to decrypt it

The advantage of the KMS approach is that key management is centralized, and revoking permissions from a client can be done by removing the client from the KMS and rotating the key.

Are there any good reasons to use asymmetric keys instead of KMS?

$\endgroup$
2
  • 1
    $\begingroup$ maybe: You can out-source the storage of the public keys (-> asymmetric), but can you really trust a third party with symmetric keys? And rotating the key should be as easy with KMS as with asymmetric keys (or I'm missing sth) $\endgroup$
    – SEJPM
    Commented Aug 24, 2015 at 19:57
  • $\begingroup$ Without any specific cryptographic algorithm this may be better suited to IT security I think. This is more about which policy fits the best to the problem field than anything else.... I can only think of things like: you don't need a KMS, you don't need a trusted third party or active service (etc. etc.). $\endgroup$
    – Maarten Bodewes
    Commented Aug 25, 2015 at 8:12

1 Answer 1

3
$\begingroup$

It's all about where you store the secret and who has access to it.

First a clarification: You are confused. KMS does not use asymmetric encryption (also called Public-Key encryption). It uses private key encryption to enable envelope encryption. They are two different things.

In asymmetric encryption the producer of the encryption never has to access the secret, they just need the public key. The producer uses the public key to encrypt, the consumer uses the corresponding private key to decrypt. In order to facilitate key rotation the producer sometimes appends the public key that was used to encrypt so that the consumer knows what private key to use to decrypt. No matter how much data is encrypted there are no hints at the private key. The algorithm for decryption is usually more compute intensive than private key encryption.

In envelope encryption the producer and the consumer must be the same (or both have access to the master key). You use a master key to generate a secondary key called a data key. You then encrypt the data key using the master key and the data itself using the data key, then you append the encrypted data key to the encrypted data. When you decrypt you use the master key to decrypt the appended data key, then use the decrypted data key to decrypt the data.

The advantage of this is that you can cost effectively store your master key in purpose build Hardware Security Module and never expose it to anything else without having to pass all the data you encrypt into the HSM. You can even generate the key inside the HSM and not take it out so that there's no chance that it has ever been exposed to anything externally. KMS provides you with a cloud based HSM and it's backed by physical HSMs at Amazon.

If you don't care about keeping your master key in an HSM, then you can do the same kind of encryption using your own key that you try to keep safe by putting in on a jump server or something like that. Also as long as you aren't encrypting more than 250 million TB you can skip the envelope.

If you're looking for some example code you can snatch up to implement either simple AES encryption or envelope encryption you might want to check our open-source project. It's got an implementation for each you can leverage...

https://github.com/kunai-consulting/KeyStor

$\endgroup$
1
  • $\begingroup$ I'd reread the question and remove the "You are confused. KMS does not use asymmetric encryption." part. The question states them as two distinct options. $\endgroup$ Commented Dec 19, 2018 at 2:57

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.