1
$\begingroup$

Simplified Question

Does it make sense from a security / cryptographic standpoint to encrypt a text in the following way:

  • create only one AES key K_Azure
  • create new random key K_Text1
  • encrypt Text1 with K_Text1
  • encrypt K_Text1 with K_Azure
  • store [ E(K_Text1), E(Text1) ] in the same storage
  • store K_Auzre somewhere else

Context

The DataProtection in asp.net core provides a mechanism to encrypt and decrypt some data.

The keys are stored in a key-value-pair format of (KeyId, XML), where XML provides some metadata and the actual encryption key itself.

The part of the XML where the key is stored can be encrypted using various providers, my question is about the ProtectKeysWithAzureKeyVault (link) implemented here.

Protecting the keys

With ProtectKeysWithAzureKeyVault a data encyption key (let's call it TEXT, because in our case this will be just a text) is encrypted using a random new generated key (let's call it K_Text). K_Text will be encrypted using a single key in the AzureKeyVault (let's call it K_Azure).

The encrypted TEXT and encrypted K_Text are saved in the same store (in the same XML which is saved in in a SQL or file or we...).

To summarize

+------------------------------------ --------+          +---------+  
| Database                                    |          | Azure   |  
| ----------------------------------- --------|          | --------|  
| Id1, E(K_Azure, K_Text1), E(K_Text1, TEXT1) |          | K_Azure |  
| Id2, E(K_Azure, K_Text2), E(K_Text2, TEXT2) |          + --------+  
+ ------------------------------------ -------+


E (KEY, TEXT) = encript TEXT with KEY

My question

Is there any reason why it does not encrypt the TEXT directly with K_Auzre?

Notes

  • AES is used to encrypt everything as far as I know in this context

Update

I think Elias is right, K_Azure is kept in separate hardware and you can not get it.

$\endgroup$
3
$\begingroup$

Just two ideas:

  1. If you have some kind of hardware security module (HSM) to protect your K_Azure you might want to avoid using that HSM to encrypt large volumes of data. But since you cannot get the K_Azure out you generate a new key and use that.
  2. If you don't have other randomization in your AES mode you will leak equality information if you use the same key for the same data.
| improve this answer | |
$\endgroup$
  • $\begingroup$ Regarding 2, does random IV fix that? $\endgroup$ – dburner Apr 29 at 12:28
  • 1
    $\begingroup$ .Actually, for the 2. case the multi-target attack is the problem for AES> $\endgroup$ – kelalaka Apr 29 at 14:36
  • $\begingroup$ @kelalaka What do you mean? $\endgroup$ – Elias Apr 30 at 6:57
3
$\begingroup$

A third possible reason one might do this is to allow quick erasure.

Suppose you want to securely delete Text1, that is, make sure that no one, not you, not a hacker, not the TLA that gains access to the computer, can possibly recover it. Now, E(Text1) may be lengthy, and scrubbing it from the files may take more time than we would care to take (and we would have to scrub the entire thing securely; if E(Text1) was encrypted with our long term key, then even partial access to E(Text1) would give partial access to Text1).

You could erase K_Azure; however that would also remove access to everything encrypted with that key; you might not want to go that far.

However, with this two-key structure, we can just securely delete E(K_Text1); without that, no one has any access to Text1 (while preserving access to all the other files you didn't want to delete).

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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