API Java
HSM Dinamo
Carregando...
Procurando...
Nenhuma entrada encontrado
GenerateDUKPT.java

Exemplo de geração de DUKPT.

Veja Nota sobre os exemplos.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class GenerateDUKPT {
private static String strAddr = "127.0.0.1";
private static String strUsrId = "master";
private static String strPwd = "12345678";
private static int nPort = 4433;
private static String strBDK = "KSI_FFFF987654";
public static void main(String[] args) {
int nFlags = 0;
Dinamo api = new Dinamo();
try {
api.openSession(strAddr, strUsrId, strPwd, nPort, nFlags);
byte[] pbKSNKeyData = { (byte)0x01, (byte)0x23, (byte)0x45, (byte)0x67,
(byte)0x89, (byte)0xAB, (byte)0xCD, (byte)0xEF,
(byte)0xFE, (byte)0xDC, (byte)0xBA, (byte)0x98,
(byte)0x76, (byte)0x54, (byte)0x32, (byte)0x10 };
System.out.println("--> Import BDK key");
api.importKey( strBDK,
TacNDJavaLib.PLAINTEXTKEY_BLOB,
TacNDJavaLib.ALG_3DES_112,
TacNDJavaLib.EXPORTABLE_KEY,
pbKSNKeyData,
pbKSNKeyData.length );
byte[] baKSI = { (byte)0xFF, (byte)0xFF, (byte)0x98,
(byte)0x76, (byte)0x54 };
byte[] baDID_CTR = { (byte)0x32, (byte)0x10, (byte)0xE0,
(byte)0x00, (byte)0x01 };
System.out.println("--> Generate DUKPT key");
String strDukpt = api.generateDUKPT( baKSI,
baDID_CTR,
TacNDJavaLib.NEW_DUKPT_MODE_DUK |
TacNDJavaLib.NEW_DUKPT_MODE_DE |
TacNDJavaLib.NEW_DUKPT_MODE_TMP);
System.out.println("DUKPT name: " + strDukpt);
System.out.println("--> Delete keys");
api.deleteKey(strDukpt);
api.deleteKey(strBDK);
api.closeSession();
} catch (TacException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}