Ejemplo de verificación de bloque de PIN.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class VerifyPinBlock {
public static void main(String[] args) throws TacException {
String ip = "127.0.0.1";
String user = "master";
String password = "12345678";
Dinamo api = new Dinamo();
api.openSession(ip, user, password);
String pgkId = "pgk";
int pgkAlg = TacNDJavaLib.ALG_3DES_168;
int pgkLen = TacNDJavaLib.ALG_DES3_168_LEN;
byte pgkData[] =
{ (byte) 0x12, (byte) 0x22, (byte) 0x22, (byte) 0x22, (byte) 0x22, (byte) 0x22, (byte) 0x22,
(byte) 0x23, (byte) 0x12, (byte) 0x22, (byte) 0x22, (byte) 0x22, (byte) 0x22, (byte) 0x22,
(byte) 0x22, (byte) 0x23, (byte) 0x12, (byte) 0x22, (byte) 0x22, (byte) 0x22, (byte) 0x22,
(byte) 0x22, (byte) 0x22, (byte) 0x23 };
String ptkId = "ptk";
int ptkAlg = TacNDJavaLib.ALG_3DES_112;
int ptkLen = TacNDJavaLib.ALG_DES3_112_LEN;
byte ptkData[] =
{ (byte) 0xF2, (byte) 0x15, (byte) 0x75, (byte) 0xBA, (byte) 0x54, (byte) 0x68, (byte) 0xC4,
(byte) 0x1C, (byte) 0xD5, (byte) 0xC7, (byte) 0x4A, (byte) 0xFE, (byte) 0x64, (byte) 0x94,
(byte)0x08, (byte)0x37 };
byte pinBlock[] =
{ (byte) 0x19, (byte) 0x37, (byte) 0x35, (byte) 0x9B, (byte) 0x46, (byte) 0x93, (byte) 0x2D,
(byte) 0x3C };
String pan = "4987654321098765";
String offset = "3152";
api.importKey(pgkId, TacNDJavaLib.PLAINTEXTKEY_BLOB, pgkAlg, pgkData, true);
System.out.println("Chave PGK importada: " + pgkId);
api.importKey(ptkId, TacNDJavaLib.PLAINTEXTKEY_BLOB, ptkAlg, ptkData, true);
System.out.println("Chave PTK importada: " + ptkId);
boolean isValid = api.verifyPINBlock(ptkId, pgkId, pan, offset, pinBlock, 0);
System.out.println("PIN Block verificado: " + isValid);
api.deleteKeyIfExists(pgkId);
System.out.println("Chave PGK deletada: " + pgkId);
api.deleteKeyIfExists(ptkId);
System.out.println("Chave PTK deletada: " + ptkId);
api.closeSession();
}
}