mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 17:06:25 +08:00
updates of
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/gmsof.h>
|
||||
#include "../../e_os.h"
|
||||
|
||||
static ERR_STRING_DATA sof_errstr[] = {
|
||||
{ SOR_OK, "Success" },
|
||||
{ SOR_UnknownErr, "Unknown error" },
|
||||
{ SOF_FileErr, "File error" },
|
||||
{ SOR_ProviderTypeErr, "Provider type error" },
|
||||
{ SOR_LoadProviderErr, "Load provider error" },
|
||||
};
|
||||
|
||||
char *SOF_GetErrorString(int err)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < OSSL_NELEM(sof_errstr); i++) {
|
||||
if (err == sof_errstr[i].error) {
|
||||
return sof_errstr[i].string;
|
||||
}
|
||||
}
|
||||
return "(undef)";
|
||||
}
|
||||
|
||||
@@ -49,53 +49,55 @@
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/gmsof.h>
|
||||
#include "../../e_os.h"
|
||||
|
||||
static long sof_sign_method = SGD_SM2;
|
||||
static long sof_enc_method = SGD_SM4_CBC;
|
||||
static long sof_last_error = SOR_OK;
|
||||
|
||||
BSTR sof_version = "1.0";
|
||||
long sof_sign_method = SGD_SM2;
|
||||
long sof_enc_method = SGD_SM4_CBC;
|
||||
|
||||
BSTR SOF_GetVersion(void)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GETVERSION, SOF_R_NOT_IMPLEMENTED);
|
||||
return NULL;
|
||||
return OpenSSL_version(0);
|
||||
}
|
||||
|
||||
long SOF_SetSignMethod(long SignMethod)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_SETSIGNMETHOD, SOF_R_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
sof_sign_method = SignMethod;
|
||||
return SOR_OK;
|
||||
}
|
||||
|
||||
long SOF_GetSignMethod(void)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GETSIGNMETHOD, SOF_R_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
return sof_sign_method;
|
||||
}
|
||||
|
||||
long SOF_SetEncryptMethod(long EncryptMethod)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_SETENCRYPTMETHOD, SOF_R_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
sof_enc_method = EncryptMethod;
|
||||
return SOR_OK;
|
||||
}
|
||||
|
||||
long SOF_GetEncryptMethod(void)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GETENCRYPTMETHOD, SOF_R_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
return sof_enc_method;
|
||||
}
|
||||
|
||||
/* list installed client's certificates */
|
||||
BSTR SOF_GetUserList(void)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GETUSERLIST, SOF_R_NOT_IMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* we need an reference to engine */
|
||||
BSTR SOF_ExportUserCert(BSTR ContainerName)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_EXPORTUSERCERT, SOF_R_NOT_IMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* LOGIN CMD ? */
|
||||
BOOL SOF_Login(BSTR ContainerName, BSTR PassWd)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_LOGIN, SOF_R_NOT_IMPLEMENTED);
|
||||
@@ -105,7 +107,7 @@ BOOL SOF_Login(BSTR ContainerName, BSTR PassWd)
|
||||
long SOF_GetPinRetryCount(BSTR ContainerName)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GETPINRETRYCOUNT, SOF_R_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
return SOR_NotSupportYetErr;
|
||||
}
|
||||
|
||||
BOOL SOF_ChangePassWd(BSTR ContainerName, BSTR OldPassWd, BSTR NewPassWd)
|
||||
@@ -114,12 +116,13 @@ BOOL SOF_ChangePassWd(BSTR ContainerName, BSTR OldPassWd, BSTR NewPassWd)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BSTR SOF_ExportExChangeUserCert(BSTR ContainerName)
|
||||
BSTR SOF_ExportExchangeUserCert(BSTR ContainerName)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_EXPORTEXCHANGEUSERCERT, SOF_R_NOT_IMPLEMENTED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* `type` defined as SGD_CERT_XXX, SGD_EXT_XXX in sgd.h */
|
||||
BSTR SOF_GetCertInfo(BSTR Base64EncodeCert, short Type)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GETCERTINFO, SOF_R_NOT_IMPLEMENTED);
|
||||
@@ -144,6 +147,7 @@ long SOF_ValidateCert(BSTR Base64EncodeCert)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* PKCS #7 or CMS ? */
|
||||
BSTR SOF_SignData(BSTR ContainerName, BSTR InData)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_SIGNDATA, SOF_R_NOT_IMPLEMENTED);
|
||||
@@ -228,6 +232,7 @@ BSTR SOF_GetXMLSignatureInfo(BSTR XMLSignedData, short Type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* return base64 encoded data */
|
||||
BSTR SOF_GenRandom(short RandomLen)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GENRANDOM, SOF_R_NOT_IMPLEMENTED);
|
||||
@@ -236,8 +241,7 @@ BSTR SOF_GenRandom(short RandomLen)
|
||||
|
||||
long SOF_GetLastError(void)
|
||||
{
|
||||
SOFerr(SOF_F_SOF_GETLASTERROR, SOF_R_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
return sof_last_error;
|
||||
}
|
||||
|
||||
long SOF_SetCertTrustList(BSTR CTLAltName, BSTR CTLContent, short CTLContentLen)
|
||||
@@ -312,3 +316,21 @@ BSTR SOF_GetTimeStampInfo(BSTR tsResponseData, short type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ERR_STRING_DATA sof_errstr[] = {
|
||||
{ SOR_OK, "Success" },
|
||||
{ SOR_UnknownErr, "Unknown error" },
|
||||
{ SOR_FileErr, "File error" },
|
||||
{ SOR_ProviderTypeErr, "Provider type error" },
|
||||
{ SOR_LoadProviderErr, "Load provider error" },
|
||||
};
|
||||
|
||||
char *SOF_GetErrorString(int err)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < OSSL_NELEM(sof_errstr); i++) {
|
||||
if (err == sof_errstr[i].error) {
|
||||
return sof_errstr[i].string;
|
||||
}
|
||||
}
|
||||
return "(undef)";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user