@@ -12,7 +12,13 @@ public class KMAsn1Parser {
1212 public static final byte ASN1_A0_TAG = (byte ) 0xA0 ;
1313 public static final byte ASN1_A1_TAG = (byte ) 0xA1 ;
1414 public static final byte ASN1_BIT_STRING = 0x03 ;
15+
1516 public static final byte ASN1_UTF8_STRING = 0x0C ;
17+ public static final byte ASN1_TELETEX_STRING = 0x14 ;
18+ public static final byte ASN1_PRINTABLE_STRING = 0x13 ;
19+ public static final byte ASN1_UNIVERSAL_STRING = 0x1C ;
20+ public static final byte ASN1_BMP_STRING = 0x1E ;
21+
1622 public static final byte [] EC_CURVE = {
1723 0x06 ,0x08 ,0x2a ,(byte )0x86 ,0x48 ,(byte )0xce ,0x3d ,0x03 ,
1824 0x01 ,0x07
@@ -58,7 +64,7 @@ public short decodeSubject(short blob) {
5864 header (ASN1_SET );
5965 header (ASN1_SEQUENCE );
6066 objectIdentifier (COMMON_NAME_OID );
61- return header ( ASN1_UTF8_STRING );
67+ return subjectHeader ( );
6268 }
6369
6470 public short decodeEcSubjectPublicKeyInfo (short blob ) {
@@ -215,6 +221,18 @@ private short header(short tag){
215221 return getLength ();
216222 }
217223
224+ private short subjectHeader (){
225+ short t = getByte ();
226+ if (t != ASN1_UTF8_STRING &&
227+ t != ASN1_TELETEX_STRING &&
228+ t != ASN1_PRINTABLE_STRING &&
229+ t != ASN1_UNIVERSAL_STRING &&
230+ t != ASN1_BMP_STRING ) {
231+ KMException .throwIt (KMError .UNKNOWN_ERROR );
232+ }
233+ return getLength ();
234+ }
235+
218236 private byte getByte (){
219237 byte d = data [cur ];
220238 incrementCursor ((short )1 );
0 commit comments