public class ASN1Integer extends ASN1Primitive
Constructor and Description |
---|
ASN1Integer(java.math.BigInteger value)
Construct an INTEGER from the passed in BigInteger value.
|
ASN1Integer(byte[] bytes)
Construct an INTEGER from the passed in byte array.
|
ASN1Integer(long value)
Construct an INTEGER from the passed in long value.
|
Modifier and Type | Method and Description |
---|---|
static ASN1Integer |
getInstance(ASN1TaggedObject obj,
boolean explicit)
Return an Integer from a tagged object.
|
static ASN1Integer |
getInstance(java.lang.Object obj)
Return an integer from the passed in object.
|
java.math.BigInteger |
getPositiveValue()
in some cases positive values get crammed into a space,
that's not quite big enough...
|
java.math.BigInteger |
getValue() |
int |
hashCode() |
java.lang.String |
toString() |
equals, fromByteArray, toASN1Primitive
getEncoded, getEncoded, hasEncodedTagValue, toASN1Object
public ASN1Integer(long value)
value
- the long representing the value desired.public ASN1Integer(java.math.BigInteger value)
value
- the BigInteger representing the value desired.public ASN1Integer(byte[] bytes)
NB: Strict Validation applied by default.
It has turned out that there are still a few applications that struggle with the ASN.1 BER encoding rules for an INTEGER as described in: https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf Section 8.3.2.
Users can set the 'org.bouncycastle.asn1.allow_unsafe_integer' to 'true' and a looser validation will be applied. Users must recognise that this is not ideal and may pave the way for an exploit based around a faulty encoding in the future.
bytes
- the byte array representing a 2's complement encoding of a BigInteger.public static ASN1Integer getInstance(java.lang.Object obj)
obj
- an ASN1Integer or an object that can be converted into one.java.lang.IllegalArgumentException
- if the object cannot be converted.public static ASN1Integer getInstance(ASN1TaggedObject obj, boolean explicit)
obj
- the tagged object holding the object we wantexplicit
- true if the object is meant to be explicitly
tagged false otherwise.java.lang.IllegalArgumentException
- if the tagged object cannot
be converted.public java.math.BigInteger getValue()
public java.math.BigInteger getPositiveValue()
public int hashCode()
hashCode
in class ASN1Primitive
public java.lang.String toString()
toString
in class java.lang.Object