/** * Generates an SM2 keypair. * * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateSM2Keypair(P11NewKeyControl control) throws P11TokenException { assertCanGenKeypair("generateSM2Keypair", PKCS11Constants.CKM_VENDOR_SM2_KEY_PAIR_GEN, control); P11Identity identity = generateSM2Keypair0(control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated SM2 keypair {}", id); return id; }
/** * Generates an SM2 keypair. * * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateSM2Keypair(P11NewKeyControl control) throws P11TokenException { assertCanGenKeypair("generateSM2Keypair", PKCS11Constants.CKM_VENDOR_SM2_KEY_PAIR_GEN, control); P11Identity identity = generateSM2Keypair0(control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated SM2 keypair {}", id); return id; }
throw new IllegalArgumentException("key size is not multiple of 1024: " + keysize); assertCanGenKeypair("generateRSAKeypair", PKCS11Constants.CKM_RSA_PKCS_KEY_PAIR_GEN, control);
throw new IllegalArgumentException("key size is not multiple of 1024: " + keysize); assertCanGenKeypair("generateRSAKeypair", PKCS11Constants.CKM_RSA_PKCS_KEY_PAIR_GEN, control);
/** * Generates an EC keypair. * * @param curveNameOrOid * Object identifier or name of the EC curve. Must not be {@code null}. * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateECKeypair(String curveNameOrOid, P11NewKeyControl control) throws P11TokenException { Args.notBlank(curveNameOrOid, "curveNameOrOid"); assertCanGenKeypair("generateECKeypair", PKCS11Constants.CKM_EC_KEY_PAIR_GEN, control); ASN1ObjectIdentifier curveId = AlgorithmUtil.getCurveOidForCurveNameOrOid(curveNameOrOid); if (curveId == null) { throw new IllegalArgumentException("unknown curve " + curveNameOrOid); } P11Identity identity = generateECKeypair0(curveId, control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated EC keypair {}", id); return id; }
/** * Generates an EC keypair. * * @param curveNameOrOid * Object identifier or name of the EC curve. Must not be {@code null}. * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateECKeypair(String curveNameOrOid, P11NewKeyControl control) throws P11TokenException { ParamUtil.requireNonBlank("curveNameOrOid", curveNameOrOid); assertCanGenKeypair("generateECKeypair", PKCS11Constants.CKM_EC_KEY_PAIR_GEN, control); ASN1ObjectIdentifier curveId = AlgorithmUtil.getCurveOidForCurveNameOrOid(curveNameOrOid); if (curveId == null) { throw new IllegalArgumentException("unknown curve " + curveNameOrOid); } P11Identity identity = generateECKeypair0(curveId, control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated EC keypair {}", id); return id; }
/** * Generates a DSA keypair. * * @param plength * bit length of P * @param qlength * bit length of Q * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateDSAKeypair(int plength, int qlength, P11NewKeyControl control) throws P11TokenException { ParamUtil.requireMin("plength", plength, 1024); if (plength % 1024 != 0) { throw new IllegalArgumentException("key size is not multiple of 1024: " + plength); } assertCanGenKeypair("generateDSAKeypair", PKCS11Constants.CKM_DSA_KEY_PAIR_GEN, control); DSAParameterSpec dsaParams = DSAParameterCache.getDSAParameterSpec(plength, qlength, random); P11Identity identity = generateDSAKeypair0(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG(), control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated DSA keypair {}", id); return id; }
/** * Generates a DSA keypair. * * @param p * p of DSA. Must not be {@code null}. * @param q * q of DSA. Must not be {@code null}. * @param g * g of DSA. Must not be {@code null}. * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11NewKeyControl control) throws P11TokenException { Args.notNull(p, "p"); Args.notNull(q, "q"); Args.notNull(g, "g"); assertCanGenKeypair("generateDSAKeypair", PKCS11Constants.CKM_DSA_KEY_PAIR_GEN, control); P11Identity identity = generateDSAKeypair0(p, q, g, control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated DSA keypair {}", id); return id; }
/** * Generates a DSA keypair. * * @param p * p of DSA. Must not be {@code null}. * @param q * q of DSA. Must not be {@code null}. * @param g * g of DSA. Must not be {@code null}. * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateDSAKeypair(BigInteger p, BigInteger q, BigInteger g, P11NewKeyControl control) throws P11TokenException { ParamUtil.requireNonNull("p", p); ParamUtil.requireNonNull("q", q); ParamUtil.requireNonNull("g", g); assertCanGenKeypair("generateDSAKeypair", PKCS11Constants.CKM_DSA_KEY_PAIR_GEN, control); P11Identity identity = generateDSAKeypair0(p, q, g, control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated DSA keypair {}", id); return id; }
/** * Generates a DSA keypair. * * @param plength * bit length of P * @param qlength * bit length of Q * @param control * Control of the key generation process. Must not be {@code null}. * @return the identifier of the identity within the PKCS#P11 token. * @throws P11TokenException * if PKCS#11 token exception occurs. */ // CHECKSTYLE:SKIP public P11IdentityId generateDSAKeypair(int plength, int qlength, P11NewKeyControl control) throws P11TokenException { Args.min(plength, "plength", 1024); if (plength % 1024 != 0) { throw new IllegalArgumentException("key size is not multiple of 1024: " + plength); } assertCanGenKeypair("generateDSAKeypair", PKCS11Constants.CKM_DSA_KEY_PAIR_GEN, control); DSAParameterSpec dsaParams = DSAParameterCache.getDSAParameterSpec(plength, qlength, random); P11Identity identity = generateDSAKeypair0(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG(), control); addIdentity(identity); P11IdentityId id = identity.getId(); LOG.info("generated DSA keypair {}", id); return id; }