Skip to content

Commit

Permalink
Convert utf-8 files to ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
guanzhi committed May 25, 2024
1 parent 39af190 commit 68fd02e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 20 deletions.
6 changes: 3 additions & 3 deletions tests/asn1test.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tests/cmstest.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion tests/gf128test.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ int test_gf128_mul_more(void)
"8000000000000000" "0000000000000000",
"0000000000000000" "0000000000000000",
},
// 这个现在显然是不对的
{
"1 * 1",
"8000000000000000" "0000000000000000",
Expand Down
4 changes: 3 additions & 1 deletion tests/sm2_enctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include <gmssl/sm2.h>
#include <gmssl/pkcs8.h>

// 应该整理出不同编码长度的椭圆曲线点,可以由x求出y

// TODO: prepare POINT with different length

static int test_sm2_ciphertext(void)
{
struct {
Expand Down
3 changes: 1 addition & 2 deletions tests/sm2_signtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 5 additions & 6 deletions tests/sm2_z256test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <gmssl/error.h>


// 计算中如何涉及无穷远点会怎么样
// TODO:
static int test_sm2_z256_point_at_infinity(void)
{
return 1;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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();
Expand All @@ -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)) {
Expand Down
3 changes: 0 additions & 3 deletions tests/tlstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion tests/x509_exttest.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ static int test_x509_policy_mapping(void)
return 1;
}

// 这里的一些OID应该在RFC中有,但是我们不实现
static int test_x509_attribute(void)
{
// TODO
Expand Down

0 comments on commit 68fd02e

Please sign in to comment.