Don't run the TLSv1.3 CCS tests if TLSv1.3 is not enabled
[openssl.git] / test / asn1_encode_test.c
index 6d3883755260cb8b990d1883fa1acdf7b716a1a7..e9f459ad6505adf9f2b17f01a524b13d7949f7a7 100644 (file)
@@ -577,14 +577,14 @@ static size_t der_encode_length(size_t len, unsigned char **pp)
 
     if (pp != NULL) {
         if (lenbytes == 1) {
-            *(*pp)++ = len;
+            *(*pp)++ = (unsigned char)len;
         } else {
-            *(*pp)++ = lenbytes - 1;
+            *(*pp)++ = (unsigned char)(lenbytes - 1);
             if (lenbytes == 2) {
-                *(*pp)++ = 0x80 | len;
+                *(*pp)++ = (unsigned char)(0x80 | len);
             } else {
-                *(*pp)++ = 0x80 | (len >> 8);
-                *(*pp)++ = len & 0xff;
+                *(*pp)++ = (unsigned char)(0x80 | (len >> 8));
+                *(*pp)++ = (unsigned char)(len);
             }
         }
     }
@@ -672,7 +672,7 @@ static int do_decode_custom(const TEST_CUSTOM_DATA *custom_data,
 {
     unsigned char *encoding = NULL;
     /*
-     * We force the defaults to be explicitely encoded to make sure we test
+     * We force the defaults to be explicitly encoded to make sure we test
      * for defaults that shouldn't be present (i.e. we check for failure)
      */
     size_t encoding_length = make_custom_der(custom_data, &encoding, 1);
@@ -717,7 +717,7 @@ static int do_print_item(const TEST_PACKAGE *package)
     OPENSSL_assert(package->encode_expectations_elem_size <= DATA_BUF_SIZE);
 
     (void)RAND_bytes(buf, (int)package->encode_expectations_elem_size);
-    ret = ASN1_item_print(bio_out, o, 0, i, NULL);
+    ret = ASN1_item_print(bio_err, o, 0, i, NULL);
 
     return ret;
 }
@@ -814,6 +814,7 @@ static int test_intern(const TEST_PACKAGE *package)
 
     if (!do_print_item(package)) {
         TEST_error("Printing of %s failed", package->name);
+        TEST_openssl_errors();
         fail++;
     }
 
@@ -852,7 +853,7 @@ static int test_uint64(void)
     return test_intern(&uint64_test_package);
 }
 
-void register_tests(void)
+int setup_tests(void)
 {
 #if OPENSSL_API_COMPAT < 0x10200000L
     ADD_TEST(test_long_32bit);
@@ -862,4 +863,5 @@ void register_tests(void)
     ADD_TEST(test_uint32);
     ADD_TEST(test_int64);
     ADD_TEST(test_uint64);
+    return 1;
 }