comparison svr-authpubkey.c @ 44:45edf30ea0a6

Improved signkey code
author Matt Johnston <matt@ucc.asn.au>
date Tue, 03 Aug 2004 15:51:55 +0000
parents f789045062e6
children 095d689fed16
comparison
equal deleted inserted replaced
43:942b22d7dd1c 44:45edf30ea0a6
56 unsigned char* algo = NULL; /* pubkey algo */ 56 unsigned char* algo = NULL; /* pubkey algo */
57 unsigned int algolen; 57 unsigned int algolen;
58 unsigned char* keyblob; 58 unsigned char* keyblob;
59 unsigned int keybloblen; 59 unsigned int keybloblen;
60 buffer * signbuf = NULL; 60 buffer * signbuf = NULL;
61 unsigned int sigoffset;
62 sign_key * key = NULL; 61 sign_key * key = NULL;
63 char* fp = NULL; 62 char* fp = NULL;
64 int type = -1; 63 int type = -1;
65 64
66 TRACE(("enter pubkeyauth")); 65 TRACE(("enter pubkeyauth"));
97 96
98 /* create the data which has been signed - this a string containing 97 /* create the data which has been signed - this a string containing
99 * session_id, concatenated with the payload packet up to the signature */ 98 * session_id, concatenated with the payload packet up to the signature */
100 signbuf = buf_new(ses.payload->pos + 4 + SHA1_HASH_SIZE); 99 signbuf = buf_new(ses.payload->pos + 4 + SHA1_HASH_SIZE);
101 buf_putstring(signbuf, ses.session_id, SHA1_HASH_SIZE); 100 buf_putstring(signbuf, ses.session_id, SHA1_HASH_SIZE);
102 sigoffset = ses.payload->pos; 101 buf_putbytes(signbuf, ses.payload->data, ses.payload->pos);
103 buf_setpos(ses.payload, 0);
104 memcpy(buf_getwriteptr(signbuf, sigoffset),
105 buf_getptr(ses.payload, sigoffset), sigoffset);
106 buf_incrwritepos(signbuf, sigoffset);
107 buf_setpos(ses.payload, sigoffset);
108
109 buf_setpos(signbuf, 0); 102 buf_setpos(signbuf, 0);
103
110 /* ... and finally verify the signature */ 104 /* ... and finally verify the signature */
111 fp = sign_key_fingerprint(key, type); 105 fp = sign_key_fingerprint(key, type);
112 if (buf_verify(ses.payload, key, buf_getptr(signbuf, signbuf->len), 106 if (buf_verify(ses.payload, key, buf_getptr(signbuf, signbuf->len),
113 signbuf->len) == DROPBEAR_SUCCESS) { 107 signbuf->len) == DROPBEAR_SUCCESS) {
114 dropbear_log(LOG_NOTICE, 108 dropbear_log(LOG_NOTICE,