diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2007-03-15 22:58:36 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2007-03-15 22:58:36 +0000 |
commit | eee009073c7e98c56ad5d8b8f9a7e583e7460012 (patch) | |
tree | 1b4d34d075f88bc7378b49b86766241879e66157 /lib/des.c | |
parent | 02489b329f4a273a8bc43c11f37e277196d64dd8 (diff) | |
download | gnulib-eee009073c7e98c56ad5d8b8f9a7e583e7460012.tar.gz |
* lib/quotearg.c: Include <wctype.h> early, before the definition of
the iswprint macro. Needed on Solaris 2.5.1.
2007-03-12 Bruno Haible <bruno@clisp.org>
* tests/test-printf-frexp.c (main): Declare x as volatile.
2007-03-12 Simon Josefsson <simon@josefsson.org>
* doc/gnulib.texi (Build robot for gnulib): New section.
2007-03-12 Jim Meyering <jim@meyering.net>
* build-aux/bootstrap: New file.
* build-aux/bootstrap.conf: New file, from coreutils.
2007-03-11 Bruno Haible <bruno@clisp.org>
* m4/cycle-check.m4 (gl_CYCLE_CHECK): Require AC_C_INLINE.
2007-03-12 Simon Josefsson <simon@josefsson.org>
* lib/des.h, lib/des.c, lib/gc-gnulib.c: Use gl_ namespace, to
avoid collisions with 'des_setkey'. Reported by Bruno Haible
<bruno@clisp.org>. Also change 'tripledes_' to '3des_'.
2007-03-11 Bruno Haible <bruno@clisp.org>
* m4/locale-tr.m4 (gt_LOCALE_TR_UTF8): If the test program fails to
compile, set LOCALE_TR_UTF8 to 'none' instead of empty.
2007-03-11 Bruno Haible <bruno@clisp.org>
* lib/stdint_.h (INT64_MIN, INTMAX_MIN): Avoid using the ~INT..._MAX
formula. Needed for SunPRO C 5.0.
Diffstat (limited to 'lib/des.c')
-rw-r--r-- | lib/des.c | 44 |
1 files changed, 18 insertions, 26 deletions
@@ -1,5 +1,5 @@ /* des.c --- DES and Triple-DES encryption/decryption Algorithm - * Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006 + * Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007 * Free Software Foundation, Inc. * * This file is free software; you can redistribute it and/or modify @@ -54,7 +54,7 @@ * unsigned char plaintext[8]; * unsigned char ciphertext[8]; * unsigned char recoverd[8]; - * des_ctx context; + * gl_des_ctx context; * * // Fill 'key' and 'plaintext' with some data * .... @@ -77,20 +77,20 @@ * unsigned char plaintext[8]; * unsigned char ciphertext[8]; * unsigned char recoverd[8]; - * tripledes_ctx context; + * gl_3des_ctx context; * * // If you would like to use two 64bit keys, fill 'key1' and'key2' * // then setup the encryption context: - * tripledes_set2keys(&context, key1, key2); + * gl_3des_set2keys(&context, key1, key2); * * // To use three 64bit keys with Triple-DES use: - * tripledes_set3keys(&context, key1, key2, key3); + * gl_3des_set3keys(&context, key1, key2, key3); * * // Encrypting plaintext with Triple-DES - * tripledes_ecb_encrypt(&context, plaintext, ciphertext); + * gl_3des_ecb_encrypt(&context, plaintext, ciphertext); * * // Decrypting ciphertext to recover the plaintext with Triple-DES - * tripledes_ecb_decrypt(&context, ciphertext, recoverd); + * gl_3des_ecb_decrypt(&context, ciphertext, recoverd); */ @@ -324,7 +324,7 @@ static const unsigned char weak_keys_chksum[20] = { }; bool -des_is_weak_key (const char * key) +gl_des_is_weak_key (const char * key) { char work[8]; int i, left, right, middle, cmp_result; @@ -424,14 +424,6 @@ des_is_weak_key (const char * key) data[6] = (right >> 8) &0xff; data[7] = right &0xff; /* - * Handy macros for encryption and decryption of data - */ -#define des_ecb_encrypt(ctx, from, to) des_ecb_crypt(ctx, from, to, 0) -#define des_ecb_decrypt(ctx, from, to) des_ecb_crypt(ctx, from, to, 1) -#define tripledes_ecb_encrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,0) -#define tripledes_ecb_decrypt(ctx, from, to) tripledes_ecb_crypt(ctx,from,to,1) - -/* * des_key_schedule(): Calculate 16 subkeys pairs (even/odd) for * 16 encryption rounds. * To calculate subkeys for decryption the caller @@ -530,7 +522,7 @@ des_key_schedule (const char * _rawkey, uint32_t * subkey) } void -des_setkey (des_ctx *ctx, const char * key) +gl_des_setkey (gl_des_ctx *ctx, const char * key) { int i; @@ -544,7 +536,7 @@ des_setkey (des_ctx *ctx, const char * key) } bool -des_makekey (des_ctx *ctx, const char * key, size_t keylen) +gl_des_makekey (gl_des_ctx *ctx, const char * key, size_t keylen) { if (keylen != 8) return false; @@ -555,7 +547,7 @@ des_makekey (des_ctx *ctx, const char * key, size_t keylen) } void -des_ecb_crypt (des_ctx *ctx, const char * _from, char * _to, int mode) +gl_des_ecb_crypt (gl_des_ctx *ctx, const char * _from, char * _to, int mode) { const unsigned char *from = (const unsigned char *) _from; unsigned char *to = (unsigned char *) _to; @@ -579,7 +571,7 @@ des_ecb_crypt (des_ctx *ctx, const char * _from, char * _to, int mode) } void -tripledes_set2keys (tripledes_ctx *ctx, const char * key1, const char * key2) +gl_3des_set2keys (gl_3des_ctx *ctx, const char * key1, const char * key2) { int i; @@ -603,7 +595,7 @@ tripledes_set2keys (tripledes_ctx *ctx, const char * key1, const char * key2) } void -tripledes_set3keys (tripledes_ctx *ctx, const char * key1, +gl_3des_set3keys (gl_3des_ctx *ctx, const char * key1, const char * key2, const char * key3) { int i; @@ -626,9 +618,9 @@ tripledes_set3keys (tripledes_ctx *ctx, const char * key1, } void -tripledes_ecb_crypt (tripledes_ctx *ctx, - const char * _from, - char * _to, int mode) +gl_3des_ecb_crypt (gl_3des_ctx *ctx, + const char * _from, + char * _to, int mode) { const unsigned char *from = (const unsigned char *) _from; unsigned char *to = (unsigned char *) _to; @@ -668,12 +660,12 @@ tripledes_ecb_crypt (tripledes_ctx *ctx, } bool -tripledes_makekey (tripledes_ctx *ctx, const char * key, size_t keylen) +gl_3des_makekey (gl_3des_ctx *ctx, const char * key, size_t keylen) { if (keylen != 24) return false; - tripledes_set3keys (ctx, key, key + 8, key + 16); + gl_3des_set3keys (ctx, key, key + 8, key + 16); return !(des_is_weak_key (key) || des_is_weak_key (key + 8) |