mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Convert utf-8 files to ascii
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2023 The GmSSL Project. All Rights Reserved.
|
* Copyright 2014-2023 The GmSSL Project. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
* 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);
|
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) {
|
if (asn1_int_to_der(-1, &p, &len) != 0) {
|
||||||
error_print();
|
error_print();
|
||||||
return -1;
|
return -1;
|
||||||
@@ -202,7 +202,7 @@ static int test_asn1_int(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试返回0时是否对val值做初始化
|
// test if val has been inited when return 0
|
||||||
if (asn1_int_from_der(&val, &cp, &len) != 0) {
|
if (asn1_int_from_der(&val, &cp, &len) != 0) {
|
||||||
error_print();
|
error_print();
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
|
* Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
* 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;
|
cp = buf;
|
||||||
len = 0;
|
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
|
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
|
|| 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,
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
&p, &len) != 1
|
&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(
|
|| cms_enced_content_info_decrypt_from_der(
|
||||||
&cipher,
|
&cipher,
|
||||||
key, sizeof(key),
|
key, sizeof(key),
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ int test_gf128_mul_more(void)
|
|||||||
"8000000000000000" "0000000000000000",
|
"8000000000000000" "0000000000000000",
|
||||||
"0000000000000000" "0000000000000000",
|
"0000000000000000" "0000000000000000",
|
||||||
},
|
},
|
||||||
// 这个现在显然是不对的
|
|
||||||
{
|
{
|
||||||
"1 * 1",
|
"1 * 1",
|
||||||
"8000000000000000" "0000000000000000",
|
"8000000000000000" "0000000000000000",
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
#include <gmssl/sm2.h>
|
#include <gmssl/sm2.h>
|
||||||
#include <gmssl/pkcs8.h>
|
#include <gmssl/pkcs8.h>
|
||||||
|
|
||||||
// 应该整理出不同编码长度的椭圆曲线点,可以由x求出y
|
|
||||||
|
// TODO: prepare POINT with different length
|
||||||
|
|
||||||
static int test_sm2_ciphertext(void)
|
static int test_sm2_ciphertext(void)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
|
|||||||
@@ -247,8 +247,7 @@ static int test_sm2_sign_ctx(void)
|
|||||||
}
|
}
|
||||||
format_print(stderr, 0, 4, "verification: %s\n", ret ? "success" : "failed");
|
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__);
|
printf("%s() ok\n", __FUNCTION__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#include <gmssl/error.h>
|
#include <gmssl/error.h>
|
||||||
|
|
||||||
|
|
||||||
// 计算中如何涉及无穷远点会怎么样
|
// TODO:
|
||||||
static int test_sm2_z256_point_at_infinity(void)
|
static int test_sm2_z256_point_at_infinity(void)
|
||||||
{
|
{
|
||||||
return 1;
|
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,
|
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;
|
sm2_z256_t a;
|
||||||
uint8_t buf[32];
|
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_from_hex(&Q, hex_negG);
|
||||||
sm2_z256_point_add(&R, &P, &Q);
|
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.X", R.X);
|
||||||
sm2_z256_print(stderr, 0, 0, "R.Y", R.Y);
|
sm2_z256_print(stderr, 0, 0, "R.Y", R.Y);
|
||||||
sm2_z256_print(stderr, 0, 0, "R.Z", R.Z);
|
sm2_z256_print(stderr, 0, 0, "R.Z", R.Z);
|
||||||
|
|
||||||
// P + (-P) = (0:0:0)
|
// P + (-P) = (0:0:0)
|
||||||
/*
|
/*
|
||||||
// 有可能在计算的时候,已经发现这是共轭点,那就不做进一步的计算了
|
//FIXME:
|
||||||
if (!sm2_z256_is_zero(R.X)
|
if (!sm2_z256_is_zero(R.X)
|
||||||
|| !sm2_z256_is_zero(R.Y)) {
|
|| !sm2_z256_is_zero(R.Y)) {
|
||||||
error_print();
|
error_print();
|
||||||
@@ -612,14 +611,14 @@ static int test_sm2_z256_point_add_conjugate(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 无穷远点相加应该还是无穷远点
|
// TODO: check O + O == O
|
||||||
static int test_sm2_z256_point_dbl_infinity(void)
|
static int test_sm2_z256_point_dbl_infinity(void)
|
||||||
{
|
{
|
||||||
SM2_Z256_POINT P_infinity;
|
SM2_Z256_POINT P_infinity;
|
||||||
SM2_Z256_POINT R;
|
SM2_Z256_POINT R;
|
||||||
|
|
||||||
sm2_z256_point_set_infinity(&P_infinity);
|
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);
|
sm2_z256_print(stderr, 0, 0, "ret", R.X);
|
||||||
|
|
||||||
if (!sm2_z256_point_is_at_infinity(&R)) {
|
if (!sm2_z256_point_is_at_infinity(&R)) {
|
||||||
|
|||||||
@@ -174,9 +174,6 @@ static int test_tls_certificate(void)
|
|||||||
size_t recordlen = 0;
|
size_t recordlen = 0;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
|
||||||
// 测试函数不要有外部的依赖
|
|
||||||
// TODO: 输出一些握手过程的record字节数组和handshake字节数组,作为后续测试的测试数据
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (!(fp = fopen("cacert.pem", "r"))) {
|
if (!(fp = fopen("cacert.pem", "r"))) {
|
||||||
error_print();
|
error_print();
|
||||||
|
|||||||
@@ -468,7 +468,6 @@ static int test_x509_policy_mapping(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 这里的一些OID应该在RFC中有,但是我们不实现
|
|
||||||
static int test_x509_attribute(void)
|
static int test_x509_attribute(void)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
Reference in New Issue
Block a user