mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-27 07:33:41 +08:00
Remove warnings
This commit is contained in:
@@ -175,7 +175,7 @@ void des_set_encrypt_key(DES_KEY *key, const unsigned char user_key[8])
|
||||
|
||||
K = GETU64(user_key);
|
||||
K = permute(PC1, sizeof(PC1), K);
|
||||
L = K >> 28;
|
||||
L = (K >> 28) & 0xffffffff;
|
||||
R = K & 0x0fffffff;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
@@ -217,7 +217,7 @@ void des_encrypt(DES_KEY *key, const unsigned char in[DES_BLOCK_SIZE],
|
||||
T ^= L;
|
||||
|
||||
L = R;
|
||||
R = T;
|
||||
R = T & 0xffffffff;
|
||||
}
|
||||
|
||||
T = ((uint64_t)L << 32) | R;
|
||||
|
||||
@@ -353,7 +353,6 @@ int pbes2_algor_from_der(
|
||||
int ret;
|
||||
const uint8_t *d;
|
||||
size_t dlen;
|
||||
int oid;
|
||||
uint32_t nodes[32];
|
||||
size_t nodes_cnt;
|
||||
|
||||
|
||||
@@ -536,8 +536,8 @@ int skf_import_object(SKF_DEVICE *dev, const char *appname, const char *pin,
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
if (SKF_CreateFile(hApp, (LPSTR)objname, datalen, ulReadRights, ulWriteRights) != SAR_OK
|
||||
|| SKF_WriteFile(hApp, (LPSTR)objname, 0, (BYTE *)data, datalen) != SAR_OK) {
|
||||
if (SKF_CreateFile(hApp, (LPSTR)objname, (ULONG)datalen, ulReadRights, ulWriteRights) != SAR_OK
|
||||
|| SKF_WriteFile(hApp, (LPSTR)objname, 0, (BYTE *)data, (ULONG)datalen) != SAR_OK) {
|
||||
error_print();
|
||||
goto end;
|
||||
}
|
||||
@@ -554,7 +554,6 @@ int skf_export_object(SKF_DEVICE *dev, const char *appname, const char *pin,
|
||||
HAPPLICATION hApp = NULL;
|
||||
FILEATTRIBUTE fileInfo;
|
||||
ULONG ulen;
|
||||
int len;
|
||||
|
||||
if (!dev || !appname || !pin || !objname || !outlen) {
|
||||
error_print();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -434,7 +434,7 @@ ULONG DEVAPI SKF_ExportCertificate(
|
||||
BYTE *pbCert,
|
||||
ULONG *pulCertLen)
|
||||
{
|
||||
*pulCertLen = strlen(sm2cert_pemstr);
|
||||
*pulCertLen = (ULONG)strlen(sm2cert_pemstr);
|
||||
memcpy(pbCert, sm2cert_pemstr, *pulCertLen);
|
||||
|
||||
return SAR_OK;
|
||||
|
||||
@@ -492,13 +492,12 @@ int sm2_do_encrypt(const SM2_KEY *key, const uint8_t *in, size_t inlen, SM2_CIPH
|
||||
|
||||
int sm2_do_decrypt(const SM2_KEY *key, const SM2_CIPHERTEXT *in, uint8_t *out, size_t *outlen)
|
||||
{
|
||||
uint32_t inlen;
|
||||
uint32_t inlen, i;
|
||||
SM2_BN d;
|
||||
SM2_JACOBIAN_POINT _P, *P = &_P;
|
||||
SM3_CTX sm3_ctx;
|
||||
uint8_t buf[64];
|
||||
uint8_t hash[32];
|
||||
int i;
|
||||
|
||||
// FIXME: check SM2_CIPHERTEXT format
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ void sm9_bn_to_bits(const sm9_bn_t a, char bits[256])
|
||||
{
|
||||
int i, j;
|
||||
for (i = 7; i >= 0; i--) {
|
||||
uint32_t w = a[i];
|
||||
uint32_t w = (uint32_t)a[i];
|
||||
for (j = 0; j < 32; j++) {
|
||||
*bits++ = (w & 0x80000000) ? '1' : '0';
|
||||
w <<= 1;
|
||||
|
||||
12
src/tls.c
12
src/tls.c
@@ -1483,7 +1483,11 @@ int tls_record_send(const uint8_t *record, size_t recordlen, int sock)
|
||||
error_print();
|
||||
return -1;
|
||||
}
|
||||
#ifdef WIN32
|
||||
if ((r = send(sock, record, (int)recordlen, 0)) < 0) {
|
||||
#else
|
||||
if ((r = send(sock, record, recordlen, 0)) < 0) {
|
||||
#endif
|
||||
perror("tls_record_send");
|
||||
error_print();
|
||||
return -1;
|
||||
@@ -1509,7 +1513,11 @@ int tls_record_do_recv(uint8_t *record, size_t *recordlen, int sock)
|
||||
|
||||
len = 5;
|
||||
while (len) {
|
||||
#ifdef WIN32
|
||||
if ((r = recv(sock, record + 5 - len, (int)len, 0)) < 0) {
|
||||
#else
|
||||
if ((r = recv(sock, record + 5 - len, len, 0)) < 0) {
|
||||
#endif
|
||||
perror("tls_record_do_recv");
|
||||
error_print();
|
||||
return -1;
|
||||
@@ -1538,7 +1546,11 @@ int tls_record_do_recv(uint8_t *record, size_t *recordlen, int sock)
|
||||
return -1;
|
||||
}
|
||||
while (len) {
|
||||
#ifdef WIN32
|
||||
if ((r = recv(sock, record + *recordlen - len, (int)len, 0)) < 0) {
|
||||
#else
|
||||
if ((r = recv(sock, record + *recordlen - len, len, 0)) < 0) {
|
||||
#endif
|
||||
perror("tls_record_do_recv");
|
||||
error_print();
|
||||
return -1;
|
||||
|
||||
@@ -502,7 +502,6 @@ int tls13_process_client_supported_versions(const uint8_t *ext_data, size_t ext_
|
||||
const uint8_t *versions;
|
||||
size_t versions_len;
|
||||
int selected_version = -1;
|
||||
size_t len;
|
||||
|
||||
if (tls_uint8array_from_bytes(&versions, &versions_len, &ext_data, &ext_datalen) != 1
|
||||
|| tls_length_is_zero(ext_datalen) != 1) {
|
||||
@@ -644,7 +643,7 @@ int tls13_server_key_share_ext_to_bytes(const SM2_POINT *point, uint8_t **out, s
|
||||
}
|
||||
tls13_key_share_entry_to_bytes(point, NULL, &ext_datalen);
|
||||
tls_uint16_to_bytes(ext_type, out, outlen);
|
||||
tls_uint16_to_bytes(ext_datalen, out, outlen);
|
||||
tls_uint16_to_bytes((uint16_t)ext_datalen, out, outlen);
|
||||
tls13_key_share_entry_to_bytes(point, out, outlen);
|
||||
return 1;
|
||||
}
|
||||
@@ -694,8 +693,8 @@ int tls13_client_key_share_ext_to_bytes(const SM2_POINT *point, uint8_t **out, s
|
||||
ext_datalen = tls_uint16_size() + client_shares_len;
|
||||
|
||||
tls_uint16_to_bytes(ext_type, out, outlen);
|
||||
tls_uint16_to_bytes(ext_datalen, out, outlen);
|
||||
tls_uint16_to_bytes(client_shares_len, out, outlen);
|
||||
tls_uint16_to_bytes((uint16_t)ext_datalen, out, outlen); // FIXME: do we need to check length < UINT16_MAX?
|
||||
tls_uint16_to_bytes((uint16_t)client_shares_len, out, outlen);
|
||||
tls13_key_share_entry_to_bytes(point, out, outlen);
|
||||
return 1;
|
||||
}
|
||||
@@ -791,8 +790,8 @@ int tls13_certificate_authorities_ext_to_bytes(const uint8_t *ca_names, size_t c
|
||||
ext_datalen = tls_uint16_size() + authorities_len;
|
||||
|
||||
tls_uint16_to_bytes(ext_type, out, outlen);
|
||||
tls_uint16_to_bytes(ext_datalen, out, outlen);
|
||||
tls_uint16_to_bytes(authorities_len, out, outlen);
|
||||
tls_uint16_to_bytes((uint16_t)ext_datalen, out, outlen);
|
||||
tls_uint16_to_bytes((uint16_t)authorities_len, out, outlen);
|
||||
while (ca_names_len) {
|
||||
x509_name_from_der(&name, &namelen, &ca_names, &ca_names_len);
|
||||
tls_uint16array_to_bytes(name, namelen, out, outlen);
|
||||
|
||||
@@ -325,7 +325,6 @@ const char *tls_signature_scheme_name(int scheme)
|
||||
|
||||
int tls_random_print(FILE *fp, const uint8_t random[32], int format, int indent)
|
||||
{
|
||||
int i;
|
||||
time_t gmt_unix_time = 0;
|
||||
const uint8_t *cp = random;
|
||||
size_t len = 4;
|
||||
@@ -590,7 +589,6 @@ int tls_server_hello_print(FILE *fp, const uint8_t *data, size_t datalen, int fo
|
||||
uint8_t comp_meth;
|
||||
const uint8_t *exts;
|
||||
size_t session_id_len, cipher_suites_len, comp_meths_len, exts_len;
|
||||
size_t i;
|
||||
|
||||
format_print(fp, format, indent, "ServerHello\n"); indent += 4;
|
||||
if (tls_uint16_from_bytes(&protocol, &data, &datalen) != 1) goto bad;
|
||||
@@ -620,7 +618,6 @@ bad:
|
||||
|
||||
int tls_certificate_print(FILE *fp, const uint8_t *data, size_t datalen, int format, int indent)
|
||||
{
|
||||
int ret;
|
||||
const uint8_t *certs;
|
||||
size_t certslen;
|
||||
const uint8_t *der;
|
||||
@@ -752,7 +749,7 @@ int tls_certificate_request_print(FILE *fp, const uint8_t *data, size_t datalen,
|
||||
{
|
||||
const uint8_t *cert_types;
|
||||
const uint8_t *ca_names;
|
||||
size_t cert_types_len, ca_names_len, i;
|
||||
size_t cert_types_len, ca_names_len;
|
||||
|
||||
format_print(fp, format, indent, "CertificateRequest\n"); indent += 4;
|
||||
if (tls_uint8array_from_bytes(&cert_types, &cert_types_len, &data, &datalen) != 1) goto bad;
|
||||
|
||||
Reference in New Issue
Block a user