mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 08:56:17 +08:00
add gmapi impls
This commit is contained in:
@@ -102,6 +102,10 @@ typedef struct err_state_st {
|
||||
# define ERR_LIB_BFIBE 59
|
||||
# define ERR_LIB_BB1IBE 60
|
||||
# define ERR_LIB_SM9 61
|
||||
# define ERR_LIB_SAF 62
|
||||
# define ERR_LIB_SDF 63
|
||||
# define ERR_LIB_SKF 64
|
||||
# define ERR_LIB_SOF 65
|
||||
|
||||
# define ERR_LIB_USER 128
|
||||
|
||||
@@ -149,6 +153,10 @@ typedef struct err_state_st {
|
||||
# define BFIBEerr(f,r) ERR_PUT_error(ERR_LIB_BFIBE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define BB1IBEerr(f,r) ERR_PUT_error(ERR_LIB_BB1IBE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SM9err(f,r) ERR_PUT_error(ERR_LIB_SM9,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SAFerr(f,r) ERR_PUT_error(ERR_LIB_SAF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SDFerr(f,r) ERR_PUT_error(ERR_LIB_SDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SKFerr(f,r) ERR_PUT_error(ERR_LIB_SKF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SOFerr(f,r) ERR_PUT_error(ERR_LIB_SOF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
|
||||
# define ERR_PACK(l,f,r) ( \
|
||||
(((unsigned int)(l) & 0x0FF) << 24L) | \
|
||||
@@ -205,6 +213,10 @@ typedef struct err_state_st {
|
||||
# define ERR_R_BFIBE_LIB ERR_LIB_BFIBE/* 59 */
|
||||
# define ERR_R_BB1IBE_LIB ERR_LIB_BB1IBE/* 60 */
|
||||
# define ERR_R_SM9_LIB ERR_LIB_SM9/* 61 */
|
||||
# define ERR_R_SAF_LIB ERR_LIB_SAF/* 62 */
|
||||
# define ERR_R_SDF_LIB ERR_LIB_SDF/* 63 */
|
||||
# define ERR_R_SKF_LIB ERR_LIB_SKF/* 64 */
|
||||
# define ERR_R_SOF_LIB ERR_LIB_SOF/* 65 */
|
||||
|
||||
# define ERR_R_NESTED_ASN1_ERROR 58
|
||||
|
||||
|
||||
120
include/openssl/gmsaf.h
Normal file
120
include/openssl/gmsaf.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2015 - 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_GMSAF_H
|
||||
#define HEADER_GMSAF_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/sgd.h>
|
||||
#include <openssl/saf.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
int SAF_PrintNameInfo(FILE *fp, SGD_NAME_INFO *nameInfo);
|
||||
const char *SAF_GetErrorString(int err);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_SAF_strings(void);
|
||||
|
||||
/* Error codes for the SAF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define SAF_F_SAF_BASE64_CREATEBASE64OBJ 100
|
||||
# define SAF_F_SAF_BASE64_DECODE 101
|
||||
# define SAF_F_SAF_BASE64_DECODEFINAL 102
|
||||
# define SAF_F_SAF_BASE64_DECODEUPDATE 103
|
||||
# define SAF_F_SAF_BASE64_ENCODE 104
|
||||
# define SAF_F_SAF_BASE64_ENCODEFINAL 105
|
||||
# define SAF_F_SAF_BASE64_ENCODEUPDATE 106
|
||||
# define SAF_F_SAF_CREATESYMMKEYOBJ 107
|
||||
# define SAF_F_SAF_ECCPUBLICKEYENC 108
|
||||
# define SAF_F_SAF_ECCPUBLICKEYENCBYCERT 109
|
||||
# define SAF_F_SAF_ECCSIGN 110
|
||||
# define SAF_F_SAF_ECCVERIFYSIGN 111
|
||||
# define SAF_F_SAF_ECCVERIFYSIGNBYCERT 112
|
||||
# define SAF_F_SAF_GENECCKEYPAIR 113
|
||||
# define SAF_F_SAF_GENERATEAGREEMENTDATAWITHECC 114
|
||||
# define SAF_F_SAF_GENERATEKEYWITHECC 115
|
||||
# define SAF_F_SAF_GETECCPUBLICKEY 116
|
||||
# define SAF_F_SAF_MACFINAL 117
|
||||
# define SAF_F_SAF_MACUPDATE 118
|
||||
# define SAF_F_SAF_PKCS7_DECODEDIGESTEDDATA 119
|
||||
# define SAF_F_SAF_PKCS7_ENCODEDIGESTEDDATA 120
|
||||
# define SAF_F_SAF_SYMMDECRYPTUPDATE 121
|
||||
# define SAF_F_SAF_SYMMENCRYPTUPDATE 122
|
||||
|
||||
/* Reason codes. */
|
||||
# define SAF_R_BUFFER_TOO_SMALL 100
|
||||
# define SAF_R_CBCMAC_FAILURE 101
|
||||
# define SAF_R_GEN_RANDOM 102
|
||||
# define SAF_R_INT_OVERFLOW 103
|
||||
# define SAF_R_INVALID_ALGOR 104
|
||||
# define SAF_R_INVALID_CONTEXT 105
|
||||
# define SAF_R_INVALID_DIGEST_ALGOR 106
|
||||
# define SAF_R_INVALID_HANDLE 107
|
||||
# define SAF_R_INVALID_INPUT_LENGTH 108
|
||||
# define SAF_R_INVALID_KEY_LENGTH 109
|
||||
# define SAF_R_INVALID_KEY_USAGE 110
|
||||
# define SAF_R_INVALID_LENGTH 111
|
||||
# define SAF_R_MAC_FAILURE 112
|
||||
# define SAF_R_OPERATION_NOT_INITIALIZED 113
|
||||
# define SAF_R_SAF_ERROR 114
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
177
include/openssl/gmsdf.h
Normal file
177
include/openssl/gmsdf.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2015 - 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_GMSDF_H
|
||||
#define HEADER_GMSDF_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/sgd.h>
|
||||
#include <openssl/sdf.h>
|
||||
|
||||
#define SDF_MIN_KEY_INDEX 1 /* defined by GM/T 0018 */
|
||||
#define SDF_MAX_KEY_INDEX 32 /* defined by GmSSL as vendor */
|
||||
#define SDF_MIN_PASSWORD_LENGTH 8 /* defined by GM/T 0018 */
|
||||
#define SDF_MAX_PASSWORD_LENGTH 255 /* defined by GmSSL as vendor */
|
||||
|
||||
#define ECCref_MAX_CIPHER_LEN 255
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int SDF_PrintDeviceInfo(FILE *fp, DEVICEINFO *devInfo);
|
||||
int SDF_PrintRSAPublicKey(FILE *fp, RSArefPublicKey *pk);
|
||||
int SDF_PrintRSAPrivateKey(FILE *fp, RSArefPrivateKey *pk);
|
||||
int SDF_PrintECCPublicKey(FILE *fp, ECCrefPublicKey *pk);
|
||||
int SDF_PrintECCPrivateKey(FILE *fp, ECCrefPrivateKey *pk);
|
||||
int SDF_PrintECCCipher(FILE *fp, ECCCipher *cipher);
|
||||
int SDF_PrintECCSignature(FILE *fp, ECCSignature *sig);
|
||||
const char *SDF_GetErrorString(int err);
|
||||
|
||||
//FIXME: implement this in a standalone file in sdf module
|
||||
int SDF_ImportKey(
|
||||
void *hSessionHandle,
|
||||
unsigned char *pucKey,
|
||||
unsigned int uiKeyLength,
|
||||
void **phKeyHandle);
|
||||
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_SDF_strings(void);
|
||||
|
||||
/* Error codes for the SDF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define SDF_F_SDF_CALCULATEMAC 100
|
||||
# define SDF_F_SDF_CLOSEDEVICE 145
|
||||
# define SDF_F_SDF_CLOSESESSION 101
|
||||
# define SDF_F_SDF_DECODE_EC_SIGNATURE 102
|
||||
# define SDF_F_SDF_DECRYPT 103
|
||||
# define SDF_F_SDF_ENCODE_EC_SIGNATURE 104
|
||||
# define SDF_F_SDF_ENCRYPT 105
|
||||
# define SDF_F_SDF_EXPORTENCPUBLICKEY_ECC 106
|
||||
# define SDF_F_SDF_EXPORTENCPUBLICKEY_RSA 107
|
||||
# define SDF_F_SDF_EXPORTSIGNPUBLICKEY_ECC 108
|
||||
# define SDF_F_SDF_EXPORTSIGNPUBLICKEY_RSA 109
|
||||
# define SDF_F_SDF_EXTERNALDECRYPT_ECC 110
|
||||
# define SDF_F_SDF_EXTERNALENCRYPT_ECC 111
|
||||
# define SDF_F_SDF_EXTERNALPRIVATEKEYOPERATION_RSA 112
|
||||
# define SDF_F_SDF_EXTERNALPUBLICKEYOPERATION_RSA 113
|
||||
# define SDF_F_SDF_EXTERNALSIGN_ECC 114
|
||||
# define SDF_F_SDF_EXTERNALVERIFY_ECC 115
|
||||
# define SDF_F_SDF_GENERATEKEYPAIR_ECC 116
|
||||
# define SDF_F_SDF_GENERATEKEYPAIR_RSA 117
|
||||
# define SDF_F_SDF_GENERATEKEYWITHEPK_ECC 118
|
||||
# define SDF_F_SDF_GENERATEKEYWITHEPK_RSA 119
|
||||
# define SDF_F_SDF_GENERATEKEYWITHIPK_ECC 120
|
||||
# define SDF_F_SDF_GENERATEKEYWITHIPK_RSA 121
|
||||
# define SDF_F_SDF_GENERATERANDOM 122
|
||||
# define SDF_F_SDF_GETDEVICEINFO 123
|
||||
# define SDF_F_SDF_GETPRIVATEKEYACCESSRIGHT 124
|
||||
# define SDF_F_SDF_GET_CIPHER 125
|
||||
# define SDF_F_SDF_GET_DIGEST 126
|
||||
# define SDF_F_SDF_HASHFINAL 127
|
||||
# define SDF_F_SDF_HASHINIT 128
|
||||
# define SDF_F_SDF_HASHUPDATE 129
|
||||
# define SDF_F_SDF_IMPORTKEY 130
|
||||
# define SDF_F_SDF_IMPORTKEYWITHISK_ECC 131
|
||||
# define SDF_F_SDF_IMPORTKEYWITHISK_RSA 132
|
||||
# define SDF_F_SDF_INTERNALDECRYPT_ECC 133
|
||||
# define SDF_F_SDF_INTERNALENCRYPT_ECC 134
|
||||
# define SDF_F_SDF_INTERNALPRIVATEKEYOPERATION_RSA 135
|
||||
# define SDF_F_SDF_INTERNALPUBLICKEYOPERATION_RSA 136
|
||||
# define SDF_F_SDF_INTERNALSIGN_ECC 137
|
||||
# define SDF_F_SDF_INTERNALVERIFY_ECC 138
|
||||
# define SDF_F_SDF_LOAD_EC_PRIVATE_KEY 139
|
||||
# define SDF_F_SDF_LOAD_EC_PUBLIC_KEY 140
|
||||
# define SDF_F_SDF_LOAD_RSA_PRIVATE_KEY 141
|
||||
# define SDF_F_SDF_LOAD_RSA_PUBLIC_KEY 142
|
||||
# define SDF_F_SDF_OPENDEVICE 143
|
||||
# define SDF_F_SDF_OPENSESSION 144
|
||||
# define SDF_F_SDF_RELEASEPRIVATEKEYACCESSRIGHT 146
|
||||
|
||||
/* Reason codes. */
|
||||
# define SDF_R_BUFFER_TOO_SMALL 100
|
||||
# define SDF_R_BUUTER_TOO_SMALL 101
|
||||
# define SDF_R_CBCMAC_FAILURE 102
|
||||
# define SDF_R_CMAC_FAILURE 126
|
||||
# define SDF_R_COMPUTE_SM2_ID_FAILURE 103
|
||||
# define SDF_R_ENGINE_LOAD_KEY_FAILURE 104
|
||||
# define SDF_R_GET_PRIVATE_KEY_FAILED 105
|
||||
# define SDF_R_GET_PUBLIC_KEY_FAILED 106
|
||||
# define SDF_R_INVALID_ALGOR 107
|
||||
# define SDF_R_INVALID_DEVICE_HANDLE 122
|
||||
# define SDF_R_INVALID_EC_CIPHERTEXT 108
|
||||
# define SDF_R_INVALID_EC_PRIVATE_KEY 109
|
||||
# define SDF_R_INVALID_EC_PUBLIC_KEY 110
|
||||
# define SDF_R_INVALID_INPUT_LENGTH 111
|
||||
# define SDF_R_INVALID_KEY_HANDLE 112
|
||||
# define SDF_R_INVALID_KEY_INDEX 123
|
||||
# define SDF_R_INVALID_KEY_LENGTH 113
|
||||
# define SDF_R_INVALID_KEY_USAGE 114
|
||||
# define SDF_R_INVALID_LENGTH 115
|
||||
# define SDF_R_INVALID_OPERATION_STATE 116
|
||||
# define SDF_R_INVALID_PASSWORD_LENGTH 124
|
||||
# define SDF_R_INVALID_SESSION 117
|
||||
# define SDF_R_INVALID_SESSION_HANDLE 125
|
||||
# define SDF_R_KEY_TYPE_NOT_MATCH 118
|
||||
# define SDF_R_LOAD_ENGINE_FAILURE 119
|
||||
# define SDF_R_RANDOM_FAILURE 120
|
||||
# define SDF_R_SDF_SESSION_NO_ENGINE 121
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
187
include/openssl/gmskf.h
Normal file
187
include/openssl/gmskf.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2015 - 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_GMSKF_H
|
||||
#define HEADER_GMSKF_H
|
||||
|
||||
#include <openssl/sgd.h>
|
||||
#include <openssl/skf.h>
|
||||
|
||||
#ifndef SKF_NO_GMSSL
|
||||
#define SKF_NO_PADDING 0
|
||||
#define SKF_PKCS5_PADDING 1
|
||||
#endif
|
||||
|
||||
#ifndef SKF_NO_GMSSL
|
||||
#define DEV_ABSENT_STATE 0x00000000
|
||||
#define DEV_PRESENT_STATE 0x00000001
|
||||
#define DEV_UNKNOW_STATE 0x00000010
|
||||
#endif
|
||||
|
||||
#ifndef SKF_NO_GMSSL
|
||||
#define CONTAINER_TYPE_UNDEF 0
|
||||
#define CONTAINER_TYPE_RSA 1
|
||||
#define CONTAINER_TYPE_ECC 2
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
//FIXME: change name
|
||||
const char *SKF_get_alg_name(ULONG ulAlgID);
|
||||
|
||||
int SKF_PrintDeviceInfo(FILE *fp, DEVINFO *devInfo);
|
||||
int SKF_PrintRSAPublicKey(FILE *fp, RSAPUBLICKEYBLOB *pk);
|
||||
int SKF_PrintRSAPrivateKey(FILE *fp, RSAPRIVATEKEYBLOB *pk);
|
||||
int SKF_PrintECCPublicKey(FILE *fp, ECCPUBLICKEYBLOB *pk);
|
||||
int SKF_PrintECCPrivateKey(FILE *fp, ECCPRIVATEKEYBLOB *pk);
|
||||
int SKF_PrintECCCipher(FILE *fp, ECCCIPHERBLOB *cipher);
|
||||
int SKF_PrintECCSignature(FILE *fp, ECCSIGNATUREBLOB *sig);
|
||||
const char *SKF_GetErrorString(ULONG error);
|
||||
|
||||
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_SKF_strings(void);
|
||||
|
||||
/* Error codes for the SKF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define SKF_F_SKF_CLOSEHANDLE 100
|
||||
# define SKF_F_SKF_DECRYPT 101
|
||||
# define SKF_F_SKF_DECRYPTFINAL 102
|
||||
# define SKF_F_SKF_DECRYPTINIT 103
|
||||
# define SKF_F_SKF_DECRYPTUPDATE 104
|
||||
# define SKF_F_SKF_DIGEST 105
|
||||
# define SKF_F_SKF_DIGESTFINAL 106
|
||||
# define SKF_F_SKF_DIGESTINIT 107
|
||||
# define SKF_F_SKF_DIGESTUPDATE 108
|
||||
# define SKF_F_SKF_ENCRYPT 109
|
||||
# define SKF_F_SKF_ENCRYPTFINAL 110
|
||||
# define SKF_F_SKF_ENCRYPTINIT 111
|
||||
# define SKF_F_SKF_ENCRYPTUPDATE 112
|
||||
# define SKF_F_SKF_EXTECCDECRYPT 113
|
||||
# define SKF_F_SKF_EXTECCENCRYPT 114
|
||||
# define SKF_F_SKF_EXTECCSIGN 115
|
||||
# define SKF_F_SKF_EXTECCVERIFY 116
|
||||
# define SKF_F_SKF_EXTRSAPRIKEYOPERATION 117
|
||||
# define SKF_F_SKF_EXTRSAPUBKEYOPERATION 118
|
||||
# define SKF_F_SKF_GENEXTECCKEYPAIR 119
|
||||
# define SKF_F_SKF_GENEXTRSAKEY 120
|
||||
# define SKF_F_SKF_GENRANDOM 121
|
||||
# define SKF_F_SKF_GETDEVINFO 122
|
||||
# define SKF_F_SKF_GETDEVSTATE 123
|
||||
# define SKF_F_SKF_HANDLE_GET_CBCMAC_CTX 124
|
||||
# define SKF_F_SKF_HANDLE_GET_CIPHER 125
|
||||
# define SKF_F_SKF_HANDLE_GET_CIPHER_CTX 126
|
||||
# define SKF_F_SKF_HANDLE_GET_KEY 127
|
||||
# define SKF_F_SKF_HANDLE_GET_MD_CTX 128
|
||||
# define SKF_F_SKF_MAC 129
|
||||
# define SKF_F_SKF_MACFINAL 130
|
||||
# define SKF_F_SKF_MACINIT 131
|
||||
# define SKF_F_SKF_MACUPDATE 132
|
||||
# define SKF_F_SKF_SETSYMMKEY 133
|
||||
|
||||
/* Reason codes. */
|
||||
# define SKF_R_BUFFER_TOO_SMALL 100
|
||||
# define SKF_R_CTX_NOT_CREATED 101
|
||||
# define SKF_R_DECRYPT_FAILED 102
|
||||
# define SKF_R_ENCODE_CIPHERTEXT_FAILED 103
|
||||
# define SKF_R_ENCODE_FAILED 104
|
||||
# define SKF_R_ENCODE_SIGNATURE_FAILED 105
|
||||
# define SKF_R_ENCRYPT_FAILED 106
|
||||
# define SKF_R_FAIL 107
|
||||
# define SKF_R_GEN_RSA_FAILED 108
|
||||
# define SKF_R_GET_PRIVATE_KEY_FAILED 109
|
||||
# define SKF_R_GET_PUBLIC_KEY_FAILED 110
|
||||
# define SKF_R_INVALID_ALGID 111
|
||||
# define SKF_R_INVALID_ALGOR 112
|
||||
# define SKF_R_INVALID_ARGUMENTS 113
|
||||
# define SKF_R_INVALID_BLOB 114
|
||||
# define SKF_R_INVALID_CIPHERTEXT 115
|
||||
# define SKF_R_INVALID_CIPHERTEXT_LENGTH 116
|
||||
# define SKF_R_INVALID_CIPHER_CTX_HANDLE 117
|
||||
# define SKF_R_INVALID_DIGEST_LENGTH 118
|
||||
# define SKF_R_INVALID_ECC_PRIVATE_KEY 119
|
||||
# define SKF_R_INVALID_ECC_PUBLIC_KEY 120
|
||||
# define SKF_R_INVALID_EC_PRIVATE_KEY 121
|
||||
# define SKF_R_INVALID_EC_PUBLIC_KEY 122
|
||||
# define SKF_R_INVALID_FEED_BIT_LENGTH 123
|
||||
# define SKF_R_INVALID_HANDLE 124
|
||||
# define SKF_R_INVALID_HANDLE_ALGOR 125
|
||||
# define SKF_R_INVALID_HANDLE_MAGIC 126
|
||||
# define SKF_R_INVALID_HANDLE_TYPE 127
|
||||
# define SKF_R_INVALID_HASH_HANDLE 128
|
||||
# define SKF_R_INVALID_ID_LENGTH 129
|
||||
# define SKF_R_INVALID_INPUT_LENGTH 130
|
||||
# define SKF_R_INVALID_IV_LENGTH 131
|
||||
# define SKF_R_INVALID_KEY_HANDLE 132
|
||||
# define SKF_R_INVALID_KEY_LENGTH 133
|
||||
# define SKF_R_INVALID_MAC_HANDLE 134
|
||||
# define SKF_R_INVALID_PLAINTEXT_LENGTH 135
|
||||
# define SKF_R_INVALID_RANDOM_LENGTH 136
|
||||
# define SKF_R_INVALID_RSA_PUBLIC_KEY 137
|
||||
# define SKF_R_INVALID_SIGNATURE 138
|
||||
# define SKF_R_MALLOC_FAILED 139
|
||||
# define SKF_R_NO_PUBLIC_KEY 140
|
||||
# define SKF_R_NULL_ARGUMENT 141
|
||||
# define SKF_R_SIGN_FAILED 142
|
||||
# define SKF_R_VERIFY_NOT_PASS 143
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
143
include/openssl/gmsof.h
Normal file
143
include/openssl/gmsof.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/* ====================================================================
|
||||
* 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_GMSOF_H
|
||||
#define HEADER_GMSOF_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/sgd.h>
|
||||
#include <openssl/sof.h>
|
||||
|
||||
/* SOF_SignMessage Flag */
|
||||
#define SOF_FLAG_SIG_WITH_MESSAGE 0
|
||||
#define SOF_FLAG_SIG_WITHOUT_MESSAGE 1
|
||||
|
||||
/* SOF_GetInfoFromSignedMessage Type */
|
||||
#define SOF_SIGNED_MESSAGE_MESSAGE 1
|
||||
#define SOF_SIGNED_MESSAGE_CERT 2
|
||||
#define SOF_SIGNED_MESSAGE_SIGNATURE 3
|
||||
|
||||
/* SOF_GetXMLSignatureInfo */
|
||||
#define SOF_XML_TYPE_MESSAGE 1
|
||||
#define SOF_XML_TYPE_DIGEST 2
|
||||
#define SOF_XML_TYPE_SIGNATURE 3
|
||||
#define SOF_XML_TYPE_CERTIFICATE 4
|
||||
#define SOF_XML_TYPE_DIGEST_ALGOR 5
|
||||
#define SOF_XML_TYPE_SIGN_ALGOR 6
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_SOF_strings(void);
|
||||
|
||||
/* Error codes for the SOF functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define SOF_F_SOF_CHANGEPASSWD 100
|
||||
# define SOF_F_SOF_CREATETIMESTAMPREQUEST 101
|
||||
# define SOF_F_SOF_CREATETIMESTAMPRESPONSE 102
|
||||
# define SOF_F_SOF_DECRYPTDATA 103
|
||||
# define SOF_F_SOF_DECRYPTFILE 104
|
||||
# define SOF_F_SOF_DELCERTTRUSTLIST 105
|
||||
# define SOF_F_SOF_ENCRYPTDATA 106
|
||||
# define SOF_F_SOF_ENCRYPTFILE 107
|
||||
# define SOF_F_SOF_EXPORTEXCHANGEUSERCERT 108
|
||||
# define SOF_F_SOF_EXPORTUSERCERT 109
|
||||
# define SOF_F_SOF_GENRANDOM 110
|
||||
# define SOF_F_SOF_GETCERTINFO 111
|
||||
# define SOF_F_SOF_GETCERTINFOBYOID 112
|
||||
# define SOF_F_SOF_GETCERTTRUSTLIST 113
|
||||
# define SOF_F_SOF_GETCERTTRUSTLISTALTNAMES 114
|
||||
# define SOF_F_SOF_GETDEVICEINFO 115
|
||||
# define SOF_F_SOF_GETENCRYPTMETHOD 116
|
||||
# define SOF_F_SOF_GETINFOFROMSIGNEDMESSAGE 117
|
||||
# define SOF_F_SOF_GETLASTERROR 118
|
||||
# define SOF_F_SOF_GETPINRETRYCOUNT 119
|
||||
# define SOF_F_SOF_GETSERVERCERTIFICATE 120
|
||||
# define SOF_F_SOF_GETSIGNMETHOD 121
|
||||
# define SOF_F_SOF_GETTIMESTAMPINFO 122
|
||||
# define SOF_F_SOF_GETUSERLIST 123
|
||||
# define SOF_F_SOF_GETVERSION 124
|
||||
# define SOF_F_SOF_GETXMLSIGNATUREINFO 125
|
||||
# define SOF_F_SOF_INITCERTAPPPOLICY 126
|
||||
# define SOF_F_SOF_LOGIN 127
|
||||
# define SOF_F_SOF_SETCERTTRUSTLIST 128
|
||||
# define SOF_F_SOF_SETENCRYPTMETHOD 129
|
||||
# define SOF_F_SOF_SETSIGNMETHOD 130
|
||||
# define SOF_F_SOF_SIGNDATA 131
|
||||
# define SOF_F_SOF_SIGNDATAXML 132
|
||||
# define SOF_F_SOF_SIGNFILE 133
|
||||
# define SOF_F_SOF_SIGNMESSAGE 134
|
||||
# define SOF_F_SOF_SIGNMESSAGEDETACH 135
|
||||
# define SOF_F_SOF_VALIDATECERT 136
|
||||
# define SOF_F_SOF_VERIFYSIGNEDDATA 137
|
||||
# define SOF_F_SOF_VERIFYSIGNEDDATAXML 138
|
||||
# define SOF_F_SOF_VERIFYSIGNEDFILE 139
|
||||
# define SOF_F_SOF_VERIFYSIGNEDMESSAGE 140
|
||||
# define SOF_F_SOF_VERIFYSIGNEDMESSAGEDETACH 141
|
||||
# define SOF_F_SOF_VERIFYTIMESTAMP 142
|
||||
|
||||
/* Reason codes. */
|
||||
# define SOF_R_NOT_IMPLEMENTED 100
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user