Mercurial > pidgin
comparison libpurple/protocols/oscar/family_oservice.c @ 23383:540a26a1a88d
Helper functions are cool
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 21 Jun 2008 20:28:14 +0000 |
parents | 9c0ee2491ed1 |
children | 3950ff527cb6 |
comparison
equal
deleted
inserted
replaced
23382:76f7e2186c38 | 23383:540a26a1a88d |
---|---|
950 if ((flag == AIM_SENDMEMBLOCK_FLAG_ISHASH) && buf && (len == 0x10)) { /* we're getting a hash */ | 950 if ((flag == AIM_SENDMEMBLOCK_FLAG_ISHASH) && buf && (len == 0x10)) { /* we're getting a hash */ |
951 | 951 |
952 byte_stream_putraw(&bs, buf, 0x10); | 952 byte_stream_putraw(&bs, buf, 0x10); |
953 | 953 |
954 } else if (buf && (len > 0)) { /* use input buffer */ | 954 } else if (buf && (len > 0)) { /* use input buffer */ |
955 PurpleCipher *cipher; | |
956 PurpleCipherContext *context; | 955 PurpleCipherContext *context; |
957 guchar digest[16]; | 956 guchar digest[16]; |
958 | 957 |
959 cipher = purple_ciphers_find_cipher("md5"); | 958 context = purple_cipher_context_new_by_name("md5", NULL); |
960 | |
961 context = purple_cipher_context_new(cipher, NULL); | |
962 purple_cipher_context_append(context, buf, len); | 959 purple_cipher_context_append(context, buf, len); |
963 purple_cipher_context_digest(context, 16, digest, NULL); | 960 purple_cipher_context_digest(context, 16, digest, NULL); |
964 purple_cipher_context_destroy(context); | 961 purple_cipher_context_destroy(context); |
965 | 962 |
966 byte_stream_putraw(&bs, digest, 0x10); | 963 byte_stream_putraw(&bs, digest, 0x10); |
967 | 964 |
968 } else if (len == 0) { /* no length, just hash NULL (buf is optional) */ | 965 } else if (len == 0) { /* no length, just hash NULL (buf is optional) */ |
969 PurpleCipher *cipher; | |
970 PurpleCipherContext *context; | 966 PurpleCipherContext *context; |
971 guchar digest[16]; | 967 guchar digest[16]; |
972 guint8 nil = '\0'; | 968 guint8 nil = '\0'; |
973 | 969 |
974 /* | 970 /* |
975 * I'm not sure if we really need the empty append with the | 971 * I'm not sure if we really need the empty append with the |
976 * new MD5 functions, so I'll leave it in, just in case. | 972 * new MD5 functions, so I'll leave it in, just in case. |
977 */ | 973 */ |
978 cipher = purple_ciphers_find_cipher("md5"); | 974 context = purple_cipher_context_new_by_name("md5", NULL); |
979 | |
980 context = purple_cipher_context_new(cipher, NULL); | |
981 purple_cipher_context_append(context, &nil, 0); | 975 purple_cipher_context_append(context, &nil, 0); |
982 purple_cipher_context_digest(context, 16, digest, NULL); | 976 purple_cipher_context_digest(context, 16, digest, NULL); |
983 purple_cipher_context_destroy(context); | 977 purple_cipher_context_destroy(context); |
984 | 978 |
985 byte_stream_putraw(&bs, digest, 0x10); | 979 byte_stream_putraw(&bs, digest, 0x10); |