Develop and Download Open Source Software

Browse Subversion Repository

Diff of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/cipher.h

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

revision 9209 by nmaya, Sat Apr 17 06:32:42 2021 UTC revision 9210 by nmaya, Sat Apr 17 08:36:59 2021 UTC
# Line 1  Line 1 
1  /*      $OpenBSD: cipher.h,v 1.34 2003/11/10 16:23:41 jakob Exp $       */  /* Imported from OpenSSH-8.5p1, TeraTerm Project */
2    
3    /* $OpenBSD: cipher.h,v 1.44 2014/01/25 10:12:50 dtucker Exp $ */
4    
5  /*  /*
6   * Author: Tatu Ylonen <ylo@cs.hut.fi>   * Author: Tatu Ylonen <ylo@cs.hut.fi>
# Line 37  Line 39 
39  #ifndef CIPHER_H  #ifndef CIPHER_H
40  #define CIPHER_H  #define CIPHER_H
41    
42    typedef unsigned int u_int;
43    typedef unsigned char u_char;
44    
45  #include <openssl/evp.h>  #include <openssl/evp.h>
46  /*  /*
47   * Cipher types for SSH-1.  New types can be added, but old types should not   * Cipher types for SSH-1.  New types can be added, but old types should not
# Line 45  Line 50 
50  #define SSH_CIPHER_SSH2         -3  #define SSH_CIPHER_SSH2         -3
51  #define SSH_CIPHER_ILLEGAL      -2      /* No valid cipher selected. */  #define SSH_CIPHER_ILLEGAL      -2      /* No valid cipher selected. */
52  #define SSH_CIPHER_NOT_SET      -1      /* None selected (invalid number). */  #define SSH_CIPHER_NOT_SET      -1      /* None selected (invalid number). */
53  #define SSH_CIPHER_NONE         0       /* no encryption */  //#define SSH_CIPHER_NONE               0       /* no encryption */
54  #define SSH_CIPHER_IDEA         1       /* IDEA CFB */  //#define SSH_CIPHER_IDEA               1       /* IDEA CFB */
55  #define SSH_CIPHER_DES          2       /* DES CBC */  //#define SSH_CIPHER_DES                2       /* DES CBC */
56  #define SSH_CIPHER_3DES         3       /* 3DES CBC */  //#define SSH_CIPHER_3DES               3       /* 3DES CBC */
57  #define SSH_CIPHER_BROKEN_TSS   4       /* TRI's Simple Stream encryption CBC */  //#define SSH_CIPHER_BROKEN_TSS 4       /* TRI's Simple Stream encryption CBC */
58  #define SSH_CIPHER_BROKEN_RC4   5       /* Alleged RC4 */  //#define SSH_CIPHER_BROKEN_RC4 5       /* Alleged RC4 */
59  #define SSH_CIPHER_BLOWFISH     6  //#define SSH_CIPHER_BLOWFISH   6
60  #define SSH_CIPHER_RESERVED     7  //#define SSH_CIPHER_RESERVED   7
61    
62  #define CIPHER_ENCRYPT          1  #define CIPHER_ENCRYPT          1
63  #define CIPHER_DECRYPT          0  #define CIPHER_DECRYPT          0
64    
 typedef struct Cipher Cipher;  
 typedef struct CipherContext CipherContext;  
65    
66  struct Cipher;  typedef enum {
67  struct CipherContext {          // SSH1
68          int     plaintext;          SSH_CIPHER_NONE, SSH_CIPHER_IDEA, SSH_CIPHER_DES, SSH_CIPHER_3DES,
69            SSH_CIPHER_TSS, SSH_CIPHER_RC4, SSH_CIPHER_BLOWFISH,
70            // SSH2
71            SSH2_CIPHER_3DES_CBC, SSH2_CIPHER_AES128_CBC,
72            SSH2_CIPHER_AES192_CBC, SSH2_CIPHER_AES256_CBC,
73            SSH2_CIPHER_BLOWFISH_CBC, SSH2_CIPHER_AES128_CTR,
74            SSH2_CIPHER_AES192_CTR, SSH2_CIPHER_AES256_CTR,
75            SSH2_CIPHER_ARCFOUR, SSH2_CIPHER_ARCFOUR128, SSH2_CIPHER_ARCFOUR256,
76            SSH2_CIPHER_CAST128_CBC,
77            SSH2_CIPHER_3DES_CTR, SSH2_CIPHER_BLOWFISH_CTR, SSH2_CIPHER_CAST128_CTR,
78            SSH2_CIPHER_CAMELLIA128_CBC, SSH2_CIPHER_CAMELLIA192_CBC, SSH2_CIPHER_CAMELLIA256_CBC,
79            SSH2_CIPHER_CAMELLIA128_CTR, SSH2_CIPHER_CAMELLIA192_CTR, SSH2_CIPHER_CAMELLIA256_CTR,
80            SSH2_CIPHER_AES128_GCM, SSH2_CIPHER_AES256_GCM, SSH2_CIPHER_CHACHAPOLY,
81            SSH_CIPHER_MAX = SSH2_CIPHER_CHACHAPOLY,
82    } SSHCipherId;
83    
84    struct ssh2cipher {
85            SSHCipherId id;
86            char *name;
87            u_int block_size;
88            u_int key_len;
89            u_int discard_len;
90            u_int iv_len;
91            u_int auth_len;
92            const EVP_CIPHER *(*func)(void);
93    };
94    
95    struct sshcipher_ctx {
96            // TTSSH では SSH_CIPHER_NONE が無効なので、plaintext は使用されない
97            // int  plaintext;
98            // TTSSH では CRYPT_encrypt_aead(), CRYPT_decrypt_aead() が別れていて encrypt で切り替えないので使用されない
99            // int  encrypt;
100          EVP_CIPHER_CTX *evp;          EVP_CIPHER_CTX *evp;
101          Cipher *cipher;          // struct chachapoly_ctx *cp_ctx;
102            // OpenSSH で ifndef WITH_OPENSSL の時に使用されるものなので、ac_ctx は使用されない
103            // aesctr_ctx ac_ctx; /* XXX union with evp? */
104            // OpenSSH では const struct sshcipher *cipher;
105            const struct ssh2cipher *cipher;
106  };  };
107    
108  u_int    cipher_mask_ssh1(int);  
109  Cipher  *cipher_by_name(const char *);  int get_cipher_id(const struct ssh2cipher *cipher);
110  Cipher  *cipher_by_number(int);  u_int get_cipher_block_size(const struct ssh2cipher *cipher);
111  int      cipher_number(const char *);  u_int get_cipher_key_len(const struct ssh2cipher *cipher);
112  char    *cipher_name(int);  u_int get_cipher_discard_len(const struct ssh2cipher *cipher);
113  int      ciphers_valid(const char *);  u_int get_cipher_iv_len(const struct ssh2cipher *cipher);
114  void     cipher_init(CipherContext *, Cipher *, const u_char *, u_int,  u_int get_cipher_auth_len(const struct ssh2cipher *cipher);
115      const u_char *, u_int, int);  const EVP_CIPHER *get_cipher_EVP_CIPHER(const struct ssh2cipher *cipher);
116  void     cipher_crypt(CipherContext *, u_char *, const u_char *, u_int);  char *get_cipher_string(const struct ssh2cipher *cipher);
117  void     cipher_cleanup(CipherContext *);  const struct ssh2cipher* get_cipher_by_name(char *name);
118  void     cipher_set_key_string(CipherContext *, Cipher *, const char *, int);  char *get_cipher_name(int cipher_id);
119  u_int    cipher_blocksize(const Cipher *);  char *get_listbox_cipher_name(int cipher_id, PTInstVar pvar);
120  u_int    cipher_keylen(const Cipher *);  
121    void normalize_cipher_order(char *buf);
122  u_int    cipher_get_number(const Cipher *);  const struct ssh2cipher *choose_SSH2_cipher_algorithm(char *server_proposal, char *my_proposal);
123  void     cipher_get_keyiv(CipherContext *, u_char *, u_int);  void SSH2_update_cipher_myproposal(PTInstVar pvar);
 void     cipher_set_keyiv(CipherContext *, u_char *);  
 int      cipher_get_keyiv_len(const CipherContext *);  
 int      cipher_get_keycontext(const CipherContext *, u_char *);  
 void     cipher_set_keycontext(CipherContext *, u_char *);  
124    
125  void cipher_init_SSH2(  void cipher_init_SSH2(
126          EVP_CIPHER_CTX *evp,          EVP_CIPHER_CTX *evp,
# Line 98  void cipher_init_SSH2( Line 132  void cipher_init_SSH2(
132          unsigned int authlen,          unsigned int authlen,
133          PTInstVar pvar          PTInstVar pvar
134  );  );
   
135  void cipher_free_SSH2(EVP_CIPHER_CTX *evp);  void cipher_free_SSH2(EVP_CIPHER_CTX *evp);
136    
137  #endif                          /* CIPHER_H */  #endif                          /* CIPHER_H */

Legend:
Removed from v.9209  
changed lines
  Added in v.9210

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