Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/crypt.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7133 by doda, Thu Jun 14 10:57:13 2018 UTC revision 7774 by maya, Sun Jun 16 03:40:20 2019 UTC
# Line 308  err: Line 308  err:
308          return FALSE;          return FALSE;
309  }  }
310    
311  static void no_encrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void no_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
312  {  {
313  }  }
314    
315  static void crypt_SSH2_encrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void crypt_SSH2_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
316  {  {
317          unsigned char *newbuff;          unsigned char *newbuff;
318          int block_size = pvar->ssh2_keys[MODE_OUT].enc.block_size;          int block_size = pvar->ssh2_keys[MODE_OUT].enc.block_size;
# Line 348  static void crypt_SSH2_encrypt(PTInstVar Line 348  static void crypt_SSH2_encrypt(PTInstVar
348          }          }
349  }  }
350    
351  static void crypt_SSH2_decrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void crypt_SSH2_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
352  {  {
353          unsigned char *newbuff;          unsigned char *newbuff;
354          int block_size = pvar->ssh2_keys[MODE_IN].enc.block_size;          int block_size = pvar->ssh2_keys[MODE_IN].enc.block_size;
# Line 384  static void crypt_SSH2_decrypt(PTInstVar Line 384  static void crypt_SSH2_decrypt(PTInstVar
384          }          }
385  }  }
386    
387  static void c3DES_encrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void c3DES_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
388  {  {
389          Cipher3DESState *encryptstate = &pvar->crypt_state.enc.c3DES;          Cipher3DESState *encryptstate = &pvar->crypt_state.enc.c3DES;
390    
# Line 396  static void c3DES_encrypt(PTInstVar pvar Line 396  static void c3DES_encrypt(PTInstVar pvar
396                           &encryptstate->k3, &encryptstate->ivec3, DES_ENCRYPT);                           &encryptstate->k3, &encryptstate->ivec3, DES_ENCRYPT);
397  }  }
398    
399  static void c3DES_decrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void c3DES_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
400  {  {
401          Cipher3DESState *decryptstate = &pvar->crypt_state.dec.c3DES;          Cipher3DESState *decryptstate = &pvar->crypt_state.dec.c3DES;
402    
# Line 408  static void c3DES_decrypt(PTInstVar pvar Line 408  static void c3DES_decrypt(PTInstVar pvar
408                           &decryptstate->k1, &decryptstate->ivec1, DES_DECRYPT);                           &decryptstate->k1, &decryptstate->ivec1, DES_DECRYPT);
409  }  }
410    
411  static void cDES_encrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void cDES_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
412  {  {
413          CipherDESState *encryptstate = &pvar->crypt_state.enc.cDES;          CipherDESState *encryptstate = &pvar->crypt_state.enc.cDES;
414    
# Line 416  static void cDES_encrypt(PTInstVar pvar, Line 416  static void cDES_encrypt(PTInstVar pvar,
416                           &encryptstate->k, &encryptstate->ivec, DES_ENCRYPT);                           &encryptstate->k, &encryptstate->ivec, DES_ENCRYPT);
417  }  }
418    
419  static void cDES_decrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void cDES_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
420  {  {
421          CipherDESState *decryptstate = &pvar->crypt_state.dec.cDES;          CipherDESState *decryptstate = &pvar->crypt_state.dec.cDES;
422    
# Line 424  static void cDES_decrypt(PTInstVar pvar, Line 424  static void cDES_decrypt(PTInstVar pvar,
424                           &decryptstate->k, &decryptstate->ivec, DES_DECRYPT);                           &decryptstate->k, &decryptstate->ivec, DES_DECRYPT);
425  }  }
426    
427  static void flip_endianness(unsigned char *cbuf, int bytes)  static void flip_endianness(unsigned char *cbuf, unsigned int bytes)
428  {  {
429          uint32 *buf = (uint32 *) cbuf;          uint32 *buf = (uint32 *) cbuf;
430          int count = bytes / 4;          int count = bytes / 4;
# Line 439  static void flip_endianness(unsigned cha Line 439  static void flip_endianness(unsigned cha
439          }          }
440  }  }
441    
442  static void cBlowfish_encrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void cBlowfish_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
443  {  {
444          CipherBlowfishState *encryptstate =          CipherBlowfishState *encryptstate =
445                  &pvar->crypt_state.enc.cBlowfish;                  &pvar->crypt_state.enc.cBlowfish;
# Line 450  static void cBlowfish_encrypt(PTInstVar Line 450  static void cBlowfish_encrypt(PTInstVar
450          flip_endianness(buf, bytes);          flip_endianness(buf, bytes);
451  }  }
452    
453  static void cBlowfish_decrypt(PTInstVar pvar, unsigned char *buf, int bytes)  static void cBlowfish_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
454  {  {
455          CipherBlowfishState *decryptstate =          CipherBlowfishState *decryptstate =
456                  &pvar->crypt_state.dec.cBlowfish;                  &pvar->crypt_state.dec.cBlowfish;
# Line 461  static void cBlowfish_decrypt(PTInstVar Line 461  static void cBlowfish_decrypt(PTInstVar
461          flip_endianness(buf, bytes);          flip_endianness(buf, bytes);
462  }  }
463    
464  void CRYPT_set_random_data(PTInstVar pvar, unsigned char *buf, int bytes)  void CRYPT_set_random_data(PTInstVar pvar, unsigned char *buf, unsigned int bytes)
465  {  {
466          RAND_bytes(buf, bytes);          RAND_bytes(buf, bytes);
467  }  }

Legend:
Removed from v.7133  
changed lines
  Added in v.7774

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26