comparison src/cipher.c @ 11597:036bd21c5560

[gaim-migrate @ 13867] Fix some declarations in cipher.c to be static and rename des_setkey to make FreeBSD happier. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Mon, 03 Oct 2005 04:57:30 +0000
parents 59aa7080eb2d
children 8004885fabbe
comparison
equal deleted inserted replaced
11596:944dadd28161 11597:036bd21c5560
809 * rawkey: 8 Bytes of key data 809 * rawkey: 8 Bytes of key data
810 * subkey: Array of at least 32 guint32s. Will be filled 810 * subkey: Array of at least 32 guint32s. Will be filled
811 * with calculated subkeys. 811 * with calculated subkeys.
812 * 812 *
813 **/ 813 **/
814 static void 814 static void
815 des_key_schedule (const guint8 * rawkey, guint32 * subkey) 815 des_key_schedule (const guint8 * rawkey, guint32 * subkey)
816 { 816 {
817 guint32 left, right, work; 817 guint32 left, right, work;
818 int round; 818 int round;
819 819
894 /* 894 /*
895 * Fill a DES context with subkeys calculated from a 64bit key. 895 * Fill a DES context with subkeys calculated from a 64bit key.
896 * Does not check parity bits, but simply ignore them. 896 * Does not check parity bits, but simply ignore them.
897 * Does not check for weak keys. 897 * Does not check for weak keys.
898 **/ 898 **/
899 void 899 static void
900 des_setkey (GaimCipherContext *context, guchar * key) 900 des_set_key (GaimCipherContext *context, guchar * key)
901 { 901 {
902 struct _des_ctx *ctx = gaim_cipher_context_get_data(context); 902 struct _des_ctx *ctx = gaim_cipher_context_get_data(context);
903 int i; 903 int i;
904 904
905 des_key_schedule (key, ctx->encrypt_subkeys); 905 des_key_schedule (key, ctx->encrypt_subkeys);
915 915
916 /* 916 /*
917 * Electronic Codebook Mode DES encryption/decryption of data according 917 * Electronic Codebook Mode DES encryption/decryption of data according
918 * to 'mode'. 918 * to 'mode'.
919 **/ 919 **/
920 int 920 static int
921 des_ecb_crypt (struct _des_ctx *ctx, const guint8 * from, guint8 * to, int mode) 921 des_ecb_crypt (struct _des_ctx *ctx, const guint8 * from, guint8 * to, int mode)
922 { 922 {
923 guint32 left, right, work; 923 guint32 left, right, work;
924 guint32 *keys; 924 guint32 *keys;
925 925
941 WRITE_64BIT_DATA (to, right, left) 941 WRITE_64BIT_DATA (to, right, left)
942 942
943 return 0; 943 return 0;
944 } 944 }
945 945
946 gint des_encrypt(GaimCipherContext *context, const guchar data[], size_t len, guchar output[], size_t *outlen) { 946 static gint
947 des_encrypt(GaimCipherContext *context, const guchar data[],
948 size_t len, guchar output[], size_t *outlen) {
947 int offset = 0; 949 int offset = 0;
948 int i = 0; 950 int i = 0;
949 int tmp; 951 int tmp;
950 guint8 buf[8] = {0,0,0,0,0,0,0,0}; 952 guint8 buf[8] = {0,0,0,0,0,0,0,0};
951 while(offset+8<=len) { 953 while(offset+8<=len) {
1000 NULL, /* digest */ 1002 NULL, /* digest */
1001 des_encrypt, /* encrypt */ 1003 des_encrypt, /* encrypt */
1002 NULL, /* decrypt */ 1004 NULL, /* decrypt */
1003 NULL, /* set salt */ 1005 NULL, /* set salt */
1004 NULL, /* get salt size */ 1006 NULL, /* get salt size */
1005 des_setkey, /* set key */ 1007 des_set_key, /* set key */
1006 NULL /* get key size */ 1008 NULL /* get key size */
1007 }; 1009 };
1008 1010
1009 1011
1010 /******************************************************************************* 1012 /*******************************************************************************