comparison signkey.c @ 731:9a5438271556

Move the more verbose TRACE() statements into TRACE2()
author Matt Johnston <matt@ucc.asn.au>
date Mon, 01 Apr 2013 00:07:26 +0800
parents a48a1f6ab43e
children 7dcb46da72d9
comparison
equal deleted inserted replaced
730:714b9106e335 731:9a5438271556
96 unsigned char* ident; 96 unsigned char* ident;
97 unsigned int len; 97 unsigned int len;
98 int keytype; 98 int keytype;
99 int ret = DROPBEAR_FAILURE; 99 int ret = DROPBEAR_FAILURE;
100 100
101 TRACE(("enter buf_get_pub_key")) 101 TRACE2(("enter buf_get_pub_key"))
102 102
103 ident = buf_getstring(buf, &len); 103 ident = buf_getstring(buf, &len);
104 keytype = signkey_type_from_name(ident, len); 104 keytype = signkey_type_from_name(ident, len);
105 m_free(ident); 105 m_free(ident);
106 106
107 if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) { 107 if (*type != DROPBEAR_SIGNKEY_ANY && *type != keytype) {
108 TRACE(("buf_get_pub_key bad type - got %d, expected %d", keytype, *type)) 108 TRACE(("buf_get_pub_key bad type - got %d, expected %d", keytype, *type))
109 return DROPBEAR_FAILURE; 109 return DROPBEAR_FAILURE;
110 } 110 }
111 111
112 TRACE(("buf_get_pub_key keytype is %d", keytype)) 112 TRACE2(("buf_get_pub_key keytype is %d", keytype))
113 113
114 *type = keytype; 114 *type = keytype;
115 115
116 /* Rewind the buffer back before "ssh-rsa" etc */ 116 /* Rewind the buffer back before "ssh-rsa" etc */
117 buf_incrpos(buf, -len - 4); 117 buf_incrpos(buf, -len - 4);
135 m_free(key->rsakey); 135 m_free(key->rsakey);
136 } 136 }
137 } 137 }
138 #endif 138 #endif
139 139
140 TRACE(("leave buf_get_pub_key")) 140 TRACE2(("leave buf_get_pub_key"))
141 141
142 return ret; 142 return ret;
143 143
144 } 144 }
145 145
151 unsigned char* ident; 151 unsigned char* ident;
152 unsigned int len; 152 unsigned int len;
153 int keytype; 153 int keytype;
154 int ret = DROPBEAR_FAILURE; 154 int ret = DROPBEAR_FAILURE;
155 155
156 TRACE(("enter buf_get_priv_key")) 156 TRACE2(("enter buf_get_priv_key"))
157 157
158 ident = buf_getstring(buf, &len); 158 ident = buf_getstring(buf, &len);
159 keytype = signkey_type_from_name(ident, len); 159 keytype = signkey_type_from_name(ident, len);
160 m_free(ident); 160 m_free(ident);
161 161
188 m_free(key->rsakey); 188 m_free(key->rsakey);
189 } 189 }
190 } 190 }
191 #endif 191 #endif
192 192
193 TRACE(("leave buf_get_priv_key")) 193 TRACE2(("leave buf_get_priv_key"))
194 194
195 return ret; 195 return ret;
196 196
197 } 197 }
198 198
199 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */ 199 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */
200 void buf_put_pub_key(buffer* buf, sign_key *key, int type) { 200 void buf_put_pub_key(buffer* buf, sign_key *key, int type) {
201 201
202 buffer *pubkeys; 202 buffer *pubkeys;
203 203
204 TRACE(("enter buf_put_pub_key")) 204 TRACE2(("enter buf_put_pub_key"))
205 pubkeys = buf_new(MAX_PUBKEY_SIZE); 205 pubkeys = buf_new(MAX_PUBKEY_SIZE);
206 206
207 #ifdef DROPBEAR_DSS 207 #ifdef DROPBEAR_DSS
208 if (type == DROPBEAR_SIGNKEY_DSS) { 208 if (type == DROPBEAR_SIGNKEY_DSS) {
209 buf_put_dss_pub_key(pubkeys, key->dsskey); 209 buf_put_dss_pub_key(pubkeys, key->dsskey);
221 buf_setpos(pubkeys, 0); 221 buf_setpos(pubkeys, 0);
222 buf_putstring(buf, buf_getptr(pubkeys, pubkeys->len), 222 buf_putstring(buf, buf_getptr(pubkeys, pubkeys->len),
223 pubkeys->len); 223 pubkeys->len);
224 224
225 buf_free(pubkeys); 225 buf_free(pubkeys);
226 TRACE(("leave buf_put_pub_key")) 226 TRACE2(("leave buf_put_pub_key"))
227 } 227 }
228 228
229 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */ 229 /* type is either DROPBEAR_SIGNKEY_DSS or DROPBEAR_SIGNKEY_RSA */
230 void buf_put_priv_key(buffer* buf, sign_key *key, int type) { 230 void buf_put_priv_key(buffer* buf, sign_key *key, int type) {
231 231
249 dropbear_exit("Bad key types in put pub key"); 249 dropbear_exit("Bad key types in put pub key");
250 } 250 }
251 251
252 void sign_key_free(sign_key *key) { 252 void sign_key_free(sign_key *key) {
253 253
254 TRACE(("enter sign_key_free")) 254 TRACE2(("enter sign_key_free"))
255 255
256 #ifdef DROPBEAR_DSS 256 #ifdef DROPBEAR_DSS
257 dss_key_free(key->dsskey); 257 dss_key_free(key->dsskey);
258 key->dsskey = NULL; 258 key->dsskey = NULL;
259 #endif 259 #endif
263 #endif 263 #endif
264 264
265 m_free(key->filename); 265 m_free(key->filename);
266 266
267 m_free(key); 267 m_free(key);
268 TRACE(("leave sign_key_free")) 268 TRACE2(("leave sign_key_free"))
269 } 269 }
270 270
271 static char hexdig(unsigned char x) { 271 static char hexdig(unsigned char x) {
272 272
273 if (x > 0xf) 273 if (x > 0xf)