Search in sources :

Example 6 with EXPLICIT

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

the class PKIArchiveOptions method encode.

/**
 * DER-encodes a PKIArchiveOptions.
 * @param implicitTag <b>This parameter is ignored.</b> A CHOICE cannot
 *      have an implicit tag.
 */
@Override
public void encode(Tag implicitTag, OutputStream ostream) throws IOException {
    // no implicit tags on a CHOICE
    assert (implicitTag.equals(tag));
    if (type == ENCRYPTED_PRIV_KEY) {
        // CHOICEs are always EXPLICITly tagged
        EXPLICIT explicit = new EXPLICIT(new Tag(0), encryptedPrivKey);
        explicit.encode(tag, ostream);
    } else if (type == KEY_GEN_PARAMETERS) {
        keyGenParameters.encode(tag, ostream);
    } else {
        assert (type == ARCHIVE_REM_GEN_PRIV_KEY);
        (new BOOLEAN(archiveRemGenPrivKey)).encode(tag, ostream);
    }
}
Also used : Tag(org.mozilla.jss.asn1.Tag) EXPLICIT(org.mozilla.jss.asn1.EXPLICIT) BOOLEAN(org.mozilla.jss.asn1.BOOLEAN)

Example 7 with EXPLICIT

use of org.mozilla.jss.asn1.EXPLICIT 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

EXPLICIT (org.mozilla.jss.asn1.EXPLICIT)7 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)5 Tag (org.mozilla.jss.asn1.Tag)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 ANY (org.mozilla.jss.asn1.ANY)2 BOOLEAN (org.mozilla.jss.asn1.BOOLEAN)2 InvalidBERException (org.mozilla.jss.asn1.InvalidBERException)2 DerOutputStream (org.mozilla.jss.netscape.security.util.DerOutputStream)2 INTEGER (org.mozilla.jss.asn1.INTEGER)1 NULL (org.mozilla.jss.asn1.NULL)1