|
Lines 79-85
userauth_pubkey(Authctxt *authctxt)
Link Here
|
| 79 |
{ |
79 |
{ |
| 80 |
Buffer b; |
80 |
Buffer b; |
| 81 |
Key *key = NULL; |
81 |
Key *key = NULL; |
| 82 |
char *pkalg, *userstyle; |
82 |
char *pkalg, *userstyle, *pubkey; |
| 83 |
u_char *pkblob, *sig; |
83 |
u_char *pkblob, *sig; |
| 84 |
u_int alen, blen, slen; |
84 |
u_int alen, blen, slen; |
| 85 |
int have_sig, pktype; |
85 |
int have_sig, pktype; |
|
Lines 168-174
userauth_pubkey(Authctxt *authctxt)
Link Here
|
| 168 |
#ifdef DEBUG_PK |
168 |
#ifdef DEBUG_PK |
| 169 |
buffer_dump(&b); |
169 |
buffer_dump(&b); |
| 170 |
#endif |
170 |
#endif |
| 171 |
pubkey_auth_info(authctxt, key, NULL); |
171 |
pubkey = pubkey_format(key); |
|
|
172 |
auth_info(authctxt, "%s", pubkey); |
| 172 |
|
173 |
|
| 173 |
/* test for correct signature */ |
174 |
/* test for correct signature */ |
| 174 |
authenticated = 0; |
175 |
authenticated = 0; |
|
Lines 176-184
userauth_pubkey(Authctxt *authctxt)
Link Here
|
| 176 |
PRIVSEP(key_verify(key, sig, slen, buffer_ptr(&b), |
177 |
PRIVSEP(key_verify(key, sig, slen, buffer_ptr(&b), |
| 177 |
buffer_len(&b))) == 1) { |
178 |
buffer_len(&b))) == 1) { |
| 178 |
authenticated = 1; |
179 |
authenticated = 1; |
|
|
180 |
authctxt->last_details = pubkey; |
| 179 |
/* Record the successful key to prevent reuse */ |
181 |
/* Record the successful key to prevent reuse */ |
| 180 |
auth2_record_userkey(authctxt, key); |
182 |
auth2_record_userkey(authctxt, key); |
| 181 |
key = NULL; /* Don't free below */ |
183 |
key = NULL; /* Don't free below */ |
|
|
184 |
} else { |
| 185 |
free(pubkey); |
| 182 |
} |
186 |
} |
| 183 |
buffer_free(&b); |
187 |
buffer_free(&b); |
| 184 |
free(sig); |
188 |
free(sig); |
|
Lines 214-253
done:
Link Here
|
| 214 |
return authenticated; |
218 |
return authenticated; |
| 215 |
} |
219 |
} |
| 216 |
|
220 |
|
| 217 |
void |
221 |
char * |
| 218 |
pubkey_auth_info(Authctxt *authctxt, const Key *key, const char *fmt, ...) |
222 |
pubkey_format(const Key *key) |
| 219 |
{ |
223 |
{ |
| 220 |
char *fp, *extra; |
224 |
char *fp, *result; |
| 221 |
va_list ap; |
|
|
| 222 |
int i; |
| 223 |
|
| 224 |
extra = NULL; |
| 225 |
if (fmt != NULL) { |
| 226 |
va_start(ap, fmt); |
| 227 |
i = vasprintf(&extra, fmt, ap); |
| 228 |
va_end(ap); |
| 229 |
if (i < 0 || extra == NULL) |
| 230 |
fatal("%s: vasprintf failed", __func__); |
| 231 |
} |
| 232 |
|
225 |
|
| 233 |
if (key_is_cert(key)) { |
226 |
if (key_is_cert(key)) { |
| 234 |
fp = sshkey_fingerprint(key->cert->signature_key, |
227 |
fp = sshkey_fingerprint(key->cert->signature_key, |
| 235 |
options.fingerprint_hash, SSH_FP_DEFAULT); |
228 |
options.fingerprint_hash, SSH_FP_DEFAULT); |
| 236 |
auth_info(authctxt, "%s ID %s (serial %llu) CA %s %s%s%s", |
229 |
xasprintf(&result, "%s ID %s (serial %llu) CA %s %s", |
| 237 |
key_type(key), key->cert->key_id, |
230 |
key_type(key), key->cert->key_id, |
| 238 |
(unsigned long long)key->cert->serial, |
231 |
(unsigned long long)key->cert->serial, |
| 239 |
key_type(key->cert->signature_key), |
232 |
key_type(key->cert->signature_key), |
| 240 |
fp == NULL ? "(null)" : fp, |
233 |
fp == NULL ? "(null)" : fp); |
| 241 |
extra == NULL ? "" : ", ", extra == NULL ? "" : extra); |
|
|
| 242 |
free(fp); |
234 |
free(fp); |
| 243 |
} else { |
235 |
} else { |
| 244 |
fp = sshkey_fingerprint(key, options.fingerprint_hash, |
236 |
fp = sshkey_fingerprint(key, options.fingerprint_hash, |
| 245 |
SSH_FP_DEFAULT); |
237 |
SSH_FP_DEFAULT); |
| 246 |
auth_info(authctxt, "%s %s%s%s", key_type(key), |
238 |
xasprintf(&result, "%s %s", key_type(key), |
| 247 |
fp == NULL ? "(null)" : fp, |
239 |
fp == NULL ? "(null)" : fp); |
| 248 |
extra == NULL ? "" : ", ", extra == NULL ? "" : extra); |
|
|
| 249 |
free(fp); |
240 |
free(fp); |
| 250 |
} |
241 |
} |
|
|
242 |
|
| 243 |
return result; |
| 244 |
} |
| 245 |
|
| 246 |
void |
| 247 |
pubkey_auth_info(Authctxt *authctxt, const Key *key, const char *fmt, ...) |
| 248 |
{ |
| 249 |
char *extra, *pubkey; |
| 250 |
va_list ap; |
| 251 |
int i; |
| 252 |
|
| 253 |
extra = NULL; |
| 254 |
if (fmt != NULL) { |
| 255 |
va_start(ap, fmt); |
| 256 |
i = vasprintf(&extra, fmt, ap); |
| 257 |
va_end(ap); |
| 258 |
if (i < 0 || extra == NULL) |
| 259 |
fatal("%s: vasprintf failed", __func__); |
| 260 |
} |
| 261 |
|
| 262 |
pubkey = pubkey_format(key); |
| 263 |
auth_info(authctxt, "%s%s%s", pubkey, extra == NULL ? "" : ", ", |
| 264 |
extra == NULL ? "" : extra); |
| 251 |
free(extra); |
265 |
free(extra); |
| 252 |
} |
266 |
} |
| 253 |
|
267 |
|