|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.me.asn1.ASN1
This class implements decoding and encoding of BER/DER encoded ASN.1 data. It also serves as the registry for ObjectIDs mapping them to (algorithm) names and vice versa.
Decoding is able to handle any valid BER encoding that comes along. Encoding always generates DER. Both processes require at least as much memory as the size of the encoded structure.
Field Summary | |
static int |
CS0
Tag for [0] (context specific 0). |
static int |
CS1
Tag for [1] (context specific 1). |
static int |
CS2
Tag for [2] (context specific 2). |
static int |
CS3
Tag for [3] (context specific 3). |
static String |
OID_AES_128_CBC
Object id 2.16.840.1.101.3.4.1.2 identifying AES/CBC/PKCS5Padding (with 128 bit key). |
static String |
OID_DES_EDE_CBC
Object id 1.2.840.113549.3.7 identifying DES/CBC/PKCS5Padding. |
static String |
OID_DH
Object id 1.2.840.113549.1.3.1 identifying DSA. |
static String |
OID_DSA
Object id 1.2.840.10040.4.1 identifying DSA. |
static String |
OID_HMAC_SHA1
Object id 1.2.840.113549.2.7 identifying HmacSHA1. |
static String |
OID_MD2
Object id 1.2.840.113549.2.2 identifying MD2. |
static String |
OID_MD2_WITH_RSA_ENCRYPTION
Object id 1.2.840.113549.1.1.2 identifying MD2withRSA signatures. |
static String |
OID_MD5
Object id 1.2.840.113549.2.5 identifying MD5. |
static String |
OID_MD5_WITH_RSA_ENCRYPTION
Object id 1.2.840.113549.1.1.4 identifying MD5withRSA signatures. |
static String |
OID_NAME_C
Object id 2.5.4.6 for the country attribute. |
static String |
OID_NAME_CN
Object id 2.5.4.3 for the commonName attribute. |
static String |
OID_NAME_EMAIL
Object id 1.2.840.113549.1.9.1 for the emailAddress attribute. |
static String |
OID_NAME_L
Object id 2.5.4.7 for the locality attribute. |
static String |
OID_NAME_O
Object id 2.5.4.10 for the organization attribute. |
static String |
OID_NAME_OU
Object id 2.5.4.11 for the organizationalUnit attribute. |
static String |
OID_NAME_SERIAL
Object id 2.5.4.5 for the serialNumber attribute. |
static String |
OID_NAME_SN
Object id 2.5.4.4 for the surName attribute. |
static String |
OID_NAME_ST
Object id 2.5.4.8 for the stateOrProvince attribute. |
static String |
OID_NAME_STREET
Object id 2.5.4.9 for the street attribute. |
static String |
OID_NAME_T
Object id 2.5.4.12 for the title attribute. |
static String |
OID_RSA
Object id 1.2.840.113549.1.1.1 identifying RSA. |
static String |
OID_SHA
Object id 1.3.14.3.2.26 identifying SHA-1. |
static String |
OID_SHA1_WITH_DSA
Object id 1.2.840.10040.4.3 identifying SHA1withDSA signatures. |
static String |
OID_SHA1_WITH_RSA_ENCRYPTION
Object id 1.2.840.113549.1.1.5 identifying SHA1withRSA signatures. |
static String |
OID_SHA224
Object id 2.16.840.1.101.3.4.2.4 identifying SHA-224. |
static String |
OID_SHA256
Object id 2.16.840.1.101.3.4.2.1 identifying SHA-256. |
static int |
TAG_APPLICATION
Mask for tag class application. |
static int |
TAG_CONTEXT_SPECIFIC
Mask for tag class context specific . |
static int |
TAG_PRIVATE
Mask for tag class private. |
static int |
TAG_UNIVERSAL
Mask for tag class universal. |
static int |
TYPE_BIT_STRING
Tag for [UNIVERSAL 3], the bit string type. |
static int |
TYPE_BMP_STRING
Tag for [UNIVERSAL 30], the BMP (Unicode) string type. |
static int |
TYPE_BOOLEAN
Tag for [UNIVERSAL 1], the boolean type. |
static int |
TYPE_CHARACTER_STRING
Tag for [UNIVERSAL 29], the character string type. |
static int |
TYPE_EMBEDDED_PDV
Tag for [UNIVERSAL 11], the embedded pdv type. |
static int |
TYPE_ENUMERATED
Tag for [UNIVERSAL 10], the enumerated type. |
static int |
TYPE_EXTERNAL
Tag for [UNIVERSAL 8], the external type. |
static int |
TYPE_GENERAL_STRING
Tag for [UNIVERSAL 27], the general string type. |
static int |
TYPE_GENERALIZED_TIME
Tag for [UNIVERSAL 24], the generalized time type. |
static int |
TYPE_GRAPHIC_STRING
Tag for [UNIVERSAL 25], the graphic string type. |
static int |
TYPE_IA5_STRING
Tag for [UNIVERSAL 22], the IA5 string type. |
static int |
TYPE_INTEGER
Tag for [UNIVERSAL 2], the integer type. |
static int |
TYPE_NULL
Tag for [UNIVERSAL 5], the null type. |
static int |
TYPE_NUMERIC_STRING
Tag for [UNIVERSAL 18], the numeric string type. |
static int |
TYPE_OBJECT_DESCRIPTOR
Tag for [UNIVERSAL 7], the object descriptor type. |
static int |
TYPE_OBJECT_ID
Tag for [UNIVERSAL 6], the object id type. |
static int |
TYPE_OCTET_STRING
Tag for [UNIVERSAL 4], the octet string type. |
static int |
TYPE_PRINTABLE_STRING
Tag for [UNIVERSAL 19], the printable string type. |
static int |
TYPE_REAL
Tag for [UNIVERSAL 9], the real type. |
static int |
TYPE_RELATIVE_OID
Tag for [UNIVERSAL 13], the relative object id type. |
static int |
TYPE_SEQUENCE
Tag for [UNIVERSAL 16], the sequence type. |
static int |
TYPE_SET
Tag for [UNIVERSAL 17], the set type. |
static int |
TYPE_T61_STRING
Tag for [UNIVERSAL 20], the T61 (teletex) string type. |
static int |
TYPE_UNIVERSAL_STRING
Tag for [UNIVERSAL 28], the universal string type. |
static int |
TYPE_UTCTIME
Tag for [UNIVERSAL 23], the UTC time type. |
static int |
TYPE_UTF8_STRING
Tag for [UNIVERSAL 12], the UTF8 string type. |
static int |
TYPE_VIDEOTEX_STRING
Tag for [UNIVERSAL 21], the videotex string type. |
static int |
TYPE_VISIBLE_STRING
Tag for [UNIVERSAL 26], the visible string type. |
Constructor Summary | |
ASN1(byte[] data)
|
|
ASN1(byte[] data,
int saveEncoding,
boolean expectImplicit)
|
|
ASN1(InputStream in)
|
|
ASN1(InputStream in,
int saveEncoding,
boolean expectImplicit)
|
|
ASN1(int type,
Object value)
|
|
ASN1(int type,
Object value,
boolean implicit)
|
Method Summary | |
void |
addElement(ASN1 asn1)
Add an element to a structured type. |
void |
clearEncoding(boolean recursive)
Clear the cached encoding. |
boolean |
equals(Object obj)
Compare this and another ASN1 object. |
ASN1 |
getElementAt(int n)
Get an element of a structured type. |
byte[] |
getEncoded()
Get the encoding of this object. |
static String |
getName(String objectId)
Get the algorithm name associated with the given object id. |
static String |
getObjectId(String name)
Return the ObjectId associated with the given algorithm name. |
int |
getSize()
Get the number of elements in this structured type. |
int |
getTagClass()
Get the tag class for this object. |
int |
getType()
Get the tag of this ASN.1 object. |
int |
getTypeOnly()
Get the type of this ASN.1 object without the tag class. |
int |
getUnusedBits()
Returns the number of unused bits if the ANS.1 type is a BIT STRING. |
String |
gvAlgorithm()
Get the algorithm value of this AlgorithmID object. |
ASN1 |
gvASN1()
Get the value as an ASN1 object. |
BigInteger |
gvBigInteger()
Get the value as BigInteger. |
boolean |
gvBoolean()
Get the value as a boolean. |
byte[] |
gvByteArray()
Get the value as a byte array. |
Date |
gvDate()
Get the value as a Date. |
int |
gvInt()
Get the value as an int. |
Object |
gvObject()
Get the value as Object. |
String |
gvObjectId()
Get the value as a object id. |
String |
gvString()
Get the value as a String. |
Vector |
gvVector()
Get the value as a Vector. |
int |
hashCode()
Get a hashCode for this ASN1 object. |
boolean |
isConstructed()
Check whether this type uses constructed encoding. |
static boolean |
isObjectId(String s)
Return whether or not the string represents an ObjectId. |
static ASN1 |
makeAlgorithmId(String objectId,
ASN1 params)
Creates a ASN.1 AlgorithmID structure. |
static ASN1 |
makeSequence(int size)
Make an ASN.1 sequence. |
static ASN1 |
makeSignatureAlgId(String objectId,
ASN1 params)
Creates a ASN.1 AlgorithmID structure {@see makeAlgorithmId( String, ASN1 ); } for digital signatures. |
static ASN1 |
makeString(String s)
Make an ASN.1 string type from s suitable for use in a X.500 name. |
static void |
register(String objectId,
String name)
Register an algorithm name for an ObjectId. |
void |
setImplicitTag(int tag)
|
void |
setUnusedBits(int bits)
Sets the number of unused bits for encoding a ASN.1 BIT STRING object. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String OID_RSA
public static final String OID_DSA
public static final String OID_DH
public static final String OID_MD2_WITH_RSA_ENCRYPTION
public static final String OID_MD5_WITH_RSA_ENCRYPTION
public static final String OID_SHA1_WITH_RSA_ENCRYPTION
public static final String OID_SHA1_WITH_DSA
public static final String OID_MD2
public static final String OID_MD5
public static final String OID_SHA
public static final String OID_SHA256
public static final String OID_SHA224
public static final String OID_DES_EDE_CBC
public static final String OID_AES_128_CBC
public static final String OID_HMAC_SHA1
public static final String OID_NAME_CN
public static final String OID_NAME_SN
public static final String OID_NAME_SERIAL
public static final String OID_NAME_C
public static final String OID_NAME_L
public static final String OID_NAME_ST
public static final String OID_NAME_STREET
public static final String OID_NAME_O
public static final String OID_NAME_OU
public static final String OID_NAME_T
public static final String OID_NAME_EMAIL
public static final int TYPE_BOOLEAN
public static final int TYPE_INTEGER
public static final int TYPE_BIT_STRING
public static final int TYPE_OCTET_STRING
public static final int TYPE_NULL
public static final int TYPE_OBJECT_ID
public static final int TYPE_OBJECT_DESCRIPTOR
public static final int TYPE_EXTERNAL
public static final int TYPE_REAL
public static final int TYPE_ENUMERATED
public static final int TYPE_EMBEDDED_PDV
public static final int TYPE_UTF8_STRING
public static final int TYPE_RELATIVE_OID
public static final int TYPE_SEQUENCE
public static final int TYPE_SET
public static final int TYPE_NUMERIC_STRING
public static final int TYPE_PRINTABLE_STRING
public static final int TYPE_T61_STRING
public static final int TYPE_VIDEOTEX_STRING
public static final int TYPE_IA5_STRING
public static final int TYPE_UTCTIME
public static final int TYPE_GENERALIZED_TIME
public static final int TYPE_GRAPHIC_STRING
public static final int TYPE_VISIBLE_STRING
public static final int TYPE_GENERAL_STRING
public static final int TYPE_UNIVERSAL_STRING
public static final int TYPE_CHARACTER_STRING
public static final int TYPE_BMP_STRING
public static final int TAG_UNIVERSAL
public static final int TAG_APPLICATION
public static final int TAG_CONTEXT_SPECIFIC
public static final int TAG_PRIVATE
public static final int CS0
ASN1.TAG_CONTEXT_SPECIFIC | 0
.public static final int CS1
ASN1.TAG_CONTEXT_SPECIFIC | 1
.public static final int CS2
ASN1.TAG_CONTEXT_SPECIFIC | 2
.public static final int CS3
ASN1.TAG_CONTEXT_SPECIFIC | 3
.Constructor Detail |
public ASN1(InputStream in) throws IOException
public ASN1(InputStream in, int saveEncoding, boolean expectImplicit) throws IOException
public ASN1(byte[] data) throws IOException
public ASN1(byte[] data, int saveEncoding, boolean expectImplicit) throws IOException
public ASN1(int type, Object value)
public ASN1(int type, Object value, boolean implicit)
Method Detail |
public static String getName(String objectId)
public static String getObjectId(String name)
public static void register(String objectId, String name)
objectId
- algorithmname
- public static boolean isObjectId(String s)
public void clearEncoding(boolean recursive)
public int getUnusedBits()
public static ASN1 makeAlgorithmId(String objectId, ASN1 params)
AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL }If the passed parameters are null, they are encoded as the NULL type.
public static ASN1 makeSignatureAlgId(String objectId, ASN1 params)
objectId
- OID of the algorithmparams
- additional algotrithm parameterspublic static ASN1 makeString(String s)
public static ASN1 makeSequence(int size)
new ASN(ASN1.TYPE_SEQUENCE, new Vector(size)).gvVector()
.
The exception is that if size is 0, a Vector with the default size is created.public void addElement(ASN1 asn1)
gvVector().addElement(asn1)
.public int getType()
public int getTypeOnly()
public int getTagClass()
public boolean isConstructed()
public byte[] getEncoded()
public Object gvObject()
public BigInteger gvBigInteger() throws IOException
public int gvInt() throws IOException
public byte[] gvByteArray() throws IOException
public Vector gvVector() throws IOException
public Date gvDate() throws IOException
public boolean gvBoolean() throws IOException
public String gvString() throws IOException
public String gvObjectId() throws IOException
public ASN1 gvASN1() throws IOException
public void setImplicitTag(int tag) throws IOException
public ASN1 getElementAt(int n) throws IOException
public int getSize() throws IOException
public String gvAlgorithm() throws IOException
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public void setUnusedBits(int bits)
bits
- number of unused bits
|
This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |