Add tests of custom negative 1
authorRichard Levitte <levitte@openssl.org>
Mon, 10 Apr 2017 23:38:00 +0000 (01:38 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 12 Apr 2017 10:30:38 +0000 (12:30 +0200)
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3174)

test/asn1_encode_test.c

index 68a069685f6f406f3ba43d976a255920c3fd63e5..763c427d1a1d4ab14ea2e0412a801c227c89fda1 100644 (file)
@@ -38,6 +38,9 @@ static unsigned char t_zero[] = {
 static unsigned char t_one[] = {
     0x01
 };
+static unsigned char t_one_neg[] = {
+    0xff
+};
 static unsigned char t_longundef[] = {
     0x7f, 0xff, 0xff, 0xff
 };
@@ -95,6 +98,7 @@ static TEST_CUSTOM_DATA test_custom_data[] = {
     CUSTOM_DATA(t_zero),
     CUSTOM_DATA(t_longundef),
     CUSTOM_DATA(t_one),
+    CUSTOM_DATA(t_one_neg),
     CUSTOM_DATA(t_9bytes_1),
     CUSTOM_DATA(t_8bytes_1),
     CUSTOM_DATA(t_8bytes_2),
@@ -194,6 +198,7 @@ static ASN1_LONG_DATA long_expected_32bit[] = {
     { 0xff, 0, 1 }, { 0, 0, 0 }, /* t_zero */
     { 0, 0, 0 }, { 0xff, 1, 0x7fffffff }, /* t_longundef */
     CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
+    CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
     CUSTOM_EXPECTED_FAILURE,     /* t_9bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_2 */
@@ -228,6 +233,7 @@ static ASN1_LONG_DATA long_expected_64bit[] = {
     { 0xff, 0, 1 }, { 0, 0, 0 }, /* t_zero */
     { 0, 0, 0 }, { 0xff, 1, 0x7fffffff }, /* t_longundef */
     CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
+    CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
     CUSTOM_EXPECTED_FAILURE,     /* t_9bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_1 */
     CUSTOM_EXPECTED_SUCCESS(LONG_MAX, LONG_MAX), /* t_8bytes_2 */
@@ -279,6 +285,7 @@ static ASN1_INT32_DATA int32_expected[] = {
     CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
+    CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
     CUSTOM_EXPECTED_FAILURE,     /* t_9bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_2 */
@@ -325,6 +332,7 @@ static ASN1_UINT32_DATA uint32_expected[] = {
     CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
+    CUSTOM_EXPECTED_FAILURE,     /* t_one_neg (illegal negative value) */
     CUSTOM_EXPECTED_FAILURE,     /* t_9bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_2 */
@@ -371,6 +379,7 @@ static ASN1_INT64_DATA int64_expected[] = {
     CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
+    CUSTOM_EXPECTED_SUCCESS(-1, -1), /* t_one_neg */
     CUSTOM_EXPECTED_FAILURE,     /* t_9bytes_1 */
     CUSTOM_EXPECTED_FAILURE,     /* t_8bytes_1 (too large positive) */
     CUSTOM_EXPECTED_SUCCESS(INT64_MAX, INT64_MAX), /* t_8bytes_2 */
@@ -418,6 +427,7 @@ static ASN1_UINT64_DATA uint64_expected[] = {
     CUSTOM_EXPECTED_SUCCESS(0, 0), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(ASN1_LONG_UNDEF, ASN1_LONG_UNDEF), /* t_zero */
     CUSTOM_EXPECTED_SUCCESS(1, 1), /* t_one */
+    CUSTOM_EXPECTED_FAILURE,     /* t_one_neg (illegal negative value) */
     CUSTOM_EXPECTED_FAILURE,     /* t_9bytes_1 */
     CUSTOM_EXPECTED_SUCCESS((uint64_t)INT64_MAX+1, (uint64_t)INT64_MAX+1),
                                  /* t_8bytes_1 */