Search in sources :

Example 1 with P12KeyGenerationResult

use of org.xipki.security.pkcs12.P12KeyGenerationResult in project xipki by xipki.

the class JceksSecretKeyGenCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (!("AES".equalsIgnoreCase(keyType) || "DES3".equalsIgnoreCase(keyType) || "GENERIC".equalsIgnoreCase(keyType))) {
        throw new IllegalCmdParamException("invalid keyType " + keyType);
    }
    P12KeyGenerationResult key = new P12KeyGenerator().generateSecretKey(keyType.toUpperCase(), keysize, getKeyGenParameters());
    saveKey(key);
    return null;
}
Also used : P12KeyGenerator(org.xipki.security.pkcs12.P12KeyGenerator) P12KeyGenerationResult(org.xipki.security.pkcs12.P12KeyGenerationResult) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException)

Example 2 with P12KeyGenerationResult

use of org.xipki.security.pkcs12.P12KeyGenerationResult in project xipki by xipki.

the class P12SM2KeyGenCmd method execute0.

@Override
protected Object execute0() throws Exception {
    P12KeyGenerationResult keypair = new P12KeyGenerator().generateECKeypair(GMObjectIdentifiers.sm2p256v1.getId(), getKeyGenParameters(), subject);
    saveKey(keypair);
    return null;
}
Also used : P12KeyGenerator(org.xipki.security.pkcs12.P12KeyGenerator) P12KeyGenerationResult(org.xipki.security.pkcs12.P12KeyGenerationResult)

Example 3 with P12KeyGenerationResult

use of org.xipki.security.pkcs12.P12KeyGenerationResult in project xipki by xipki.

the class P12DSAKeyGenCmd method execute0.

@Override
protected Object execute0() throws Exception {
    if (plen % 1024 != 0) {
        throw new IllegalCmdParamException("plen is not multiple of 1024: " + plen);
    }
    if (qlen == null) {
        if (plen <= 1024) {
            qlen = 160;
        } else if (plen <= 2048) {
            qlen = 224;
        } else {
            qlen = 256;
        }
    }
    P12KeyGenerationResult keypair = new P12KeyGenerator().generateDSAKeypair(plen, qlen, getKeyGenParameters(), subject);
    saveKey(keypair);
    return null;
}
Also used : P12KeyGenerator(org.xipki.security.pkcs12.P12KeyGenerator) P12KeyGenerationResult(org.xipki.security.pkcs12.P12KeyGenerationResult) IllegalCmdParamException(org.xipki.console.karaf.IllegalCmdParamException)

Example 4 with P12KeyGenerationResult

use of org.xipki.security.pkcs12.P12KeyGenerationResult in project xipki by xipki.

the class P12HMACSignLoadTest method generateKeystore.

private static byte[] generateKeystore(String signatureAlgorithm) throws Exception {
    int keysize = getKeysize(signatureAlgorithm);
    P12KeyGenerationResult identity = new P12KeyGenerator().generateSecretKey("GENERIC", keysize, new KeystoreGenerationParameters(PASSWORD.toCharArray()));
    return identity.keystore();
}
Also used : P12KeyGenerator(org.xipki.security.pkcs12.P12KeyGenerator) P12KeyGenerationResult(org.xipki.security.pkcs12.P12KeyGenerationResult) KeystoreGenerationParameters(org.xipki.security.pkcs12.KeystoreGenerationParameters)

Example 5 with P12KeyGenerationResult

use of org.xipki.security.pkcs12.P12KeyGenerationResult in project xipki by xipki.

the class P12ECSignLoadTest method generateKeystore.

private static byte[] generateKeystore(String curveNameOrOid) throws Exception {
    byte[] keystoreBytes = getPrecomputedECKeystore(curveNameOrOid);
    if (keystoreBytes == null) {
        KeystoreGenerationParameters params = new KeystoreGenerationParameters(PASSWORD.toCharArray());
        params.setRandom(new SecureRandom());
        P12KeyGenerationResult identity = new P12KeyGenerator().generateECKeypair(curveNameOrOid, params, null);
        keystoreBytes = identity.keystore();
    }
    return keystoreBytes;
}
Also used : P12KeyGenerator(org.xipki.security.pkcs12.P12KeyGenerator) P12KeyGenerationResult(org.xipki.security.pkcs12.P12KeyGenerationResult) SecureRandom(java.security.SecureRandom) KeystoreGenerationParameters(org.xipki.security.pkcs12.KeystoreGenerationParameters)

Aggregations

P12KeyGenerationResult (org.xipki.security.pkcs12.P12KeyGenerationResult)11 P12KeyGenerator (org.xipki.security.pkcs12.P12KeyGenerator)11 KeystoreGenerationParameters (org.xipki.security.pkcs12.KeystoreGenerationParameters)6 SecureRandom (java.security.SecureRandom)4 IllegalCmdParamException (org.xipki.console.karaf.IllegalCmdParamException)3