[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS shishi/gl
From: |
shishi-commit |
Subject: |
CVS shishi/gl |
Date: |
Sat, 22 Oct 2005 17:54:48 +0200 |
Update of /home/cvs/shishi/gl
In directory dopio:/tmp/cvs-serv16026/gl
Modified Files:
Makefile.am gc-gnulib.c gc-libgcrypt.c gc-pbkdf2-sha1.c gc.h
hmac-sha1.c
Added Files:
arcfour.c arcfour.h des.c des.h hmac-md5.c md4.c md4.h md5.c
Log Message:
Update.
--- /home/cvs/shishi/gl/Makefile.am 2005/10/12 13:24:41 1.69
+++ /home/cvs/shishi/gl/Makefile.am 2005/10/22 15:54:48 1.70
@@ -8,7 +8,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl
--m4-base=gl/m4 --aux-dir=. --avoid=xalloc-die --libtool --macro-prefix=gl
base64 error gc-pbkdf2-sha1 getaddrinfo getdate gethostname getline getopt
getpass getsubopt progname realloc setenv socklen strcase strchrnul strdup
strndup strtok_r timegm vasnprintf vasprintf xalloc xgetdomainname xgethostname
xreadlink xstrndup xvasprintf
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl
--m4-base=gl/m4 --aux-dir=. --avoid=xalloc-die --libtool --macro-prefix=gl
base64 error gc-arcfour gc-des gc-hmac-md5 gc-hmac-sha1 gc-md4 gc-pbkdf2-sha1
getaddrinfo getdate gethostname getline getopt getpass getsubopt progname
realloc setenv socklen strcase strchrnul strdup strndup strtok_r timegm
vasnprintf vasprintf xalloc xgetdomainname xgethostname xreadlink xstrndup
xvasprintf
AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies
@@ -53,7 +53,11 @@
## begin gnulib module gc
+if GL_COND_LIBTOOL
+libgnu_la_LIBADD += $(LTLIBGCRYPT)
+else
libgnu_la_LIBADD += $(LIBGCRYPT)
+endif
## end gnulib module gc
--- /home/cvs/shishi/gl/gc-gnulib.c 2005/10/12 13:24:41 1.1
+++ /home/cvs/shishi/gl/gc-gnulib.c 2005/10/22 15:54:48 1.2
@@ -25,7 +25,7 @@
#endif
/* Get prototype. */
-#include <gc.h>
+#include "gc.h"
#include <stdlib.h>
#include <string.h>
@@ -37,6 +37,10 @@
#include <fcntl.h>
#include <errno.h>
+/* Hashes. */
+#ifdef GC_USE_MD4
+# include "md4.h"
+#endif
#ifdef GC_USE_MD5
# include "md5.h"
#endif
@@ -47,6 +51,20 @@
# include "hmac.h"
#endif
+/* Ciphers. */
+#ifdef GC_USE_ARCFOUR
+# include "arcfour.h"
+#endif
+#ifdef GC_USE_ARCTWO
+# include "arctwo.h"
+#endif
+#ifdef GC_USE_DES
+# include "des.h"
+#endif
+#ifdef GC_USE_RIJNDAEL
+# include "rijndael-api-fst.h"
+#endif
+
Gc_rc
gc_init (void)
{
@@ -141,6 +159,381 @@
{
return;
}
+/* Ciphers. */
+
+typedef struct _gc_cipher_ctx {
+ Gc_cipher alg;
+ Gc_cipher_mode mode;
+#ifdef GC_USE_ARCTWO
+ arctwo_context arctwoContext;
+ char arctwoIV[ARCTWO_BLOCK_SIZE];
+#endif
+#ifdef GC_USE_ARCFOUR
+ arcfour_context arcfourContext;
+#endif
+#ifdef GC_USE_DES
+ des_ctx desContext;
+#endif
+#ifdef GC_USE_RIJNDAEL
+ rijndaelKeyInstance aesEncKey;
+ rijndaelKeyInstance aesDecKey;
+ rijndaelCipherInstance aesContext;
+#endif
+} _gc_cipher_ctx;
+
+Gc_rc
+gc_cipher_open (Gc_cipher alg, Gc_cipher_mode mode,
+ gc_cipher_handle * outhandle)
+{
+ _gc_cipher_ctx *ctx;
+ Gc_rc rc = GC_OK;
+
+ ctx = calloc (sizeof (*ctx), 1);
+
+ ctx->alg = alg;
+ ctx->mode = mode;
+
+ switch (alg)
+ {
+#ifdef GC_USE_ARCTWO
+ case GC_ARCTWO40:
+ switch (mode)
+ {
+ case GC_ECB:
+ case GC_CBC:
+ break;
+
+ default:
+ rc = GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+#ifdef GC_USE_ARCFOUR
+ case GC_ARCFOUR128:
+ case GC_ARCFOUR40:
+ switch (mode)
+ {
+ case GC_STREAM:
+ break;
+
+ default:
+ rc = GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+#ifdef GC_USE_DES
+ case GC_DES:
+ switch (mode)
+ {
+ case GC_ECB:
+ break;
+
+ default:
+ rc = GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+#ifdef GC_USE_RIJNDAEL
+ case GC_AES128:
+ case GC_AES192:
+ case GC_AES256:
+ switch (mode)
+ {
+ case GC_ECB:
+ case GC_CBC:
+ break;
+
+ default:
+ rc = GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+ default:
+ rc = GC_INVALID_CIPHER;
+ }
+
+ if (rc == GC_OK)
+ *outhandle = ctx;
+ else
+ free (ctx);
+
+ return rc;
+}
+
+Gc_rc
+gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
+{
+ _gc_cipher_ctx *ctx = handle;
+
+ switch (ctx->alg)
+ {
+#ifdef GC_USE_ARCTWO
+ case GC_ARCTWO40:
+ arctwo_setkey (&ctx->arctwoContext, keylen, key);
+ break;
+#endif
+
+#ifdef GC_USE_ARCFOUR
+ case GC_ARCFOUR128:
+ case GC_ARCFOUR40:
+ arcfour_setkey (&ctx->arcfourContext, key, keylen);
+ break;
+#endif
+
+#ifdef GC_USE_DES
+ case GC_DES:
+ if (keylen != 8)
+ return GC_INVALID_CIPHER;
+ des_setkey (&ctx->desContext, key);
+ break;
+#endif
+
+#ifdef GC_USE_RIJNDAEL
+ case GC_AES128:
+ case GC_AES192:
+ case GC_AES256:
+ {
+ rijndael_rc rc;
+ size_t i;
+ char keyMaterial[RIJNDAEL_MAX_KEY_SIZE + 1];
+
+ for (i = 0; i < keylen; i++)
+ sprintf (&keyMaterial[2*i], "%02x", key[i] & 0xFF);
+
+ rc = rijndaelMakeKey (&ctx->aesEncKey, RIJNDAEL_DIR_ENCRYPT,
+ keylen * 8, keyMaterial);
+ if (rc < 0)
+ return GC_INVALID_CIPHER;
+
+ rc = rijndaelMakeKey (&ctx->aesDecKey, RIJNDAEL_DIR_DECRYPT,
+ keylen * 8, keyMaterial);
+ if (rc < 0)
+ return GC_INVALID_CIPHER;
+
+ rc = rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_ECB, NULL);
+ if (rc < 0)
+ return GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
+{
+ _gc_cipher_ctx *ctx = handle;
+
+ switch (ctx->alg)
+ {
+#ifdef GC_USE_ARCTWO
+ case GC_ARCTWO40:
+ if (ivlen != ARCTWO_BLOCK_SIZE)
+ return GC_INVALID_CIPHER;
+ memcpy (ctx->arctwoIV, iv, ivlen);
+ break;
+#endif
+
+#ifdef GC_USE_RIJNDAEL
+ case GC_AES128:
+ case GC_AES192:
+ case GC_AES256:
+ switch (ctx->mode)
+ {
+ case GC_ECB:
+ /* Doesn't use IV. */
+ break;
+
+ case GC_CBC:
+ {
+ rijndael_rc rc;
+ size_t i;
+ char ivMaterial[2 * RIJNDAEL_MAX_IV_SIZE + 1];
+
+ for (i = 0; i < ivlen; i++)
+ sprintf (&ivMaterial[2*i], "%02x", iv[i] & 0xFF);
+
+ rc = rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_CBC,
+ ivMaterial);
+ if (rc < 0)
+ return GC_INVALID_CIPHER;
+ }
+ break;
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+{
+ _gc_cipher_ctx *ctx = handle;
+
+ switch (ctx->alg)
+ {
+#ifdef GC_USE_ARCTWO
+ case GC_ARCTWO40:
+ switch (ctx->mode)
+ {
+ case GC_ECB:
+ arctwo_encrypt (&ctx->arctwoContext, data, data, len);
+ break;
+
+ case GC_CBC:
+ for (; len >= ARCTWO_BLOCK_SIZE; len -= ARCTWO_BLOCK_SIZE,
+ data += ARCTWO_BLOCK_SIZE)
+ {
+ size_t i;
+ for (i = 0; i < ARCTWO_BLOCK_SIZE; i++)
+ data[i] ^= ctx->arctwoIV[i];
+ arctwo_encrypt (&ctx->arctwoContext, data, data,
+ ARCTWO_BLOCK_SIZE);
+ memcpy (ctx->arctwoIV, data, ARCTWO_BLOCK_SIZE);
+ }
+ break;
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+#ifdef GC_USE_ARCFOUR
+ case GC_ARCFOUR128:
+ case GC_ARCFOUR40:
+ arcfour_stream (&ctx->arcfourContext, data, data, len);
+ break;
+#endif
+
+#ifdef GC_USE_DES
+ case GC_DES:
+ for (; len >= 8; len -= 8, data += 8)
+ des_ecb_encrypt (&ctx->desContext, data, data);
+ break;
+#endif
+
+#ifdef GC_USE_RIJNDAEL
+ case GC_AES128:
+ case GC_AES192:
+ case GC_AES256:
+ {
+ int nblocks;
+
+ nblocks = rijndaelBlockEncrypt (&ctx->aesContext, &ctx->aesEncKey,
+ data, 8 * len, data);
+ if (nblocks < 0)
+ return GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+{
+ _gc_cipher_ctx *ctx = handle;
+
+ switch (ctx->alg)
+ {
+#ifdef GC_USE_ARCTWO
+ case GC_ARCTWO40:
+ switch (ctx->mode)
+ {
+ case GC_ECB:
+ arctwo_decrypt (&ctx->arctwoContext, data, data, len);
+ break;
+
+ case GC_CBC:
+ for (; len >= ARCTWO_BLOCK_SIZE; len -= ARCTWO_BLOCK_SIZE,
+ data += ARCTWO_BLOCK_SIZE)
+ {
+ char tmpIV[ARCTWO_BLOCK_SIZE];
+ size_t i;
+ memcpy (tmpIV, data, ARCTWO_BLOCK_SIZE);
+ arctwo_decrypt (&ctx->arctwoContext, data, data,
+ ARCTWO_BLOCK_SIZE);
+ for (i = 0; i < ARCTWO_BLOCK_SIZE; i++)
+ data[i] ^= ctx->arctwoIV[i];
+ memcpy (ctx->arctwoIV, tmpIV, ARCTWO_BLOCK_SIZE);
+ }
+ break;
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+ break;
+#endif
+
+#ifdef GC_USE_ARCFOUR
+ case GC_ARCFOUR128:
+ case GC_ARCFOUR40:
+ arcfour_stream (&ctx->arcfourContext, data, data, len);
+ break;
+#endif
+
+#ifdef GC_USE_DES
+ case GC_DES:
+ for (; len >= 8; len -= 8, data += 8)
+ des_ecb_decrypt (&ctx->desContext, data, data);
+ break;
+#endif
+
+#ifdef GC_USE_RIJNDAEL
+ case GC_AES128:
+ case GC_AES192:
+ case GC_AES256:
+ {
+ int nblocks;
+
+ nblocks = rijndaelBlockDecrypt (&ctx->aesContext, &ctx->aesDecKey,
+ data, 8 * len, data);
+ if (nblocks < 0)
[54 lines skipped]
--- /home/cvs/shishi/gl/gc-libgcrypt.c 2005/10/12 13:24:41 1.1
+++ /home/cvs/shishi/gl/gc-libgcrypt.c 2005/10/22 15:54:48 1.2
@@ -94,15 +94,263 @@
func_realloc, func_free);
}
+/* Ciphers. */
+
+Gc_rc
+gc_cipher_open (Gc_cipher alg, Gc_cipher_mode mode,
+ gc_cipher_handle * outhandle)
+{
+ int gcryalg, gcrymode;
+ gcry_error_t err;
+
+ switch (alg)
+ {
+ case GC_AES128:
+ gcryalg = GCRY_CIPHER_RIJNDAEL;
+ break;
+
+ case GC_AES192:
+ gcryalg = GCRY_CIPHER_RIJNDAEL;
+ break;
+
+ case GC_AES256:
+ gcryalg = GCRY_CIPHER_RIJNDAEL256;
+ break;
+
+ case GC_3DES:
+ gcryalg = GCRY_CIPHER_3DES;
+ break;
+
+ case GC_DES:
+ gcryalg = GCRY_CIPHER_DES;
+ break;
+
+ case GC_ARCFOUR128:
+ case GC_ARCFOUR40:
+ gcryalg = GCRY_CIPHER_ARCFOUR;
+ break;
+
+ case GC_ARCTWO40:
+ gcryalg = GCRY_CIPHER_RFC2268_40;
+ break;
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+
+ switch (mode)
+ {
+ case GC_ECB:
+ gcrymode = GCRY_CIPHER_MODE_ECB;
+ break;
+
+ case GC_CBC:
+ gcrymode = GCRY_CIPHER_MODE_CBC;
+ break;
+
+ case GC_STREAM:
+ gcrymode = GCRY_CIPHER_MODE_STREAM;
+ break;
+
+ default:
+ return GC_INVALID_CIPHER;
+ }
+
+ err = gcry_cipher_open ((gcry_cipher_hd_t *) outhandle,
+ gcryalg, gcrymode, 0);
+ if (gcry_err_code (err))
+ return GC_INVALID_CIPHER;
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_setkey (gc_cipher_handle handle, size_t keylen, const char *key)
+{
+ gcry_error_t err;
+
+ err = gcry_cipher_setkey ((gcry_cipher_hd_t) handle, key, keylen);
+ if (gcry_err_code (err))
+ return GC_INVALID_CIPHER;
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_setiv (gc_cipher_handle handle, size_t ivlen, const char *iv)
+{
+ gcry_error_t err;
+
+ err = gcry_cipher_setiv ((gcry_cipher_hd_t) handle, iv, ivlen);
+ if (gcry_err_code (err))
+ return GC_INVALID_CIPHER;
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_encrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+{
+ if (gcry_cipher_encrypt ((gcry_cipher_hd_t) handle,
+ data, len, NULL, len) != 0)
+ return GC_INVALID_CIPHER;
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_decrypt_inline (gc_cipher_handle handle, size_t len, char *data)
+{
+ if (gcry_cipher_decrypt ((gcry_cipher_hd_t) handle,
+ data, len, NULL, len) != 0)
+ return GC_INVALID_CIPHER;
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_cipher_close (gc_cipher_handle handle)
+{
+ gcry_cipher_close (handle);
+
+ return GC_OK;
+}
+
/* Hashes. */
Gc_rc
+gc_hash_open (Gc_hash hash, Gc_hash_mode mode, gc_hash_handle * outhandle)
+{
+ int gcryalg, gcrymode;
+ gcry_error_t err;
+
+ switch (hash)
+ {
+ case GC_MD4:
+ gcryalg = GCRY_MD_MD4;
+ break;
+
+ case GC_MD5:
+ gcryalg = GCRY_MD_MD5;
+ break;
+
+ case GC_SHA1:
+ gcryalg = GCRY_MD_SHA1;
+ break;
+
+ case GC_RMD160:
+ gcryalg = GCRY_MD_RMD160;
+ break;
+
+ default:
+ return GC_INVALID_HASH;
+ }
+
+ switch (mode)
+ {
+ case 0:
+ gcrymode = 0;
+ break;
+
+ case GC_HMAC:
+ gcrymode = GCRY_MD_FLAG_HMAC;
+ break;
+
+ default:
+ return GC_INVALID_HASH;
+ }
+
+ err = gcry_md_open ((gcry_md_hd_t *) outhandle, gcryalg, gcrymode);
+ if (gcry_err_code (err))
+ return GC_INVALID_HASH;
+
+ return GC_OK;
+}
+
+Gc_rc
+gc_hash_clone (gc_hash_handle handle, gc_hash_handle * outhandle)
+{
+ int err;
+
+ err = gcry_md_copy ((gcry_md_hd_t *) outhandle, (gcry_md_hd_t) handle);
+ if (err)
+ return GC_INVALID_HASH;
+
+ return GC_OK;
+}
+
+size_t
+gc_hash_digest_length (Gc_hash hash)
+{
+ int gcryalg;
+
+ switch (hash)
+ {
+ case GC_MD4:
+ gcryalg = GCRY_MD_MD4;
+ break;
+
+ case GC_MD5:
+ gcryalg = GCRY_MD_MD5;
+ break;
+
+ case GC_SHA1:
+ gcryalg = GCRY_MD_SHA1;
+ break;
+
+ case GC_RMD160:
+ gcryalg = GCRY_MD_RMD160;
+ break;
+
+ default:
+ return 0;
+ }
+
+ return gcry_md_get_algo_dlen (gcryalg);
+}
+
+void
+gc_hash_hmac_setkey (gc_hash_handle handle, size_t len, const char *key)
+{
+ gcry_md_setkey ((gcry_md_hd_t) handle, key, len);
+}
+
+void
+gc_hash_write (gc_hash_handle handle, size_t len, const char *data)
+{
+ gcry_md_write ((gcry_md_hd_t) handle, data, len);
+}
+
+const char *
+gc_hash_read (gc_hash_handle handle)
+{
+ const char *digest;
+
+ gcry_md_final ((gcry_md_hd_t) handle);
+ digest = gcry_md_read ((gcry_md_hd_t) handle, 0);
+
+ return digest;
+}
+
+void
+gc_hash_close (gc_hash_handle handle)
+{
+ gcry_md_close ((gcry_md_hd_t) handle);
+}
+
+Gc_rc
gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *resbuf)
{
int gcryalg;
switch (hash)
{
+#ifdef GC_USE_MD4
+ case GC_MD4:
+ gcryalg = GCRY_MD_MD4;
+ break;
+#endif
+
#ifdef GC_USE_MD5
case GC_MD5:
gcryalg = GCRY_MD_MD5;
@@ -115,6 +363,12 @@
break;
#endif
+#ifdef GC_USE_RMD160
+ case GC_RMD160:
+ gcryalg = GCRY_MD_RMD160;
+ break;
+#endif
+
default:
return GC_INVALID_HASH;
}
@@ -126,6 +380,38 @@
/* One-call interface. */
+#ifdef GC_USE_MD4
+Gc_rc
+gc_md4 (const void *in, size_t inlen, void *resbuf)
+{
+ size_t outlen = gcry_md_get_algo_dlen (GCRY_MD_MD4);
+ gcry_md_hd_t hd;
+ gpg_error_t err;
+ unsigned char *p;
+
+ assert (outlen == GC_MD4_DIGEST_SIZE);
+
+ err = gcry_md_open (&hd, GCRY_MD_MD4, 0);
+ if (err != GPG_ERR_NO_ERROR)
+ return GC_INVALID_HASH;
+
+ gcry_md_write (hd, in, inlen);
+
+ p = gcry_md_read (hd, GCRY_MD_MD4);
+ if (p == NULL)
+ {
+ gcry_md_close (hd);
+ return GC_INVALID_HASH;
+ }
+
+ memcpy (resbuf, p, outlen);
+
+ gcry_md_close (hd);
+
+ return GC_OK;
+}
+#endif
+
#ifdef GC_USE_MD5
Gc_rc
gc_md5 (const void *in, size_t inlen, void *resbuf)
@@ -240,7 +526,7 @@
unsigned char *hash;
gpg_error_t err;
- assert (hlen == 16);
+ assert (hlen == GC_SHA1_DIGEST_SIZE);
err = gcry_md_open (&mdh, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
if (err != GPG_ERR_NO_ERROR)
--- /home/cvs/shishi/gl/gc-pbkdf2-sha1.c 2005/10/12 13:24:41 1.1
+++ /home/cvs/shishi/gl/gc-pbkdf2-sha1.c 2005/10/22 15:54:48 1.2
@@ -68,6 +68,8 @@
unsigned int i;
unsigned int k;
int rc;
+ char *tmp;
+ size_t tmplen = Slen + 4;
if (c == 0)
return GC_PKCS5_INVALID_ITERATION_COUNT;
@@ -98,9 +100,7 @@
* integer greater than, or equal to, x.
*/
- l = dkLen / hLen;
- if (dkLen % hLen)
- l++;
+ l = ((dkLen - 1) / hLen) + 1;
r = dkLen - (l - 1) * hLen;
/*
@@ -145,6 +145,12 @@
*
*/
+ tmp = malloc (tmplen);
+ if (tmp == NULL)
+ return GC_MALLOC_ERROR;
+
+ memcpy (tmp, S, Slen);
+
for (i = 1; i <= l; i++)
{
memset (T, 0, hLen);
@@ -153,28 +159,21 @@
{
if (u == 1)
{
- char *tmp;
- size_t tmplen = Slen + 4;
-
- tmp = malloc (tmplen);
- if (tmp == NULL)
- return GC_MALLOC_ERROR;
-
- memcpy (tmp, S, Slen);
tmp[Slen + 0] = (i & 0xff000000) >> 24;
tmp[Slen + 1] = (i & 0x00ff0000) >> 16;
tmp[Slen + 2] = (i & 0x0000ff00) >> 8;
tmp[Slen + 3] = (i & 0x000000ff) >> 0;
rc = gc_hmac_sha1 (P, Plen, tmp, tmplen, U);
-
- free (tmp);
}
else
rc = gc_hmac_sha1 (P, Plen, U, hLen, U);
if (rc != GC_OK)
- return rc;
+ {
+ free (tmp);
+ return rc;
+ }
for (k = 0; k < hLen; k++)
T[k] ^= U[k];
@@ -183,5 +182,7 @@
memcpy (DK + (i - 1) * hLen, T, i == l ? r : hLen);
}
+ free (tmp);
+
return GC_OK;
}
--- /home/cvs/shishi/gl/gc.h 2005/10/12 13:24:41 1.1
+++ /home/cvs/shishi/gl/gc.h 2005/10/22 15:54:48 1.2
@@ -25,30 +25,66 @@
# include <stddef.h>
enum Gc_rc
- {
- GC_OK = 0,
- GC_MALLOC_ERROR,
- GC_INIT_ERROR,
- GC_RANDOM_ERROR,
- GC_INVALID_CIPHER,
- GC_INVALID_HASH,
- GC_PKCS5_INVALID_ITERATION_COUNT,
- GC_PKCS5_INVALID_DERIVED_KEY_LENGTH,
- GC_PKCS5_DERIVED_KEY_TOO_LONG
- };
+{
+ GC_OK = 0,
+ GC_MALLOC_ERROR,
+ GC_INIT_ERROR,
+ GC_RANDOM_ERROR,
+ GC_INVALID_CIPHER,
+ GC_INVALID_HASH,
+ GC_PKCS5_INVALID_ITERATION_COUNT,
+ GC_PKCS5_INVALID_DERIVED_KEY_LENGTH,
+ GC_PKCS5_DERIVED_KEY_TOO_LONG
+};
typedef enum Gc_rc Gc_rc;
/* Hash types. */
enum Gc_hash
- {
- GC_MD5,
- GC_SHA1
- };
+{
+ GC_MD4,
+ GC_MD5,
+ GC_SHA1,
+ GC_MD2,
+ GC_RMD160
+};
typedef enum Gc_hash Gc_hash;
+enum Gc_hash_mode
+{
+ GC_HMAC = 1
+};
+typedef enum Gc_hash_mode Gc_hash_mode;
+
+typedef void *gc_hash_handle;
+
+#define GC_MD4_DIGEST_SIZE 16
#define GC_MD5_DIGEST_SIZE 16
#define GC_SHA1_DIGEST_SIZE 20
+/* Cipher types. */
+enum Gc_cipher
+{
+ GC_AES128,
+ GC_AES192,
+ GC_AES256,
+ GC_3DES,
+ GC_DES,
+ GC_ARCFOUR128,
+ GC_ARCFOUR40,
+ GC_ARCTWO40
+};
+typedef enum Gc_cipher Gc_cipher;
+
+enum Gc_cipher_mode
+{
+ GC_ECB,
+ GC_CBC,
+ GC_STREAM
+};
+typedef enum Gc_cipher_mode Gc_cipher_mode;
+
+typedef void *gc_cipher_handle;
+
/* Call before respectively after any other functions. */
extern Gc_rc gc_init (void);
extern void gc_done (void);
@@ -64,8 +100,37 @@
gc_realloc_t func_realloc,
gc_free_t func_free);
+/* Randomness. */
+extern Gc_rc gc_nonce (char *data, size_t datalen);
+extern Gc_rc gc_pseudo_random (char *data, size_t datalen);
+extern Gc_rc gc_random (char *data, size_t datalen);
+
+/* Ciphers. */
+extern Gc_rc gc_cipher_open (Gc_cipher cipher, Gc_cipher_mode mode,
+ gc_cipher_handle *outhandle);
+extern Gc_rc gc_cipher_setkey (gc_cipher_handle handle,
+ size_t keylen, const char *key);
+extern Gc_rc gc_cipher_setiv (gc_cipher_handle handle,
+ size_t ivlen, const char *iv);
+extern Gc_rc gc_cipher_encrypt_inline (gc_cipher_handle handle,
+ size_t len, char *data);
+extern Gc_rc gc_cipher_decrypt_inline (gc_cipher_handle handle,
+ size_t len, char *data);
+extern Gc_rc gc_cipher_close (gc_cipher_handle handle);
+
/* Hashes. */
+extern Gc_rc gc_hash_open (Gc_hash hash, Gc_hash_mode mode,
+ gc_hash_handle *outhandle);
+extern Gc_rc gc_hash_clone (gc_hash_handle handle, gc_hash_handle *outhandle);
+extern size_t gc_hash_digest_length (Gc_hash hash);
+extern void gc_hash_hmac_setkey (gc_hash_handle handle,
+ size_t len, const char *key);
+extern void gc_hash_write (gc_hash_handle handle,
+ size_t len, const char *data);
+extern const char *gc_hash_read (gc_hash_handle handle);
+extern void gc_hash_close (gc_hash_handle handle);
+
/* Compute a hash value over buffer IN of INLEN bytes size using the
algorithm HASH, placing the result in the pre-allocated buffer OUT.
The required size of OUT depends on HASH, and is generally
@@ -79,11 +144,9 @@
extern Gc_rc gc_md5 (const void *in, size_t inlen, void *resbuf);
extern Gc_rc gc_sha1 (const void *in, size_t inlen, void *resbuf);
extern Gc_rc gc_hmac_md5 (const void *key, size_t keylen,
- const void *in, size_t inlen,
- char *resbuf);
+ const void *in, size_t inlen, char *resbuf);
extern Gc_rc gc_hmac_sha1 (const void *key, size_t keylen,
- const void *in, size_t inlen,
- char *resbuf);
+ const void *in, size_t inlen, char *resbuf);
/* Derive cryptographic keys from a password P of length PLEN, with
salt S of length SLEN, placing the result in pre-allocated buffer
@@ -95,8 +158,7 @@
extern Gc_rc
gc_pbkdf2_sha1 (const char *P, size_t Plen,
const char *S, size_t Slen,
- unsigned int c,
- char *DK, size_t dkLen);
+ unsigned int c, char *DK, size_t dkLen);
/*
TODO:
@@ -112,7 +174,7 @@
> Simon Josefsson <address@hidden> writes:
>
- >> * Perhaps the /dev/*random reading should be separated into a separate
+ >> * Perhaps the /dev/?random reading should be separated into a separate
>> module? It might be useful outside of the gc layer too.
>
> Absolutely. I've been meaning to do that for months (for a "shuffle"
@@ -123,9 +185,9 @@
I'll write a separate module for that part.
I think we should even add a good PRNG that is re-seeded from
- /dev/*random frequently. GnuTLS can need a lot of random data on a
+ /dev/?random frequently. GnuTLS can need a lot of random data on a
big server, more than /dev/random can supply. And /dev/urandom might
- not be strong enough. Further, the security of /dev/*random can also
+ not be strong enough. Further, the security of /dev/?random can also
be questionable.
>> I'm also not sure about the names of those functions, they suggest
@@ -163,12 +225,12 @@
it isn't called too often. You can guess what the next value will be,
but it will always be different.
- The problem is that /dev/*random doesn't offer any kind of semantic
+ The problem is that /dev/?random doesn't offer any kind of semantic
guarantees. But applications need an API that make that promise.
I think we should do this in several steps:
- 1) Write a module that can read from /dev/*random.
+ 1) Write a module that can read from /dev/?random.
2) Add a module for a known-good PRNG suitable for random number
generation, that can be continuously re-seeded.
--- /home/cvs/shishi/gl/hmac-sha1.c 2005/10/12 13:24:41 1.1
+++ /home/cvs/shishi/gl/hmac-sha1.c 2005/10/22 15:54:48 1.2
@@ -23,6 +23,7 @@
#include "hmac.h"
+#include "memxor.h"
#include "sha1.h"
#include <string.h>
@@ -40,6 +41,8 @@
char block[64];
char innerhash[20];
+ /* Reduce the key's size, so that it becomes <= 64 bytes large. */
+
if (keylen > 64)
{
struct sha1_ctx keyhash;
@@ -52,6 +55,8 @@
keylen = 20;
}
+ /* Compute INNERHASH from KEY and IN. */
+
sha1_init_ctx (&inner);
memset (block, IPAD, sizeof (block));
@@ -62,6 +67,8 @@
sha1_finish_ctx (&inner, innerhash);
+ /* Compute result from KEY and INNERHASH. */
+
sha1_init_ctx (&outer);
memset (block, OPAD, sizeof (block));
--- /home/cvs/shishi/gl/arcfour.c 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/arcfour.c 2005/10/22 15:54:48 1.1
/* arcfour.c --- The arcfour stream cipher
* Copyright (C) 2000, 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2, or (at your
* option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*/
/* Code from Libgcrypt adapted for gnulib by Simon Josefsson. */
/*
* For a description of the algorithm, see:
* Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996.
* ISBN 0-471-11709-9. Pages 397 ff.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "arcfour.h"
void
arcfour_stream (arcfour_context * context, const char *inbuf, char *outbuf,
size_t length)
{
size_t i = context->idx_i;
size_t j = context->idx_j;
char *sbox = context->sbox;
for (; length > 0; length--)
{
char t;
i = (i + 1) % ARCFOUR_SBOX_SIZE;
j = (j + sbox[i]) % ARCFOUR_SBOX_SIZE;
t = sbox[i];
sbox[i] = sbox[j];
sbox[j] = t;
*outbuf++ = (*inbuf++
^ sbox[(0U + sbox[i] + sbox[j]) % ARCFOUR_SBOX_SIZE]);
}
context->idx_i = i;
context->idx_j = j;
}
void
arcfour_setkey (arcfour_context * context, const char *key, size_t keylen)
{
size_t i, j, k;
char *sbox = context->sbox;
context->idx_i = context->idx_j = 0;
for (i = 0; i < ARCFOUR_SBOX_SIZE; i++)
sbox[i] = i;
for (i = j = k = 0; i < ARCFOUR_SBOX_SIZE; i++)
{
char t;
j = (j + sbox[i] + key[k]) % ARCFOUR_SBOX_SIZE;
t = sbox[i];
sbox[i] = sbox[j];
sbox[j] = t;
if (++k == keylen)
k = 0;
}
}
--- /home/cvs/shishi/gl/arcfour.h 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/arcfour.h 2005/10/22 15:54:48 1.1
/* arcfour.h --- The arcfour stream cipher
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
* Free Software Foundation, Inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2, or (at your
* option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*/
/* Code from Libgcrypt adapted for gnulib by Simon Josefsson. */
#ifndef ARCFOUR_H
# define ARCFOUR_H
# include <stddef.h>
#define ARCFOUR_SBOX_SIZE 256
typedef struct
{
size_t idx_i, idx_j;
char sbox[ARCFOUR_SBOX_SIZE];
} arcfour_context;
/* Apply ARCFOUR stream to INBUF placing the result in OUTBUF, both of
LENGTH size. CONTEXT must be initialized with arcfour_setkey
before this function is called. */
extern void
arcfour_stream (arcfour_context * context,
const char *inbuf, char *outbuf, size_t length);
/* Initialize CONTEXT using encryption KEY of KEYLEN bytes. KEY
should be 40 bits (5 bytes) or longer. The KEY cannot be zero
length. */
extern void
arcfour_setkey (arcfour_context * context, const char *key, size_t keylen);
#endif /* ARCFOUR_H */
--- /home/cvs/shishi/gl/des.c 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/des.c 2005/10/22 15:54:48 1.1
/* des.c --- DES and Triple-DES encryption/decryption Algorithm
* Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005
* Free Software Foundation, Inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2, or (at your
* option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this file; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*/
/* Adapted for gnulib by Simon Josefsson, based on Libgcrypt. */
/*
* For a description of triple encryption, see:
* Bruce Schneier: Applied Cryptography. Second Edition.
* John Wiley & Sons, 1996. ISBN 0-471-12845-7. Pages 358 ff.
* This implementation is according to the definition of DES in FIPS
* PUB 46-2 from December 1993.
*
* Written by Michael Roth <address@hidden>, September 1998
*/
/*
* U S A G E
* ===========
*
* For DES or Triple-DES encryption/decryption you must initialize a proper
* encryption context with a key.
*
* A DES key is 64bit wide but only 56bits of the key are used. The remaining
* bits are parity bits and they will _not_ checked in this implementation, but
* simply ignored.
*
* For Triple-DES you could use either two 64bit keys or three 64bit keys.
* The parity bits will _not_ checked, too.
*
* After initializing a context with a key you could use this context to
* encrypt or decrypt data in 64bit blocks in Electronic Codebook Mode.
*
* DES Example
* -----------
* unsigned char key[8];
* unsigned char plaintext[8];
* unsigned char ciphertext[8];
* unsigned char recoverd[8];
* des_ctx context;
*
* // Fill 'key' and 'plaintext' with some data
* ....
*
* // Set up the DES encryption context
* des_setkey(&context, key);
*
* // Encrypt the plaintext
* des_ecb_encrypt(&context, plaintext, ciphertext);
*
* // To recover the orginal plaintext from ciphertext use:
* des_ecb_decrypt(&context, ciphertext, recoverd);
*
*
* Triple-DES Example
* ------------------
* unsigned char key1[8];
* unsigned char key2[8];
* unsigned char key3[8];
* unsigned char plaintext[8];
* unsigned char ciphertext[8];
* unsigned char recoverd[8];
* tripledes_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);
*
* // To use three 64bit keys with Triple-DES use:
* tripledes_set3keys(&context, key1, key2, key3);
*
* // Encrypting plaintext with Triple-DES
* tripledes_ecb_encrypt(&context, plaintext, ciphertext);
*
* // Decrypting ciphertext to recover the plaintext with Triple-DES
* tripledes_ecb_decrypt(&context, ciphertext, recoverd);
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "des.h"
#include <stdio.h>
#include <string.h> /* memcpy, memcmp */
/*
* The s-box values are permuted according to the 'primitive function P'
* and are rotated one bit to the left.
*/
static const uint32_t sbox1[64] = {
0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404,
0x00000004, 0x00010000, 0x00000400, 0x01010400, 0x01010404, 0x00000400,
0x01000404, 0x01010004, 0x01000000, 0x00000004, 0x00000404, 0x01000400,
0x01000400, 0x00010400, 0x00010400, 0x01010000, 0x01010000, 0x01000404,
0x00010004, 0x01000004, 0x01000004, 0x00010004, 0x00000000, 0x00000404,
0x00010404, 0x01000000, 0x00010000, 0x01010404, 0x00000004, 0x01010000,
0x01010400, 0x01000000, 0x01000000, 0x00000400, 0x01010004, 0x00010000,
0x00010400, 0x01000004, 0x00000400, 0x00000004, 0x01000404, 0x00010404,
0x01010404, 0x00010004, 0x01010000, 0x01000404, 0x01000004, 0x00000404,
0x00010404, 0x01010400, 0x00000404, 0x01000400, 0x01000400, 0x00000000,
0x00010004, 0x00010400, 0x00000000, 0x01010004
};
static const uint32_t sbox2[64] = {
0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020,
0x80100020, 0x80008020, 0x80000020, 0x80108020, 0x80108000, 0x80000000,
0x80008000, 0x00100000, 0x00000020, 0x80100020, 0x00108000, 0x00100020,
0x80008020, 0x00000000, 0x80000000, 0x00008000, 0x00108020, 0x80100000,
0x00100020, 0x80000020, 0x00000000, 0x00108000, 0x00008020, 0x80108000,
0x80100000, 0x00008020, 0x00000000, 0x00108020, 0x80100020, 0x00100000,
0x80008020, 0x80100000, 0x80108000, 0x00008000, 0x80100000, 0x80008000,
0x00000020, 0x80108020, 0x00108020, 0x00000020, 0x00008000, 0x80000000,
0x00008020, 0x80108000, 0x00100000, 0x80000020, 0x00100020, 0x80008020,
0x80000020, 0x00100020, 0x00108000, 0x00000000, 0x80008000, 0x00008020,
0x80000000, 0x80100020, 0x80108020, 0x00108000
};
static const uint32_t sbox3[64] = {
0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000,
0x00020208, 0x08000200, 0x00020008, 0x08000008, 0x08000008, 0x00020000,
0x08020208, 0x00020008, 0x08020000, 0x00000208, 0x08000000, 0x00000008,
0x08020200, 0x00000200, 0x00020200, 0x08020000, 0x08020008, 0x00020208,
0x08000208, 0x00020200, 0x00020000, 0x08000208, 0x00000008, 0x08020208,
0x00000200, 0x08000000, 0x08020200, 0x08000000, 0x00020008, 0x00000208,
0x00020000, 0x08020200, 0x08000200, 0x00000000, 0x00000200, 0x00020008,
0x08020208, 0x08000200, 0x08000008, 0x00000200, 0x00000000, 0x08020008,
0x08000208, 0x00020000, 0x08000000, 0x08020208, 0x00000008, 0x00020208,
0x00020200, 0x08000008, 0x08020000, 0x08000208, 0x00000208, 0x08020000,
0x00020208, 0x00000008, 0x08020008, 0x00020200
};
static const uint32_t sbox4[64] = {
0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081,
0x00800001, 0x00002001, 0x00000000, 0x00802000, 0x00802000, 0x00802081,
0x00000081, 0x00000000, 0x00800080, 0x00800001, 0x00000001, 0x00002000,
0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002001, 0x00002080,
0x00800081, 0x00000001, 0x00002080, 0x00800080, 0x00002000, 0x00802080,
0x00802081, 0x00000081, 0x00800080, 0x00800001, 0x00802000, 0x00802081,
0x00000081, 0x00000000, 0x00000000, 0x00802000, 0x00002080, 0x00800080,
0x00800081, 0x00000001, 0x00802001, 0x00002081, 0x00002081, 0x00000080,
0x00802081, 0x00000081, 0x00000001, 0x00002000, 0x00800001, 0x00002001,
0x00802080, 0x00800081, 0x00002001, 0x00002080, 0x00800000, 0x00802001,
0x00000080, 0x00800000, 0x00002000, 0x00802080
};
static const uint32_t sbox5[64] = {
0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100,
0x40000000, 0x02080000, 0x40080100, 0x00080000, 0x02000100, 0x40080100,
0x42000100, 0x42080000, 0x00080100, 0x40000000, 0x02000000, 0x40080000,
0x40080000, 0x00000000, 0x40000100, 0x42080100, 0x42080100, 0x02000100,
0x42080000, 0x40000100, 0x00000000, 0x42000000, 0x02080100, 0x02000000,
0x42000000, 0x00080100, 0x00080000, 0x42000100, 0x00000100, 0x02000000,
0x40000000, 0x02080000, 0x42000100, 0x40080100, 0x02000100, 0x40000000,
0x42080000, 0x02080100, 0x40080100, 0x00000100, 0x02000000, 0x42080000,
0x42080100, 0x00080100, 0x42000000, 0x42080100, 0x02080000, 0x00000000,
0x40080000, 0x42000000, 0x00080100, 0x02000100, 0x40000100, 0x00080000,
0x00000000, 0x40080000, 0x02080100, 0x40000100
};
static const uint32_t sbox6[64] = {
0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010,
0x20404010, 0x00400000, 0x20004000, 0x00404010, 0x00400000, 0x20000010,
0x00400010, 0x20004000, 0x20000000, 0x00004010, 0x00000000, 0x00400010,
0x20004010, 0x00004000, 0x00404000, 0x20004010, 0x00000010, 0x20400010,
0x20400010, 0x00000000, 0x00404010, 0x20404000, 0x00004010, 0x00404000,
0x20404000, 0x20000000, 0x20004000, 0x00000010, 0x20400010, 0x00404000,
0x20404010, 0x00400000, 0x00004010, 0x20000010, 0x00400000, 0x20004000,
0x20000000, 0x00004010, 0x20000010, 0x20404010, 0x00404000, 0x20400000,
0x00404010, 0x20404000, 0x00000000, 0x20400010, 0x00000010, 0x00004000,
0x20400000, 0x00404010, 0x00004000, 0x00400010, 0x20004010, 0x00000000,
0x20404000, 0x20000000, 0x00400010, 0x20004010
};
static const uint32_t sbox7[64] = {
0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802,
0x00200802, 0x04200800, 0x04200802, 0x00200000, 0x00000000, 0x04000002,
0x00000002, 0x04000000, 0x04200002, 0x00000802, 0x04000800, 0x00200802,
0x00200002, 0x04000800, 0x04000002, 0x04200000, 0x04200800, 0x00200002,
0x04200000, 0x00000800, 0x00000802, 0x04200802, 0x00200800, 0x00000002,
0x04000000, 0x00200800, 0x04000000, 0x00200800, 0x00200000, 0x04000802,
0x04000802, 0x04200002, 0x04200002, 0x00000002, 0x00200002, 0x04000000,
0x04000800, 0x00200000, 0x04200800, 0x00000802, 0x00200802, 0x04200800,
0x00000802, 0x04000002, 0x04200802, 0x04200000, 0x00200800, 0x00000000,
0x00000002, 0x04200802, 0x00000000, 0x00200802, 0x04200000, 0x00000800,
0x04000002, 0x04000800, 0x00000800, 0x00200002
};
static const uint32_t sbox8[64] = {
0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040,
0x00000040, 0x10000000, 0x00040040, 0x10040000, 0x10041040, 0x00041000,
0x10041000, 0x00041040, 0x00001000, 0x00000040, 0x10040000, 0x10000040,
0x10001000, 0x00001040, 0x00041000, 0x00040040, 0x10040040, 0x10041000,
0x00001040, 0x00000000, 0x00000000, 0x10040040, 0x10000040, 0x10001000,
0x00041040, 0x00040000, 0x00041040, 0x00040000, 0x10041000, 0x00001000,
0x00000040, 0x10040040, 0x00001000, 0x00041040, 0x10001000, 0x00000040,
0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x00040000, 0x10001040,
0x00000000, 0x10041040, 0x00040040, 0x10000040, 0x10040000, 0x10001000,
0x10001040, 0x00000000, 0x10041040, 0x00041000, 0x00041000, 0x00001040,
0x00001040, 0x00040040, 0x10000000, 0x10041000
};
/*
* These two tables are part of the 'permuted choice 1' function.
* In this implementation several speed improvements are done.
*/
static const uint32_t leftkey_swap[16] = {
0x00000000, 0x00000001, 0x00000100, 0x00000101,
0x00010000, 0x00010001, 0x00010100, 0x00010101,
0x01000000, 0x01000001, 0x01000100, 0x01000101,
0x01010000, 0x01010001, 0x01010100, 0x01010101
};
static const uint32_t rightkey_swap[16] = {
0x00000000, 0x01000000, 0x00010000, 0x01010000,
[449 lines skipped]
--- /home/cvs/shishi/gl/des.h 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/des.h 2005/10/22 15:54:48 1.1
[563 lines skipped]
--- /home/cvs/shishi/gl/hmac-md5.c 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/hmac-md5.c 2005/10/22 15:54:48 1.1
[646 lines skipped]
--- /home/cvs/shishi/gl/md4.c 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/md4.c 2005/10/22 15:54:48 1.1
[1027 lines skipped]
--- /home/cvs/shishi/gl/md4.h 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/md4.h 2005/10/22 15:54:48 1.1
[1115 lines skipped]
--- /home/cvs/shishi/gl/md5.c 2005/10/22 15:54:48 NONE
+++ /home/cvs/shishi/gl/md5.c 2005/10/22 15:54:48 1.1
[1575 lines skipped]
- CVS shishi/gl, shishi-commit, 2005/10/12
- CVS shishi/gl,
shishi-commit <=
- CVS shishi/gl, shishi-commit, 2005/10/22
- CVS shishi/gl, shishi-commit, 2005/10/22
- CVS shishi/gl, shishi-commit, 2005/10/22
- CVS shishi/gl, shishi-commit, 2005/10/22
- CVS shishi/gl, shishi-commit, 2005/10/22
- CVS shishi/gl, shishi-commit, 2005/10/23