Java API
HSM Dinamo
Loading...
Looking for...
No entries found
GenerateMACLAU.java

Example of using HMAC generation with Swift Local Authentication (LAU).

See Note on examples.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class GenerateMACLAU {
private static String strAddr = "127.0.0.1";
private static String strUsrId = "master";
private static String strPwd = "12345678";
private static String hmacKeyName = "hmac_key";
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
System.out.println("--> Login HSM");
api.openSession(strAddr, strUsrId, strPwd);
System.out.println("--> Create a HMAC key");
String hmac256KeyString = "LEFTLAUCSHARPNETRIGHTLAUSWIFTRJE";
api.importKey(hmacKeyName, TacNDJavaLib.PLAINTEXTKEY_BLOB,
TacNDJavaLib.ALG_HMAC_SHA2_256, hmac256KeyString.getBytes(), true);
String message = "{1:F01BANKAEBBAXXX0004000001}{2:I999BANKAEBBXXXXN}{4:\r\n" +
":20:LAUTEST1\r\n" +
":79:THIS IS EXAMPLE1 FOR LAU TEST RJE CSHARP\r\n" +
"-}";
System.out.println("--> Generate HMAC in one operation");
byte[] mac = api.generateMAC(TacNDJavaLib.ALG_HMAC_SHA2_256,
hmacKeyName,
message.getBytes());
System.out.println("--> Delete HMAC key");
api.deleteKey(hmacKeyName);
api.closeSession();
System.out.println("The process ended sucessfully");
}
}