OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 /* | 4 /* |
5 * This file deals with PKCS #11 passwords and authentication. | 5 * This file deals with PKCS #11 passwords and authentication. |
6 */ | 6 */ |
7 #include "seccomon.h" | 7 #include "seccomon.h" |
8 #include "secmod.h" | 8 #include "secmod.h" |
9 #include "secmodi.h" | 9 #include "secmodi.h" |
10 #include "secmodti.h" | 10 #include "secmodti.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 * Check the user's password. Log into the card if it's correct. | 45 * Check the user's password. Log into the card if it's correct. |
46 * succeed if the user is already logged in. | 46 * succeed if the user is already logged in. |
47 */ | 47 */ |
48 static SECStatus | 48 static SECStatus |
49 pk11_CheckPassword(PK11SlotInfo *slot, CK_SESSION_HANDLE session, | 49 pk11_CheckPassword(PK11SlotInfo *slot, CK_SESSION_HANDLE session, |
50 char *pw, PRBool alreadyLocked, PRBool contextSpecific) | 50 char *pw, PRBool alreadyLocked, PRBool contextSpecific) |
51 { | 51 { |
52 int len = 0; | 52 int len = 0; |
53 CK_RV crv; | 53 CK_RV crv; |
54 SECStatus rv; | 54 SECStatus rv; |
55 int64 currtime = PR_Now(); | 55 PRTime currtime = PR_Now(); |
56 PRBool mustRetry; | 56 PRBool mustRetry; |
57 int retry = 0; | 57 int retry = 0; |
58 | 58 |
59 if (slot->protectedAuthPath) { | 59 if (slot->protectedAuthPath) { |
60 len = 0; | 60 len = 0; |
61 pw = NULL; | 61 pw = NULL; |
62 } else if (pw == NULL) { | 62 } else if (pw == NULL) { |
63 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 63 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
64 return SECFailure; | 64 return SECFailure; |
65 } else { | 65 } else { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 /* | 125 /* |
126 * Check the user's password. Logout before hand to make sure that | 126 * Check the user's password. Logout before hand to make sure that |
127 * we are really checking the password. | 127 * we are really checking the password. |
128 */ | 128 */ |
129 SECStatus | 129 SECStatus |
130 PK11_CheckUserPassword(PK11SlotInfo *slot, const char *pw) | 130 PK11_CheckUserPassword(PK11SlotInfo *slot, const char *pw) |
131 { | 131 { |
132 int len = 0; | 132 int len = 0; |
133 CK_RV crv; | 133 CK_RV crv; |
134 SECStatus rv; | 134 SECStatus rv; |
135 int64 currtime = PR_Now(); | 135 PRTime currtime = PR_Now(); |
136 | 136 |
137 if (slot->protectedAuthPath) { | 137 if (slot->protectedAuthPath) { |
138 len = 0; | 138 len = 0; |
139 pw = NULL; | 139 pw = NULL; |
140 } else if (pw == NULL) { | 140 } else if (pw == NULL) { |
141 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 141 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
142 return SECFailure; | 142 return SECFailure; |
143 } else { | 143 } else { |
144 len = PORT_Strlen(pw); | 144 len = PORT_Strlen(pw); |
145 } | 145 } |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 PK11_FreeSlot(def_slot); | 731 PK11_FreeSlot(def_slot); |
732 } | 732 } |
733 } | 733 } |
734 | 734 |
735 if ((wincx != NULL) && (PK11_Global.isLoggedIn != NULL) && | 735 if ((wincx != NULL) && (PK11_Global.isLoggedIn != NULL) && |
736 (*PK11_Global.isLoggedIn)(slot, wincx) == PR_FALSE) { return PR_FALSE; } | 736 (*PK11_Global.isLoggedIn)(slot, wincx) == PR_FALSE) { return PR_FALSE; } |
737 | 737 |
738 | 738 |
739 /* forget the password if we've been inactive too long */ | 739 /* forget the password if we've been inactive too long */ |
740 if (askpw == 1) { | 740 if (askpw == 1) { |
741 » int64 currtime = PR_Now(); | 741 » PRTime currtime = PR_Now(); |
742 » int64 result; | 742 » PRTime result; |
743 » int64 mult; | 743 » PRTime mult; |
744 | 744 |
745 LL_I2L(result, timeout); | 745 LL_I2L(result, timeout); |
746 LL_I2L(mult, 60*1000*1000); | 746 LL_I2L(mult, 60*1000*1000); |
747 LL_MUL(result,result,mult); | 747 LL_MUL(result,result,mult); |
748 LL_ADD(result, result, slot->authTime); | 748 LL_ADD(result, result, slot->authTime); |
749 if (LL_CMP(result, <, currtime) ) { | 749 if (LL_CMP(result, <, currtime) ) { |
750 PK11_EnterSlotMonitor(slot); | 750 PK11_EnterSlotMonitor(slot); |
751 PK11_GETTAB(slot)->C_Logout(slot->session); | 751 PK11_GETTAB(slot)->C_Logout(slot->session); |
752 slot->lastLoginCheck = 0; | 752 slot->lastLoginCheck = 0; |
753 PK11_ExitSlotMonitor(slot); | 753 PK11_ExitSlotMonitor(slot); |
(...skipping 25 matching lines...) Expand all Loading... |
779 case CKS_RO_PUBLIC_SESSION: | 779 case CKS_RO_PUBLIC_SESSION: |
780 default: | 780 default: |
781 break; /* fail */ | 781 break; /* fail */ |
782 case CKS_RW_USER_FUNCTIONS: | 782 case CKS_RW_USER_FUNCTIONS: |
783 case CKS_RW_SO_FUNCTIONS: | 783 case CKS_RW_SO_FUNCTIONS: |
784 case CKS_RO_USER_FUNCTIONS: | 784 case CKS_RO_USER_FUNCTIONS: |
785 return PR_TRUE; | 785 return PR_TRUE; |
786 } | 786 } |
787 return PR_FALSE; | 787 return PR_FALSE; |
788 } | 788 } |
OLD | NEW |