mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 00:46:17 +08:00
remove compiler errors
still some warnings and undef code pieces
This commit is contained in:
@@ -1,4 +1,18 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=saf_lib.c saf_errstr.c saf_app.c saf_keyhandle.c \
|
||||
saf_ec.c saf_sm2.c saf_rand.c saf_hash.c saf_enc.c saf_mac.c saf_symmkeyobj.c \
|
||||
saf_base64.c saf_cert.c saf_err.c saf_pkcs7.c
|
||||
SOURCE[../../libcrypto]= \
|
||||
saf_app.c \
|
||||
saf_base64.c \
|
||||
saf_cert.c \
|
||||
saf_ec.c \
|
||||
saf_enc.c \
|
||||
saf_err.c \
|
||||
saf_errstr.c \
|
||||
saf_hash.c \
|
||||
saf_keyhandle.c \
|
||||
saf_lib.c \
|
||||
saf_mac.c \
|
||||
saf_pkcs7.c \
|
||||
saf_rand.c \
|
||||
saf_rsa.c \
|
||||
saf_sm2.c \
|
||||
saf_symmkeyobj.c
|
||||
|
||||
@@ -57,6 +57,12 @@
|
||||
#include "saf_lcl.h"
|
||||
#include "../../apps/apps.h"
|
||||
|
||||
int load_certs(const char *file, STACK_OF(X509) **certs, int format,
|
||||
const char *pass, const char *cert_descrip)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 7.2.2 */
|
||||
int SAF_AddTrustedRootCaCertificate(
|
||||
void *hAppHandle,
|
||||
|
||||
@@ -598,3 +598,29 @@ int SAF_GenerateAgreementDataAdnKeyWithECC(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* GmSSL Extension */
|
||||
int SAF_EccSignFile(
|
||||
void *hAppHandle,
|
||||
unsigned char *pucContainerName,
|
||||
unsigned int uiContainerNameLen,
|
||||
unsigned int uiHashAlgoType,
|
||||
unsigned char *pucFileName,
|
||||
unsigned char *pucSignature,
|
||||
unsigned int *puiSignatureLen)
|
||||
{
|
||||
return SAR_OK;
|
||||
}
|
||||
|
||||
int SAF_EccVerifySignFile(
|
||||
unsigned int uiHashAlgoType,
|
||||
unsigned char *pucPublicKey,
|
||||
unsigned int uiPublicKeyLen,
|
||||
unsigned char *pucFileName,
|
||||
unsigned char *pucSignature,
|
||||
unsigned int uiSignatureLen)
|
||||
{
|
||||
return SAR_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ EVP_PKEY *SAF_load_private_key(SAF_APP *app, const char *container, int flags)
|
||||
EVP_PKEY *ret = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
char key_id[1024];
|
||||
int type;
|
||||
|
||||
if (!app->engine) {
|
||||
SAFerr(SAF_F_SAF_LOAD_PRIVATE_KEY, SAF_R_INVALID_APP);
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/pkcs7.h>
|
||||
@@ -74,13 +78,11 @@ int SAF_Pkcs7_EncodeData(
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* 7.4.3 */
|
||||
int SAF_Pkcs7_DecodeData(
|
||||
void *hAppHandle,
|
||||
unsigned char *pucDecContainerName,
|
||||
unsigned int uiDecContainerNameLen,
|
||||
unsigned int uiDecKeyUsage,
|
||||
unsigned char *pucDerP7Data,
|
||||
unsigned int uiDerP7DataLen,
|
||||
unsigned char *pucData,
|
||||
@@ -186,6 +188,7 @@ int SAF_Pkcs7_DecodeSignedData(
|
||||
unsigned int *puiSigLen)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
#if 0
|
||||
PKCS7 *p7 = NULL;
|
||||
PKCS7_SIGNED *p7signed;
|
||||
X509 *x509 = NULL;
|
||||
@@ -267,13 +270,13 @@ int SAF_Pkcs7_DecodeSignedData(
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (*puiDataLen < ASN1_OCTET_STRING_length(data)) {
|
||||
if (*puiDataLen < ASN1_STRING_length(data)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODESIGNEDDATA, SAF_R_BUFFER_TOO_SMALL);
|
||||
goto end;
|
||||
}
|
||||
|
||||
memcpy(pucData, ASN1_OCTET_STRING_get0_data(data), ASN1_OCTET_STRING_length(data));
|
||||
*puiDataLen = ASN1_OCTET_STRING_length(data);
|
||||
memcpy(pucData, ASN1_STRING_get0_data(data), ASN1_STRING_length(data));
|
||||
*puiDataLen = ASN1_STRING_length(data);
|
||||
|
||||
/* get signature */
|
||||
if (sk_SIGNER_INFO_num(p7signed->signer_info) <= 0
|
||||
@@ -282,19 +285,20 @@ int SAF_Pkcs7_DecodeSignedData(
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (*puiSigLen < ASN1_OCTET_STRING_length(signer_info->enc_digest)) {
|
||||
if (*puiSigLen < ASN1_STRING_length(signer_info->enc_digest)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODESIGNEDDATA, SAF_R_BUFFER_TOO_SMALL);
|
||||
goto end;
|
||||
}
|
||||
memcpy(pucSig, ASN1_OCTET_STRING_get0_data(signer_info->enc_digest),
|
||||
ASN1_OCTET_STRING_length(signer_info->enc_digest));
|
||||
*puiSigLen = ASN1_OCTET_STRING_length(signer_info->enc_digest);
|
||||
memcpy(pucSig, ASN1_STRING_get0_data(signer_info->enc_digest),
|
||||
ASN1_STRING_length(signer_info->enc_digest));
|
||||
*puiSigLen = ASN1_STRING_length(signer_info->enc_digest);
|
||||
|
||||
ret = SAR_Ok;
|
||||
end:
|
||||
PKCS7_free(p7);
|
||||
X509_free(x509);
|
||||
BIO_free(bio);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -310,6 +314,7 @@ int SAF_Pkcs7_EncodeEnvelopedData(
|
||||
unsigned int *puiDerP7EnvelopedDataLen)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
#if 0
|
||||
PKCS7 *p7 = NULL;
|
||||
X509 *x509 = NULL;
|
||||
STACK_OF(X509) *certs = NULL;
|
||||
@@ -384,6 +389,7 @@ end:
|
||||
X509_free(x509);
|
||||
sk_X509_free(certs);
|
||||
BIO_free(bio);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -398,6 +404,7 @@ int SAF_Pkcs7_DecodeEnvelopedData(
|
||||
unsigned int *puiDataLen)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
#if 0
|
||||
SAF_APP *app = (SAF_APP *)hAppHandle;
|
||||
PKCS7 *p7 = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
@@ -420,7 +427,7 @@ int SAF_Pkcs7_DecodeEnvelopedData(
|
||||
*puiDataLen = uiDerP7EnvelopedDataLen;
|
||||
return SAR_Ok;
|
||||
} else if (*puiDataLen <= 0 || *puiDataLen > INT_MAX) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEENVELOPEDDATA, SAR_R_INVALID_INPUT_LENGTH);
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEENVELOPEDDATA, SAF_R_INVALID_INPUT_LENGTH);
|
||||
return SAR_IndataLenErr;
|
||||
}
|
||||
|
||||
@@ -456,6 +463,7 @@ end:
|
||||
EVP_PKEY_free(pkey);
|
||||
X509_free(x509);
|
||||
BIO_free(bio);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -522,7 +530,7 @@ end:
|
||||
/* 7.4.9 */
|
||||
int SAF_Pkcs7_DecodeDigestedData(
|
||||
void *hAppHandle,
|
||||
unsigned char pucDerP7DigestedData,
|
||||
unsigned char *pucDerP7DigestedData,
|
||||
unsigned int uiDerP7DigestedDataLen,
|
||||
unsigned int *puiDigestAlgorithm,
|
||||
unsigned char *pucData,
|
||||
@@ -558,14 +566,15 @@ int SAF_Pkcs7_DecodeDigestedData(
|
||||
}
|
||||
|
||||
/* process */
|
||||
if (!(p7 = d2i_PKCS7(NULL, &pucDerP7DigestedData, uiDerP7DigestedDataLen))) {
|
||||
if (!(p7 = d2i_PKCS7(NULL, (const unsigned char **)&pucDerP7DigestedData,
|
||||
uiDerP7DigestedDataLen))) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_INVALID_PKCS7);
|
||||
ret = SAR_IndataErr;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!PKCS7_type_is_digest(p7)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_INVALID_PKCS7_TYPE;
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_INVALID_PKCS7_TYPE);
|
||||
ret = SAR_IndataErr;
|
||||
goto end;
|
||||
}
|
||||
@@ -574,46 +583,46 @@ int SAF_Pkcs7_DecodeDigestedData(
|
||||
/* output digset algor */
|
||||
if ((*puiDigestAlgorithm = EVP_MD_sgd(
|
||||
EVP_get_digestbyobj(p7dgst->md->algorithm))) <= 0) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_UNSUPPORTED_DIGEST_ALGOR;
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_UNSUPPORTED_DIGEST_ALGOR);
|
||||
ret = SAR_IndataErr;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* output digested data */
|
||||
if (!PKCS7_type_is_data(p7dgst->contents)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAR_R_INVALID_PKCS7_DATA);
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_INVALID_PKCS7_DATA);
|
||||
ret = SAR_IndataErr;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!(data = p7dgst->contents->d.data)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAR_R_INVALID_PKCS7_DATA);
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_INVALID_PKCS7_DATA);
|
||||
ret = SAR_IndataErr;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (*puiDataLen < ASN1_OCTET_STRING_length(data)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAR_R_BUFFER_TOO_SMALL);
|
||||
if (*puiDataLen < ASN1_STRING_length(data)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_BUFFER_TOO_SMALL);
|
||||
ret = SAR_IndataLenErr;
|
||||
goto end;
|
||||
}
|
||||
memcpy(pucData, ASN1_OCTET_STRING_get0_data(data), ASN1_OCTET_STRING_length(data));
|
||||
*puiDataLen = ASN1_OCTET_STRING_length(data);
|
||||
memcpy(pucData, ASN1_STRING_get0_data(data), ASN1_STRING_length(data));
|
||||
*puiDataLen = ASN1_STRING_length(data);
|
||||
|
||||
/* output digest */
|
||||
if (!p7dgst->digest) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAR_R_INVALID_PKCS7_DATA);
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_INVALID_PKCS7_DATA);
|
||||
ret = SAR_IndataErr;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (*puiDigestLen < ASN1_OCTET_STRING_length(p7dgst->digest)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAR_R_BUFFER_TOO_SMALL);
|
||||
if (*puiDigestLen < ASN1_STRING_length(p7dgst->digest)) {
|
||||
SAFerr(SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA, SAF_R_BUFFER_TOO_SMALL);
|
||||
ret = SAR_IndataLenErr;
|
||||
goto end;
|
||||
}
|
||||
memcpy(pucDigest, ASN1_OCTET_STRING_get0_data(p7dgst->digest), ASN1_OCTET_STRING_length(p7dgst->digest));
|
||||
*puiDigestLen = ASN1_OCTET_STRING_length(p7dgst->digest);
|
||||
memcpy(pucDigest, ASN1_STRING_get0_data(p7dgst->digest), ASN1_STRING_length(p7dgst->digest));
|
||||
*puiDigestLen = ASN1_STRING_length(p7dgst->digest);
|
||||
|
||||
ret = SAR_Ok;
|
||||
end:
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
crypto/saf/saf_pkcs7.o: crypto/saf/saf_pkcs7.c include/openssl/evp.h \
|
||||
include/openssl/opensslconf.h include/openssl/ossl_typ.h \
|
||||
include/openssl/e_os2.h include/openssl/symhacks.h \
|
||||
include/openssl/bio.h include/openssl/crypto.h include/openssl/stack.h \
|
||||
include/openssl/safestack.h include/openssl/opensslv.h \
|
||||
include/openssl/objects.h include/openssl/obj_mac.h \
|
||||
include/openssl/asn1.h include/openssl/bn.h include/openssl/pkcs7.h \
|
||||
include/openssl/gmapi.h include/openssl/ec.h include/openssl/sm2.h \
|
||||
include/openssl/err.h include/openssl/lhash.h include/openssl/kdf2.h \
|
||||
include/openssl/kdf.h include/openssl/x509.h include/openssl/buffer.h \
|
||||
include/openssl/rsa.h include/openssl/dsa.h include/openssl/dh.h \
|
||||
include/openssl/sha.h include/openssl/x509_vfy.h \
|
||||
include/openssl/ecies.h include/openssl/sm3.h include/openssl/sgd.h \
|
||||
include/openssl/saf.h include/openssl/sdf.h include/openssl/skf.h \
|
||||
include/openssl/sof.h include/openssl/gmsaf.h crypto/saf/saf_lcl.h \
|
||||
include/openssl/cmac.h include/openssl/gmsdf.h \
|
||||
include/openssl/engine.h include/openssl/rand.h include/openssl/ui.h
|
||||
@@ -62,6 +62,7 @@ int SAF_GenRsaKeyPair(void *hAppHandle,
|
||||
unsigned int uiExportFlag)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
#if 0
|
||||
SAF_APP *app = (SAF_APP *)hAppHandle;
|
||||
|
||||
/* process */
|
||||
@@ -80,6 +81,7 @@ int SAF_GenRsaKeyPair(void *hAppHandle,
|
||||
end:
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
EVP_PKEY_free(pkey);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -93,6 +95,7 @@ int SAF_GetRsaPublicKey(
|
||||
unsigned int *puiPublicKeyLen)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
#if 0
|
||||
SAF_APP *app = (SAF_APP *)hAppHandle;
|
||||
|
||||
/* process */
|
||||
@@ -123,6 +126,7 @@ int SAF_GetRsaPublicKey(
|
||||
|
||||
end:
|
||||
EVP_PKEY_free(pkey);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -138,6 +142,8 @@ int SAF_RsaSign(
|
||||
unsigned int *puiSignatureLen)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
|
||||
#if 0
|
||||
SAF_APP *app = (SAF_APP *)hAppHandle;
|
||||
|
||||
/* process */
|
||||
@@ -162,6 +168,7 @@ int SAF_RsaSign(
|
||||
end:
|
||||
EVP_PKEY_free(pkey);
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -189,6 +196,7 @@ int SAF_RsaVerifySign(
|
||||
unsigned int uiSignatureLen)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
#if 0
|
||||
/* process */
|
||||
EVP_PKEY *pkey = NULL;
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
@@ -205,6 +213,7 @@ int SAF_RsaVerifySign(
|
||||
end:
|
||||
EVP_PKEY_free(pkey);
|
||||
EVP_PKEY_CTX_free(pctx);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -231,6 +240,7 @@ int SAF_VerifySignByCert(
|
||||
unsigned int uiSignatureLen)
|
||||
{
|
||||
int ret = SAR_UnknownErr;
|
||||
#if 0
|
||||
/* process */
|
||||
X509 *x509 = NULL;
|
||||
unsigned char pucPublicKey[1024];
|
||||
@@ -264,5 +274,6 @@ int SAF_VerifySignByCert(
|
||||
ret = SAR_Ok;
|
||||
end:
|
||||
X509_free(x509);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ int SAF_SM2_EncodeSignedData(
|
||||
return SAF_Pkcs7_EncodeSignedData(
|
||||
hAppHandle,
|
||||
pucSignContainerName,
|
||||
pucSignContainerName,
|
||||
uiSignContainerNameLen,
|
||||
uiSignKeyUsage,
|
||||
pucSignerCertificate,
|
||||
uiSignerCertificateLen,
|
||||
@@ -143,11 +143,11 @@ int SAF_SM2_DecodeSignedData(
|
||||
void *hAppHandle,
|
||||
unsigned char *pucDerSignedData,
|
||||
unsigned int uiDerSignedDataLen,
|
||||
unsigned int *puiDigestAlgorithm,
|
||||
unsigned char *pucSignerCertificate,
|
||||
unsigned int uiSignerCertificateLen,
|
||||
unsigned int uiDigestAlgorithm,
|
||||
unsigned int *puiSignerCertificateLen,
|
||||
unsigned char *pucData,
|
||||
unsigned int uiDataLen,
|
||||
unsigned int *puiDataLen,
|
||||
unsigned char *pucSign,
|
||||
unsigned int *puiSignLen)
|
||||
{
|
||||
@@ -155,11 +155,11 @@ int SAF_SM2_DecodeSignedData(
|
||||
hAppHandle,
|
||||
pucDerSignedData,
|
||||
uiDerSignedDataLen,
|
||||
puiDigestAlgorithm,
|
||||
pucSignerCertificate,
|
||||
uiSignerCertificateLen,
|
||||
uiDigestAlgorithm,
|
||||
puiSignerCertificateLen,
|
||||
pucData,
|
||||
uiDataLen,
|
||||
puiDataLen,
|
||||
pucSign,
|
||||
puiSignLen);
|
||||
}
|
||||
@@ -191,7 +191,6 @@ int SAF_SM2_DecodeEnvelopedData(
|
||||
void *hAppHandle,
|
||||
unsigned char *pucDecContainerName,
|
||||
unsigned int uiDecContainerNameLen,
|
||||
unsigned int uiDecKeyUsage,
|
||||
unsigned char *pucDerEnvelopedData,
|
||||
unsigned int uiDerEnvelopedDataLen,
|
||||
unsigned char *pucData,
|
||||
@@ -201,7 +200,6 @@ int SAF_SM2_DecodeEnvelopedData(
|
||||
hAppHandle,
|
||||
pucDecContainerName,
|
||||
uiDecContainerNameLen,
|
||||
uiDecKeyUsage,
|
||||
pucDerEnvelopedData,
|
||||
uiDerEnvelopedDataLen,
|
||||
pucData,
|
||||
|
||||
Reference in New Issue
Block a user