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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations