added sequence size check on MessageImprint
byte[] hashedMessage;
/**
- * @param o
+ * Return an instance of MessageImprint, or null, based on o.
+ *
+ * @param o the object to be converted.
* @return a MessageImprint object.
*/
public static MessageImprint getInstance(Object o)
@@ -37,10 +39,17 @@ public static MessageImprint getInstance(Object o)
private MessageImprint(
ASN1Sequence seq)
+ {
+ if (seq.size() == 2)
{
this.hashAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(0));
this.hashedMessage = ASN1OctetString.getInstance(seq.getObjectAt(1)).getOctets();
}
+ else
+ {
+ throw new IllegalArgumentException("sequence has wrong number of elements");
+ }
+ }
public MessageImprint(
AlgorithmIdentifier hashAlgorithm,
