Przeglądaj źródła

add OID testcase from x.690

Steffen Jaeckel 7 lat temu
rodzic
commit
079ed04b17
1 zmienionych plików z 22 dodań i 0 usunięć
  1. 22 0
      tests/der_test.c

+ 22 - 0
tests/der_test.c

@@ -673,6 +673,26 @@ static void der_set_test(void)
 
 */
 
+static void _der_oid_test(void)
+{
+   static const unsigned char oid_x690_8_19_5_example[] = { 0x06, 0x03, 0x88, 0x37, 0x03 };
+   unsigned long len;
+   unsigned char buf[64];
+
+   ltc_asn1_list *decoded_list, static_list[1];
+
+   len = sizeof(oid_x690_8_19_5_example);
+   DO(der_decode_sequence_flexi(oid_x690_8_19_5_example, &len, &decoded_list));
+
+   LTC_SET_ASN1(static_list, 0, LTC_ASN1_OBJECT_IDENTIFIER, (void *)decoded_list->data, decoded_list->size);
+   len = sizeof(buf);
+   DO(der_encode_object_identifier(decoded_list->data, decoded_list->size, buf, &len));
+   der_sequence_free(decoded_list);
+
+   DO(do_compare_testvector(buf, len, oid_x690_8_19_5_example, sizeof(oid_x690_8_19_5_example), "OID X6.90 Ch. 8.19.5 Example", 0));
+
+}
+
 static void der_flexi_test(void)
 {
    static const char printable_str[]    = "printable";
@@ -1589,6 +1609,8 @@ int der_test(void)
 
    der_cacert_test();
 
+   _der_oid_test();
+
    y = 0xffffff00;
 #if ULONG_MAX == ULLONG_MAX
    y <<= 32;