Example usage for org.bouncycastle.asn1.teletrust TeleTrusTObjectIdentifiers brainpoolP256r1

List of usage examples for org.bouncycastle.asn1.teletrust TeleTrusTObjectIdentifiers brainpoolP256r1

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.teletrust TeleTrusTObjectIdentifiers brainpoolP256r1.

Prototype

ASN1ObjectIdentifier brainpoolP256r1

To view the source code for org.bouncycastle.asn1.teletrust TeleTrusTObjectIdentifiers brainpoolP256r1.

Click Source Link

Document

1.3.36.3.3.2.8.1.1.7

Usage

From source file:org.xipki.ca.certprofile.internal.ProfileConfCreatorDemo.java

License:Open Source License

private static KeyAlgorithms createKeyAlgorithms() {
    KeyAlgorithms ret = new KeyAlgorithms();
    List<AlgorithmType> list = ret.getAlgorithm();
    // RSA/* w w w .  java 2 s.c o m*/
    {
        AlgorithmType algorithm = new AlgorithmType();
        list.add(algorithm);

        algorithm.getAlgorithm().add(createOidType(PKCSObjectIdentifiers.rsaEncryption, "RSA"));

        RSAParameters params = new RSAParameters();
        algorithm.setParameters(createKeyParametersType(params));

        RangesType ranges = new RangesType();
        params.setModulusLength(ranges);
        List<RangeType> modulusLengths = ranges.getRange();
        modulusLengths.add(createRange(2048));
        modulusLengths.add(createRange(3072));
    }

    // DSA
    {
        AlgorithmType algorithm = new AlgorithmType();
        list.add(algorithm);

        algorithm.getAlgorithm().add(createOidType(X9ObjectIdentifiers.id_dsa, "DSA"));
        DSAParameters params = new DSAParameters();
        algorithm.setParameters(createKeyParametersType(params));

        RangesType ranges = new RangesType();
        params.setPLength(ranges);

        List<RangeType> pLengths = ranges.getRange();
        pLengths.add(createRange(1024));
        pLengths.add(createRange(2048));

        ranges = new RangesType();
        params.setQLength(ranges);
        List<RangeType> qLengths = ranges.getRange();
        qLengths.add(createRange(160));
        qLengths.add(createRange(224));
        qLengths.add(createRange(256));
    }

    // EC
    {
        AlgorithmType algorithm = new AlgorithmType();
        list.add(algorithm);

        algorithm.getAlgorithm().add(createOidType(X9ObjectIdentifiers.id_ecPublicKey, "EC"));
        ECParameters params = new ECParameters();
        algorithm.setParameters(createKeyParametersType(params));

        Curves curves = new Curves();
        params.setCurves(curves);

        ASN1ObjectIdentifier[] curveIds = new ASN1ObjectIdentifier[] { SECObjectIdentifiers.secp256r1,
                TeleTrusTObjectIdentifiers.brainpoolP256r1 };

        for (ASN1ObjectIdentifier curveId : curveIds) {
            String name = SecurityUtil.getCurveName(curveId);
            curves.getCurve().add(createOidType(curveId, name));
        }

        params.setPointEncodings(new PointEncodings());
        final Byte unpressed = 4;
        params.getPointEncodings().getPointEncoding().add(unpressed);
    }

    return ret;
}

From source file:org.xipki.pki.ca.certprofile.test.ProfileConfCreatorDemo.java

License:Open Source License

private static X509ProfileType getBaseProfile(final String description, final X509CertLevel certLevel,
        final String validity, final boolean useMidnightNotBefore) {
    X509ProfileType profile = new X509ProfileType();

    profile.setAppInfo(createDescription(description));
    profile.setCertLevel(certLevel.toString());
    profile.setMaxSize(5000);// ww  w. j a va2 s  .com
    profile.setVersion(X509CertVersion.v3.name());
    profile.setValidity(validity);
    profile.setNotBeforeTime(useMidnightNotBefore ? "midnight" : "current");

    profile.setDuplicateKey(false);
    profile.setSerialNumberInReq(false);

    // SignatureAlgorithms
    String[] sigHashAlgos = new String[] { "SHA3-512", "SHA3-384", "SHA3-256", "SHA3-224", "SHA512", "SHA384",
            "SHA256", "SHA1" };

    SignatureAlgorithms sigAlgosType = new SignatureAlgorithms();
    profile.setSignatureAlgorithms(sigAlgosType);

    List<String> algos = sigAlgosType.getAlgorithm();
    String[] algoPart2s = new String[] { "withRSA", "withDSA", "withECDSA", "withRSAandMGF1" };
    for (String part2 : algoPart2s) {
        for (String hashAlgo : sigHashAlgos) {
            algos.add(hashAlgo + part2);
        }
    }

    String part2 = "withPlainECDSA";
    for (String hashAlgo : sigHashAlgos) {
        if (!hashAlgo.startsWith("SHA3-")) {
            algos.add(hashAlgo + part2);
        }
    }

    // Subject
    Subject subject = new Subject();
    subject.setDuplicateSubjectPermitted(false);
    profile.setSubject(subject);
    subject.setKeepRdnOrder(false);

    ASN1ObjectIdentifier[] curveIds = (X509CertLevel.EndEntity != certLevel) ? null
            : new ASN1ObjectIdentifier[] { SECObjectIdentifiers.secp256r1,
                    TeleTrusTObjectIdentifiers.brainpoolP256r1 };

    // Key
    profile.setKeyAlgorithms(createKeyAlgorithms(curveIds));

    // Extensions
    ExtensionsType extensions = new ExtensionsType();
    profile.setExtensions(extensions);

    return profile;
}