comparison rsa.c @ 1295:750ec4ec4cbe

Convert #ifdef to #if, other build changes
author Matt Johnston <matt@ucc.asn.au>
date Wed, 04 May 2016 15:33:40 +0200
parents 2bb4c662d1c2
children c98e242dc505 553c6bb80265
comparison
equal deleted inserted replaced
1294:56aba7dedbea 1295:750ec4ec4cbe
34 #include "rsa.h" 34 #include "rsa.h"
35 #include "buffer.h" 35 #include "buffer.h"
36 #include "ssh.h" 36 #include "ssh.h"
37 #include "dbrandom.h" 37 #include "dbrandom.h"
38 38
39 #ifdef DROPBEAR_RSA 39 #if DROPBEAR_RSA
40 40
41 static void rsa_pad_em(dropbear_rsa_key * key, 41 static void rsa_pad_em(dropbear_rsa_key * key,
42 buffer *data_buf, mp_int * rsa_em); 42 buffer *data_buf, mp_int * rsa_em);
43 43
44 /* Load a public rsa key from a buffer, initialising the values. 44 /* Load a public rsa key from a buffer, initialising the values.
202 202
203 TRACE(("leave buf_put_rsa_priv_key")) 203 TRACE(("leave buf_put_rsa_priv_key"))
204 204
205 } 205 }
206 206
207 #ifdef DROPBEAR_SIGNKEY_VERIFY 207 #if DROPBEAR_SIGNKEY_VERIFY
208 /* Verify a signature in buf, made on data by the key given. 208 /* Verify a signature in buf, made on data by the key given.
209 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 209 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
210 int buf_rsa_verify(buffer * buf, dropbear_rsa_key *key, buffer *data_buf) { 210 int buf_rsa_verify(buffer * buf, dropbear_rsa_key *key, buffer *data_buf) {
211 unsigned int slen; 211 unsigned int slen;
212 DEF_MP_INT(rsa_s); 212 DEF_MP_INT(rsa_s);
277 277
278 rsa_pad_em(key, data_buf, &rsa_tmp1); 278 rsa_pad_em(key, data_buf, &rsa_tmp1);
279 279
280 /* the actual signing of the padded data */ 280 /* the actual signing of the padded data */
281 281
282 #ifdef RSA_BLINDING 282 #if DROPBEAR_RSA_BLINDING
283 283
284 /* With blinding, s = (r^(-1))((em)*r^e)^d mod n */ 284 /* With blinding, s = (r^(-1))((em)*r^e)^d mod n */
285 285
286 /* generate the r blinding value */ 286 /* generate the r blinding value */
287 /* rsa_tmp2 is r */ 287 /* rsa_tmp2 is r */
320 /* rsa_tmp1 is em */ 320 /* rsa_tmp1 is em */
321 if (mp_exptmod(&rsa_tmp1, key->d, key->n, &rsa_s) != MP_OKAY) { 321 if (mp_exptmod(&rsa_tmp1, key->d, key->n, &rsa_s) != MP_OKAY) {
322 dropbear_exit("RSA error"); 322 dropbear_exit("RSA error");
323 } 323 }
324 324
325 #endif /* RSA_BLINDING */ 325 #endif /* DROPBEAR_RSA_BLINDING */
326 326
327 mp_clear_multi(&rsa_tmp1, &rsa_tmp2, &rsa_tmp3, NULL); 327 mp_clear_multi(&rsa_tmp1, &rsa_tmp2, &rsa_tmp3, NULL);
328 328
329 /* create the signature to return */ 329 /* create the signature to return */
330 buf_putstring(buf, SSH_SIGNKEY_RSA, SSH_SIGNKEY_RSA_LEN); 330 buf_putstring(buf, SSH_SIGNKEY_RSA, SSH_SIGNKEY_RSA_LEN);