/cpw/tomkiewicz/masterpassword: e130174a28fb: Merge from main
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Mon May 6 10:03:04 EDT 2013
Changeset: e130174a28fb6e8e8972bc5569b21682669101ff
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-05-06 16:02 +0200
Branch: soc.2008.masterpassword
URL: https://hg.pidgin.im/cpw/tomkiewicz/masterpassword/rev/e130174a28fb
Description:
Merge from main
diffstat:
libpurple/cipher.c | 2 +-
libpurple/cipher.h | 4 ++--
libpurple/ciphers/hmac.c | 19 +++++++++++--------
3 files changed, 14 insertions(+), 11 deletions(-)
diffs (103 lines):
diff --git a/libpurple/cipher.c b/libpurple/cipher.c
--- a/libpurple/cipher.c
+++ b/libpurple/cipher.c
@@ -551,7 +551,7 @@ purple_cipher_context_decrypt(PurpleCiph
}
void
-purple_cipher_context_set_salt(PurpleCipherContext *context, guchar *salt, size_t len) {
+purple_cipher_context_set_salt(PurpleCipherContext *context, const guchar *salt, size_t len) {
PurpleCipher *cipher = NULL;
g_return_if_fail(context);
diff --git a/libpurple/cipher.h b/libpurple/cipher.h
--- a/libpurple/cipher.h
+++ b/libpurple/cipher.h
@@ -113,7 +113,7 @@ struct _PurpleCipherOps {
ssize_t (*decrypt)(PurpleCipherContext *context, const guchar input[], size_t in_len, guchar output[], size_t out_size);
/** The set salt function */
- void (*set_salt)(PurpleCipherContext *context, guchar *salt, size_t len);
+ void (*set_salt)(PurpleCipherContext *context, const guchar *salt, size_t len);
/** The get salt size function */
size_t (*get_salt_size)(PurpleCipherContext *context);
@@ -393,7 +393,7 @@ ssize_t purple_cipher_context_decrypt(Pu
* @param salt The salt
* @param len The length of the salt
*/
-void purple_cipher_context_set_salt(PurpleCipherContext *context, guchar *salt, size_t len);
+void purple_cipher_context_set_salt(PurpleCipherContext *context, const guchar *salt, size_t len);
/**
* Gets the size of the salt if the cipher supports it
diff --git a/libpurple/ciphers/hmac.c b/libpurple/ciphers/hmac.c
--- a/libpurple/ciphers/hmac.c
+++ b/libpurple/ciphers/hmac.c
@@ -30,7 +30,7 @@ struct HMAC_Context {
PurpleCipherContext *hash;
char *name;
int blocksize;
- guchar *opad;
+ guchar *opad, *ipad;
};
static void
@@ -57,6 +57,8 @@ hmac_reset(PurpleCipherContext *context,
hctx->blocksize = 0;
g_free(hctx->opad);
hctx->opad = NULL;
+ g_free(hctx->ipad);
+ hctx->ipad = NULL;
}
static void
@@ -66,8 +68,10 @@ hmac_reset_state(PurpleCipherContext *co
hctx = purple_cipher_context_get_data(context);
- if (hctx->hash)
- purple_cipher_context_reset_state(hctx->hash, extra);
+ if (hctx->hash) {
+ purple_cipher_context_reset_state(hctx->hash, NULL);
+ purple_cipher_context_append(hctx->hash, hctx->ipad, hctx->blocksize);
+ }
}
static void
@@ -168,15 +172,15 @@ hmac_set_key(PurpleCipherContext *contex
{
struct HMAC_Context *hctx = purple_cipher_context_get_data(context);
int blocksize, i;
- guchar *ipad;
guchar *full_key;
g_return_if_fail(hctx->hash != NULL);
g_free(hctx->opad);
+ g_free(hctx->ipad);
blocksize = hctx->blocksize;
- ipad = g_malloc(blocksize);
+ hctx->ipad = g_malloc(blocksize);
hctx->opad = g_malloc(blocksize);
if (key_len > blocksize) {
@@ -195,15 +199,14 @@ hmac_set_key(PurpleCipherContext *contex
}
for(i = 0; i < blocksize; i++) {
- ipad[i] = 0x36 ^ full_key[i];
+ hctx->ipad[i] = 0x36 ^ full_key[i];
hctx->opad[i] = 0x5c ^ full_key[i];
}
g_free(full_key);
purple_cipher_context_reset(hctx->hash, NULL);
- purple_cipher_context_append(hctx->hash, ipad, blocksize);
- g_free(ipad);
+ purple_cipher_context_append(hctx->hash, hctx->ipad, blocksize);
}
static size_t
More information about the Commits
mailing list