use of org.mozilla.jss.crypto.PBEAlgorithm in project OpenAM by OpenRock.
the class JSSEncryption method initSymmetricKeysAndInitializationVectors.
private void initSymmetricKeysAndInitializationVectors(String password) {
sKeys = new SymmetricKey[NUM_KEYGEN_ALG];
ivParamSpecs = new IVParameterSpec[NUM_KEYGEN_ALG];
byte[] salt = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 };
Password pass = new Password(password.toCharArray());
for (int i = 0; i < NUM_KEYGEN_ALG; i++) {
try {
PBEAlgorithm keyAlg = getKeyGenAlg(KEYGEN_ALGS[i]);
KeyGenerator kg = mToken.getKeyGenerator(keyAlg);
PBEKeyGenParams kgp = new PBEKeyGenParams(pass, salt, 5);
kg.initialize(kgp);
sKeys[i] = kg.generate();
ivParamSpecs[i] = new IVParameterSpec(kg.generatePBE_IV());
if (debug.messageEnabled()) {
debug.message("Created symKey successfully : " + KEYGEN_ALGS[i]);
}
} catch (Exception e) {
debug.error("Failed creating symKey : " + KEYGEN_ALGS[i], e);
}
}
pass.clear();
}
Aggregations