@@ -767,10 +767,17 @@ private final void processResetRetryCounter(final short lc,
767767
768768 case (byte )0x02 :
769769 assertAdmin ();
770- if ((lc < Constants .USER_PIN_MIN_SIZE ) ||
771- (lc > Constants .USER_PIN_MAX_SIZE )) {
772- ISOException .throwIt (ISO7816 .SW_WRONG_LENGTH );
773- return ;
770+ if (data .keyDerivationIsActive ()) {
771+ if (lc != data .keyDerivationSize ()) {
772+ ISOException .throwIt (ISO7816 .SW_WRONG_LENGTH );
773+ return ;
774+ }
775+ } else {
776+ if ((lc < Constants .USER_PIN_MIN_SIZE ) ||
777+ (lc > Constants .USER_PIN_MAX_SIZE )) {
778+ ISOException .throwIt (ISO7816 .SW_WRONG_LENGTH );
779+ return ;
780+ }
774781 }
775782 transients .setUserPinMode81 (false );
776783 transients .setUserPinMode82 (false );
@@ -1142,10 +1149,17 @@ private final void processPutData(final short lc,
11421149
11431150 case Constants .TAG_RESETTING_CODE :
11441151 assertAdmin ();
1145- if ((lc < Constants .USER_PUK_MIN_SIZE ) ||
1146- (lc > Constants .USER_PUK_MAX_SIZE )) {
1147- ISOException .throwIt (ISO7816 .SW_WRONG_LENGTH );
1148- return ;
1152+ if (data .keyDerivationIsActive ()) {
1153+ if (lc != data .keyDerivationSize ()) {
1154+ ISOException .throwIt (ISO7816 .SW_WRONG_LENGTH );
1155+ return ;
1156+ }
1157+ } else {
1158+ if ((lc < Constants .USER_PUK_MIN_SIZE ) ||
1159+ (lc > Constants .USER_PUK_MAX_SIZE )) {
1160+ ISOException .throwIt (ISO7816 .SW_WRONG_LENGTH );
1161+ return ;
1162+ }
11491163 }
11501164 JCSystem .beginTransaction ();
11511165 data .user_puk_length = (byte )lc ;
0 commit comments