Search in sources :

Example 11 with PasswordAttributesType

use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.

the class PinEntryStep method createPinEntryGui.

private void createPinEntryGui() {
    setInstantReturn(false);
    if (lastTryFailed) {
        addVerifyFailed();
    } else {
        String desc = LANG.translationForKey("action.pinentry.userconsent.pinstep.enter_pin");
        Text descText = new Text(desc);
        getInputInfoUnits().add(descText);
    }
    PasswordField pass = new PasswordField(PIN_FIELD);
    pass.setDescription("PIN");
    // set length restrictions based on DID description. No info means no value set
    PasswordAttributesType pwAttr = pinMarker.getPasswordAttributes();
    if (pwAttr != null) {
        if (pwAttr.getMinLength() != null) {
            pass.setMinLength(pwAttr.getMinLength().intValue());
        }
        if (pwAttr.getMaxLength() != null) {
            pass.setMaxLength(pwAttr.getMaxLength().intValue());
        }
    }
    getInputInfoUnits().add(pass);
    if (pinState == PinState.PIN_FINAL_TRY) {
        String noteStr = LANG.translationForKey("action.pinentry.userconsent.pinstep.final_try_note");
        Text noteText = new Text(noteStr);
        getInputInfoUnits().add(noteText);
    }
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) Text(org.openecard.gui.definition.Text) PasswordField(org.openecard.gui.definition.PasswordField)

Example 12 with PasswordAttributesType

use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.

the class PINTest method testHalfNibble.

@Test
public void testHalfNibble() throws UtilException {
    PasswordAttributesType pwdAttr = create(false, HALF_NIBBLE_BCD, 6, 6);
    byte[] pinResult = PINUtils.encodePin("123456".toCharArray(), pwdAttr);
    assertEquals(new byte[] { (byte) 0xF1, (byte) 0xF2, (byte) 0xF3, (byte) 0xF4, (byte) 0xF5, (byte) 0xF6 }, pinResult);
    pwdAttr = create(true, HALF_NIBBLE_BCD, 6, 7);
    pwdAttr.setPadChar(new byte[] { (byte) 0xFF });
    pinResult = PINUtils.encodePin("123456".toCharArray(), pwdAttr);
    assertEquals(new byte[] { (byte) 0xF1, (byte) 0xF2, (byte) 0xF3, (byte) 0xF4, (byte) 0xF5, (byte) 0xF6, (byte) 0xFF }, pinResult);
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) Test(org.testng.annotations.Test)

Example 13 with PasswordAttributesType

use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.

the class PINTest method create.

private static PasswordAttributesType create(boolean needsPadding, PasswordTypeType pwdType, int minLen, int storedLen) {
    PasswordAttributesType r = new PasswordAttributesType();
    r.setMinLength(BigInteger.valueOf(minLen));
    r.setStoredLength(BigInteger.valueOf(storedLen));
    r.setPwdType(pwdType);
    if (needsPadding) {
        r.getPwdFlags().add("needs-padding");
    }
    return r;
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType)

Example 14 with PasswordAttributesType

use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.

the class PINTest method testASCII.

@Test
public void testASCII() throws UtilException {
    PasswordAttributesType pwdAttr = create(false, ASCII_NUMERIC, 6, 6);
    byte[] pinResult = PINUtils.encodePin("123456".toCharArray(), pwdAttr);
    assertEquals(new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36 }, pinResult);
    try {
        pwdAttr = create(true, ASCII_NUMERIC, 6, 6);
        PINUtils.encodePin("123456".toCharArray(), pwdAttr);
        // padding needed, but no char given
        fail();
    } catch (UtilException ex) {
    }
// try {
// pwdAttr = create(false, ASCII_NUMERIC, 6, 7);
// PINUtils.encodePin("123456", pwdAttr);
// fail(); // padding inferred, but no char given
// } catch (UtilException ex) {
// }
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) UtilException(org.openecard.common.util.UtilException) Test(org.testng.annotations.Test)

Example 15 with PasswordAttributesType

use of iso.std.iso_iec._24727.tech.schema.PasswordAttributesType in project open-ecard by ecsec.

the class PINTest method verifyISO.

@Test
public void verifyISO() throws IFDException {
    PasswordAttributesType pwdAttr = create(true, ISO_9564_1, 4, 8);
    PCSCPinVerify ctrlStruct = new PCSCPinVerify(pwdAttr, StringUtils.toByteArray("00200001"));
    ctrlStruct.setLang(Locale.GERMANY);
    byte[] structData = ctrlStruct.toBytes();
    // length=13
    String pinStr = "00 20 00 01 08 20 FF FF FF FF FF FF FF";
    String ctrlStr = "3C 00 89 47 04 0E04 02 01 0704 00 000000 0D000000";
    byte[] referenceData = StringUtils.toByteArray(ctrlStr + pinStr, true);
    assertEquals(referenceData, structData);
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) PCSCPinVerify(org.openecard.ifd.scio.reader.PCSCPinVerify) Test(org.testng.annotations.Test)

Aggregations

PasswordAttributesType (iso.std.iso_iec._24727.tech.schema.PasswordAttributesType)17 Test (org.testng.annotations.Test)7 ControlIFD (iso.std.iso_iec._24727.tech.schema.ControlIFD)3 InputAPDUInfoType (iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType)3 Transmit (iso.std.iso_iec._24727.tech.schema.Transmit)3 ControlIFDResponse (iso.std.iso_iec._24727.tech.schema.ControlIFDResponse)2 InputUnitType (iso.std.iso_iec._24727.tech.schema.InputUnitType)2 KeyRefType (iso.std.iso_iec._24727.tech.schema.KeyRefType)2 PasswordTypeType (iso.std.iso_iec._24727.tech.schema.PasswordTypeType)2 PinCompareMarkerType (iso.std.iso_iec._24727.tech.schema.PinCompareMarkerType)2 PinInputType (iso.std.iso_iec._24727.tech.schema.PinInputType)2 TransmitResponse (iso.std.iso_iec._24727.tech.schema.TransmitResponse)2 VerifyUserResponse (iso.std.iso_iec._24727.tech.schema.VerifyUserResponse)2 BigInteger (java.math.BigInteger)2 CardResponseAPDU (org.openecard.common.apdu.common.CardResponseAPDU)2 PCSCPinModify (org.openecard.ifd.scio.reader.PCSCPinModify)2 PCSCPinVerify (org.openecard.ifd.scio.reader.PCSCPinVerify)2 AccessControlListType (iso.std.iso_iec._24727.tech.schema.AccessControlListType)1 AccessRuleType (iso.std.iso_iec._24727.tech.schema.AccessRuleType)1 AltVUMessagesType (iso.std.iso_iec._24727.tech.schema.AltVUMessagesType)1