OLD | NEW |
1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
3 * | 3 * |
4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
8 * | 8 * |
9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 } | 472 } |
473 | 473 |
474 /* | 474 /* |
475 * Change an existing user password | 475 * Change an existing user password |
476 */ | 476 */ |
477 SECStatus | 477 SECStatus |
478 PK11_ChangePW(PK11SlotInfo *slot, const char *oldpw, const char *newpw) | 478 PK11_ChangePW(PK11SlotInfo *slot, const char *oldpw, const char *newpw) |
479 { | 479 { |
480 CK_RV crv; | 480 CK_RV crv; |
481 SECStatus rv = SECFailure; | 481 SECStatus rv = SECFailure; |
482 int newLen; | 482 int newLen = 0; |
483 int oldLen; | 483 int oldLen = 0; |
484 CK_SESSION_HANDLE rwsession; | 484 CK_SESSION_HANDLE rwsession; |
485 | 485 |
486 /* use NULL values to trigger the protected authentication path */ | 486 /* use NULL values to trigger the protected authentication path */ |
487 if (slot->protectedAuthPath) { | 487 if (!slot->protectedAuthPath) { |
488 » if (newpw == NULL) newLen = 0; | |
489 » if (oldpw == NULL) oldLen = 0; | |
490 } else { | |
491 if (newpw == NULL) newpw = ""; | 488 if (newpw == NULL) newpw = ""; |
492 if (oldpw == NULL) oldpw = ""; | 489 if (oldpw == NULL) oldpw = ""; |
493 newLen = PORT_Strlen(newpw); | |
494 oldLen = PORT_Strlen(oldpw); | |
495 } | 490 } |
496 | 491 if (newpw) newLen = PORT_Strlen(newpw); |
| 492 if (oldpw) oldLen = PORT_Strlen(oldpw); |
497 | 493 |
498 /* get a rwsession */ | 494 /* get a rwsession */ |
499 rwsession = PK11_GetRWSession(slot); | 495 rwsession = PK11_GetRWSession(slot); |
500 if (rwsession == CK_INVALID_SESSION) { | 496 if (rwsession == CK_INVALID_SESSION) { |
501 PORT_SetError(SEC_ERROR_BAD_DATA); | 497 PORT_SetError(SEC_ERROR_BAD_DATA); |
502 return rv; | 498 return rv; |
503 } | 499 } |
504 | 500 |
505 crv = PK11_GETTAB(slot)->C_SetPIN(rwsession, | 501 crv = PK11_GETTAB(slot)->C_SetPIN(rwsession, |
506 (unsigned char *)oldpw,oldLen,(unsigned char *)newpw,newLen); | 502 (unsigned char *)oldpw,oldLen,(unsigned char *)newpw,newLen); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 case CKS_RO_PUBLIC_SESSION: | 779 case CKS_RO_PUBLIC_SESSION: |
784 default: | 780 default: |
785 break; /* fail */ | 781 break; /* fail */ |
786 case CKS_RW_USER_FUNCTIONS: | 782 case CKS_RW_USER_FUNCTIONS: |
787 case CKS_RW_SO_FUNCTIONS: | 783 case CKS_RW_SO_FUNCTIONS: |
788 case CKS_RO_USER_FUNCTIONS: | 784 case CKS_RO_USER_FUNCTIONS: |
789 return PR_TRUE; | 785 return PR_TRUE; |
790 } | 786 } |
791 return PR_FALSE; | 787 return PR_FALSE; |
792 } | 788 } |
OLD | NEW |