rnpgp / rnp

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

Bogus unused function `pgp_write_symm_enc_data` #133

Closed randombit closed 6 years ago

randombit commented 7 years ago

Working on #132 I noticed that pgp_write_symm_enc_data seems wrong. It creates a cipher object with pgp_crypt_any and then - without setting a key or IV - calls pgp_encrypt_init: https://github.com/riboseinc/rnp/blob/master/src/lib/create.c#L1302

This will end up keying the cipher with uninitialized data!

It appears this function is not used/called anywhere (probably good, considering). Also, I notice this function seems to be the only caller of pgp_encrypt_se, so likely that function also can be removed. pgp_decrypt_se also appears unused.

I think all of these functions can be removed entirely but maybe there is something worth salvaging - I'm not entirely sure what these functions are trying to do, or if the same functionality is replicated elsewhere in the lib.

ronaldtse commented 7 years ago

This is very interesting. Apparently pgp_write_symm_enc_data wasn't even used in NetPGP (https://github.com/riboseinc/netpgp/search?utf8=%E2%9C%93&q=pgp_write_symm_enc_data&type=) so let' just simply remove it.

I suspect it was an enhancement in progress done previously but never actually made useful.

ni4 commented 6 years ago

This is fixed number of commits ago.