Search in sources :

Example 1 with SignatureAlgorithms

use of org.xipki.ca.certprofile.x509.jaxb.X509ProfileType.SignatureAlgorithms in project xipki by xipki.

the class ProfileConfCreatorDemo method getBaseProfile.

private static X509ProfileType getBaseProfile(String description, X509CertLevel certLevel, String validity, boolean useMidnightNotBefore) {
    X509ProfileType profile = new X509ProfileType();
    profile.setAppInfo(createDescription(description));
    profile.setCertLevel(certLevel.toString());
    profile.setMaxSize(5000);
    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);
        }
    }
    algos.add("SM3withSM2");
    // 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, GMObjectIdentifiers.sm2p256v1 };
    // Key
    profile.setKeyAlgorithms(createKeyAlgorithms(curveIds));
    // Extensions
    ExtensionsType extensions = new ExtensionsType();
    profile.setExtensions(extensions);
    return profile;
}
Also used : SignatureAlgorithms(org.xipki.ca.certprofile.x509.jaxb.X509ProfileType.SignatureAlgorithms) ExtensionsType(org.xipki.ca.certprofile.x509.jaxb.ExtensionsType) X509ProfileType(org.xipki.ca.certprofile.x509.jaxb.X509ProfileType) Subject(org.xipki.ca.certprofile.x509.jaxb.X509ProfileType.Subject) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)1 ExtensionsType (org.xipki.ca.certprofile.x509.jaxb.ExtensionsType)1 X509ProfileType (org.xipki.ca.certprofile.x509.jaxb.X509ProfileType)1 SignatureAlgorithms (org.xipki.ca.certprofile.x509.jaxb.X509ProfileType.SignatureAlgorithms)1 Subject (org.xipki.ca.certprofile.x509.jaxb.X509ProfileType.Subject)1