use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class CertificateAlgorithmId method encode.
/**
* Encode the algorithm identifier in DER form to the stream.
*
* @param out the DerOutputStream to marshal the contents to.
* @exception IOException on errors.
*/
@Override
public void encode(OutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
algId.encode(tmp);
out.write(tmp.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class CertificatePoliciesExtension method encodeThis.
// Encode this extension value
private void encodeThis() throws IOException {
try (DerOutputStream os = new DerOutputStream()) {
DerOutputStream tmp = new DerOutputStream();
for (int i = 0; i < mInfos.size(); i++) {
mInfos.elementAt(i).encode(tmp);
}
os.write(DerValue.tag_Sequence, tmp);
extensionValue = os.toByteArray();
}
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class AVA method derEncode.
/**
* DER encode this object onto an output stream.
* Implements the <code>DerEncoder</code> interface.
*
* @param out
* the output stream on which to write the DER encoding.
*
* @exception IOException on encoding error.
*/
@Override
public void derEncode(OutputStream out) throws IOException {
try (DerOutputStream tmp2 = new DerOutputStream()) {
DerOutputStream tmp = new DerOutputStream();
tmp.putOID(oid);
value.encode(tmp);
tmp2.write(DerValue.tag_Sequence, tmp);
out.write(tmp2.toByteArray());
}
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class AlgorithmId method derEncodeWithContext.
/**
* DER encode this object onto an output stream.
* Implements the <code>DerEncoder</code> interface.
*
* @param out the output stream on which to write the DER encoding params,
* using context value.
* @param contextVal context value
*
* @exception IOException on encoding error.
*/
public void derEncodeWithContext(OutputStream out, int contextVal) throws IOException {
try (DerOutputStream tmp = new DerOutputStream()) {
DerOutputStream bytes = new DerOutputStream();
bytes.putOID(algid);
byte val = (byte) contextVal;
// omit parameter field for ECDSA
if (!algid.equals(sha224WithEC_oid) && !algid.equals(sha256WithEC_oid) && !algid.equals(sha384WithEC_oid) && !algid.equals(sha512WithEC_oid)) {
if (params == null) {
bytes.putNull();
} else {
bytes.putDerValue(params);
}
}
DerOutputStream seq = new DerOutputStream();
seq.write(DerValue.tag_Sequence, bytes);
tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, val), seq);
out.write(tmp.toByteArray());
}
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class AlgorithmId method encode.
// XXXX cleaning required
/**
* Returns the DER-encoded X.509 AlgorithmId as a byte array.
* @return the byte array
* @throws IOException If an error occurred.
*/
public final byte[] encode() throws IOException {
try (DerOutputStream out = new DerOutputStream()) {
DerOutputStream bytes = new DerOutputStream();
bytes.putOID(algid);
// omit parameter field for ECDSA
if (!algid.equals(sha224WithEC_oid) && !algid.equals(sha256WithEC_oid) && !algid.equals(sha384WithEC_oid) && !algid.equals(sha512WithEC_oid)) {
if (params == null) {
bytes.putNull();
} else
bytes.putDerValue(params);
}
out.write(DerValue.tag_Sequence, bytes);
return out.toByteArray();
}
}
Aggregations