aes: 94ae183c: The start of an aes implementation, for ...
grim at pidgin.im
grim at pidgin.im
Mon Mar 21 03:23:04 EDT 2011
----------------------------------------------------------------------
Revision: 94ae183ca2c85131a2530ad07a6fb23cc65e587e
Parent: 8b5d777aea21ddc152e2892ab93fe51bb8483cde
Author: grim at pidgin.im
Date: 02/19/11 17:37:15
Branch: im.pidgin.aes
URL: http://d.pidgin.im/viewmtn/revision/info/94ae183ca2c85131a2530ad07a6fb23cc65e587e
Changelog:
The start of an aes implementation, for 128, 192, and 256
Changes against parent 8b5d777aea21ddc152e2892ab93fe51bb8483cde
patched libpurple/cipher.c
patched libpurple/ciphers/Makefile.am
patched libpurple/tests/test_cipher.c
-------------- next part --------------
============================================================
--- libpurple/cipher.c b0704d8e1daf51384de3f0af5e651e670e896655
+++ libpurple/cipher.c 7ba980e9bcc66f6f883a697dc4d7410ecce55021
@@ -228,6 +228,9 @@ purple_ciphers_get_handle() {
* the developer to just add it here since they have to register it here as
* well.
*/
+PurpleCipherOps *purple_aes128_cipher_get_ops();
+PurpleCipherOps *purple_aes192_cipher_get_ops();
+PurpleCipherOps *purple_aes256_cipher_get_ops();
PurpleCipherOps *purple_des_cipher_get_ops();
PurpleCipherOps *purple_des3_cipher_get_ops();
PurpleCipherOps *purple_hmac_cipher_get_ops();
@@ -260,6 +263,9 @@ purple_ciphers_init() {
purple_ciphers_register_cipher("des", purple_des_cipher_get_ops());
purple_ciphers_register_cipher("des3", purple_des3_cipher_get_ops());
purple_ciphers_register_cipher("rc4", purple_rc4_cipher_get_ops());
+ purple_ciphers_register_cipher("aes128", purple_aes128_cipher_get_ops());
+ purple_ciphers_register_cipher("aes192", purple_aes192_cipher_get_ops());
+ purple_ciphers_register_cipher("aes256", purple_aes256_cipher_get_ops());
}
void
============================================================
--- libpurple/tests/test_cipher.c 773c2ab6f21fb2337f3a49f848672b48f0f4ff8a
+++ libpurple/tests/test_cipher.c fa993776d824ac21912e76b0f2ea2072d462de7f
@@ -762,6 +762,50 @@ END_TEST
END_TEST
/******************************************************************************
+ * AES Tests
+ *****************************************************************************/
+#define AES_TEST(keysize, question, key, answer, len) { \
+ PurpleCipher *cipher = NULL; \
+ PurpleCipherContext *context = NULL; \
+ gint ret = 0; \
+ guchar encrypted[len]; \
+ guchar decrypted[len]; \
+ size_t outlen; \
+ \
+ cipher = purple_ciphers_find_cipher("aes#keysize"); \
+ context = purple_cipher_context_new(cipher, NULL); \
+ purple_cipher_context_set_key(context, key); \
+ \
+ ret = purple_cipher_context_encrypt(context, question, len, encrypted, &outlen); \
+ fail_unless(ret == 0, NULL); \
+ fail_unless(outlen == (len), NULL); \
+ fail_unless(memcmp(encrypted, answer, len) == 0, NULL); \
+ \
+ ret = purple_cipher_context_decrypt(context, encrypted, len, decrypted, &outlen); \
+ fail_unless(ret == 0, NULL); \
+ fail_unless(outlen == (len), NULL); \
+ fail_unless(memcmp(decrypted, answer, len) == 0, NULL); \
+ \
+ purple_cipher_context_destroy(context); \
+}
+
+START_TEST(test_aes128)
+ AES_TEST(128,
+ "00112233445566778899aabbccddeeff",
+ "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f",
+ "69c4e0d86a7b0430d8cdb78070b4c55a",
+ 32);
+END_TEST
+
+START_TEST(test_aes192)
+ AES_TEST(192,
+ "00112233445566778899aabbccddeeff",
+ "000102030405060708090a0b0c0d0e0f1011121314151617",
+ "dda97ca4864cdfe06eaf70a0ec0d7191",
+ 32);
+END_TEST
+
+/******************************************************************************
* Suite
*****************************************************************************/
Suite *
@@ -856,6 +900,12 @@ cipher_suite(void) {
tcase_add_test(tc, test_hmac_sha1_null_key_and_text);
suite_add_tcase(s, tc);
+ /* aes128 tests */
+ tc = tcase_create("AES");
+ tcase_add_test(tc, test_aes128);
+ tcase_add_test(tc, test_aes192);
+ suite_add_tcase(s, tc);
+
return s;
}
============================================================
--- libpurple/ciphers/Makefile.am 15b306380ab2ae11dbaa1755e76e625a273fd62a
+++ libpurple/ciphers/Makefile.am b0ec7e5e3491fcb389f9e12fa71abb60762c936b
@@ -1,6 +1,7 @@ libpurple_ciphers_la_SOURCES=\
noinst_LTLIBRARIES=libpurple-ciphers.la
libpurple_ciphers_la_SOURCES=\
+ aes.c \
des.c \
gchecksum.c \
hmac.c \
More information about the Commits
mailing list