[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.25 and 1.26

version 1.25, 2000/04/12 09:39:10 version 1.26, 2000/04/14 10:30:30
Line 1 
Line 1 
 /*  /*
  *   *
  * cipher.c   * cipher.c
  *   *
  * Author: Tatu Ylonen <ylo@cs.hut.fi>   * Author: Tatu Ylonen <ylo@cs.hut.fi>
  *   *
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland   * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved   *                    All rights reserved
  *   *
  * Created: Wed Apr 19 17:41:39 1995 ylo   * Created: Wed Apr 19 17:41:39 1995 ylo
  *   *
  */   */
   
 #include "includes.h"  #include "includes.h"
Line 133 
Line 133 
  * supported cipher.   * supported cipher.
  */   */
   
 unsigned int  unsigned int
 cipher_mask1()  cipher_mask1()
 {  {
         unsigned int mask = 0;          unsigned int mask = 0;
Line 141 
Line 141 
         mask |= 1 << SSH_CIPHER_BLOWFISH;          mask |= 1 << SSH_CIPHER_BLOWFISH;
         return mask;          return mask;
 }  }
 unsigned int  unsigned int
 cipher_mask2()  cipher_mask2()
 {  {
         unsigned int mask = 0;          unsigned int mask = 0;
Line 151 
Line 151 
         mask |= 1 << SSH_CIPHER_CAST128_CBC;          mask |= 1 << SSH_CIPHER_CAST128_CBC;
         return mask;          return mask;
 }  }
 unsigned int  unsigned int
 cipher_mask()  cipher_mask()
 {  {
         return cipher_mask1() | cipher_mask2();          return cipher_mask1() | cipher_mask2();
Line 213 
Line 213 
  * passphrase and using the resulting 16 bytes as the key.   * passphrase and using the resulting 16 bytes as the key.
  */   */
   
 void  void
 cipher_set_key_string(CipherContext *context, int cipher, const char *passphrase)  cipher_set_key_string(CipherContext *context, int cipher, const char *passphrase)
 {  {
         MD5_CTX md;          MD5_CTX md;
Line 231 
Line 231 
   
 /* Selects the cipher to use and sets the key. */  /* Selects the cipher to use and sets the key. */
   
 void  void
 cipher_set_key(CipherContext *context, int cipher, const unsigned char *key,  cipher_set_key(CipherContext *context, int cipher, const unsigned char *key,
     int keylen)      int keylen)
 {  {
Line 292 
Line 292 
         memset(padded, 0, sizeof(padded));          memset(padded, 0, sizeof(padded));
 }  }
   
 void  void
 cipher_set_key_iv(CipherContext * context, int cipher,  cipher_set_key_iv(CipherContext * context, int cipher,
     const unsigned char *key, int keylen,      const unsigned char *key, int keylen,
     const unsigned char *iv, int ivlen)      const unsigned char *iv, int ivlen)
 {  {
         /* Set cipher type. */          /* Set cipher type. */
Line 352 
Line 352 
   
 /* Encrypts data using the cipher. */  /* Encrypts data using the cipher. */
   
 void  void
 cipher_encrypt(CipherContext *context, unsigned char *dest,  cipher_encrypt(CipherContext *context, unsigned char *dest,
                const unsigned char *src, unsigned int len)                 const unsigned char *src, unsigned int len)
 {  {
Line 374 
Line 374 
         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,
                                &context->u.bf.key, context->u.bf.iv,                                 &context->u.bf.key, context->u.bf.iv,
                                BF_ENCRYPT);                                 BF_ENCRYPT);
                 swap_bytes(dest, dest, len);                  swap_bytes(dest, dest, len);
                 break;                  break;
   
         case SSH_CIPHER_BLOWFISH_CBC:          case SSH_CIPHER_BLOWFISH_CBC:
                 BF_cbc_encrypt((void *)src, dest, len,                  BF_cbc_encrypt((void *)src, dest, len,
                                &context->u.bf.key, context->u.bf.iv,                                 &context->u.bf.key, context->u.bf.iv,
                                BF_ENCRYPT);                                 BF_ENCRYPT);
                 break;                  break;
   
Line 407 
Line 407 
   
 /* Decrypts data using the cipher. */  /* Decrypts data using the cipher. */
   
 void  void
 cipher_decrypt(CipherContext *context, unsigned char *dest,  cipher_decrypt(CipherContext *context, unsigned char *dest,
                const unsigned char *src, unsigned int len)                 const unsigned char *src, unsigned int len)
 {  {

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26