diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-02-02 22:48:53 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-02-03 11:06:16 +1100 |
commit | cb3bde373e80902c7d5d0db429f85068d19b2918 (patch) | |
tree | f5cb6453e5036e33a93ffedf5fac0c75229e5004 /ssh-pkcs11.c | |
parent | 15ad750e5ec3cc69765b7eba1ce90060e7083399 (diff) |
upstream commit
handle PKCS#11 C_Login returning
CKR_USER_ALREADY_LOGGED_IN; based on patch from Yuri Samoilenko; ok markus@
Diffstat (limited to 'ssh-pkcs11.c')
-rw-r--r-- | ssh-pkcs11.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ssh-pkcs11.c b/ssh-pkcs11.c index e91df8bb1..ddc89d515 100644 --- a/ssh-pkcs11.c +++ b/ssh-pkcs11.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-pkcs11.c,v 1.15 2015/01/15 09:40:00 djm Exp $ */ | 1 | /* $OpenBSD: ssh-pkcs11.c,v 1.16 2015/02/02 22:48:53 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2010 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2010 Markus Friedl. All rights reserved. |
4 | * | 4 | * |
@@ -263,8 +263,9 @@ pkcs11_rsa_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa, | |||
263 | pin = read_passphrase(prompt, RP_ALLOW_EOF); | 263 | pin = read_passphrase(prompt, RP_ALLOW_EOF); |
264 | if (pin == NULL) | 264 | if (pin == NULL) |
265 | return (-1); /* bail out */ | 265 | return (-1); /* bail out */ |
266 | if ((rv = f->C_Login(si->session, CKU_USER, | 266 | rv = f->C_Login(si->session, CKU_USER, |
267 | (u_char *)pin, strlen(pin))) != CKR_OK) { | 267 | (u_char *)pin, strlen(pin)); |
268 | if (rv != CKR_OK && rv != CKR_USER_ALREADY_LOGGED_IN) { | ||
268 | free(pin); | 269 | free(pin); |
269 | error("C_Login failed: %lu", rv); | 270 | error("C_Login failed: %lu", rv); |
270 | return (-1); | 271 | return (-1); |
@@ -366,8 +367,9 @@ pkcs11_open_session(struct pkcs11_provider *p, CK_ULONG slotidx, char *pin) | |||
366 | return (-1); | 367 | return (-1); |
367 | } | 368 | } |
368 | if (login_required && pin) { | 369 | if (login_required && pin) { |
369 | if ((rv = f->C_Login(session, CKU_USER, | 370 | rv = f->C_Login(session, CKU_USER, |
370 | (u_char *)pin, strlen(pin))) != CKR_OK) { | 371 | (u_char *)pin, strlen(pin)) |
372 | if (rv != CKR_OK && rv != CKR_USER_ALREADY_LOGGED_IN) { | ||
371 | error("C_Login failed: %lu", rv); | 373 | error("C_Login failed: %lu", rv); |
372 | if ((rv = f->C_CloseSession(session)) != CKR_OK) | 374 | if ((rv = f->C_CloseSession(session)) != CKR_OK) |
373 | error("C_CloseSession failed: %lu", rv); | 375 | error("C_CloseSession failed: %lu", rv); |