Create Versioned Key
Create an
NAEParameterSpecobject. To create a versioned key, the constructor needs the following parameters:name (String),exportable (boolean),deletable (boolean),versioned (boolean),length (int),attrs (CustomAttributes), andsession (NAESession).Obtain an instance of
KeyGenerator. Pass the key algorithm and provider name (IngrianProvider) as arguments.Call the
generateKeymethod of theKeyGeneratorobject to create the key.Get instance of the key.
Code sample
The following code sample generates a global AES key named mykey.
NAESession session = NAESession.getSession("user1", "password1".toCharArray());
NAEParameterSpec paramSpec = new NAEParameterSpec(keyName, true, true, true, 256, session);
KeyGenerator kg = KeyGenerator.getInstance("AES", "IngrianProvider");
kg.init(paramSpec);
SecretKey secret_key = kg.generateKey();
NAEKey key = NAEKey.getSecretKey(keyName, session);
The first version of the key is automatically created.