Search in sources :

Example 66 with NULL

use of org.mozilla.jss.asn1.NULL in project jss by dogtagpki.

the class CertTemplate method dateToASN1.

/**
 * Converts a Date into a UTCTime or GeneralizedTime, depending on
 * whether it falls before or after the cutoff date.
 */
private static TimeBase dateToASN1(Date d) {
    if (d == null) {
        return null;
    }
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.setTime(d);
    if (cal.get(Calendar.YEAR) <= UTCTIME_CUTOFF_YEAR) {
        return new UTCTime(d);
    } else {
        return new GeneralizedTime(d);
    }
}
Also used : UTCTime(org.mozilla.jss.asn1.UTCTime) Calendar(java.util.Calendar) GeneralizedTime(org.mozilla.jss.asn1.GeneralizedTime)

Example 67 with NULL

use of org.mozilla.jss.asn1.NULL in project jss by dogtagpki.

the class ProofOfPossession method encode.

@Override
public void encode(OutputStream ostream) throws IOException {
    if (type == RA_VERIFIED) {
        (new NULL()).encode(Tag.get(0), ostream);
    } else if (type == SIGNATURE) {
        signature.encode(Tag.get(1), ostream);
    } else if (type == KEY_ENCIPHERMENT) {
        // a CHOICE must be explicitly tagged
        EXPLICIT e = new EXPLICIT(Tag.get(2), keyEncipherment);
        e.encode(ostream);
    } else {
        assert (type == KEY_AGREEMENT);
        // a CHOICE must be explicitly tagged
        EXPLICIT e = new EXPLICIT(Tag.get(3), keyAgreement);
        e.encode(ostream);
    }
}
Also used : NULL(org.mozilla.jss.asn1.NULL) EXPLICIT(org.mozilla.jss.asn1.EXPLICIT)

Aggregations

SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)33 OCTET_STRING (org.mozilla.jss.asn1.OCTET_STRING)19 InvalidBERException (org.mozilla.jss.asn1.InvalidBERException)17 ANY (org.mozilla.jss.asn1.ANY)14 CryptoToken (org.mozilla.jss.crypto.CryptoToken)14 AlgorithmIdentifier (org.mozilla.jss.pkix.primitive.AlgorithmIdentifier)11 IOException (java.io.IOException)10 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)10 ASN1Value (org.mozilla.jss.asn1.ASN1Value)10 BMPString (org.mozilla.jss.asn1.BMPString)10 CryptoManager (org.mozilla.jss.CryptoManager)9 SET (org.mozilla.jss.asn1.SET)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 AlgorithmParameterSpec (java.security.spec.AlgorithmParameterSpec)8 OBJECT_IDENTIFIER (org.mozilla.jss.asn1.OBJECT_IDENTIFIER)8 EncryptionAlgorithm (org.mozilla.jss.crypto.EncryptionAlgorithm)8 FileOutputStream (java.io.FileOutputStream)7 Cipher (org.mozilla.jss.crypto.Cipher)7 CertificateException (java.security.cert.CertificateException)6 BadPaddingException (javax.crypto.BadPaddingException)6