From 68fd02e2ac796f0a2b985bc03222ce7dfe46b1e7 Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Sat, 25 May 2024 18:45:23 +0800 Subject: [PATCH] Convert utf-8 files to ascii --- tests/asn1test.c | 6 +++--- tests/cmstest.c | 6 +++--- tests/gf128test.c | 1 - tests/sm2_enctest.c | 4 +++- tests/sm2_signtest.c | 3 +-- tests/sm2_z256test.c | 11 +++++------ tests/tlstest.c | 3 --- tests/x509_exttest.c | 1 - 8 files changed, 15 insertions(+), 20 deletions(-) diff --git a/tests/asn1test.c b/tests/asn1test.c index 4bbcff2e2..211b457e3 100644 --- a/tests/asn1test.c +++ b/tests/asn1test.c @@ -1,4 +1,4 @@ -/* +/* * Copyright 2014-2023 The GmSSL Project. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the License); you may @@ -183,7 +183,7 @@ static int test_asn1_int(void) } format_bytes(stderr, 0, 4, "", buf, len); } - // 测试 -1 表示默认不编码 + // integer == -1 (similar as NULL for other types) means do not encode if (asn1_int_to_der(-1, &p, &len) != 0) { error_print(); return -1; @@ -202,7 +202,7 @@ static int test_asn1_int(void) return -1; } - // 测试返回0时是否对val值做初始化 + // test if val has been inited when return 0 if (asn1_int_from_der(&val, &cp, &len) != 0) { error_print(); return -1; diff --git a/tests/cmstest.c b/tests/cmstest.c index 4561e244c..923c16bf8 100644 --- a/tests/cmstest.c +++ b/tests/cmstest.c @@ -1,4 +1,4 @@ -/* +/* * Copyright 2014-2022 The GmSSL Project. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the License); you may @@ -80,7 +80,7 @@ static int test_cms_content_info(void) cp = buf; len = 0; -// 当类型为OID_cms_data, 数据是OCTET STRING,需要再解析一次 +// When type is OID_cms_data, value is OCTET STRING, we need to parse the value again if (cms_content_info_to_der(OID_cms_data, data, sizeof(data), &p, &len) != 1 || cms_content_info_from_der(&oid, &d, &dlen, &cp, &len) != 1 @@ -203,7 +203,7 @@ static int test_cms_enced_content_info_encrypt(void) NULL, 0, NULL, 0, &p, &len) != 1 - // 显然这个解密函数是有问题的,在from_der的时候不知道密文的长度,因此无法知道需要的输出缓冲长度 + // FIXME: we do not know the ciphertext length when `from_der`, so can not know the output buffer length || cms_enced_content_info_decrypt_from_der( &cipher, key, sizeof(key), diff --git a/tests/gf128test.c b/tests/gf128test.c index ddc298c0e..7275fb60d 100644 --- a/tests/gf128test.c +++ b/tests/gf128test.c @@ -31,7 +31,6 @@ int test_gf128_mul_more(void) "8000000000000000" "0000000000000000", "0000000000000000" "0000000000000000", }, - // 这个现在显然是不对的 { "1 * 1", "8000000000000000" "0000000000000000", diff --git a/tests/sm2_enctest.c b/tests/sm2_enctest.c index 751c04a37..4a07d0c48 100644 --- a/tests/sm2_enctest.c +++ b/tests/sm2_enctest.c @@ -17,7 +17,9 @@ #include #include -// 应该整理出不同编码长度的椭圆曲线点,可以由x求出y + +// TODO: prepare POINT with different length + static int test_sm2_ciphertext(void) { struct { diff --git a/tests/sm2_signtest.c b/tests/sm2_signtest.c index 3c1757cf8..142b4addd 100644 --- a/tests/sm2_signtest.c +++ b/tests/sm2_signtest.c @@ -247,8 +247,7 @@ static int test_sm2_sign_ctx(void) } format_print(stderr, 0, 4, "verification: %s\n", ret ? "success" : "failed"); - // FIXME: 还应该增加验证不通过的测试 - // 还应该增加底层的参数 + // FIXME: add some test vectors that can not pass verificate printf("%s() ok\n", __FUNCTION__); return 1; } diff --git a/tests/sm2_z256test.c b/tests/sm2_z256test.c index 418f8c7af..49eee01b9 100644 --- a/tests/sm2_z256test.c +++ b/tests/sm2_z256test.c @@ -19,7 +19,7 @@ #include -// 计算中如何涉及无穷远点会怎么样 +// TODO: static int test_sm2_z256_point_at_infinity(void) { return 1; @@ -77,7 +77,7 @@ static int test_sm2_z256_from_bytes(void) 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20, }; - // 应该选一个to_bytes和一个from_bytes + // TODO: choose both `to_bytes` and `from_bytes` sm2_z256_t a; uint8_t buf[32]; @@ -588,14 +588,13 @@ static int test_sm2_z256_point_add_conjugate(void) sm2_z256_point_from_hex(&Q, hex_negG); sm2_z256_point_add(&R, &P, &Q); - // 汇编代码在实现点加的时候,为什么会出现X, Y != 0的情况呢? sm2_z256_print(stderr, 0, 0, "R.X", R.X); sm2_z256_print(stderr, 0, 0, "R.Y", R.Y); sm2_z256_print(stderr, 0, 0, "R.Z", R.Z); // P + (-P) = (0:0:0) /* - // 有可能在计算的时候,已经发现这是共轭点,那就不做进一步的计算了 + //FIXME: if (!sm2_z256_is_zero(R.X) || !sm2_z256_is_zero(R.Y)) { error_print(); @@ -612,14 +611,14 @@ static int test_sm2_z256_point_add_conjugate(void) return 1; } -// 无穷远点相加应该还是无穷远点 +// TODO: check O + O == O static int test_sm2_z256_point_dbl_infinity(void) { SM2_Z256_POINT P_infinity; SM2_Z256_POINT R; sm2_z256_point_set_infinity(&P_infinity); - sm2_z256_point_dbl(&R, &P_infinity); // 显然这个计算就会出错了! + sm2_z256_point_dbl(&R, &P_infinity); sm2_z256_print(stderr, 0, 0, "ret", R.X); if (!sm2_z256_point_is_at_infinity(&R)) { diff --git a/tests/tlstest.c b/tests/tlstest.c index a374ae573..0d9c8aef8 100644 --- a/tests/tlstest.c +++ b/tests/tlstest.c @@ -174,9 +174,6 @@ static int test_tls_certificate(void) size_t recordlen = 0; FILE *fp = NULL; - // 测试函数不要有外部的依赖 - // TODO: 输出一些握手过程的record字节数组和handshake字节数组,作为后续测试的测试数据 - /* if (!(fp = fopen("cacert.pem", "r"))) { error_print(); diff --git a/tests/x509_exttest.c b/tests/x509_exttest.c index c45c926ac..af80e3cfa 100644 --- a/tests/x509_exttest.c +++ b/tests/x509_exttest.c @@ -468,7 +468,6 @@ static int test_x509_policy_mapping(void) return 1; } -// 这里的一些OID应该在RFC中有,但是我们不实现 static int test_x509_attribute(void) { // TODO