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

Example of generating a symmetric key and an asymmetric key.

See Note on examples.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class GenKey {
static String ipHSM = "127.0.0.1";
static String usr_admin = "master";
static String pass_admin = "12345678";
static String keyName1 = "aes_key";
static String keyName2 = "rsa_key";
public static void main(String[] args) throws TacException {
Dinamo api = new Dinamo();
System.out.println("--> Login HSM and create AES and RSA key");
api.openSession(ipHSM, usr_admin, pass_admin);
System.out.println("--> Create AES and RSA key");
api.createKey(keyName1, TacNDJavaLib.ALG_AES_256, TacNDJavaLib.EXPORTABLE_KEY);
api.createKey(keyName2, TacNDJavaLib.ALG_RSA_2048, TacNDJavaLib.NONEXPORTABLE_KEY);
System.out.println("--> Delete AES and RSA key");
api.deleteKey(keyName1);
api.deleteKey(keyName2);
api.closeSession();
System.out.println("The process ended sucessfully");
}
}