Search in sources :

Example 16 with PasswordAttributesType

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

the class PINTest method verifyASCII.

@Test
public void verifyASCII() throws IFDException {
    PasswordAttributesType pwdAttr = create(false, ASCII_NUMERIC, 4, 4);
    PCSCPinVerify ctrlStruct = new PCSCPinVerify(pwdAttr, StringUtils.toByteArray("00200001"));
    ctrlStruct.setLang(Locale.GERMANY);
    byte[] structData = ctrlStruct.toBytes();
    // length=5
    String pinStr = "00 20 00 01";
    String ctrlStr = "3C 00 82 04 00 0404 02 01 0704 00 000000 04000000";
    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)

Example 17 with PasswordAttributesType

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

the class GenericPINAction method sendModifyPIN.

/**
 * Send a ModifyPIN-PCSC-Command to the Terminal.
 *
 * @throws IFDException If building the Command fails.
 */
private ControlIFDResponse sendModifyPIN() throws IFDException {
    PasswordAttributesType pwdAttr = create(true, ASCII_NUMERIC, 6, 6, 6);
    pwdAttr.setPadChar(new byte[] { (byte) 0x3F });
    PCSCPinModify ctrlStruct = new PCSCPinModify(pwdAttr, StringUtils.toByteArray("002C0203"));
    byte[] structData = ctrlStruct.toBytes();
    ControlIFD controlIFD = new ControlIFD();
    controlIFD.setCommand(ByteUtils.concatenate((byte) PCSCFeatures.MODIFY_PIN_DIRECT, structData));
    controlIFD.setSlotHandle(slotHandle);
    return (ControlIFDResponse) dispatcher.safeDeliver(controlIFD);
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) ControlIFDResponse(iso.std.iso_iec._24727.tech.schema.ControlIFDResponse) ControlIFD(iso.std.iso_iec._24727.tech.schema.ControlIFD) PCSCPinModify(org.openecard.ifd.scio.reader.PCSCPinModify)

Example 18 with PasswordAttributesType

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

the class PINStepAction method sendModifyPIN.

/**
 * Send a ModifyPIN-PCSC-Command to the Terminal.
 *
 * @throws IFDException If building the Command fails.
 */
private void sendModifyPIN() throws IFDException {
    PasswordAttributesType pwdAttr = create(true, ASCII_NUMERIC, 6, 6, 6);
    pwdAttr.setPadChar(new byte[] { (byte) 0x3F });
    PCSCPinModify ctrlStruct = new PCSCPinModify(pwdAttr, StringUtils.toByteArray("002C0203"));
    byte[] structData = ctrlStruct.toBytes();
    ControlIFD controlIFD = new ControlIFD();
    controlIFD.setCommand(ByteUtils.concatenate((byte) PCSCFeatures.MODIFY_PIN_DIRECT, structData));
    controlIFD.setSlotHandle(conHandle.getSlotHandle());
    dispatcher.safeDeliver(controlIFD);
}
Also used : PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) ControlIFD(iso.std.iso_iec._24727.tech.schema.ControlIFD) PCSCPinModify(org.openecard.ifd.scio.reader.PCSCPinModify)

Example 19 with PasswordAttributesType

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

the class PINStepAction method create.

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

Example 20 with PasswordAttributesType

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

the class PINUtils method buildVerifyTransmit.

/**
 * Build a Transmit containing a verify APDU.
 *
 * @param rawPIN the pin as entered by the user
 * @param attributes attributes of the password (e.g. encoding and length)
 * @param template the verify template
 * @param slotHandle slot handle
 * @return Transmit containing the built verify APDU
 * @throws UtilException if an pin related error occurs (e.g. wrong PIN length)
 */
public static Transmit buildVerifyTransmit(char[] rawPIN, PasswordAttributesType attributes, byte[] template, byte[] slotHandle) throws UtilException {
    // concatenate template with encoded pin
    byte[] pin = PINUtils.encodePin(rawPIN, attributes);
    byte[] pinCmd = ByteUtils.concatenate(template, (byte) pin.length);
    pinCmd = ByteUtils.concatenate(pinCmd, pin);
    Arrays.fill(pin, (byte) 0);
    Transmit transmit = new Transmit();
    transmit.setSlotHandle(slotHandle);
    InputAPDUInfoType pinApdu = new InputAPDUInfoType();
    pinApdu.setInputAPDU(pinCmd);
    pinApdu.getAcceptableStatusCode().add(new byte[] { (byte) 0x90, (byte) 0x00 });
    transmit.getInputAPDUInfo().add(pinApdu);
    return transmit;
}
Also used : Transmit(iso.std.iso_iec._24727.tech.schema.Transmit) InputAPDUInfoType(iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType)

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