I am using Java to connect to the HSM on Windows 2008
I am sending a 'GC' command for getting clear components of key.
I am expecting receive something like
Output from HSM : 000b3015
The code is below:
I am sending a 'GC' command for getting clear components of key.
I am expecting receive something like
Clear component: XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
Encrypted component: U XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
Key check value: XXXXXX
The answer from HSM is:Output from HSM : 000b3015
The code is below:
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 = "000b3030303041303030303255";
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("");
}
}
}