Create New Version of Key
Create a new
NAEKeyobject and call thegetSecretKeymethod to get a key from the Key Manager. This must be a versioned key, otherwise the next step will fail with anNAEException.Call the
generateVersionmethod of theNAEKey. This method returns an integer indicating the version number. You may want to capture that information. The new version is automatically put in the Active state. There can be no more than 4000 versions.Obtain an instance of
KeyGenerator. Pass the key algorithm and provider name (IngrianProvider) as arguments.Initialize the cipher for encryption.
Call the
generateKeymethod of theKeyGeneratorobject to create the key.
Code sample
The following code sample generates a version of a key.
NAEKey key = NAEKey.getSecretKey(keyName, session);
int newVersion = key.generateVersion();
The most active version of a key is always the default version.