$NetBSD: patch-ba,v 1.1 2000/03/20 02:25:42 itojun Exp $ --- des.c.orig Wed May 12 07:19:25 1999 +++ des.c Fri Dec 24 21:50:04 1999 @@ -38,7 +38,7 @@ #include "includes.h" #include "getput.h" -#include "des.h" +#include "ssh-des.h" /* Table for key generation. This used to be in sk.h. */ /* Copyright (C) 1993 Eric Young - see README for more details */ @@ -400,7 +400,7 @@ /* This part is based on code that used to be in ecb_enc.c. */ /* Copyright (C) 1993 Eric Young - see README for more details */ -void des_encrypt(word32 l, word32 r, word32 *output, DESContext *ks, +void ssh_des_encrypt(word32 l, word32 r, word32 *output, DESContext *ks, int encrypt) { register word32 t,u; @@ -452,7 +452,7 @@ #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ (a)=(a)^(t)^(t>>(16-(n)))) -void des_set_key(unsigned char *key, DESContext *ks) +void ssh_des_set_key(unsigned char *key, DESContext *ks) { register word32 c, d, t, s, shifts; register int i; @@ -507,7 +507,7 @@ } } -void des_cbc_encrypt(DESContext *ks, unsigned char *iv, +void ssh_des_cbc_encrypt(DESContext *ks, unsigned char *iv, unsigned char *dest, const unsigned char *src, unsigned int len) { @@ -523,7 +523,7 @@ { iv0 ^= GET_32BIT_LSB_FIRST(src + i); iv1 ^= GET_32BIT_LSB_FIRST(src + i + 4); - des_encrypt(iv0, iv1, out, ks, 1); + ssh_des_encrypt(iv0, iv1, out, ks, 1); iv0 = out[0]; iv1 = out[1]; PUT_32BIT_LSB_FIRST(dest + i, iv0); @@ -533,7 +533,7 @@ PUT_32BIT_LSB_FIRST(iv + 4, iv1); } -void des_cbc_decrypt(DESContext *ks, unsigned char *iv, +void ssh_des_cbc_decrypt(DESContext *ks, unsigned char *iv, unsigned char *dest, const unsigned char *src, unsigned int len) { @@ -549,7 +549,7 @@ { d0 = GET_32BIT_LSB_FIRST(src + i); d1 = GET_32BIT_LSB_FIRST(src + i + 4); - des_encrypt(d0, d1, out, ks, 0); + ssh_des_encrypt(d0, d1, out, ks, 0); iv0 ^= out[0]; iv1 ^= out[1]; PUT_32BIT_LSB_FIRST(dest + i, iv0); @@ -561,38 +561,38 @@ PUT_32BIT_LSB_FIRST(iv + 4, iv1); } -void des_3cbc_encrypt(DESContext *ks1, unsigned char *iv1, +void ssh_des_3cbc_encrypt(DESContext *ks1, unsigned char *iv1, DESContext *ks2, unsigned char *iv2, DESContext *ks3, unsigned char *iv3, unsigned char *dest, const unsigned char *src, unsigned int len) { - des_cbc_encrypt(ks1, iv1, dest, src, len); - des_cbc_decrypt(ks2, iv2, dest, dest, len); - des_cbc_encrypt(ks3, iv3, dest, dest, len); + ssh_des_cbc_encrypt(ks1, iv1, dest, src, len); + ssh_des_cbc_decrypt(ks2, iv2, dest, dest, len); + ssh_des_cbc_encrypt(ks3, iv3, dest, dest, len); } -void des_3cbc_decrypt(DESContext *ks1, unsigned char *iv1, +void ssh_des_3cbc_decrypt(DESContext *ks1, unsigned char *iv1, DESContext *ks2, unsigned char *iv2, DESContext *ks3, unsigned char *iv3, unsigned char *dest, const unsigned char *src, unsigned int len) { - des_cbc_decrypt(ks3, iv3, dest, src, len); - des_cbc_encrypt(ks2, iv2, dest, dest, len); - des_cbc_decrypt(ks1, iv1, dest, dest, len); + ssh_des_cbc_decrypt(ks3, iv3, dest, src, len); + ssh_des_cbc_encrypt(ks2, iv2, dest, dest, len); + ssh_des_cbc_decrypt(ks1, iv1, dest, dest, len); } -#ifdef DES_TEST +#ifdef SSH_DES_TEST -void des_encrypt_buf(DESContext *ks, unsigned char *out, +void ssh_des_encrypt_buf(DESContext *ks, unsigned char *out, const unsigned char *in, int encrypt) { word32 in0, in1, output[0]; in0 = GET_32BIT_LSB_FIRST(in); in1 = GET_32BIT_LSB_FIRST(in + 4); - des_encrypt(in0, in1, output, ks, encrypt); + ssh_des_encrypt(in0, in1, output, ks, encrypt); PUT_32BIT_LSB_FIRST(out, output[0]); PUT_32BIT_LSB_FIRST(out + 4, output[1]); } @@ -634,15 +634,15 @@ } result[i] = value; } - des_set_key(key, &ks); - des_encrypt_buf(&ks, output, data, 1); + ssh_des_set_key(key, &ks); + ssh_des_encrypt_buf(&ks, output, data, 1); if (memcmp(output, result, 8) != 0) fprintf(stderr, "Encrypt failed: %s", line); - des_encrypt_buf(&ks, output, result, 0); + ssh_des_encrypt_buf(&ks, output, result, 0); if (memcmp(output, data, 8) != 0) fprintf(stderr, "Decrypt failed: %s", line); } exit(0); } -#endif /* DES_TEST */ +#endif /* SSH_DES_TEST */