use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.
the class NSCCommentExtension method encode.
/**
* Write the extension to the OutputStream.
*
* @param out the OutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
@Override
public void encode(OutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
if (extensionValue == null) {
extensionId = new ObjectIdentifier("2.16.840.1.113730.1.13");
critical = false;
encodeThis();
}
super.encode(tmp);
out.write(tmp.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.
the class RSAPSSAlgorithmParameters method decode.
private void decode(DerInputStream in, byte[] encoded) throws IOException {
if (in == null) {
throw new IOException("Invalid input: got null DerInputStream");
}
// Sequence has 3 members, trailer field ignored
DerValue[] seq = in.getSequence(3);
if (seq.length < 3 || seq.length > 4) {
throw new IOException("Invalid data! Expected a sequence with either 3 or 4 members; got " + seq.length);
}
if (seq[0].isContextSpecific((byte) 0)) {
seq[0] = seq[0].data.getDerValue();
} else {
throw new IOException("Invalid encoded data! Expecting OAEP-PSSDigestAlgorithms (hashAlgorithm).");
}
AlgorithmId algid = AlgorithmId.parse(seq[0]);
String specAlgName = getSpecAlgName(algid.getName());
String specMGF1Name = "";
// Now the MFG1 parameter hash fun is the same as the main hash func.
MGF1ParameterSpec specMFG1ParamSpec = new MGF1ParameterSpec(specAlgName);
if (seq[1].isContextSpecific((byte) 1)) {
seq[1] = seq[1].data.getDerValue();
} else {
throw new IOException("Invalid encoded data! Expecting OAEP-PSSDigestAlgorithms (maskGenAlgorithm).");
}
DerInputStream mgf1Str = new DerInputStream(seq[1].toByteArray());
DerValue[] seqMgf1 = mgf1Str.getSequence(2);
ObjectIdentifier mgf1OID = seqMgf1[0].getOID();
if (!mgf1OID.equals(AlgorithmId.MGF1_oid)) {
throw new IOException("Invalid encoded data: expected MGF1 OID but got: " + mgf1OID.toString());
} else {
specMGF1Name = "MGF1";
}
if (seq[2].isContextSpecific((byte) 2)) {
seq[2] = seq[2].data.getDerValue();
} else {
throw new IOException("Invalid encoded data! Expected INTEGER (saltLength).");
}
BigInt sLength = seq[2].getInteger();
this.spec = new PSSParameterSpec(specAlgName, specMGF1Name, specMFG1ParamSpec, sLength.toInt(), 1);
populateFromSpec();
}
Aggregations