summaryrefslogtreecommitdiff
path: root/ssh-pkcs11.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2013-09-14 15:43:03 +0100
committerColin Watson <cjwatson@debian.org>2013-09-14 15:43:03 +0100
commit8faf8c84430cf3c19705b1d9f8889d256e7fd1fd (patch)
treee6cb74192adb00fda5e4d1457547851d7e0d86af /ssh-pkcs11.c
parent328b60656f29db6306994d7498dede386ec2d1c3 (diff)
parentc41345ad7ee5a22689e2c009595e85fa27b4b39a (diff)
merge 6.3p1
Diffstat (limited to 'ssh-pkcs11.c')
-rw-r--r--ssh-pkcs11.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c
index 1f4c1c8e4..618c07526 100644
--- a/ssh-pkcs11.c
+++ b/ssh-pkcs11.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-pkcs11.c,v 1.6 2010/06/08 21:32:19 markus Exp $ */ 1/* $OpenBSD: ssh-pkcs11.c,v 1.8 2013/07/12 00:20:00 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved. 3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
4 * 4 *
@@ -120,9 +120,9 @@ pkcs11_provider_unref(struct pkcs11_provider *p)
120 if (--p->refcount <= 0) { 120 if (--p->refcount <= 0) {
121 if (p->valid) 121 if (p->valid)
122 error("pkcs11_provider_unref: %p still valid", p); 122 error("pkcs11_provider_unref: %p still valid", p);
123 xfree(p->slotlist); 123 free(p->slotlist);
124 xfree(p->slotinfo); 124 free(p->slotinfo);
125 xfree(p); 125 free(p);
126 } 126 }
127} 127}
128 128
@@ -180,9 +180,8 @@ pkcs11_rsa_finish(RSA *rsa)
180 rv = k11->orig_finish(rsa); 180 rv = k11->orig_finish(rsa);
181 if (k11->provider) 181 if (k11->provider)
182 pkcs11_provider_unref(k11->provider); 182 pkcs11_provider_unref(k11->provider);
183 if (k11->keyid) 183 free(k11->keyid);
184 xfree(k11->keyid); 184 free(k11);
185 xfree(k11);
186 } 185 }
187 return (rv); 186 return (rv);
188} 187}
@@ -264,13 +263,13 @@ pkcs11_rsa_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
264 pin = read_passphrase(prompt, RP_ALLOW_EOF); 263 pin = read_passphrase(prompt, RP_ALLOW_EOF);
265 if (pin == NULL) 264 if (pin == NULL)
266 return (-1); /* bail out */ 265 return (-1); /* bail out */
267 if ((rv = f->C_Login(si->session, CKU_USER, pin, strlen(pin))) 266 if ((rv = f->C_Login(si->session, CKU_USER,
268 != CKR_OK) { 267 (u_char *)pin, strlen(pin))) != CKR_OK) {
269 xfree(pin); 268 free(pin);
270 error("C_Login failed: %lu", rv); 269 error("C_Login failed: %lu", rv);
271 return (-1); 270 return (-1);
272 } 271 }
273 xfree(pin); 272 free(pin);
274 si->logged_in = 1; 273 si->logged_in = 1;
275 } 274 }
276 key_filter[1].pValue = k11->keyid; 275 key_filter[1].pValue = k11->keyid;
@@ -329,7 +328,7 @@ pkcs11_rsa_wrap(struct pkcs11_provider *provider, CK_ULONG slotidx,
329 328
330/* remove trailing spaces */ 329/* remove trailing spaces */
331static void 330static void
332rmspace(char *buf, size_t len) 331rmspace(u_char *buf, size_t len)
333{ 332{
334 size_t i; 333 size_t i;
335 334
@@ -367,8 +366,8 @@ pkcs11_open_session(struct pkcs11_provider *p, CK_ULONG slotidx, char *pin)
367 return (-1); 366 return (-1);
368 } 367 }
369 if (login_required && pin) { 368 if (login_required && pin) {
370 if ((rv = f->C_Login(session, CKU_USER, pin, strlen(pin))) 369 if ((rv = f->C_Login(session, CKU_USER,
371 != CKR_OK) { 370 (u_char *)pin, strlen(pin))) != CKR_OK) {
372 error("C_Login failed: %lu", rv); 371 error("C_Login failed: %lu", rv);
373 if ((rv = f->C_CloseSession(session)) != CKR_OK) 372 if ((rv = f->C_CloseSession(session)) != CKR_OK)
374 error("C_CloseSession failed: %lu", rv); 373 error("C_CloseSession failed: %lu", rv);
@@ -470,7 +469,7 @@ pkcs11_fetch_keys(struct pkcs11_provider *p, CK_ULONG slotidx, Key ***keysp,
470 } 469 }
471 } 470 }
472 for (i = 0; i < 3; i++) 471 for (i = 0; i < 3; i++)
473 xfree(attribs[i].pValue); 472 free(attribs[i].pValue);
474 } 473 }
475 if ((rv = f->C_FindObjectsFinal(session)) != CKR_OK) 474 if ((rv = f->C_FindObjectsFinal(session)) != CKR_OK)
476 error("C_FindObjectsFinal failed: %lu", rv); 475 error("C_FindObjectsFinal failed: %lu", rv);
@@ -579,11 +578,9 @@ fail:
579 if (need_finalize && (rv = f->C_Finalize(NULL)) != CKR_OK) 578 if (need_finalize && (rv = f->C_Finalize(NULL)) != CKR_OK)
580 error("C_Finalize failed: %lu", rv); 579 error("C_Finalize failed: %lu", rv);
581 if (p) { 580 if (p) {
582 if (p->slotlist) 581 free(p->slotlist);
583 xfree(p->slotlist); 582 free(p->slotinfo);
584 if (p->slotinfo) 583 free(p);
585 xfree(p->slotinfo);
586 xfree(p);
587 } 584 }
588 if (handle) 585 if (handle)
589 dlclose(handle); 586 dlclose(handle);