comparison bignum.c @ 910:89555751c489 asm

merge up to 2013.63, improve ASM makefile rules a bit
author Matt Johnston <matt@ucc.asn.au>
date Thu, 27 Feb 2014 21:35:58 +0800
parents 7540c0822374
children 2bb4c662d1c2
comparison
equal deleted inserted replaced
909:e4b75744acab 910:89555751c489
50 cur_arg = va_arg(args, mp_int*); 50 cur_arg = va_arg(args, mp_int*);
51 } 51 }
52 va_end(args); 52 va_end(args);
53 } 53 }
54 54
55 void m_mp_alloc_init_multi(mp_int **mp, ...)
56 {
57 mp_int** cur_arg = mp;
58 va_list args;
59
60 va_start(args, mp); /* init args to next argument from caller */
61 while (cur_arg != NULL) {
62 *cur_arg = m_malloc(sizeof(mp_int));
63 if (mp_init(*cur_arg) != MP_OKAY) {
64 dropbear_exit("Mem alloc error");
65 }
66 cur_arg = va_arg(args, mp_int**);
67 }
68 va_end(args);
69 }
70
55 void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) { 71 void bytes_to_mp(mp_int *mp, const unsigned char* bytes, unsigned int len) {
56 72
57 if (mp_read_unsigned_bin(mp, (unsigned char*)bytes, len) != MP_OKAY) { 73 if (mp_read_unsigned_bin(mp, (unsigned char*)bytes, len) != MP_OKAY) {
58 dropbear_exit("Mem alloc error"); 74 dropbear_exit("Mem alloc error");
59 } 75 }
60 } 76 }
61 77
62 /* hash the ssh representation of the mp_int mp */ 78 /* hash the ssh representation of the mp_int mp */
63 void sha1_process_mp(hash_state *hs, mp_int *mp) { 79 void hash_process_mp(const struct ltc_hash_descriptor *hash_desc,
64 80 hash_state *hs, mp_int *mp) {
65 int i;
66 buffer * buf; 81 buffer * buf;
67 82
68 buf = buf_new(512 + 20); /* max buffer is a 4096 bit key, 83 buf = buf_new(512 + 20); /* max buffer is a 4096 bit key,
69 plus header + some leeway*/ 84 plus header + some leeway*/
70 buf_putmpint(buf, mp); 85 buf_putmpint(buf, mp);
71 i = buf->pos; 86 hash_desc->process(hs, buf->data, buf->len);
72 buf_setpos(buf, 0);
73 sha1_process(hs, buf_getptr(buf, i), i);
74 buf_free(buf); 87 buf_free(buf);
75 } 88 }