Suggested changes to PurpleCipherOps and need for code review

Tomasz Wasilczyk tomkiewicz at
Wed May 1 10:55:41 EDT 2013


In my opinion, current PurpleCipherOps structure is incomplete and
could be improved. I think, most of these is related to 2.x.y backward
compatibility, so we could tidy things up for 3.0.0.

My suggestions:
- merge set_key() with set_key_with_len() (using ssize_t len instead
of size_t, if we don't want to provide length)
- add get_digest_size(), if we don't want to guess buffer length for digest()
- add (optional) length parameter for set_salt()
- add output_size parameter to encrypt() and decrypt() to prevent
buffer overflow (outlen is used to store actual data length after
- add some reserved fields at the end of struct, there are none left
(this struct should be hidden anyway, but maybe not this time)

I need it for master password branch, where I would like to add
lacking "master password" feature. I decided to use PBKDF2 for turning
passphrase into encryption key as it seems to be wide standard and can
be adjusted later. Thus, when setting up new master passphrase, there
will be some information stored: used key derivation method (only
pbkdf2-sha256, for now) and specific data for selected method (salt,
iterations count). Default iterations count parameter could be changed
later. Encryption will be done with AES (provided by NSS and GnuTLS).

I've done a draft implementation of pbkdf2 using source code grabbed
from gnutls. For a reference, I also done independent implementation
using NSS library. Please review it, especially gnutls one (patch is
made against my masterpassword branch). Though, it hasn't been
triple-checked yet, so it may still contain minor bugs.

Waiting for feedback, especially for PurpleCipherOps,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pbkdf2-draft.diff
Type: application/octet-stream
Size: 8849 bytes
Desc: not available
URL: <>

More information about the Devel mailing list