X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=serpent.c;h=7c5850535f24f87655f2508b0c4045f89e3dcd9a;hp=6407c5776624eef4801685aab34864b238b19614;hb=3ff31eda6e86ffc7d276635fe117c7408a72b719;hpb=af43f0b77a10716921d13c047d1d3c39570cae17 diff --git a/serpent.c b/serpent.c index 6407c57..7c58505 100644 --- a/serpent.c +++ b/serpent.c @@ -22,6 +22,7 @@ #include +#include "hexdebug.h" #include "serpent.h" #include "serpentsboxes.h" @@ -41,6 +42,26 @@ #endif /* !defined(SERPENT_BIGENDIAN) */ +#if 0 + +#include + +static void SERP_DEBUG(const char *str1, + const void *ary, int sz, + const char *str2) +{ + fprintf(stderr,"%s",str1); + hexdebug(stderr,ary,sz); + fprintf(stderr,"%s",str2); +} + +#else + +#define SERP_DEBUG(str1,aryv,sz,str2) /*empty*/ + +#endif + + static uint32_t serpent_get_32bit(const uint8_t *basep, int lenbytes, int offset) { @@ -65,6 +86,8 @@ void SERPENT_DECORATE(makekey)(struct keyInstance *key, int keyLen, uint32_t j; uint32_t w[132],k[132]; + SERP_DEBUG("SERPENT makekey ",keyMaterial,keyLen/8,"\n"); + for(i=0; i"); + x0=serpent_get_32bit(plaintext,16,+0); x1=serpent_get_32bit(plaintext,16,+4); x2=serpent_get_32bit(plaintext,16,+8); @@ -234,6 +259,8 @@ void SERPENT_DECORATE(encrypt)(struct keyInstance *key, serpent_put_32bit(ciphertext,16,+4, x1); serpent_put_32bit(ciphertext,16,+8, x2); serpent_put_32bit(ciphertext,16,12, x3); + + SERP_DEBUG(" ",ciphertext,16,"\n"); } void SERPENT_DECORATE(decrypt)(struct keyInstance *key, @@ -243,6 +270,8 @@ void SERPENT_DECORATE(decrypt)(struct keyInstance *key, register uint32_t x0, x1, x2, x3; register uint32_t y0, y1, y2, y3; + SERP_DEBUG("SERPENT decrypt ",ciphertext,16," ->"); + x0=serpent_get_32bit(ciphertext,16,+0); x1=serpent_get_32bit(ciphertext,16,+4); x2=serpent_get_32bit(ciphertext,16,+8); @@ -352,4 +381,6 @@ void SERPENT_DECORATE(decrypt)(struct keyInstance *key, serpent_put_32bit(plaintext,16,+4, x1); serpent_put_32bit(plaintext,16,+8, x2); serpent_put_32bit(plaintext,16,12, x3); + + SERP_DEBUG(" ",plaintext,16,"\n"); }