Search in sources :

Example 1 with PBEKeyGenParams

use of org.mozilla.jss.crypto.PBEKeyGenParams 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();
}
Also used : PBEKeyGenParams(org.mozilla.jss.crypto.PBEKeyGenParams) IVParameterSpec(org.mozilla.jss.crypto.IVParameterSpec) PBEAlgorithm(org.mozilla.jss.crypto.PBEAlgorithm) KeyGenerator(org.mozilla.jss.crypto.KeyGenerator) Password(org.mozilla.jss.util.Password)

Aggregations

IVParameterSpec (org.mozilla.jss.crypto.IVParameterSpec)1 KeyGenerator (org.mozilla.jss.crypto.KeyGenerator)1 PBEAlgorithm (org.mozilla.jss.crypto.PBEAlgorithm)1 PBEKeyGenParams (org.mozilla.jss.crypto.PBEKeyGenParams)1 Password (org.mozilla.jss.util.Password)1