Ticket #4381 (closed patch: fixed)

Opened 3 years ago

Last modified 3 years ago

Add HMAC digest to libpurple

Reported by: QuLogic Owned by: grim
Milestone: Component: libpurple
Version: 2.3.1 Keywords: HMAC, digest
Cc:

Description

So khc wanted to take a look at the MSNP15 stuff, so I'm posting these tickets.

This patch adds the HMAC digest to libpurple. A few points:

  • The underlying hash function can be set via purple_cipher_context_set_option(cipher, "hash", hash). The blocksize isn't really available, so I just assumed a size of 64 bytes. Fortunately, the supplied hashes all have a blocksize of 64 bytes, but this will need to be fixed if a different hash is added.
  • The key can be set with purple_cipher_context_set_key. Because of the way it's implemented, this acts almost like a reset (but without changing the hash).
  • Since the key can be of any length, perhaps with NULLs, and _set_key doesn't accept a length, I've had to add purple_cipher_context_set_option(cipher, "keyLen", key_len) so that things would work properly.
  • Finally, I've added some tests with both MD5 and SHA1 as underlying hashes from RFC2202.

Attachments

purple-hmac-digest.diff (24.0 kB) - added by QuLogic 3 years ago.
Adds HMAC digest to libpurple. Also adds _get_block_size and _set_key_with_len to PurpleCipherOps? structure.

Change History

Changed 3 years ago by khc

  • owner set to grim

Changed 3 years ago by grim

We have 4 padded memebers in the PurpleCipherOps? structure, and I see no reason why we shouldn't use them for the majority of this.

Adding a _get_block_size op seems totally reasonable, we may also want to add a _set_block_size, but I can't come up with a case were it would be useful. Mind you my crypto in general isn't that great :).

We could add a purple_cipher_context_set_key_with_len function, and use another op.

I'd like to see these changes use the padding rather than the option system, since that seems like it'd be a lot harder to debug and what not.

Changed 3 years ago by QuLogic

OK, updated this patch as well. It adds purple_cipher_context_get_block_size and purple_cipher_context_set_key_with_len.

Since I've added to the PurpleCipherOps structure in both #4380 and here, this one is probably dependant on you applying the previous patch first. I've noticed some fuzz when applying it, but it still seems to work alright.

Changed 3 years ago by QuLogic

Adds HMAC digest to libpurple. Also adds _get_block_size and _set_key_with_len to PurpleCipherOps? structure.

Changed 3 years ago by grim

This has my blessing, good work!

What should I use for the author on the commit?

Changed 3 years ago by QuLogic

Cool. You can use Elliott Sales de Andrade, it should be in the Authors list already.

Changed 3 years ago by grim

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.
All information, including names and email addresses, entered onto this website or sent to mailing lists affiliated with this website will be public. Do not post confidential information, especially passwords!