rnpgp / rnp

RNP: high performance C++ OpenPGP library used by Mozilla Thunderbird
https://www.rnpgp.org
Other
194 stars 55 forks source link

Role of the key store (discussion) #351

Open dewyatt opened 7 years ago

dewyatt commented 7 years ago

I wanted to have a quick discussion on what the role of the key store should be as the lines seem a bit blurry (to me) right now.

I guess my main question revolves around the passphrase parameters in things like:

bool
rnp_key_store_write_to_mem(rnp_t *          rnp,
                           rnp_key_store_t *key_store,
                           const uint8_t *  passphrase,
                           const unsigned   armour,
                           pgp_memory_t *   memory)

So if we had 1000 unencrypted keys in this key store, it would use the same passphrase to encrypt all of them, which is a bit odd. This issue is mostly avoided currently because our key generation involves immediately writing the generated key to disk (when the generated key is the only decrypted key in the store).

This is basically inherited from netpgp, where saving a keyring involved pgp_write_xfer_*key (which we still do in master, though it's not correct). This is also one of the reasons we don't currently support writing out a keyring that contains an unencrypted (loaded) key.

My initial thoughts are that we should be able to:

I did tackle the first 2 for .gpg/.kbx in my branch here

But it seems worth discussing whether the key store should deal with passphrases and key encryption/decryption. I personally lean towards no at the moment.

(Also I haven't spent time looking at the private-keys-v1.d/s-expr format so I don't know if that adds restrictions, etc.)

catap commented 7 years ago

@dewyatt Well...

rnp_key_store_write_to_mem use passphrase to save unencrypted key from keystore. So, if keystore has 2 keys and one of them unencrypted, this function will use this passphrase to encrypt only unencrypted key.

Another keys will save as is. So, I agree that I should add somenotes how it works and change the API because now it might confused.

So, I think we only need the API to set/change/remove passphrase to specified key. So, as result we will remove passphrase option from rnp_key_store_write_to_mem.

ronaldtse commented 7 years ago

I think we should look at the key store as a secure key storage structure for "keys", this includes public and private (asymmetric / symmetric) keys.

At the most general level a key store interface should be able to:

A key store could take any of the following forms (even each might only be able to support certain features):

I'm just going to list out some thoughts here and see anyone agrees.

A good key store should

Private keys should:

ni4 commented 7 years ago

I also came over this issue with key passwords recently. My opinion is that: