comparison svr-authpubkey.c @ 1059:703c7cdd2577 nocircbuffer

Fix pubkey auth after change to reuse ses.readbuf as ses.payload (4d7b4c5526c5)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 01 Mar 2015 23:02:06 +0800
parents b11cb2518116
children c45d65392c1a
comparison
equal deleted inserted replaced
1057:16584026a1f0 1059:703c7cdd2577
84 unsigned char testkey; /* whether we're just checking if a key is usable */ 84 unsigned char testkey; /* whether we're just checking if a key is usable */
85 unsigned char* algo = NULL; /* pubkey algo */ 85 unsigned char* algo = NULL; /* pubkey algo */
86 unsigned int algolen; 86 unsigned int algolen;
87 unsigned char* keyblob = NULL; 87 unsigned char* keyblob = NULL;
88 unsigned int keybloblen; 88 unsigned int keybloblen;
89 unsigned int sign_payload_length;
89 buffer * signbuf = NULL; 90 buffer * signbuf = NULL;
90 sign_key * key = NULL; 91 sign_key * key = NULL;
91 char* fp = NULL; 92 char* fp = NULL;
92 enum signkey_type type = -1; 93 enum signkey_type type = -1;
93 94
123 goto out; 124 goto out;
124 } 125 }
125 126
126 /* create the data which has been signed - this a string containing 127 /* create the data which has been signed - this a string containing
127 * session_id, concatenated with the payload packet up to the signature */ 128 * session_id, concatenated with the payload packet up to the signature */
129 assert(ses.payload_beginning <= ses.payload->pos);
130 sign_payload_length = ses.payload->pos - ses.payload_beginning;
128 signbuf = buf_new(ses.payload->pos + 4 + ses.session_id->len); 131 signbuf = buf_new(ses.payload->pos + 4 + ses.session_id->len);
129 buf_putbufstring(signbuf, ses.session_id); 132 buf_putbufstring(signbuf, ses.session_id);
130 buf_putbytes(signbuf, ses.payload->data, ses.payload->pos); 133
134 /* The entire contents of the payload prior. */
135 buf_setpos(ses.payload, ses.payload_beginning);
136 buf_putbytes(signbuf,
137 buf_getptr(ses.payload, sign_payload_length),
138 sign_payload_length);
139 buf_incrpos(ses.payload, sign_payload_length);
140
131 buf_setpos(signbuf, 0); 141 buf_setpos(signbuf, 0);
132 142
133 /* ... and finally verify the signature */ 143 /* ... and finally verify the signature */
134 fp = sign_key_fingerprint(keyblob, keybloblen); 144 fp = sign_key_fingerprint(keyblob, keybloblen);
135 if (buf_verify(ses.payload, key, signbuf) == DROPBEAR_SUCCESS) { 145 if (buf_verify(ses.payload, key, signbuf) == DROPBEAR_SUCCESS) {