Here is code to send and receive data from HSM
public class TestHSMJava {
public static void main(String args[]) {
System.out.println("<<< Main Method Entry >>>");
String command = null;
Socket socket = null;
DataOutputStream out = null;
DataInputStream in = null;
byte[] b= new byte[100];
try {
socket = new Socket("10.10.10.10", 7500);
System.out.println("<<< Socket >>> :" + socket);
if (socket != null) {
System.out.println("<<< Connected to HSM >>>:"
+ socket.isConnected());
in = new DataInputStream (new BufferedInputStream(socket.getInputStream()));
out = new DataOutputStream (new BufferedOutputStream(socket.getOutputStream()));
command = "0006303030304e43";
out.writeUTF(command);
System.out.println("Input to HSM : " +command);
out.flush();
String response = in.readUTF();
System.out.println("Output from HSM : " +response);
System.out.println("");
}
}
}
The questions is which command I need to send for execute "GC" command (Translate a ZPK from LMK to ZMK Encryption) I need to generate a clear components for TPK-key. Usually I do
gc
Enter key length [1,2,3]: 2
Enter key type: 002
Enter key scheme: u
and then
fk
Enter key length [1,2,3]: 2
Enter key type: 002
Enter key scheme: u
Enter component type [X,H,T,E,S]: x
Enter number of components [1-9]: 2
I need to do those actions using Java-program.