diff lib/des.c @ 8433:51634bc628de

* 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.
author Paul Eggert <eggert@cs.ucla.edu>
date Thu, 15 Mar 2007 22:58:36 +0000
parents a88f85e4728f
children b396ac3f1039
line wrap: on
line diff
--- a/lib/des.c	Mon Mar 12 00:48:31 2007 +0000
+++ b/lib/des.c	Thu Mar 15 22:58:36 2007 +0000
@@ -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 @@
 };
 
 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 @@
     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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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)