summaryrefslogtreecommitdiff
path: root/ssh-pkcs11.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-pkcs11.c')
-rw-r--r--ssh-pkcs11.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c
index a302c79c0..ec0e91865 100644
--- a/ssh-pkcs11.c
+++ b/ssh-pkcs11.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-pkcs11.c,v 1.47 2020/01/25 00:03:36 djm Exp $ */ 1/* $OpenBSD: ssh-pkcs11.c,v 1.49 2020/03/13 04:16:27 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2010 Markus Friedl. All rights reserved. 3 * Copyright (c) 2010 Markus Friedl. All rights reserved.
4 * Copyright (c) 2014 Pedro Martelletto. All rights reserved. 4 * Copyright (c) 2014 Pedro Martelletto. All rights reserved.
@@ -271,9 +271,24 @@ pkcs11_login_slot(struct pkcs11_provider *provider, struct pkcs11_slotinfo *si,
271 (pin != NULL) ? strlen(pin) : 0); 271 (pin != NULL) ? strlen(pin) : 0);
272 if (pin != NULL) 272 if (pin != NULL)
273 freezero(pin, strlen(pin)); 273 freezero(pin, strlen(pin));
274 if (rv != CKR_OK && rv != CKR_USER_ALREADY_LOGGED_IN) { 274
275 error("C_Login failed: %lu", rv); 275 switch (rv) {
276 return (-1); 276 case CKR_OK:
277 case CKR_USER_ALREADY_LOGGED_IN:
278 /* success */
279 break;
280 case CKR_PIN_LEN_RANGE:
281 error("PKCS#11 login failed: PIN length out of range");
282 return -1;
283 case CKR_PIN_INCORRECT:
284 error("PKCS#11 login failed: PIN incorrect");
285 return -1;
286 case CKR_PIN_LOCKED:
287 error("PKCS#11 login failed: PIN locked");
288 return -1;
289 default:
290 error("PKCS#11 login failed: error %lu", rv);
291 return -1;
277 } 292 }
278 si->logged_in = 1; 293 si->logged_in = 1;
279 return (0); 294 return (0);
@@ -1627,6 +1642,8 @@ fail:
1627 } 1642 }
1628 if (handle) 1643 if (handle)
1629 dlclose(handle); 1644 dlclose(handle);
1645 if (ret > 0)
1646 ret = -1;
1630 return (ret); 1647 return (ret);
1631} 1648}
1632 1649