mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-11-15 17:15:17 +08:00
Update Makefile and code style in tests
This commit is contained in:
@@ -342,8 +342,6 @@ void sm2_bn_rand_range(SM2_BN r, const SM2_BN range)
|
||||
} while (sm2_bn_cmp(r, range) >= 0);
|
||||
}
|
||||
|
||||
typedef SM2_BN SM2_Fp;
|
||||
|
||||
void sm2_fp_add(SM2_Fp r, const SM2_Fp a, const SM2_Fp b)
|
||||
{
|
||||
sm2_bn_add(r, a, b);
|
||||
|
||||
@@ -446,12 +446,14 @@ int tlcp_do_connect(TLS_CONNECT *conn)
|
||||
sm3_hmac_init(&conn->server_write_mac_ctx, conn->key_block + 32, 32);
|
||||
sm4_set_encrypt_key(&conn->client_write_enc_key, conn->key_block + 64);
|
||||
sm4_set_decrypt_key(&conn->server_write_enc_key, conn->key_block + 80);
|
||||
/*
|
||||
tls_secrets_print(stderr,
|
||||
pre_master_secret, 48,
|
||||
client_random, server_random,
|
||||
conn->master_secret,
|
||||
conn->key_block, 96,
|
||||
0, 4);
|
||||
*/
|
||||
|
||||
// send ClientKeyExchange
|
||||
tls_trace("send ClientKeyExchange\n");
|
||||
@@ -926,12 +928,14 @@ int tlcp_do_accept(TLS_CONNECT *conn)
|
||||
sm3_hmac_init(&conn->server_write_mac_ctx, conn->key_block + 32, 32);
|
||||
sm4_set_decrypt_key(&conn->client_write_enc_key, conn->key_block + 64);
|
||||
sm4_set_encrypt_key(&conn->server_write_enc_key, conn->key_block + 80);
|
||||
/*
|
||||
tls_secrets_print(stderr,
|
||||
pre_master_secret, 48,
|
||||
client_random, server_random,
|
||||
conn->master_secret,
|
||||
conn->key_block, 96,
|
||||
0, 4);
|
||||
*/
|
||||
|
||||
// recv [ChangeCipherSpec]
|
||||
tls_trace("recv [ChangeCipherSpec]\n");
|
||||
|
||||
@@ -308,7 +308,6 @@ int tls_record_set_data(uint8_t *record, const uint8_t *data, size_t datalen)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int tls_cbc_encrypt(const SM3_HMAC_CTX *inited_hmac_ctx, const SM4_KEY *enc_key,
|
||||
const uint8_t seq_num[8], const uint8_t header[5],
|
||||
const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen)
|
||||
@@ -327,6 +326,10 @@ int tls_cbc_encrypt(const SM3_HMAC_CTX *inited_hmac_ctx, const SM4_KEY *enc_key,
|
||||
error_print_msg("invalid tls record data length %zu\n", inlen);
|
||||
return -1;
|
||||
}
|
||||
if ((((size_t)header[3]) << 8) + header[4] != inlen) {
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
|
||||
rem = (inlen + 32) % 16;
|
||||
memcpy(last_blocks, in + inlen - rem, rem);
|
||||
@@ -405,6 +408,7 @@ int tls_cbc_decrypt(const SM3_HMAC_CTX *inited_hmac_ctx, const SM4_KEY *dec_key,
|
||||
}
|
||||
|
||||
*outlen = inlen - 32 - padding_len - 1;
|
||||
|
||||
header[0] = enced_header[0];
|
||||
header[1] = enced_header[1];
|
||||
header[2] = enced_header[2];
|
||||
@@ -1717,6 +1721,8 @@ int tls_send(TLS_CONNECT *conn, const uint8_t *in, size_t inlen, size_t *sentlen
|
||||
|
||||
tls_trace("send ApplicationData\n");
|
||||
|
||||
format_bytes(stderr, 0, 0, "tls_send: payload", in, inlen);
|
||||
|
||||
if (tls_record_set_type(record, TLS_record_application_data) != 1
|
||||
|| tls_record_set_protocol(record, conn->protocol) != 1
|
||||
|| tls_record_set_length(record, inlen) != 1) {
|
||||
|
||||
@@ -538,12 +538,14 @@ int tls12_do_connect(TLS_CONNECT *conn)
|
||||
sm3_hmac_init(&conn->server_write_mac_ctx, conn->key_block + 32, 32);
|
||||
sm4_set_encrypt_key(&conn->client_write_enc_key, conn->key_block + 64);
|
||||
sm4_set_decrypt_key(&conn->server_write_enc_key, conn->key_block + 80);
|
||||
/*
|
||||
tls_secrets_print(stderr,
|
||||
pre_master_secret, 48,
|
||||
client_random, server_random,
|
||||
conn->master_secret,
|
||||
conn->key_block, 96,
|
||||
0, 4);
|
||||
*/
|
||||
|
||||
// send ClientKeyExchange
|
||||
tls_trace("send ClientKeyExchange\n");
|
||||
@@ -1002,8 +1004,10 @@ int tls12_do_accept(TLS_CONNECT *conn)
|
||||
sm3_hmac_init(&conn->server_write_mac_ctx, conn->key_block + 32, 32);
|
||||
sm4_set_decrypt_key(&conn->client_write_enc_key, conn->key_block + 64);
|
||||
sm4_set_encrypt_key(&conn->server_write_enc_key, conn->key_block + 80);
|
||||
/*
|
||||
tls_secrets_print(stderr, pre_master_secret, 32, client_random, server_random,
|
||||
conn->master_secret, conn->key_block, 96, 0, 4);
|
||||
*/
|
||||
|
||||
// recv [ChangeCipherSpec]
|
||||
tls_trace("recv [ChangeCipherSpec]\n");
|
||||
|
||||
Reference in New Issue
Block a user