| 510 mctx->hash[3] = 0x10325476; |
510 mctx->hash[3] = 0x10325476; |
| 511 mctx->byte_count = 0; |
511 mctx->byte_count = 0; |
| 512 } |
512 } |
| 513 |
513 |
| 514 static void |
514 static void |
| 515 md4_append(PurpleCipherContext *context, const guchar *data, size_t len) |
515 md4_append(PurpleCipherContext *context, const guchar *data, size_t len) |
| 516 { |
516 { |
| 517 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
517 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
| 518 const guint32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); |
518 const guint32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); |
| 519 |
519 |
| 520 mctx->byte_count += len; |
520 mctx->byte_count += len; |
| 549 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
549 struct MD4_Context *mctx = purple_cipher_context_get_data(context); |
| 550 const unsigned int offset = mctx->byte_count & 0x3f; |
550 const unsigned int offset = mctx->byte_count & 0x3f; |
| 551 char *p = (char *)mctx->block + offset; |
551 char *p = (char *)mctx->block + offset; |
| 552 int padding = 56 - (offset + 1); |
552 int padding = 56 - (offset + 1); |
| 553 |
553 |
| 554 |
554 |
| 555 if(in_len<16) return FALSE; |
555 if(in_len<16) return FALSE; |
| 556 if(out_len) *out_len = 16; |
556 if(out_len) *out_len = 16; |
| 557 *p++ = 0x80; |
557 *p++ = 0x80; |
| 558 if (padding < 0) { |
558 if (padding < 0) { |
| 559 memset(p, 0x00, padding + sizeof (guint64)); |
559 memset(p, 0x00, padding + sizeof (guint64)); |
| 776 hmac_set_key(PurpleCipherContext *context, const guchar * key) |
776 hmac_set_key(PurpleCipherContext *context, const guchar * key) |
| 777 { |
777 { |
| 778 hmac_set_key_with_len(context, key, strlen((char *)key)); |
778 hmac_set_key_with_len(context, key, strlen((char *)key)); |
| 779 } |
779 } |
| 780 |
780 |
| 781 static size_t |
781 static size_t |
| 782 hmac_get_block_size(PurpleCipherContext *context) |
782 hmac_get_block_size(PurpleCipherContext *context) |
| 783 { |
783 { |
| 784 struct HMAC_Context *hctx = purple_cipher_context_get_data(context); |
784 struct HMAC_Context *hctx = purple_cipher_context_get_data(context); |
| 785 |
785 |
| 786 return hctx->blocksize; |
786 return hctx->blocksize; |
| 1020 /* |
1020 /* |
| 1021 * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for |
1021 * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for |
| 1022 * 16 encryption rounds. |
1022 * 16 encryption rounds. |
| 1023 * To calculate subkeys for decryption the caller |
1023 * To calculate subkeys for decryption the caller |
| 1024 * have to reorder the generated subkeys. |
1024 * have to reorder the generated subkeys. |
| 1025 * |
1025 * |
| 1026 * rawkey: 8 Bytes of key data |
1026 * rawkey: 8 Bytes of key data |
| 1027 * subkey: Array of at least 32 guint32s. Will be filled |
1027 * subkey: Array of at least 32 guint32s. Will be filled |
| 1028 * with calculated subkeys. |
1028 * with calculated subkeys. |
| 1029 * |
1029 * |
| 1030 **/ |
1030 **/ |
| 1031 static void |
1031 static void |
| 1032 des_key_schedule (const guint8 * rawkey, guint32 * subkey) |
1032 des_key_schedule (const guint8 * rawkey, guint32 * subkey) |
| 1033 { |
1033 { |
| 1034 guint32 left, right, work; |
1034 guint32 left, right, work; |
| 1945 if(purple_strequal(name, "key_len")) { |
1945 if(purple_strequal(name, "key_len")) { |
| 1946 ctx->key_len = GPOINTER_TO_INT(value); |
1946 ctx->key_len = GPOINTER_TO_INT(value); |
| 1947 } |
1947 } |
| 1948 } |
1948 } |
| 1949 |
1949 |
| 1950 static size_t |
1950 static size_t |
| 1951 rc4_get_key_size (PurpleCipherContext *context) |
1951 rc4_get_key_size (PurpleCipherContext *context) |
| 1952 { |
1952 { |
| 1953 struct RC4Context *ctx; |
1953 struct RC4Context *ctx; |
| 1954 |
1954 |
| 1955 g_return_val_if_fail(context, -1); |
1955 g_return_val_if_fail(context, -1); |