comparison algo.h @ 759:76fba0856749 ecc

More changes for KEX and ECDH. Set up hash descriptors, make ECC code work, ses.hash and ses.session_id are now buffers (doesn't compile)
author Matt Johnston <matt@ucc.asn.au>
date Fri, 29 Mar 2013 00:28:09 +0800
parents bf9dc2d9c2b1
children ac2158e3e403
comparison
equal deleted inserted replaced
758:1c607a62d235 759:76fba0856749
33 #define DROPBEAR_MODE_CBC 1 33 #define DROPBEAR_MODE_CBC 1
34 #define DROPBEAR_MODE_CTR 2 34 #define DROPBEAR_MODE_CTR 2
35 35
36 struct Algo_Type { 36 struct Algo_Type {
37 37
38 unsigned char *name; /* identifying name */ 38 const unsigned char *name; /* identifying name */
39 char val; /* a value for this cipher, or -1 for invalid */ 39 const char val; /* a value for this cipher, or -1 for invalid */
40 const void *data; /* algorithm specific data */ 40 const void *data; /* algorithm specific data */
41 char usable; /* whether we can use this algorithm */ 41 char usable; /* whether we can use this algorithm */
42 const void *mode; /* the mode, currently only used for ciphers, 42 const void *mode; /* the mode, currently only used for ciphers,
43 points to a 'struct dropbear_cipher_mode' */ 43 points to a 'struct dropbear_cipher_mode' */
44 }; 44 };
57 extern const struct dropbear_cipher_mode dropbear_mode_none; 57 extern const struct dropbear_cipher_mode dropbear_mode_none;
58 extern const struct dropbear_hash dropbear_nohash; 58 extern const struct dropbear_hash dropbear_nohash;
59 59
60 struct dropbear_cipher { 60 struct dropbear_cipher {
61 const struct ltc_cipher_descriptor *cipherdesc; 61 const struct ltc_cipher_descriptor *cipherdesc;
62 unsigned long keysize; 62 const unsigned long keysize;
63 unsigned char blocksize; 63 const unsigned char blocksize;
64 }; 64 };
65 65
66 struct dropbear_cipher_mode { 66 struct dropbear_cipher_mode {
67 int (*start)(int cipher, const unsigned char *IV, 67 int (*start)(int cipher, const unsigned char *IV,
68 const unsigned char *key, 68 const unsigned char *key,
73 unsigned long len, void *cipher_state); 73 unsigned long len, void *cipher_state);
74 }; 74 };
75 75
76 struct dropbear_hash { 76 struct dropbear_hash {
77 const struct ltc_hash_descriptor *hashdesc; 77 const struct ltc_hash_descriptor *hashdesc;
78 unsigned long keysize; 78 const unsigned long keysize;
79 unsigned char hashsize; 79 const unsigned char hashsize;
80 }; 80 };
81 81
82 struct dropbear_kex { 82 struct dropbear_kex {
83 // "normal" DH KEX 83 // "normal" DH KEX
84 unsigned char *dh_p_bytes; 84 const unsigned char *dh_p_bytes;
85 int dh_p_len; 85 const int dh_p_len;
86 86
87 // elliptic curve DH KEX 87 // elliptic curve DH KEX
88 #ifdef DROPBEAR_ECDH 88 #ifdef DROPBEAR_ECDH
89 const struct dropbear_ecc_curve *ecc_curve; 89 const struct dropbear_ecc_curve *ecc_curve;
90 #endif 90 #endif
106 int check_user_algos(const char* user_algo_list, algo_type * algos, 106 int check_user_algos(const char* user_algo_list, algo_type * algos,
107 const char *algo_desc); 107 const char *algo_desc);
108 char * algolist_string(algo_type algos[]); 108 char * algolist_string(algo_type algos[]);
109 #endif 109 #endif
110 110
111 enum kex_type {
112 DROPBEAR_KEX_DH_GROUP1,
113 DROPBEAR_KEX_DH_GROUP14,
114 DROPBEAR_KEX_ECDH_SECP256R1,
115 DROPBEAR_KEX_ECDH_SECP384R1,
116 DROPBEAR_KEX_ECDH_SECP521R1,
117 };
118
119 #ifdef DROPBEAR_ECDH 111 #ifdef DROPBEAR_ECDH
120 #define IS_NORMAL_DH(algo) ((algo)->dh_p_bytes != NULL) 112 #define IS_NORMAL_DH(algo) ((algo)->dh_p_bytes != NULL)
121 #else 113 #else
122 #define IS_NORMAL_DH(algo) 1 114 #define IS_NORMAL_DH(algo) 1
123 #endif 115 #endif