From: c.igaly@doc.ic.ac.uk (Cedomir Igaly) Newsgroups: comp.security.ssh Subject: Re: skipjack, anyone? Date: 27 Jun 1998 19:16:06 -0000 Organization: news.cs.hut.fi mail2news gateway Lines: 691 Distribution: world Message-ID: <3.0.2.32.19980627183421.00be76b0@localhost> References: <87g1gtfp62.fsf@jekyll.piermont.com> NNTP-Posting-Host: nukkekoti.cs.hut.fi Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_898965261==_" Xref: news.lut.fi comp.security.ssh:5438 --=====================_898965261==_ Content-Type: text/plain; charset="us-ascii" At 11:59 AM 6/25/98 -0400, Perry E. Metzger wrote: >Someone should produce a skipjack'ed ssh now that the algorithm is >public, if only for amusement. This patch is compatible at least with itself. I've tested skipjack implementation for single block of data. Best regards, Cedomir Igaly --=====================_898965261==_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ssh-1.2.25.cdi" diff -cr ssh-1.2.25.orig/Makefile.in ssh-1.2.25/Makefile.in *** ssh-1.2.25.orig/Makefile.in Thu Jun 11 15:01:13 1998 --- ssh-1.2.25/Makefile.in Sat Jun 27 16:32:03 1998 *************** *** 308,314 **** rsa.o randoms.o md5.o buffer.o emulate.o packet.o compress.o \ xmalloc.o ttymodes.o newchannels.o bufaux.o authfd.o authfile.o \ crc32.o rsaglue.o cipher.o des.o match.o arcfour.o mpaux.o \ ! userfile.o signals.o blowfish.o deattack.o SSHD_OBJS =3D sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o= pty.o \ log-server.o login.o hostfile.o canohost.o servconf.o tildexpand.o \ serverloop.o $(COMMON_OBJS) $(KERBEROS_OBJS) $(SSHDCONFOBJS) --- 308,314 ---- rsa.o randoms.o md5.o buffer.o emulate.o packet.o compress.o \ xmalloc.o ttymodes.o newchannels.o bufaux.o authfd.o authfile.o \ crc32.o rsaglue.o cipher.o des.o match.o arcfour.o mpaux.o \ ! userfile.o signals.o blowfish.o deattack.o skipjack.o SSHD_OBJS =3D sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o= pty.o \ log-server.o login.o hostfile.o canohost.o servconf.o tildexpand.o \ serverloop.o $(COMMON_OBJS) $(KERBEROS_OBJS)= $(SSHDCONFOBJS) *************** *** 316,330 **** tildexpand.o clientloop.o canohost.o $(COMMON_OBJS) $(SSHCONFOBJS) KEYGEN_OBJS =3D ssh-keygen.o log-client.o readpass.o rsa.o randoms.o md5.o= \ buffer.o xmalloc.o authfile.o cipher.o des.o arcfour.o mpaux.o \ ! bufaux.o userfile.o signals.o blowfish.o $(LIBOBJS) $(CONFOBJS) AGENT_OBJS =3D ssh-agent.o log-client.o rsa.o randoms.o md5.o buffer.o \ xmalloc.o bufaux.o authfd.o authfile.o rsaglue.o cipher.o \ des.o arcfour.o mpaux.o userfile.o signals.o blowfish.o \ ! $(LIBOBJS) $(CONFOBJS) ADD_OBJS =3D ssh-add.o log-client.o readpass.o rsa.o randoms.o md5.o= buffer.o \ xmalloc.o bufaux.o authfd.o authfile.o cipher.o blowfish.o \ ! des.o arcfour.o mpaux.o userfile.o signals.o $(LIBOBJS) \ ! $(CONFOBJS) SCP_OBJS =3D scp.o xmalloc.o #ifdef F_SECURE_COMMERCIAL # --- 316,331 ---- tildexpand.o clientloop.o canohost.o $(COMMON_OBJS) $(SSHCONFOBJS) KEYGEN_OBJS =3D ssh-keygen.o log-client.o readpass.o rsa.o randoms.o md5.o= \ buffer.o xmalloc.o authfile.o cipher.o des.o arcfour.o mpaux.o \ ! bufaux.o userfile.o signals.o blowfish.o skipjack.o \ ! $(LIBOBJS) $(CONFOBJS) AGENT_OBJS =3D ssh-agent.o log-client.o rsa.o randoms.o md5.o buffer.o \ xmalloc.o bufaux.o authfd.o authfile.o rsaglue.o cipher.o \ des.o arcfour.o mpaux.o userfile.o signals.o blowfish.o \ ! skipjack.o $(LIBOBJS) $(CONFOBJS) ADD_OBJS =3D ssh-add.o log-client.o readpass.o rsa.o randoms.o md5.o= buffer.o \ xmalloc.o bufaux.o authfd.o authfile.o cipher.o blowfish.o \ ! des.o arcfour.o mpaux.o userfile.o signals.o skipjack.o \ ! $(LIBOBJS) $(CONFOBJS) SCP_OBJS =3D scp.o xmalloc.o #ifdef F_SECURE_COMMERCIAL # *************** *** 352,358 **** randoms.h ttymodes.h authfd.h crc32.h includes.h \ readconf.h userfile.h blowfish.h des.h md5.h rsa.h version.h bufaux.h \ mpaux.h servconf.h xmalloc.h buffer.h emulate.h packet.h ssh.h \ ! deattack.h DISTFILES =3D $(srcdir)/COPYING $(srcdir)/README $(srcdir)/README.SECURID= \ $(srcdir)/README.TIS $(srcdir)/README.SECURERPC \ --- 353,359 ---- randoms.h ttymodes.h authfd.h crc32.h includes.h \ readconf.h userfile.h blowfish.h des.h md5.h rsa.h version.h bufaux.h \ mpaux.h servconf.h xmalloc.h buffer.h emulate.h packet.h ssh.h \ ! deattack.h skipjack.h DISTFILES =3D $(srcdir)/COPYING $(srcdir)/README $(srcdir)/README.SECURID= \ $(srcdir)/README.TIS $(srcdir)/README.SECURERPC \ *************** *** 511,518 **** # not be available if non-root and using shadow passwords. install: $(PROGRAMS) make-dirs generate-host-key install-configs -rm -f $(install_prefix)$(bindir)/ssh1.old -mv $(install_prefix)$(bindir)/ssh1 $(install_prefix)$(bindir)/ssh1.old - -chmod 755 $(install_prefix)$(bindir)/ssh1.old $(INSTALL_PROGRAM) -o root -m $(SSH_INSTALL_MODE) ssh= $(install_prefix)$(bindir)/ssh1 -if test -f $(install_prefix)$(bindir)/ssh2; then \ echo "Ssh version 2 program found, installation doesn't touch ssh= link"; \ --- 512,520 ---- # not be available if non-root and using shadow passwords. install: $(PROGRAMS) make-dirs generate-host-key install-configs -rm -f $(install_prefix)$(bindir)/ssh1.old + -chmod 755 $(install_prefix)$(bindir)/ssh1 + -chmod 755 $(install_prefix)$(bindir)/ssh -mv $(install_prefix)$(bindir)/ssh1 $(install_prefix)$(bindir)/ssh1.old $(INSTALL_PROGRAM) -o root -m $(SSH_INSTALL_MODE) ssh= $(install_prefix)$(bindir)/ssh1 -if test -f $(install_prefix)$(bindir)/ssh2; then \ echo "Ssh version 2 program found, installation doesn't touch ssh= link"; \ *************** *** 519,525 **** else \ rm -f $(install_prefix)$(bindir)/ssh.old; \ mv $(install_prefix)$(bindir)/ssh $(install_prefix)$(bindir)/ssh.old= ;\ - chmod 755 $(install_prefix)$(bindir)/ssh.old ;\ $(LN_S) ssh1 $(install_prefix)$(bindir)/ssh ;\ fi -if test "`echo ssh | sed '$(transform)'`" '!=3D' ssh; then \ --- 521,526 ---- diff -cr ssh-1.2.25.orig/acconfig.h ssh-1.2.25/acconfig.h *** ssh-1.2.25.orig/acconfig.h Thu Jun 11 15:01:09 1998 --- ssh-1.2.25/acconfig.h Sat Jun 27 16:36:49 1998 *************** *** 227,232 **** --- 227,233 ---- #undef WITH_DES #undef WITH_ARCFOUR #undef WITH_BLOWFISH + #undef WITH_SKIPJACK #undef WITH_NONE /* Define this to include libwrap (tcp_wrappers) support. */ diff -cr ssh-1.2.25.orig/cipher.c ssh-1.2.25/cipher.c *** ssh-1.2.25.orig/cipher.c Thu Jun 11 15:01:10 1998 --- ssh-1.2.25/cipher.c Sat Jun 27 16:28:30 1998 *************** *** 73,79 **** int cipher.h. */ static char *cipher_names[] =3D { "none", "idea", "des", "3des", "used to be tss", "arcfour",= "blowfish", ! "reserved"}; /* Returns a bit mask indicating which ciphers are supported by this implementation. The bit mask has the corresponding bit set of each --- 73,79 ---- int cipher.h. */ static char *cipher_names[] =3D { "none", "idea", "des", "3des", "used to be tss", "arcfour",= "blowfish", ! "reserved", "skipjack"}; /* Returns a bit mask indicating which ciphers are supported by this implementation. The bit mask has the corresponding bit set of= each *************** *** 104,109 **** --- 104,114 ---- #ifdef WITH_BLOWFISH mask |=3D 1 << SSH_CIPHER_BLOWFISH; #endif /* WITH_BLOWFISH */ + + #ifdef WITH_SKIPJACK + mask |=3D 1 << SSH_CIPHER_SKIPJACK; + #endif /* WITH_SKIPJACK */ + return mask; } *************** *** 248,253 **** --- 253,267 ---- blowfish_set_key(&context->u.blowfish, key, keylen,= for_encryption); break; #endif /* WITH_BLOWFISH */ + + #ifdef WITH_SKIPJACK + case SSH_CIPHER_SKIPJACK: + if (keylen < 10) + error("Key length %d is insufficient for SkipJack", keylen); + skipjack_set_key(&context->u.skipjack.ctx, key); + memset(context->u.skipjack.iv, 0, sizeof(context->u.skipjack.iv)); + break; + #endif /* WITH_SKIPJACK */ default: fatal("cipher_set_key: unknown cipher: %d", cipher); } *************** *** 296,301 **** --- 310,321 ---- blowfish_cbc_encrypt(&context->u.blowfish, dest, src, len); break; #endif /* WITH_BLOWFISH */ + + #ifdef WITH_SKIPJACK + case SSH_CIPHER_SKIPJACK: + skipjack_cbc_encrypt(&context->u.skipjack.ctx,= context->u.skipjack.iv, dest, src, len); + break; + #endif /* WITH_SKIPJACK */ default: fatal("cipher_encrypt: unknown cipher: %d",= context->type); *************** *** 344,349 **** --- 364,375 ---- blowfish_cbc_decrypt(&context->u.blowfish, dest, src, len); break; #endif /* WITH_BLOWFISH */ + + #ifdef WITH_SKIPJACK + case SSH_CIPHER_SKIPJACK: + skipjack_cbc_decrypt(&context->u.skipjack.ctx,= context->u.skipjack.iv, dest, src, len); + break; + #endif /* WITH_SKIPJACK */ default: fatal("cipher_decrypt: unknown cipher: %d", context->type); diff -cr ssh-1.2.25.orig/cipher.h ssh-1.2.25/cipher.h *** ssh-1.2.25.orig/cipher.h Thu Jun 11 15:01:10 1998 --- ssh-1.2.25/cipher.h Sat Jun 27 16:24:00 1998 *************** *** 65,70 **** --- 65,73 ---- #ifdef WITH_BLOWFISH #include "blowfish.h" #endif /* WITH_BLOWFISH */ + #ifdef WITH_SKIPJACK + #include "skipjack.h" + #endif /* WITH_SKIPJACK */ /* Cipher types. New types can be added, but old types should not be= removed for compatibility. The maximum allowed value is 31.= */ *************** *** 77,82 **** --- 80,86 ---- #define SSH_CIPHER_BLOWFISH 6 /* Bruce Schneier's Blowfish */ #define SSH_CIPHER_RESERVED 7 /* Reserved for 40 bit crippled encryption, Bernard Perrot */ + #define SSH_CIPHER_SKIPJACK 8 /* SkipJack */ typedef struct { unsigned int type; *************** *** 107,112 **** --- 111,122 ---- #ifdef WITH_BLOWFISH BlowfishContext blowfish; #endif /* WITH_BLOWFISH */ + #ifdef WITH_SKIPJACK + struct { + SkipJackContext ctx; + unsigned char iv[8]; + } skipjack; + #endif /* WITH_SKIPJACK */ } u; } CipherContext; diff -cr ssh-1.2.25.orig/config.h.in ssh-1.2.25/config.h.in *** ssh-1.2.25.orig/config.h.in Thu Jun 11 15:01:46 1998 --- ssh-1.2.25/config.h.in Sat Jun 27 16:36:10 1998 *************** *** 277,282 **** --- 277,283 ---- #undef WITH_DES #undef WITH_ARCFOUR #undef WITH_BLOWFISH + #undef WITH_SKIPJACK #undef WITH_NONE /* Define this to include libwrap (tcp_wrappers) support. */ diff -cr ssh-1.2.25.orig/configure ssh-1.2.25/configure *** ssh-1.2.25.orig/configure Thu Jun 11 15:01:48 1998 --- ssh-1.2.25/configure Sat Jun 27 16:40:10 1998 *************** *** 6008,6013 **** --- 6008,6036 ---- fi + echo $ac_n "checking whether to include the SkipJack encryption= algorithm""... $ac_c" 1>&6 + echo "configure:6012: checking whether to include the SkipJack encryption= algorithm" >&5 + # Check whether --with-skipjack or --without-skipjack was given. + if test "${with_skipjack+set}" =3D set; then + withval=3D"$with_skipjack" + case "$withval" in + yes) + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF + #define WITH_SKIPJACK 1 + EOF + + ;; + *) + echo "$ac_t""no" 1>&6 + ;; + esac + else + echo "$ac_t""no" 1>&6 + + fi + + echo $ac_n "checking whether to include the none encryption algorithm""...= $ac_c" 1>&6 echo "configure:6013: checking whether to include the none encryption= algorithm" >&5 # Check whether --with-none or --without-none was given. diff -cr ssh-1.2.25.orig/configure.in ssh-1.2.25/configure.in *** ssh-1.2.25.orig/configure.in Thu Jun 11 15:01:44 1998 --- ssh-1.2.25/configure.in Sat Jun 27 16:41:17 1998 *************** *** 1054,1059 **** --- 1054,1076 ---- AC_DEFINE(WITH_BLOWFISH) ) + AC_MSG_CHECKING(whether to include the SkipJack encryption algorithm) + AC_ARG_WITH(skipjack, + [ --with-skipjack Include skipjack (default). + --without-skipjack Don't include skipjack], + [ case "$withval" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + AC_DEFINE(WITH_SKIPJACK) + ;; + esac ], + AC_MSG_RESULT(yes) + AC_DEFINE(WITH_SKIPJACK) + ) + AC_MSG_CHECKING(whether to include the DES encryption algorithm) AC_ARG_WITH(des, [ --with-des Include single-DES support. diff -cr ssh-1.2.25.orig/skipjack.c ssh-1.2.25/skipjack.c *** /dev/null Sat Jun 27 17:07:09 1998 --- ssh-1.2.25/skipjack.c Sat Jun 27 16:30:48 1998 *************** *** 0 **** --- 1,266 ---- + /* $Log: SkipJack.cpp $ + * Revision 1.1 1998/06/26 21:09:27 Administrator + * Initial revision + * + */ + + /* SkipJack algorithm implementation by Cedomir Igaly + + Basical encryption written during first 15 minutes of second + halftime of football match England vs Columbia in France '98. + Due to lack of light in room, decryption was written later. + */ + + #ifndef WITHOUT_SKIPJACK + + #include "includes.h" + #include "skipjack.h" + #include "getput.h" + + static const unsigned char F[] =3D + { + 0xA3, 0xD7, 0x09, 0x83, 0xF8, 0x48, 0xF6, 0xF4, + 0xB3, 0x21, 0x15, 0x78, 0x99, 0xB1, 0xAF, 0xF9, + 0xE7, 0x2D, 0x4D, 0x8A, 0xCE, 0x4C, 0xCA, 0x2E, + 0x52, 0x95, 0xD9, 0x1E, 0x4E, 0x38, 0x44, 0x28, + 0x0A, 0xDF, 0x02, 0xA0, 0x17, 0xF1, 0x60, 0x68, + 0x12, 0xB7, 0x7A, 0xC3, 0xE9, 0xFA, 0x3D, 0x53, + 0x96, 0x84, 0x6B, 0xBA, 0xF2, 0x63, 0x9A, 0x19, + 0x7C, 0xAE, 0xE5, 0xF5, 0xF7, 0x16, 0x6A, 0xA2, + 0x39, 0xB6, 0x7B, 0x0F, 0xC1, 0x93, 0x81, 0x1B, + 0xEE, 0xB4, 0x1A, 0xEA, 0xD0, 0x91, 0x2F, 0xB8, + 0x55, 0xB9, 0xDA, 0x85, 0x3F, 0x41, 0xBF, 0xE0, + 0x5A, 0x58, 0x80, 0x5F, 0x66, 0x0B, 0xD8, 0x90, + 0x35, 0xD5, 0xC0, 0xA7, 0x33, 0x06, 0x65, 0x69, + 0x45, 0x00, 0x94, 0x56, 0x6D, 0x98, 0x9B, 0x76, + 0x97, 0xFC, 0xB2, 0xC2, 0xB0, 0xFE, 0xDB, 0x20, + 0xE1, 0xEB, 0xD6, 0xE4, 0xDD, 0x47, 0x4A, 0x1D, + 0x42, 0xED, 0x9E, 0x6E, 0x49, 0x3C, 0xCD, 0x43, + 0x27, 0xD2, 0x07, 0xD4, 0xDE, 0xC7, 0x67, 0x18, + 0x89, 0xCB, 0x30, 0x1F, 0x8D, 0xC6, 0x8F, 0xAA, + 0xC8, 0x74, 0xDC, 0xC9, 0x5D, 0x5C, 0x31, 0xA4, + 0x70, 0x88, 0x61, 0x2C, 0x9F, 0x0D, 0x2B, 0x87, + 0x50, 0x82, 0x54, 0x64, 0x26, 0x7D, 0x03, 0x40, + 0x34, 0x4B, 0x1C, 0x73, 0xD1, 0xC4, 0xFD, 0x3B, + 0xCC, 0xFB, 0x7F, 0xAB, 0xE6, 0x3E, 0x5B, 0xA5, + 0xAD, 0x04, 0x23, 0x9C, 0x14, 0x51, 0x22, 0xF0, + 0x29, 0x79, 0x71, 0x7E, 0xFF, 0x8C, 0x0E, 0xE2, + 0x0C, 0xEF, 0xBC, 0x72, 0x75, 0x6F, 0x37, 0xA1, + 0xEC, 0xD3, 0x8E, 0x62, 0x8B, 0x86, 0x10, 0xE8, + 0x08, 0x77, 0x11, 0xBE, 0x92, 0x4F, 0x24, 0xC5, + 0x32, 0x36, 0x9D, 0xCF, 0xF3, 0xA6, 0xBB, 0xAC, + 0x5E, 0x6C, 0xA9, 0x13, 0x57, 0x25, 0xB5, 0xE3, + 0xBD, 0xA8, 0x3A, 0x01, 0x05, 0x59, 0x2A, 0x46 + }; + + static void GEnc (SkipJackContext *ctx, unsigned char g1, unsigned char= g2, unsigned char *hi, unsigned char *lo) + { + g1 ^=3D F[g2^*ctx->schptr++]; + g2 ^=3D F[g1^*ctx->schptr++]; + *hi =3D F[g2^*ctx->schptr++] ^ g1; + *lo =3D F[*hi^*ctx->schptr++] ^ g2; + } + + static void GDec (SkipJackContext *ctx, unsigned char g5, unsigned char= g6, unsigned char *hi, unsigned char *lo) + { + g6 ^=3D F[g5^*--ctx->schptr]; + g5 ^=3D F[g6^*--ctx->schptr]; + *lo =3D F[g5^*--ctx->schptr] ^ g6; + *hi =3D F[*lo^*--ctx->schptr] ^ g5; + } + + static void RuleAEnc (SkipJackContext *ctx, unsigned char *b) + { + unsigned char Ghi, Glo; + GEnc (ctx, b[0], b[1], &Ghi, &Glo); + b[0] =3D Ghi ^ b[6]; + b[1] =3D Glo ^ b[7] ^ ++ctx->counter; + b[6] =3D b[4]; + b[7] =3D b[5]; + b[4] =3D b[2]; + b[5] =3D b[3]; + b[2] =3D Ghi; + b[3] =3D Glo; + } + + static void RuleADec (SkipJackContext *ctx, unsigned char *b) + { + unsigned char Ghi, Glo, temp; + GDec (ctx, b[2], b[3], &Ghi, &Glo); + temp =3D b[4]; + b[4] =3D b[6]; + b[6] =3D b[0] ^ b[2]; + b[0] =3D Ghi; + b[2] =3D temp; + temp =3D b[5]; + b[5] =3D b[7]; + b[7] =3D b[1] ^ b[3] ^ ctx->counter--; + b[1] =3D Glo; + b[3] =3D temp; + } + + static void RuleBEnc (SkipJackContext *ctx, unsigned char *b) + { + unsigned char Ghi, Glo, temp; + GEnc (ctx, b[0], b[1], &Ghi, &Glo); + temp =3D b[6]; + b[6] =3D b[4]; + b[4] =3D b[0] ^ b[2]; + b[0] =3D temp; + b[2] =3D Ghi; + temp =3D b[7]; + b[7] =3D b[5]; + b[5] =3D b[1] ^ b[3] ^ ++ctx->counter; + b[1] =3D temp; + b[3] =3D Glo; + } + + static void RuleBDec (SkipJackContext *ctx, unsigned char *b) + { + unsigned char Ghi, Glo; + GDec (ctx, b[2], b[3], &Ghi, &Glo); + b[2] =3D Ghi ^ b[4]; + b[3] =3D Glo ^ b[5] ^ ctx->counter--; + b[4] =3D b[6]; + b[5] =3D b[7]; + b[6] =3D b[0]; + b[7] =3D b[1]; + b[0] =3D Ghi; + b[1] =3D Glo; + } + + static void SkipJackEncryptBlock (SkipJackContext *ctx, unsigned char= *in) + { + ctx->schptr =3D ctx->schedule; + ctx->counter =3D 0; + + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleAEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + RuleBEnc (ctx, in); + } + + static void SkipJackDecryptBlock (SkipJackContext *ctx, unsigned char= *in) + { + ctx->schptr =3D ctx->schedule + 128; + ctx->counter =3D 32; + + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleBDec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + RuleADec (ctx, in); + } + + void skipjack_set_key(SkipJackContext *ctx, const unsigned char key[20]) + { + memcpy (ctx->schedule, key, 10); + memcpy (ctx->schedule+10, key, 10); + memcpy (ctx->schedule+20, ctx->schedule, 20); + memcpy (ctx->schedule+40, ctx->schedule, 40); + memcpy (ctx->schedule+80, ctx->schedule, 40); + memcpy (ctx->schedule+120, key, 8); + } + + void skipjack_cbc_encrypt(SkipJackContext *ctx, unsigned char *iv,= unsigned char *out, + const unsigned char *in, unsigned int len) + { + assert((len & 7) =3D=3D 0); + + while (len > 0) { + PUT_32BIT (iv, GET_32BIT(iv) ^ GET_32BIT(in)); + PUT_32BIT (iv+4, GET_32BIT(iv+4) ^ GET_32BIT(in+4)); + SkipJackEncryptBlock (ctx, iv); + memcpy (out, iv, 8); + in +=3D 8; + out +=3D 8; + len -=3D 8; + } + } + + void skipjack_cbc_decrypt(SkipJackContext *ctx, unsigned char *iv,= unsigned char *out, + const unsigned char *in, unsigned int len) + { + word32 iv0, iv1; + + assert((len & 7) =3D=3D 0); + + iv0 =3D GET_32BIT(iv); + iv1 =3D GET_32BIT(iv + 4); + + while (len > 0) { + memcpy (out, in, 8); + SkipJackDecryptBlock (ctx, out); + PUT_32BIT (out, GET_32BIT (out) ^ iv0); + PUT_32BIT (out+4, GET_32BIT (out+4) ^ iv1); + iv0 =3D GET_32BIT(in); + iv1 =3D GET_32BIT(in+4); + in +=3D 8; + out +=3D 8; + len -=3D 8; + } + PUT_32BIT (iv, iv0); + PUT_32BIT (iv+4, iv1); + } + + void skipjack_destroy_context(SkipJackContext *ctx) + { + memset (ctx->schedule, 0, 128); + } + + #endif diff -cr ssh-1.2.25.orig/skipjack.h ssh-1.2.25/skipjack.h *** /dev/null Sat Jun 27 17:07:09 1998 --- ssh-1.2.25/skipjack.h Sat Jun 27 16:28:28 1998 *************** *** 0 **** --- 1,39 ---- + /* + + SkipJack.h + + Author: Cedomir Igaly + + The SkipJack encryption algorithm. + + */ + + /* + * $Log: idea.h,v $ + */ + + #ifndef SKIPJACK_H + #define SKIPJACK_H + + typedef struct { + unsigned char schedule[128]; + unsigned char *schptr; + int counter; + } SkipJackContext; + + /* Sets SkipJack key for encryption. */ + void skipjack_set_key(SkipJackContext *, const unsigned char *); + + /* Destroys any sensitive data in the context. */ + void skipjack_destroy_context(SkipJackContext *); + + /* Encrypts len bytes from src to dest in CBC mode. */ + void skipjack_cbc_encrypt(SkipJackContext *, unsigned char *, unsigned= char *, + const unsigned char *, unsigned int); + + /* Decrypts len bytes from src to dest in CBC mode. */ + void skipjack_cbc_decrypt(SkipJackContext *, unsigned char *, unsigned= char *, + const unsigned char *, unsigned int); + + #endif /* SKIPJACK_H */ + --=====================_898965261==_ Content-Type: text/plain; charset="us-ascii" --=====================_898965261==_--