Create global key
Create an
NAEParameterSpecobject. Pass the keyname as an argument.Obtain an instance of
KeyGenerator. Pass the key algorithm and provider name (IngrianProvider) as arguments.Call the
generateKeymethod of theKeyGeneratorobject to create the key.
Code sample
The following sample generates a global key AES key named mykey.
NAEParameterSpec spec = new NAEParameterSpec("mykey");
KeyGenerator keygen = KeyGenerator.getInstance("AES", "IngrianProvider");
keygen.init(spec);
SecretKey aesKey = keygen.generateKey();
To mark a global key exportable and deletale, pass the boolean values to the NAEParameterSpec object. The following sample shows how to make mykey exportable and deletable:
NAEParameterSpec spec = new NAEParameterSpec("mykey", true, true);
To mark a global key exportable and non-deletable and specify key size for a key, pass the boolean values and key size to the NAEParameterSpec object. The following sample shows how to make mykey exportable and non-deletable and assign the key bit length to 256 bits.
NAEParameterSpec spec = new NAEParameterSpec("mykey", true, false, 256);
Note
Global keys cannot be created with KMIP.