[BACK]Return to cipher.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/cipher.c between version 1.3 and 1.4

version 1.3, 1999/09/26 22:53:25 version 1.4, 1999/09/28 04:45:36
Line 16 
Line 16 
   
 #include "ssh.h"  #include "ssh.h"
 #include "cipher.h"  #include "cipher.h"
   #include "ssh_md5.h"
   
 /*  /*
  * What kind of tripple DES are these 2 routines?   * What kind of tripple DES are these 2 routines?
Line 120 
Line 121 
 /* Names of all encryption algorithms.  These must match the numbers defined  /* Names of all encryption algorithms.  These must match the numbers defined
    int cipher.h. */     int cipher.h. */
 static char *cipher_names[] =  static char *cipher_names[] =
 { "none",  {
     "none",
   "no idea",    "no idea",
 #ifdef WITH_DES  #ifdef WITH_DES
   "des",    "des",
Line 129 
Line 131 
 #endif  #endif
   "3des",    "3des",
   "no tss",    "no tss",
 #ifdef WITH_RC4  
   "rc4",  
 #else  
   "no rc4",    "no rc4",
 #endif  
   "blowfish"    "blowfish"
 };  };
   
Line 149 
Line 147 
   mask |= 1 << SSH_CIPHER_DES;    mask |= 1 << SSH_CIPHER_DES;
 #endif  #endif
   mask |= 1 << SSH_CIPHER_3DES; /* Mandatory */    mask |= 1 << SSH_CIPHER_3DES; /* Mandatory */
 #ifdef WITH_RC4  
   mask |= 1 << SSH_CIPHER_RC4;  
 #endif  
   mask |= 1 << SSH_CIPHER_BLOWFISH;    mask |= 1 << SSH_CIPHER_BLOWFISH;
   return mask;    return mask;
 }  }
   
 /* Returns the name of the cipher. */  /* Returns the name of the cipher. */
   
 const char *cipher_name(int cipher)  const
   char *cipher_name(int cipher)
 {  {
   if (cipher < 0 || cipher >= sizeof(cipher_names) / sizeof(cipher_names[0]))    if (cipher < 0 || cipher >= sizeof(cipher_names) / sizeof(cipher_names[0]))
     fatal("cipher_name: bad cipher number: %d", cipher);      fatal("cipher_name: bad cipher number: %d", cipher);
Line 168 
Line 164 
 /* Parses the name of the cipher.  Returns the number of the corresponding  /* Parses the name of the cipher.  Returns the number of the corresponding
    cipher, or -1 on error. */     cipher, or -1 on error. */
   
 int cipher_number(const char *name)  int
   cipher_number(const char *name)
 {  {
   int i;    int i;
   for (i = 0; i < sizeof(cipher_names) / sizeof(cipher_names[0]); i++)    for (i = 0; i < sizeof(cipher_names) / sizeof(cipher_names[0]); i++)
Line 245 
Line 242 
       memset(context->u.des3.iv3, 0, sizeof(context->u.des3.iv3));        memset(context->u.des3.iv3, 0, sizeof(context->u.des3.iv3));
       break;        break;
   
 #ifdef WITH_RC4  
     case SSH_CIPHER_RC4:  
       rc4_init(&context->u.rc4, key, keylen);  
       break;  
 #endif /* WITH_RC4 */  
   
     case SSH_CIPHER_BLOWFISH:      case SSH_CIPHER_BLOWFISH:
       BF_set_key(&context->u.bf.key, keylen, padded);        BF_set_key(&context->u.bf.key, keylen, padded);
       memset(context->u.bf.iv, 0, 8);        memset(context->u.bf.iv, 0, 8);
Line 290 
Line 281 
                        dest, (void*)src, len);                         dest, (void*)src, len);
       break;        break;
   
 #ifdef WITH_RC4  
     case SSH_CIPHER_RC4:  
       rc4_encrypt(&context->u.rc4, dest, src, len);  
       break;  
 #endif /* WITH_RC4 */  
   
     case SSH_CIPHER_BLOWFISH:      case SSH_CIPHER_BLOWFISH:
       swap_bytes(src, dest, len);        swap_bytes(src, dest, len);
       BF_cbc_encrypt(dest, dest, len,        BF_cbc_encrypt(dest, dest, len,
Line 337 
Line 322 
                        context->u.des3.key3, &context->u.des3.iv3,                         context->u.des3.key3, &context->u.des3.iv3,
                        dest, (void*)src, len);                         dest, (void*)src, len);
       break;        break;
   
 #ifdef WITH_RC4  
     case SSH_CIPHER_RC4:  
       /* CRC-32 attack? */  
       rc4_decrypt(&context->u.rc4, dest, src, len);  
       break;  
 #endif /* WITH_RC4 */  
   
     case SSH_CIPHER_BLOWFISH:      case SSH_CIPHER_BLOWFISH:
       detect_cbc_attack(src, len);        detect_cbc_attack(src, len);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4