first step of v2 final release

This commit is contained in:
Zhi Guan
2017-11-05 21:00:36 +08:00
parent 480b9e8d88
commit 27bde477a5
395 changed files with 26341 additions and 31364 deletions

View File

@@ -1,5 +1,5 @@
/* ====================================================================
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
* Copyright (c) 2014 - 2017 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
@@ -47,11 +47,11 @@
* ====================================================================
*/
#ifndef HEADER_SDF_METH_H
#define HEADER_SDF_METH_H
#ifndef HEADER_SDF_INT_H
#define HEADER_SDF_INT_H
#include <openssl/sgd.h>
#include <openssl/sdf.h>
#include <openssl/gmsdf.h>
#include "internal/dso.h"
@@ -359,13 +359,13 @@ typedef int (*SDF_HashFinal_FuncPtr)(void *hSessionHandle,
unsigned char *pucHash,
unsigned int *puiHashLength);
typedef int (*SDF_CreateFile_FuncPtr)(
typedef int (*SDF_CreateObject_FuncPtr)(
void *hSessionHandle,
unsigned char *pucFileName,
unsigned int uiNameLen,
unsigned int uiFileSize);
typedef int (*SDF_ReadFile_FuncPtr)(
typedef int (*SDF_ReadObject_FuncPtr)(
void *hSessionHandle,
unsigned char *pucFileName,
unsigned int uiNameLen,
@@ -373,7 +373,7 @@ typedef int (*SDF_ReadFile_FuncPtr)(
unsigned int *puiReadLength,
unsigned char *pucBuffer);
typedef int (*SDF_WriteFile_FuncPtr)(
typedef int (*SDF_WriteObject_FuncPtr)(
void *hSessionHandle,
unsigned char *pucFileName,
unsigned int uiNameLen,
@@ -381,13 +381,14 @@ typedef int (*SDF_WriteFile_FuncPtr)(
unsigned int uiWriteLength,
unsigned char *pucBuffer);
typedef int (*SDF_DeleteFile_FuncPtr)(
typedef int (*SDF_DeleteObject_FuncPtr)(
void *hSessionHandle,
unsigned char *pucFileName,
unsigned int uiNameLen);
typedef struct sdf_method_st {
char *name;
DSO *dso;
SDF_OpenDevice_FuncPtr OpenDevice;
SDF_CloseDevice_FuncPtr CloseDevice;
SDF_OpenSession_FuncPtr OpenSession;
@@ -432,12 +433,32 @@ typedef struct sdf_method_st {
SDF_HashInit_FuncPtr HashInit;
SDF_HashUpdate_FuncPtr HashUpdate;
SDF_HashFinal_FuncPtr HashFinal;
SDF_CreateFile_FuncPtr CreateFileObject;
SDF_ReadFile_FuncPtr ReadFileObject;
SDF_WriteFile_FuncPtr WriteFileObject;
SDF_DeleteFile_FuncPtr DeleteFileObject;
SDF_CreateObject_FuncPtr CreateObject;
SDF_ReadObject_FuncPtr ReadObject;
SDF_WriteObject_FuncPtr WriteObject;
SDF_DeleteObject_FuncPtr DeleteObject;
} SDF_METHOD;
SDF_METHOD *SDF_METHOD_load_library(const char *so_path);
void SDF_METHOD_free(SDF_METHOD *meth);
typedef struct sdf_vendor_st {
char *name;
unsigned int (*get_cipher_algor)(unsigned int vendor_id);
unsigned int (*get_digest_algor)(unsigned int vendor_id);
unsigned int (*get_pkey_algor)(unsigned int vendor_id);
unsigned int (*get_cipher_cap)(unsigned int vendor_cap);
unsigned int (*get_digest_cap)(unsigned int vendor_cap);
unsigned int (*get_pkey_cap)(unsigned int vendor_cap);
int (*encode_ecccipher)(const ECCCipher *a, void *buf);
int (*decode_ecccipher)(ECCCipher *a, const void *buf);
unsigned long (*get_error_reason)(int err);
} SDF_VENDOR;
typedef struct {
int err;
unsigned long reason;
} SDF_ERR_REASON;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ typedef struct aes_key_st AES_KEY;
const char *AES_options(void);
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
int AES_set_encrypt_key(const unsigned char *userKey, const unsigned int bits,
AES_KEY *key);
int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
AES_KEY *key);

View File

@@ -49,9 +49,10 @@
#ifndef HEADER_BASE58_H
#define HEADER_BASE58_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_BASE58
#include <string.h>
#ifdef __cplusplus
extern "C" {
@@ -77,7 +78,8 @@ int ERR_load_BASE58_strings(void);
/* Reason codes. */
# define BASE58_R_HIGHBIT_SET_ON_INVALID_DIGIT 100
# ifdef __cplusplus
# ifdef __cplusplus
}
# endif
# endif
#endif

View File

@@ -56,6 +56,9 @@
#ifndef HEADER_BB1IBE_H
#define HEADER_BB1IBE_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_BB1IBE
#include <string.h>
#include <openssl/bn.h>
#include <openssl/ec.h>
@@ -142,3 +145,4 @@ int ERR_load_BB1IBE_strings(void);
}
# endif
#endif
#endif

View File

@@ -56,6 +56,9 @@
#ifndef HEADER_BFIBE_H
#define HEADER_BFIBE_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_BFIBE
#include <string.h>
#include <openssl/bn.h>
#include <openssl/ec.h>
@@ -140,3 +143,4 @@ int ERR_load_BFIBE_strings(void);
}
# endif
#endif
#endif

View File

@@ -450,11 +450,22 @@ int BIO_read_filename(BIO *b, const char *name);
/* defined in evp.h */
/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */
# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
# define BIO_set_mem_eof_return(b,v) \
# ifndef OPENSSL_NO_MACRO
# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp)
# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm)
# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp)
# define BIO_set_mem_eof_return(b,v) \
BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL)
# else
long BIO_get_mem_data(BIO *b, char **pp);
long BIO_set_mem_buf(BIO *b, BUF_MEM *bm, int c);
long BIO_get_mem_ptr(BIO *b, BUF_MEM **pp);
long BIO_set_mem_eof_return(BIO *b, int v)
BIO *BIO_new_mem_buf(const void *buf, int len);
# endif
/* For the BIO_f_buffer() type */
# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL)

View File

@@ -566,12 +566,14 @@ int ERR_load_BN_strings(void);
/* Reason codes. */
# define BN_R_ARG2_LT_ARG3 100
# define BN_R_BAD_ENCODING 123
# define BN_R_BAD_RECIPROCAL 101
# define BN_R_BIGNUM_TOO_LONG 114
# define BN_R_BITS_TOO_SMALL 118
# define BN_R_BUFFER_TOO_SMALL 120
# define BN_R_CALLED_WITH_EVEN_MODULUS 102
# define BN_R_DIV_BY_ZERO 103
# define BN_R_ENCODE_ERROR 124
# define BN_R_ENCODING_ERROR 104
# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
# define BN_R_INPUT_NOT_REDUCED 110
@@ -580,6 +582,7 @@ int ERR_load_BN_strings(void);
# define BN_R_INVALID_SHIFT 119
# define BN_R_INVALID_SOLINAS 121
# define BN_R_INVALID_SOLINAS_PARAMETERS 122
# define BN_R_NEGATIVE_NUMBER 125
# define BN_R_NOT_A_SQUARE 111
# define BN_R_NOT_INITIALIZED 107
# define BN_R_NO_INVERSE 108

View File

@@ -461,6 +461,7 @@ int ERR_load_CMS_strings(void);
# define CMS_R_NOT_KEY_TRANSPORT 124
# define CMS_R_NOT_PWRI 177
# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125
# define CMS_R_NO_AVAILABLE_CIPHER 161
# define CMS_R_NO_CIPHER 126
# define CMS_R_NO_CONTENT 127
# define CMS_R_NO_CONTENT_TYPE 173

View File

@@ -54,6 +54,9 @@
#ifndef HEADER_CPK_H
#define HEADER_CPK_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_CPK
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/ossl_typ.h>
@@ -126,8 +129,7 @@ int ERR_load_CPK_strings(void);
# define CPK_F_CPK_PUBLIC_PARAMS_COMPUTE_SHARE_KEY 105
# define CPK_F_CPK_PUBLIC_PARAMS_EXTRACT_PUBLIC_KEY 106
# define CPK_F_CPK_PUBLIC_PARAMS_VALIDATE_PRIVATE_KEY 107
# define CPK_F_X509_ALGOR_GET1_DSA 108
# define CPK_F_X509_ALGOR_GET1_EC_KEY 109
# define CPK_F_X509_ALGOR_GET1_EC_KEY 108
/* Reason codes. */
# define CPK_R_BAD_ARGUMENT 100
@@ -136,7 +138,8 @@ int ERR_load_CPK_strings(void);
# define CPK_R_INVALID_MAP_ALGOR 103
# define CPK_R_INVALID_PKEY_TYPE 104
# ifdef __cplusplus
# ifdef __cplusplus
}
# endif
# endif
#endif

View File

@@ -166,6 +166,7 @@ const char *OpenSSL_version(int type);
# define OPENSSL_PLATFORM 3
# define OPENSSL_DIR 4
# define OPENSSL_ENGINES_DIR 5
char *GmSSL_version(void);
int OPENSSL_issetugid(void);
@@ -367,6 +368,8 @@ int CRYPTO_memcmp(const volatile void * volatile in_a,
# define OPENSSL_INIT_ENGINE_CAPI 0x00002000L
# define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L
# define OPENSSL_INIT_ENGINE_AFALG 0x00008000L
# define OPENSSL_INIT_ENGINE_SKF 0x00020000L
# define OPENSSL_INIT_ENGINE_SDF 0x00040000L
/* OPENSSL_INIT flag 0x00010000 reserved for internal use */
/* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */
/* Max OPENSSL_INIT flag value is 0x80000000 */
@@ -374,6 +377,7 @@ int CRYPTO_memcmp(const volatile void * volatile in_a,
/* openssl and dasync not counted as builtin */
# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \
(OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \
| OPENSSL_INIT_ENGINE_SKF | OPENSSL_INIT_ENGINE_SDF \
| OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \
OPENSSL_INIT_ENGINE_PADLOCK)

92
include/openssl/digest.h Normal file
View File

@@ -0,0 +1,92 @@
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 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 acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS 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 AUTHOR OR 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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.] */
#ifndef OPENSSL_HEADER_DIGEST_H
#define OPENSSL_HEADER_DIGEST_H
#include <openssl/base.h>
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__cplusplus)
} /* extern C */
#if !defined(BORINGSSL_NO_CXX)
extern "C++" {
namespace bssl {
BORINGSSL_MAKE_DELETER(EVP_MD_CTX, EVP_MD_CTX_destroy)
using ScopedEVP_MD_CTX =
internal::StackAllocated<EVP_MD_CTX, int, EVP_MD_CTX_init,
EVP_MD_CTX_cleanup>;
} // namespace bssl
} // extern C++
#endif
#endif
#define DIGEST_R_INPUT_NOT_INITIALIZED 100
#define DIGEST_R_DECODE_ERROR 101
#define DIGEST_R_UNKNOWN_HASH 102
#endif /* OPENSSL_HEADER_DIGEST_H */

View File

@@ -1282,66 +1282,81 @@ void EC_KEY_METHOD_get_verify(EC_KEY_METHOD *meth,
# endif
# endif
# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
// 把两者顺序调换一下
# ifdef OPENSSL_NO_MACRO
int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid);
int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc);
int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx, int co_mode);
int EVP_PKEY_CTX_get_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx);
int EVP_PKEY_CTX_set_ecdh_kdf_type(EVP_PKEY_CTX *ctx, int kdf);
int EVP_PKEY_CTX_get_ecdh_kdf_type(EVP_PKEY_CTX *ctx);
int EVP_PKEY_CTX_set_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **pmd);
int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int len);
int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int *plen);
int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *der, int len);
int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **pder);
# else
# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)
# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \
# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \
EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL)
# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \
# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL)
# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \
# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL)
# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \
# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL)
# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \
# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL)
# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \
# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md)
# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \
# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd)
# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \
# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL)
# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \
# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen)
# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \
# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p)
# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \
# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p)
# endif /* OPENSSL_NO_MACRO */
# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1)
# define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2)
@@ -1369,313 +1384,282 @@ int ERR_load_EC_strings(void);
/* Error codes for the EC functions. */
/* Function codes. */
# define EC_F_BN_TO_FELEM 224
# define EC_F_D2I_ECIESPARAMETERS 270
# define EC_F_D2I_ECPARAMETERS 144
# define EC_F_D2I_ECPKPARAMETERS 145
# define EC_F_D2I_ECPRIVATEKEY 146
# define EC_F_D2I_SM2_CIPHERTEXT_VALUE 280
# define EC_F_DO_EC_KEY_PRINT 221
# define EC_F_ECDH_CMS_DECRYPT 238
# define EC_F_ECDH_CMS_SET_SHARED_INFO 239
# define EC_F_ECDH_COMPUTE_KEY 246
# define EC_F_ECDH_SIMPLE_COMPUTE_KEY 257
# define EC_F_ECDSA_DO_SIGN_EX 251
# define EC_F_ECDSA_DO_VERIFY 252
# define EC_F_ECDSA_SIGN_EX 254
# define EC_F_ECDSA_SIGN_SETUP 248
# define EC_F_ECDSA_SIG_NEW 265
# define EC_F_ECDSA_VERIFY 253
# define EC_F_ECIES_DECRYPT 271
# define EC_F_ECIES_DO_DECRYPT 272
# define EC_F_ECIES_DO_ENCRYPT 273
# define EC_F_ECIES_ENCRYPT 274
# define EC_F_ECIES_PARAMS_GET_ENC 275
# define EC_F_ECIES_PARAMS_GET_KDF 276
# define EC_F_ECIES_PARAMS_GET_MAC 277
# define EC_F_ECIES_PARAMS_INIT_WITH_RECOMMENDED 278
# define EC_F_ECIES_PARAMS_INIT_WITH_TYPE 320
# define EC_F_ECKEY_PARAM2TYPE 223
# define EC_F_ECKEY_PARAM_DECODE 212
# define EC_F_ECKEY_PRIV_DECODE 213
# define EC_F_ECKEY_PRIV_ENCODE 214
# define EC_F_ECKEY_PUB_DECODE 215
# define EC_F_ECKEY_PUB_ENCODE 216
# define EC_F_ECKEY_TYPE2PARAM 220
# define EC_F_ECPARAMETERS_PRINT 147
# define EC_F_ECPARAMETERS_PRINT_FP 148
# define EC_F_ECPKPARAMETERS_PRINT 149
# define EC_F_ECPKPARAMETERS_PRINT_FP 150
# define EC_F_ECP_NISTZ256_GET_AFFINE 240
# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243
# define EC_F_ECP_NISTZ256_POINTS_MUL 241
# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244
# define EC_F_ECP_NISTZ256_WINDOWED_MUL 242
# define EC_F_ECX_KEY_OP 266
# define EC_F_ECX_PRIV_ENCODE 267
# define EC_F_ECX_PUB_ENCODE 268
# define EC_F_EC_ASN1_GROUP2CURVE 153
# define EC_F_EC_ASN1_GROUP2FIELDID 154
# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208
# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159
# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195
# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160
# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161
# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162
# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163
# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164
# define EC_F_EC_GFP_MONT_FIELD_DECODE 133
# define EC_F_EC_GFP_MONT_FIELD_ENCODE 134
# define EC_F_EC_GFP_MONT_FIELD_MUL 131
# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209
# define EC_F_EC_GFP_MONT_FIELD_SQR 132
# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189
# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225
# define EC_F_EC_GFP_NISTP224_POINTS_MUL 228
# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226
# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230
# define EC_F_EC_GFP_NISTP256_POINTS_MUL 231
# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232
# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233
# define EC_F_EC_GFP_NISTP521_POINTS_MUL 234
# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235
# define EC_F_EC_GFP_NIST_FIELD_MUL 200
# define EC_F_EC_GFP_NIST_FIELD_SQR 201
# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
# define EC_F_EC_GFP_SIMPLE_OCT2POINT 103
# define EC_F_EC_GFP_SIMPLE_POINT2OCT 104
# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137
# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167
# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168
# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169
# define EC_F_EC_GROUP_CHECK 170
# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171
# define EC_F_EC_GROUP_COPY 106
# define EC_F_EC_GROUP_GENERATE_TYPE1CURVE 307
# define EC_F_EC_GROUP_GET_CURVE_GF2M 172
# define EC_F_EC_GROUP_GET_CURVE_GFP 130
# define EC_F_EC_GROUP_GET_DEGREE 173
# define EC_F_EC_GROUP_GET_ECPARAMETERS 261
# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 262
# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193
# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ETA 308
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ZETA 309
# define EC_F_EC_GROUP_IS_TYPE1CURVE 310
# define EC_F_EC_GROUP_NEW 108
# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174
# define EC_F_EC_GROUP_NEW_FROM_DATA 175
# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263
# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264
# define EC_F_EC_GROUP_NEW_TYPE1CURVE 311
# define EC_F_EC_GROUP_SET_CURVE_GF2M 176
# define EC_F_EC_GROUP_SET_CURVE_GFP 109
# define EC_F_EC_GROUP_SET_GENERATOR 111
# define EC_F_EC_KEY_CHECK_KEY 177
# define EC_F_EC_KEY_COPY 178
# define EC_F_EC_KEY_GENERATE_KEY 179
# define EC_F_EC_KEY_NEW 182
# define EC_F_EC_KEY_NEW_METHOD 245
# define EC_F_EC_KEY_OCT2PRIV 255
# define EC_F_EC_KEY_PRINT 180
# define EC_F_EC_KEY_PRINT_FP 181
# define EC_F_EC_KEY_PRIV2OCT 256
# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229
# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 258
# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 259
# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 260
# define EC_F_EC_POINTS_MAKE_AFFINE 136
# define EC_F_EC_POINT_ADD 112
# define EC_F_EC_POINT_CMP 113
# define EC_F_EC_POINT_CMP_FPPOINT 312
# define EC_F_EC_POINT_COPY 114
# define EC_F_EC_POINT_DBL 115
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116
# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117
# define EC_F_EC_POINT_HASH2POINT 313
# define EC_F_EC_POINT_INVERT 210
# define EC_F_EC_POINT_IS_AT_INFINITY 118
# define EC_F_EC_POINT_IS_ON_CURVE 119
# define EC_F_EC_POINT_MAKE_AFFINE 120
# define EC_F_EC_POINT_NEW 121
# define EC_F_EC_POINT_OCT2POINT 122
# define EC_F_EC_POINT_POINT2OCT 123
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125
# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126
# define EC_F_EC_POINT_SET_TO_INFINITY 127
# define EC_F_EC_PRE_COMP_NEW 196
# define EC_F_EC_TYPE1CURVE_TATE 314
# define EC_F_EC_WNAF_MUL 187
# define EC_F_EC_WNAF_PRECOMPUTE_MULT 188
# define EC_F_I2D_ECIESPARAMETERS 279
# define EC_F_I2D_ECPARAMETERS 190
# define EC_F_I2D_ECPKPARAMETERS 191
# define EC_F_I2D_ECPRIVATEKEY 192
# define EC_F_I2D_SM2_CIPHERTEXT_VALUE 281
# define EC_F_I2O_ECPUBLICKEY 151
# define EC_F_NISTP224_PRE_COMP_NEW 227
# define EC_F_NISTP256_PRE_COMP_NEW 236
# define EC_F_NISTP521_PRE_COMP_NEW 237
# define EC_F_O2I_ECPUBLICKEY 152
# define EC_F_OLD_EC_PRIV_DECODE 222
# define EC_F_OSSL_ECDH_COMPUTE_KEY 247
# define EC_F_OSSL_ECDSA_SIGN_SIG 249
# define EC_F_OSSL_ECDSA_VERIFY_SIG 250
# define EC_F_PKEY_ECX_DERIVE 269
# define EC_F_PKEY_EC_CTRL 197
# define EC_F_PKEY_EC_CTRL_STR 198
# define EC_F_PKEY_EC_DECRYPT 318
# define EC_F_PKEY_EC_DERIVE 217
# define EC_F_PKEY_EC_ENCRYPT 319
# define EC_F_PKEY_EC_KEYGEN 199
# define EC_F_PKEY_EC_PARAMGEN 219
# define EC_F_PKEY_EC_SIGN 218
# define EC_F_SM2_CIPHERTEXT_VALUE_DECODE 282
# define EC_F_SM2_CIPHERTEXT_VALUE_ENCODE 283
# define EC_F_SM2_CIPHERTEXT_VALUE_GET_ECIES_CIPHERTEXT_VALUE 284
# define EC_F_SM2_CIPHERTEXT_VALUE_NEW 285
# define EC_F_SM2_CIPHERTEXT_VALUE_NEW_FROM_ECIES_CIPHERTEXT_VALUE 286
# define EC_F_SM2_CIPHERTEXT_VALUE_SET_ECIES_CIPHERTEXT_VALUE 287
# define EC_F_SM2_CIPHERTEXT_VALUE_SIZE 288
# define EC_F_SM2_COMPUTE_ID_DIGEST 289
# define EC_F_SM2_COMPUTE_MESSAGE_DIGEST 290
# define EC_F_SM2_DECRYPT 291
# define EC_F_SM2_DO_DECRYPT 292
# define EC_F_SM2_DO_ENCRYPT 293
# define EC_F_SM2_DO_SIGN 294
# define EC_F_SM2_DO_VERIFY 295
# define EC_F_SM2_ENCRYPT 296
# define EC_F_SM2_ENC_PARAMS_DUP 297
# define EC_F_SM2_ENC_PARAMS_INIT_WITH_RECOMMENDED 298
# define EC_F_SM2_ENC_PARAMS_NEW 299
# define EC_F_SM2_ENC_PARAMS_SET_TYPE 300
# define EC_F_SM2_GET_PUBLIC_KEY_DATA 301
# define EC_F_SM2_KAP_COMPUTE_KEY 302
# define EC_F_SM2_KAP_CTX_INIT 303
# define EC_F_SM2_KAP_FINAL_CHECK 304
# define EC_F_SM2_KAP_PREPARE 305
# define EC_F_SM2_SIGN_SETUP 306
# define EC_F_TYPE1CURVE_EVAL_LINE_TEXTBOOK 315
# define EC_F_TYPE1CURVE_EVAL_MILLER_TEXTBOOK 316
# define EC_F_TYPE1CURVE_PHI 317
# define EC_F_BN_TO_FELEM 100
# define EC_F_D2I_ECIESPARAMETERS 101
# define EC_F_D2I_ECPARAMETERS 102
# define EC_F_D2I_ECPKPARAMETERS 103
# define EC_F_D2I_ECPRIVATEKEY 104
# define EC_F_DO_EC_KEY_PRINT 105
# define EC_F_ECDH_CMS_DECRYPT 106
# define EC_F_ECDH_CMS_SET_SHARED_INFO 107
# define EC_F_ECDH_COMPUTE_KEY 108
# define EC_F_ECDH_SIMPLE_COMPUTE_KEY 109
# define EC_F_ECDSA_DO_SIGN_EX 110
# define EC_F_ECDSA_DO_VERIFY 111
# define EC_F_ECDSA_SIGN_EX 112
# define EC_F_ECDSA_SIGN_SETUP 113
# define EC_F_ECDSA_SIG_NEW 114
# define EC_F_ECDSA_VERIFY 115
# define EC_F_ECIES_DECRYPT 116
# define EC_F_ECIES_DO_DECRYPT 117
# define EC_F_ECIES_DO_ENCRYPT 118
# define EC_F_ECIES_ENCRYPT 119
# define EC_F_ECIES_PARAMS_GET_ENC 120
# define EC_F_ECIES_PARAMS_GET_KDF 121
# define EC_F_ECIES_PARAMS_GET_MAC 122
# define EC_F_ECIES_PARAMS_INIT_WITH_RECOMMENDED 123
# define EC_F_ECIES_PARAMS_INIT_WITH_TYPE 124
# define EC_F_ECKEY_PARAM2TYPE 125
# define EC_F_ECKEY_PARAM_DECODE 126
# define EC_F_ECKEY_PRIV_DECODE 127
# define EC_F_ECKEY_PRIV_ENCODE 128
# define EC_F_ECKEY_PUB_DECODE 129
# define EC_F_ECKEY_PUB_ENCODE 130
# define EC_F_ECKEY_TYPE2PARAM 131
# define EC_F_ECPARAMETERS_PRINT_FP 132
# define EC_F_ECPKPARAMETERS_PRINT 133
# define EC_F_ECPKPARAMETERS_PRINT_FP 134
# define EC_F_ECP_NISTZ256_GET_AFFINE 135
# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 136
# define EC_F_ECP_NISTZ256_POINTS_MUL 137
# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 138
# define EC_F_ECP_NISTZ256_WINDOWED_MUL 139
# define EC_F_ECX_KEY_OP 140
# define EC_F_ECX_PRIV_ENCODE 141
# define EC_F_ECX_PUB_ENCODE 142
# define EC_F_EC_ASN1_GROUP2CURVE 143
# define EC_F_EC_ASN1_GROUP2FIELDID 144
# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 145
# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 146
# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 147
# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 148
# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 149
# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 150
# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 151
# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 152
# define EC_F_EC_GFP_MONT_FIELD_DECODE 153
# define EC_F_EC_GFP_MONT_FIELD_ENCODE 154
# define EC_F_EC_GFP_MONT_FIELD_MUL 155
# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 156
# define EC_F_EC_GFP_MONT_FIELD_SQR 157
# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 158
# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 159
# define EC_F_EC_GFP_NISTP224_POINTS_MUL 160
# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 161
# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 162
# define EC_F_EC_GFP_NISTP256_POINTS_MUL 163
# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 164
# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 165
# define EC_F_EC_GFP_NISTP521_POINTS_MUL 166
# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 167
# define EC_F_EC_GFP_NIST_FIELD_MUL 168
# define EC_F_EC_GFP_NIST_FIELD_SQR 169
# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 170
# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 171
# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 172
# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 173
# define EC_F_EC_GFP_SIMPLE_OCT2POINT 174
# define EC_F_EC_GFP_SIMPLE_POINT2OCT 175
# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 176
# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 177
# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 178
# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 179
# define EC_F_EC_GROUP_CHECK 180
# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 181
# define EC_F_EC_GROUP_COPY 182
# define EC_F_EC_GROUP_GENERATE_TYPE1CURVE 183
# define EC_F_EC_GROUP_GET_CURVE_GF2M 184
# define EC_F_EC_GROUP_GET_CURVE_GFP 185
# define EC_F_EC_GROUP_GET_DEGREE 186
# define EC_F_EC_GROUP_GET_ECPARAMETERS 187
# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 188
# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 189
# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 190
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ETA 191
# define EC_F_EC_GROUP_GET_TYPE1CURVE_ZETA 192
# define EC_F_EC_GROUP_IS_TYPE1CURVE 193
# define EC_F_EC_GROUP_NEW 194
# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 195
# define EC_F_EC_GROUP_NEW_FROM_DATA 196
# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 197
# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 198
# define EC_F_EC_GROUP_NEW_TYPE1CURVE 199
# define EC_F_EC_GROUP_SET_CURVE_GF2M 200
# define EC_F_EC_GROUP_SET_CURVE_GFP 201
# define EC_F_EC_GROUP_SET_GENERATOR 202
# define EC_F_EC_KEY_CHECK_KEY 203
# define EC_F_EC_KEY_COPY 204
# define EC_F_EC_KEY_GENERATE_KEY 205
# define EC_F_EC_KEY_NEW_METHOD 206
# define EC_F_EC_KEY_OCT2PRIV 207
# define EC_F_EC_KEY_PRINT_FP 208
# define EC_F_EC_KEY_PRIV2OCT 209
# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 210
# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 211
# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 212
# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 213
# define EC_F_EC_POINTS_MAKE_AFFINE 214
# define EC_F_EC_POINT_ADD 215
# define EC_F_EC_POINT_CMP 216
# define EC_F_EC_POINT_CMP_FPPOINT 217
# define EC_F_EC_POINT_COPY 218
# define EC_F_EC_POINT_DBL 219
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 220
# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 221
# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 222
# define EC_F_EC_POINT_HASH2POINT 223
# define EC_F_EC_POINT_INVERT 224
# define EC_F_EC_POINT_IS_AT_INFINITY 225
# define EC_F_EC_POINT_IS_ON_CURVE 226
# define EC_F_EC_POINT_MAKE_AFFINE 227
# define EC_F_EC_POINT_NEW 228
# define EC_F_EC_POINT_OCT2POINT 229
# define EC_F_EC_POINT_POINT2OCT 230
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 231
# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 232
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 233
# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 234
# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 235
# define EC_F_EC_POINT_SET_TO_INFINITY 236
# define EC_F_EC_PRE_COMP_NEW 237
# define EC_F_EC_TYPE1CURVE_TATE 238
# define EC_F_EC_WNAF_MUL 239
# define EC_F_EC_WNAF_PRECOMPUTE_MULT 240
# define EC_F_I2D_ECIESPARAMETERS 241
# define EC_F_I2D_ECPARAMETERS 242
# define EC_F_I2D_ECPKPARAMETERS 243
# define EC_F_I2D_ECPRIVATEKEY 244
# define EC_F_I2O_ECPUBLICKEY 245
# define EC_F_NISTP224_PRE_COMP_NEW 246
# define EC_F_NISTP256_PRE_COMP_NEW 247
# define EC_F_NISTP521_PRE_COMP_NEW 248
# define EC_F_O2I_ECPUBLICKEY 249
# define EC_F_OLD_EC_PRIV_DECODE 250
# define EC_F_OSSL_ECDH_COMPUTE_KEY 251
# define EC_F_OSSL_ECDSA_SIGN_SIG 252
# define EC_F_OSSL_ECDSA_VERIFY_SIG 253
# define EC_F_PKEY_ECX_DERIVE 254
# define EC_F_PKEY_EC_CTRL 255
# define EC_F_PKEY_EC_CTRL_STR 256
# define EC_F_PKEY_EC_DECRYPT 257
# define EC_F_PKEY_EC_DERIVE 258
# define EC_F_PKEY_EC_ENCRYPT 259
# define EC_F_PKEY_EC_KEYGEN 260
# define EC_F_PKEY_EC_PARAMGEN 261
# define EC_F_PKEY_EC_SIGN 262
# define EC_F_SM2_COMPUTE_ID_DIGEST 263
# define EC_F_SM2_COMPUTE_MESSAGE_DIGEST 264
# define EC_F_SM2_DO_ENCRYPT 265
# define EC_F_SM2_GET_PUBLIC_KEY_DATA 266
# define EC_F_SM2_KAP_COMPUTE_KEY 267
# define EC_F_SM2_KAP_CTX_INIT 268
# define EC_F_SM2_KAP_FINAL_CHECK 269
# define EC_F_SM2_KAP_PREPARE 270
# define EC_F_TYPE1CURVE_EVAL_LINE_TEXTBOOK 271
# define EC_F_TYPE1CURVE_EVAL_MILLER_TEXTBOOK 272
# define EC_F_TYPE1CURVE_PHI 273
/* Reason codes. */
# define EC_R_ASN1_ERROR 115
# define EC_R_BAD_SIGNATURE 156
# define EC_R_BIGNUM_OUT_OF_RANGE 144
# define EC_R_BUFFER_TOO_SMALL 100
# define EC_R_CIPHERTEXT_ENCODE_FAILED 173
# define EC_R_CMAC_FINAL_FAILURE 136
# define EC_R_CMAC_INIT_FAILURE 153
# define EC_R_CMAC_UPDATE_FAILURE 162
# define EC_R_COORDINATES_OUT_OF_RANGE 146
# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160
# define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159
# define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
# define EC_R_DECODE_ERROR 142
# define EC_R_DECRYPT_FAILED 163
# define EC_R_DISCRIMINANT_IS_ZERO 118
# define EC_R_ECDH_FAILED 164
# define EC_R_ECDH_FAILURE 165
# define EC_R_ECIES_DECRYPT_FAILED 196
# define EC_R_ECIES_DECRYPT_INIT_FAILURE 166
# define EC_R_ECIES_DECRYPT_WITH_RECOMMENDED_FAILED 197
# define EC_R_ECIES_ENCRYPT_FAILED 198
# define EC_R_ECIES_ENCRYPT_WITH_RECOMMENDED_FAILED 199
# define EC_R_ECIES_VERIFY_MAC_FAILURE 167
# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119
# define EC_R_ENCRYPT_FAILED 168
# define EC_R_ENCRYPT_FAILURE 206
# define EC_R_ERROR 174
# define EC_R_FIELD_TOO_LARGE 143
# define EC_R_GEN_MAC_FAILED 169
# define EC_R_GET_CIPHERTEXT_SIZE_FAILED 175
# define EC_R_GET_KDF_FAILED 176
# define EC_R_GET_PUBLIC_KEY_DATA_FAILURE 177
# define EC_R_GET_TYPE1CURVE_ZETA_FAILURE 192
# define EC_R_GF2M_NOT_SUPPORTED 147
# define EC_R_GROUP2PKPARAMETERS_FAILURE 120
# define EC_R_HMAC_FAILURE 170
# define EC_R_I2D_ECPKPARAMETERS_FAILURE 121
# define EC_R_INCOMPATIBLE_OBJECTS 101
# define EC_R_INNOR_ERROR 178
# define EC_R_INVALID_ARGUMENT 112
# define EC_R_INVALID_COMPRESSED_POINT 110
# define EC_R_INVALID_COMPRESSION_BIT 109
# define EC_R_INVALID_CURVE 141
# define EC_R_INVALID_DIGEST 151
# define EC_R_INVALID_DIGEST_ALGOR 179
# define EC_R_INVALID_DIGEST_TYPE 138
# define EC_R_INVALID_ECIES_CIPHERTEXT 171
# define EC_R_INVALID_ECIES_PARAMETERS 172
# define EC_R_INVALID_ECIES_PARAMS 207
# define EC_R_INVALID_EC_KEY 180
# define EC_R_INVALID_ENCODING 102
# define EC_R_INVALID_ENC_PARAM 208
# define EC_R_INVALID_ENC_TYPE 200
# define EC_R_INVALID_FIELD 103
# define EC_R_INVALID_FORM 104
# define EC_R_INVALID_GROUP_ORDER 122
# define EC_R_INVALID_ID_LENGTH 181
# define EC_R_INVALID_INPUT_LENGTH 209
# define EC_R_INVALID_KDF_MD 182
# define EC_R_INVALID_KEY 116
# define EC_R_INVALID_MD 205
# define EC_R_INVALID_OUTPUT_LENGTH 161
# define EC_R_INVALID_PEER_KEY 133
# define EC_R_INVALID_PENTANOMIAL_BASIS 132
# define EC_R_INVALID_PRIVATE_KEY 123
# define EC_R_INVALID_SM2_ID 183
# define EC_R_INVALID_SM2_KAP_CHECKSUM_LENGTH 184
# define EC_R_INVALID_SM2_KAP_CHECKSUM_VALUE 185
# define EC_R_INVALID_TRINOMIAL_BASIS 137
# define EC_R_INVALID_TYPE1CURVE 193
# define EC_R_INVALID_TYPE1_CURVE 194
# define EC_R_INVLID_TYPE1CURVE 195
# define EC_R_KDF_PARAMETER_ERROR 148
# define EC_R_KEYS_NOT_SET 140
# define EC_R_MALLOC_FAILED 186
# define EC_R_MISSING_PARAMETERS 124
# define EC_R_MISSING_PRIVATE_KEY 125
# define EC_R_NEED_NEW_SETUP_VALUES 157
# define EC_R_NOT_A_NIST_PRIME 135
# define EC_R_NOT_IMPLEMENTED 126
# define EC_R_NOT_INITIALIZED 111
# define EC_R_NO_PARAMETERS_SET 139
# define EC_R_NO_PRIVATE_VALUE 154
# define EC_R_NULL_ARGUMENT 187
# define EC_R_OCT2POINT_FAILED 188
# define EC_R_OPERATION_NOT_SUPPORTED 152
# define EC_R_PASSED_NULL_PARAMETER 134
# define EC_R_PEER_KEY_ERROR 149
# define EC_R_PKPARAMETERS2GROUP_FAILURE 127
# define EC_R_POINT2OCT_FAILED 189
# define EC_R_POINT_ARITHMETIC_FAILURE 155
# define EC_R_POINT_AT_INFINITY 106
# define EC_R_POINT_IS_NOT_ON_CURVE 107
# define EC_R_POINT_NEW_FAILED 190
# define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158
# define EC_R_SHARED_INFO_ERROR 150
# define EC_R_SLOT_FULL 108
# define EC_R_SM2_DECRYPT_FAILED 201
# define EC_R_SM2_DECRYPT_WITH_RECOMMENDED_FAILED 202
# define EC_R_SM2_ENCRYPT_FAILED 203
# define EC_R_SM2_ENCRYPT_WITH_RECOMMENDED_FAILED 204
# define EC_R_SM2_KAP_NOT_INITED 191
# define EC_R_UNDEFINED_GENERATOR 113
# define EC_R_UNDEFINED_ORDER 128
# define EC_R_UNKNOWN_GROUP 129
# define EC_R_UNKNOWN_ORDER 114
# define EC_R_UNSUPPORTED_FIELD 131
# define EC_R_WRONG_CURVE_PARAMETERS 145
# define EC_R_WRONG_ORDER 130
# define EC_R_ASN1_ERROR 100
# define EC_R_BAD_SIGNATURE 101
# define EC_R_BIGNUM_OUT_OF_RANGE 102
# define EC_R_BUFFER_TOO_SMALL 103
# define EC_R_CMAC_FINAL_FAILURE 104
# define EC_R_CMAC_INIT_FAILURE 105
# define EC_R_CMAC_UPDATE_FAILURE 106
# define EC_R_COORDINATES_OUT_OF_RANGE 107
# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 108
# define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 109
# define EC_R_D2I_ECPKPARAMETERS_FAILURE 110
# define EC_R_DECODE_ERROR 111
# define EC_R_DECRYPT_FAILED 112
# define EC_R_DISCRIMINANT_IS_ZERO 113
# define EC_R_ECDH_FAILED 114
# define EC_R_ECDH_FAILURE 115
# define EC_R_ECIES_DECRYPT_FAILED 116
# define EC_R_ECIES_DECRYPT_INIT_FAILURE 117
# define EC_R_ECIES_ENCRYPT_FAILED 118
# define EC_R_ECIES_VERIFY_MAC_FAILURE 119
# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 120
# define EC_R_ENCODE_ERROR 198
# define EC_R_ENCRYPT_FAILED 121
# define EC_R_ENCRYPT_FAILURE 122
# define EC_R_ERROR 123
# define EC_R_FIELD_TOO_LARGE 124
# define EC_R_GEN_MAC_FAILED 125
# define EC_R_GET_PUBLIC_KEY_DATA_FAILURE 126
# define EC_R_GET_TYPE1CURVE_ZETA_FAILURE 127
# define EC_R_GF2M_NOT_SUPPORTED 128
# define EC_R_GROUP2PKPARAMETERS_FAILURE 129
# define EC_R_GROUP_MISMATCH 199
# define EC_R_HMAC_FAILURE 130
# define EC_R_I2D_ECPKPARAMETERS_FAILURE 131
# define EC_R_INCOMPATIBLE_OBJECTS 132
# define EC_R_INVALID_ARGUMENT 133
# define EC_R_INVALID_COMPRESSED_POINT 134
# define EC_R_INVALID_COMPRESSION_BIT 135
# define EC_R_INVALID_CURVE 136
# define EC_R_INVALID_DIGEST 137
# define EC_R_INVALID_DIGEST_ALGOR 138
# define EC_R_INVALID_DIGEST_TYPE 139
# define EC_R_INVALID_ECIES_CIPHERTEXT 140
# define EC_R_INVALID_ECIES_PARAMETERS 141
# define EC_R_INVALID_ECIES_PARAMS 142
# define EC_R_INVALID_EC_ENCRYPT_PARAM 143
# define EC_R_INVALID_EC_SCHEME 144
# define EC_R_INVALID_ENCODING 145
# define EC_R_INVALID_ENC_PARAM 146
# define EC_R_INVALID_ENC_TYPE 147
# define EC_R_INVALID_FIELD 148
# define EC_R_INVALID_FORM 149
# define EC_R_INVALID_GROUP_ORDER 150
# define EC_R_INVALID_ID_LENGTH 151
# define EC_R_INVALID_INPUT_LENGTH 152
# define EC_R_INVALID_KDF_MD 153
# define EC_R_INVALID_KEY 154
# define EC_R_INVALID_MD 155
# define EC_R_INVALID_OUTPUT_LENGTH 156
# define EC_R_INVALID_PEER_KEY 157
# define EC_R_INVALID_PENTANOMIAL_BASIS 158
# define EC_R_INVALID_PRIVATE_KEY 159
# define EC_R_INVALID_SIGNER_ID 160
# define EC_R_INVALID_SM2_ID 161
# define EC_R_INVALID_SM2_KAP_CHECKSUM_LENGTH 162
# define EC_R_INVALID_SM2_KAP_CHECKSUM_VALUE 163
# define EC_R_INVALID_TRINOMIAL_BASIS 164
# define EC_R_INVALID_TYPE1CURVE 165
# define EC_R_INVALID_TYPE1_CURVE 166
# define EC_R_INVLID_TYPE1CURVE 167
# define EC_R_KDF_PARAMETER_ERROR 168
# define EC_R_KEYS_NOT_SET 169
# define EC_R_MISSING_PARAMETERS 170
# define EC_R_MISSING_PRIVATE_KEY 171
# define EC_R_NEED_NEW_SETUP_VALUES 172
# define EC_R_NOT_A_NIST_PRIME 173
# define EC_R_NOT_IMPLEMENTED 174
# define EC_R_NOT_INITIALIZED 175
# define EC_R_NO_PARAMETERS_SET 176
# define EC_R_NO_PRIVATE_VALUE 177
# define EC_R_OPERATION_NOT_SUPPORTED 178
# define EC_R_PASSED_NULL_PARAMETER 179
# define EC_R_PEER_KEY_ERROR 180
# define EC_R_PKPARAMETERS2GROUP_FAILURE 181
# define EC_R_POINT_ARITHMETIC_FAILURE 182
# define EC_R_POINT_AT_INFINITY 183
# define EC_R_POINT_IS_NOT_ON_CURVE 184
# define EC_R_RANDOM_NUMBER_GENERATION_FAILED 185
# define EC_R_SHARED_INFO_ERROR 186
# define EC_R_SLOT_FULL 187
# define EC_R_SM2_DECRYPT_FAILED 188
# define EC_R_SM2_ENCRYPT_FAILED 189
# define EC_R_SM2_KAP_NOT_INITED 190
# define EC_R_UNDEFINED_GENERATOR 191
# define EC_R_UNDEFINED_ORDER 192
# define EC_R_UNKNOWN_GROUP 193
# define EC_R_UNKNOWN_ORDER 194
# define EC_R_UNSUPPORTED_FIELD 195
# define EC_R_WRONG_CURVE_PARAMETERS 196
# define EC_R_WRONG_ORDER 197
# ifdef __cplusplus
}

View File

@@ -50,6 +50,9 @@
#ifndef HEADER_ECIES_H
#define HEADER_ECIES_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_ECIES
#include <openssl/ec.h>
#include <openssl/err.h>
#include <openssl/evp.h>
@@ -134,14 +137,15 @@ ECIES_PARAMS *d2i_ECIESParameters(ECIES_PARAMS **param,
typedef struct ecies_ciphertext_value_st ECIES_CIPHERTEXT_VALUE;
DECLARE_ASN1_FUNCTIONS(ECIES_CIPHERTEXT_VALUE)
int ECIES_CIPHERTEXT_VALUE_ciphertext_length(const ECIES_CIPHERTEXT_VALUE *a);
ECIES_CIPHERTEXT_VALUE *ECIES_do_encrypt(const ECIES_PARAMS *param,
const unsigned char *in, size_t inlen, EC_KEY *ec_key);
int ECIES_do_decrypt(const ECIES_PARAMS *param, const ECIES_CIPHERTEXT_VALUE *in,
unsigned char *out, size_t *outlen, EC_KEY *ec_key);
int ECIES_encrypt(int type, const unsigned char *in, size_t inlen,
int ECIES_encrypt(int param, const unsigned char *in, size_t inlen,
unsigned char *out, size_t *outlen, EC_KEY *ec_key);
int ECIES_decrypt(int type, const unsigned char *in, size_t inlen,
int ECIES_decrypt(int param, const unsigned char *in, size_t inlen,
unsigned char *out, size_t *outlen, EC_KEY *ec_key);
#define ECIES_encrypt_with_recommended(in,inlen,out,outlen,ec_key) \
ECIES_encrypt(NID_ecies_with_x9_63_sha256_xor_hmac,in,inlen,out,outlen,ec_key)
@@ -153,3 +157,4 @@ int ECIES_decrypt(int type, const unsigned char *in, size_t inlen,
}
#endif
#endif
#endif

View File

@@ -334,6 +334,10 @@ ENGINE *ENGINE_by_id(const char *id);
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL)
# define ENGINE_load_capi() \
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL)
# define ENGINE_load_skf() \
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_SKF, NULL)
# define ENGINE_load_sdf() \
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_SDF, NULL)
# define ENGINE_load_afalg() \
OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL)
# endif

View File

@@ -107,9 +107,7 @@ typedef struct err_state_st {
# define ERR_LIB_SDF 63
# define ERR_LIB_SKF 64
# define ERR_LIB_SOF 65
#ifndef OPENSSL_NO_BASE58
# define ERR_LIB_BASE58 66
#endif
# define ERR_LIB_USER 128
@@ -162,9 +160,8 @@ typedef struct err_state_st {
# 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)
#ifndef OPENSSL_NO_BASE58
# define BASE58err(f,r) ERR_PUT_error(ERR_LIB_BASE58,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
#endif
# define ERR_PACK(l,f,r) ( \
(((unsigned int)(l) & 0x0FF) << 24L) | \
(((unsigned int)(f) & 0xFFF) << 12L) | \
@@ -225,9 +222,8 @@ typedef struct err_state_st {
# 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 */
#ifndef OPENSSL_NO_BASE58
# define ERR_R_BASE58_LIB ERR_LIB_BASE58/* 66 */
#endif
# define ERR_R_NESTED_ASN1_ERROR 58
# define ERR_R_NESTED_ASN1_ERROR 58
@@ -303,6 +299,8 @@ int ERR_get_next_error_library(void);
int ERR_set_mark(void);
int ERR_pop_to_mark(void);
#define OPENSSL_PUT_ERROR(a,b) do {} while(0)
#ifdef __cplusplus
}
#endif

View File

@@ -111,6 +111,9 @@ extern "C" {
# define EVP_PKEY_MO_ENCRYPT 0x0004
# define EVP_PKEY_MO_DECRYPT 0x0008
char *EVP_get_ciphernames(int aliases);
char *EVP_get_digestnames(int aliases);
# ifndef EVP_MD
EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type);
EVP_MD *EVP_MD_meth_dup(const EVP_MD *md);
@@ -427,39 +430,71 @@ typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,
int en_de);
# ifndef OPENSSL_NO_RSA
# define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
(char *)(rsa))
# ifndef OPENSSL_NO_MACRO
# define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
(char *)(rsa))
# else
int EVP_PKEY_assign_RSA(EVP_PKEY *pkey, RSA *rsa);
# endif
# endif
# ifndef OPENSSL_NO_DSA
# define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
(char *)(dsa))
# ifndef OPENSSL_NO_MACRO
# define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
(char *)(dsa))
# else
int EVP_PKEY_assign_DSA(EVP_PKEY *pkey, DSA *dsa);
# endif
# endif
# ifndef OPENSSL_NO_DH
# define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
(char *)(dh))
# ifndef OPENSSL_NO_MACRO
# define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
(char *)(dh))
# else
int EVP_PKEY_assign_DH(EVP_PKEY *pkey, DH *dh);
# endif
# endif
# ifndef OPENSSL_NO_EC
# define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
(char *)(eckey))
# ifndef OPENSSL_NO_MACRO
# define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
(char *)(eckey))
# else
int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey, EC_KEY *ec_key);
# endif
# endif
# ifndef OPENSSL_NO_PAILLIER
# define EVP_PKEY_assign_PAILLIER(pkey,paillier) EVP_PKEY_assign((pkey),EVP_PKEY_PAILLIER,\
# ifndef OPENSSL_NO_MACRO
# define EVP_PKEY_assign_PAILLIER(pkey,paillier) EVP_PKEY_assign((pkey),EVP_PKEY_PAILLIER,\
(char *)(paillier))
# else
int EVP_PKEY_assign_PAILLIER(EVP_PKEY *pkey, PAILLIER *paillier);
# endif
# endif
/* Add some extra combinations */
# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
# ifndef OPENSSL_NO_MACRO
# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
# else
const EVP_MD *EVP_get_digestbynid(int nid);
const EVP_MD *EVP_get_digestbyobj(ASN1_OBJECT *obj);
const EVP_CIPHER *EVP_get_cipherbynid(int nid);
const EVP_CIPHER *EVP_get_cipherbyobj(ASN1_OBJECT *obj);
# endif
int EVP_MD_type(const EVP_MD *md);
# define EVP_MD_nid(e) EVP_MD_type(e)
# define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
# ifndef OPENSSL_NO_MACRO
# define EVP_MD_nid(e) EVP_MD_type(e)
# define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
# else
int EVP_MD_nid(const EVP_MD *md);
const char *EVP_MD_name(const EVP_MD *md);
# endif
int EVP_MD_pkey_type(const EVP_MD *md);
int EVP_MD_size(const EVP_MD *md);
int EVP_MD_block_size(const EVP_MD *md);
@@ -471,20 +506,35 @@ int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx,
void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx,
int (*update) (EVP_MD_CTX *ctx,
const void *data, size_t count));
# define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
# define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e))
# define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e))
# ifndef OPENSSL_NO_MACRO
# define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
# define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e))
# define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e))
# else
int EVP_MD_CTX_size(EVP_MD_CTX *ctx);
int EVP_MD_CTX_block_size(EVP_MD_CTX *ctx);
int EVP_MD_CTX_type(EVP_MD_CTX *ctx);
# endif
EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx);
void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx);
void *EVP_MD_CTX_set_md_data(EVP_MD_CTX *ctx, void *md_data);
int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
# define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
# ifndef OPENSSL_NO_MACRO
# define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
# else
const char *EVP_CIPHER_name(const EVP_CIPHER *cipher);
# endif
int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher);
int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
# define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)
# ifndef OPENSSL_NO_MACRO
# define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)
# else
int EVP_CIPHER_mode(const EVP_CIPHER *cipher);
# endif
const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx);
@@ -503,57 +553,106 @@ void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);
void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);
# define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
# if OPENSSL_API_COMPAT < 0x10100000L
# define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c))
# ifndef OPENSSL_NO_MACRO
# define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
# else
int EVP_CIPHER_CTX_type(EVP_CIPHER_CTX *ctx);
# endif
# define EVP_CIPHER_CTX_mode(c) EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c))
# if OPENSSL_API_COMPAT < 0x10100000L
# ifndef OPENSSL_NO_MACRO
# define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c))
# else
int EVP_CIPHER_CTX_flags(EVP_CIPHER_CTX *ctx);
# endif
# endif
# ifndef OPENSSL_NO_MACRO
# define EVP_CIPHER_CTX_mode(c) EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c))
# define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
# define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
# define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
# define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
# define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
# define EVP_SignInit(a,b) EVP_DigestInit(a,b)
# define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
# define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
# define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
# define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
# define EVP_DigestSignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# define EVP_DigestVerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
# define EVP_SignInit(a,b) EVP_DigestInit(a,b)
# define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
# define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
# define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
# define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
# define EVP_DigestSignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# define EVP_DigestVerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
# else
int EVP_CIPHER_CTX_mode(EVP_CIPHER_CTX *ctx);
long EVP_ENCODE_LENGTH(long l);
long EVP_DECODE_LENGTH(long l);
__owur int EVP_SignInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,
ENGINE *impl);
__owur int EVP_SignInit(EVP_MD_CTX *ctx, const EVP_MD *type);
__owur int EVP_SignUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
__owur int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,
ENGINE *impl);
__owur int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
__owur int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
/*__owur*/ int EVP_OpenUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
int *outl, const unsigned char *in, int inl);
/*__owur*/ int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
int *outl, const unsigned char *in, int inl);
__owur int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
__owur int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt);
# endif
# ifdef CONST_STRICT
void BIO_set_md(BIO *, const EVP_MD *md);
# else
# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)
# endif
# define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
# define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
# define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)
# define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)
# ifndef OPENSSL_NO_MACRO
# define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
# define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
# define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp)
# define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)
# else
long BIO_get_md(BIO *bio, const EVP_MD **pmd);
long BIO_get_md_ctx(BIO *bio, EVP_MD_CTX **pmctx);
long BIO_set_md_ctx(BIO *bio, EVP_MD_CTX *mctx);
long BIO_get_cipher_status(BIO *bio);
long BIO_get_cipher_ctx(BIO *bio, EVP_CIPHER_CTX *pcctx);
# endif
/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c,
unsigned char *out,
const unsigned char *in, unsigned int inl);
# define EVP_add_cipher_alias(n,alias) \
# ifndef OPENSSL_NO_MACRO
# define EVP_add_cipher_alias(n,alias) \
OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
# define EVP_add_digest_alias(n,alias) \
# define EVP_add_digest_alias(n,alias) \
OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
# define EVP_delete_cipher_alias(alias) \
# define EVP_delete_cipher_alias(alias) \
OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
# define EVP_delete_digest_alias(alias) \
# define EVP_delete_digest_alias(alias) \
OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
# else
int EVP_add_cipher_alias(int type, const char *alias);
int EVP_add_digest_alias(int type, const char *alias);
int EVP_delete_cipher_alias(const char *alias);
int EVP_delete_digest_alias(const char *alias);
# endif
int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
EVP_MD_CTX *EVP_MD_CTX_new(void);
int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
# define EVP_MD_CTX_create() EVP_MD_CTX_new()
# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
# ifndef OPENSSL_NO_MACRO
# define EVP_MD_CTX_create() EVP_MD_CTX_new()
# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
# else
EVP_MD_CTX *EVP_MD_CTX_create(void);
int EVP_MD_CTX_init(EVP_MD_CTX *ctx);
void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
# endif
__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
@@ -678,8 +777,13 @@ int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
# if OPENSSL_API_COMPAT < 0x10100000L
# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c)
# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c)
# ifndef OPENSSL_NO_MACRO
# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c)
# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c)
# else
int EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx);
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *ctx);
# endif
# endif
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
@@ -917,36 +1021,48 @@ const EVP_CIPHER *EVP_sms4_wrap_pad(void);
# endif
# if OPENSSL_API_COMPAT < 0x10100000L
# define OPENSSL_add_all_algorithms_conf() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
# ifndef OPENSSL_NO_MACRO
# define OPENSSL_add_all_algorithms_conf() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
| OPENSSL_INIT_ADD_ALL_DIGESTS \
| OPENSSL_INIT_LOAD_CONFIG, NULL)
# define OPENSSL_add_all_algorithms_noconf() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
# define OPENSSL_add_all_algorithms_noconf() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
| OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
# ifdef OPENSSL_LOAD_CONF
# define OpenSSL_add_all_algorithms() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
# ifdef OPENSSL_LOAD_CONF
# define OpenSSL_add_all_algorithms() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
| OPENSSL_INIT_ADD_ALL_DIGESTS \
| OPENSSL_INIT_LOAD_CONFIG, NULL)
# else
# define OpenSSL_add_all_algorithms() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
| OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
# endif
# define OpenSSL_add_all_ciphers() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL)
# define OpenSSL_add_all_digests() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
# define EVP_cleanup() while(0) continue
# else
# define OpenSSL_add_all_algorithms() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
| OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
# endif
# define OpenSSL_add_all_ciphers() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL)
# define OpenSSL_add_all_digests() \
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
# define EVP_cleanup() while(0) continue
# endif
int OPENSSL_add_all_algorithms_conf(void);
int OPENSSL_add_all_algorithms_noconf(void);
int OpenSSL_add_all_algorithms(void);
int OpenSSL_add_all_ciphers(void);
int OPENSSL_add_all_digests(void);
void OPENSSL_cleanup(void);
# endif /* OPENSSL_NO_MACRO */
# endif /* OPENSSL_API_COMPAT < 0x10100000L */
int EVP_add_cipher(const EVP_CIPHER *cipher);
int EVP_add_digest(const EVP_MD *digest);
const EVP_CIPHER *EVP_get_default_cipher(void);
const EVP_MD *EVP_get_default_digest(void);
const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
const EVP_MD *EVP_get_digestbyname(const char *name);
@@ -1061,9 +1177,11 @@ int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
ASN1_TYPE *param, const EVP_CIPHER *cipher,
const EVP_MD *md, int en_de);
#ifndef OPENSSL_NO_SHA
int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
const unsigned char *salt, int saltlen, int iter,
int keylen, unsigned char *out);
#endif
int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
const unsigned char *salt, int saltlen, int iter,
const EVP_MD *digest, int keylen, unsigned char *out);
@@ -1224,6 +1342,7 @@ void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
# define EVP_PKEY_OP_TYPE_GEN \
(EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
# ifndef OPENSSL_NO_MACRO
# define EVP_PKEY_CTX_set_signature_md(ctx, md) \
EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
EVP_PKEY_CTRL_MD, 0, (void *)md)
@@ -1235,6 +1354,11 @@ void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
# define EVP_PKEY_CTX_set_mac_key(ctx, key, len) \
EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_KEYGEN, \
EVP_PKEY_CTRL_SET_MAC_KEY, len, (void *)key)
# else
int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **pmd);
int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key, int keylen);
# endif
# define EVP_PKEY_CTRL_MD 1
# define EVP_PKEY_CTRL_PEER_KEY 2
@@ -1526,6 +1650,7 @@ void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth,
void EVP_add_alg_module(void);
/* BEGIN ERROR CODES */
/*
* The following lines are auto generated by the script mkerr.pl. Any changes
@@ -1645,6 +1770,7 @@ int ERR_load_EVP_strings(void);
# define EVP_R_MESSAGE_DIGEST_IS_NULL 159
# define EVP_R_METHOD_NOT_SUPPORTED 144
# define EVP_R_MISSING_PARAMETERS 103
# define EVP_R_NO_AVAIABLE_DIGEST 178
# define EVP_R_NO_CIPHER_SET 131
# define EVP_R_NO_DEFAULT_DIGEST 158
# define EVP_R_NO_DIGEST_SET 139
@@ -1656,6 +1782,7 @@ int ERR_load_EVP_strings(void);
# define EVP_R_PRIVATE_KEY_DECODE_ERROR 145
# define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146
# define EVP_R_PUBLIC_KEY_NOT_RSA 106
# define EVP_R_PUBLIC_KEY_NOT_RSA_OR_EC 177
# define EVP_R_RSA_PUBLIC_ENCRYPT_FAILED 175
# define EVP_R_UNKNOWN_CIPHER 160
# define EVP_R_UNKNOWN_DIGEST 161

View File

@@ -49,6 +49,7 @@
#ifndef HEADER_FFX_H
#define HEADER_FFX_H
#include <string.h>
#include <openssl/evp.h>

View File

@@ -53,9 +53,18 @@
#ifndef HEADER_GMAPI_H
#define HEADER_GMAPI_H
#include <openssl/ec.h>
#include <openssl/sm2.h>
#include <openssl/rsa.h>
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_GMAPI
#ifndef OPENSSL_NO_EC
# include <openssl/ec.h>
# ifndef OPENSSL_NO_SM2
# include <openssl/sm2.h>
# endif
#endif
#ifndef OPENSSL_NO_RSA
# include <openssl/rsa.h>
#endif
#include <openssl/evp.h>
#include <openssl/sgd.h>
#include <openssl/saf.h>
@@ -67,57 +76,112 @@
extern "C" {
#endif
const char *GMAPI_keyusage2str(int usage);
int GMAPI_sgd2ciphernid(int sgd);
int GMAPI_sgd2mdnid(int sgd);
/* SGD */
const EVP_CIPHER *EVP_get_cipherbysgd(ULONG ulAlgId, ULONG ulFeedBitLen);
int EVP_CIPHER_get_sgd(const EVP_CIPHER *cipher, ULONG *pulAlgId, ULONG *pulFeedBits);
int EVP_CIPHER_CTX_get_sgd(const EVP_CIPHER_CTX *ctx, ULONG *pulAlgId, ULONG *pulFeedBits);
const EVP_MD *EVP_get_digestbysgd(ULONG ulAlgId);
int EVP_MD_get_sgd(const EVP_MD *md, ULONG *ulAlgId);
int EVP_MD_CTX_get_sgd(const EVP_MD_CTX *ctx, ULONG *ulAlgId);
//convert sgd to pkey type
int EVP_PKEY_get_sgd(const EVP_PKEY *pkey, ULONG *ulAlgId);
int EVP_PKEY_CTX_get_sgd(const EVP_PKEY_CTX *ctx, ULONG *ulAlgId);
int EVP_MD_sgd(const EVP_MD *md);
int EVP_CIPHER_sgd(const EVP_CIPHER *cipher);
/* SGD <==> EVP */
const EVP_MD *EVP_get_digestbysgd(int sgd);
const EVP_CIPHER *EVP_get_cipherbysgd(int sgd);
/* SDF types <==> Native types */
/* SDF */
#ifndef OPENSSL_NO_SDF
# ifndef OPENSSL_NO_RSA
RSA *RSA_new_from_RSArefPublicKey(const RSArefPublicKey *ref);
RSA *RSA_new_from_RSArefPrivateKey(const RSArefPrivateKey *ref);
int RSA_set_RSArefPublicKey(RSA *rsa, const RSArefPublicKey *ref);
int RSA_set_RSArefPrivateKey(RSA *rsa, const RSArefPrivateKey *ref);
int RSA_get_RSArefPublicKey(RSA *rsa, RSArefPublicKey *ref);
RSA *RSA_new_from_RSArefPrivateKey(const RSArefPrivateKey *ref);
int RSA_set_RSArefPrivateKey(RSA *rsa, const RSArefPrivateKey *ref);
int RSA_get_RSArefPrivateKey(RSA *rsa, RSArefPrivateKey *ref);
# endif
# ifndef OPENSSL_NO_EC
EC_KEY *EC_KEY_new_from_ECCrefPublicKey(const ECCrefPublicKey *ref);
EC_KEY *EC_KEY_new_from_ECCrefPrivateKey(const ECCrefPrivateKey *ref);
int EC_KEY_set_ECCrefPublicKey(EC_KEY *ec_key, const ECCrefPublicKey *ref);
int EC_KEY_set_ECCrefPrivateKey(EC_KEY *ec_key, const ECCrefPrivateKey *ref);
int EC_KEY_get_ECCrefPublicKey(EC_KEY *ec_key, ECCrefPublicKey *ref);
EC_KEY *EC_KEY_new_from_ECCrefPrivateKey(const ECCrefPrivateKey *ref);
int EC_KEY_set_ECCrefPrivateKey(EC_KEY *ec_key, const ECCrefPrivateKey *ref);
int EC_KEY_get_ECCrefPrivateKey(EC_KEY *ec_key, ECCrefPrivateKey *ref);
# ifndef OPENSSL_NO_SM2
SM2CiphertextValue *SM2CiphertextValue_new_from_ECCCipher(const ECCCipher *ref);
int SM2CiphertextValue_set_ECCCipher(SM2CiphertextValue *cv, const ECCCipher *ref);
int SM2CiphertextValue_get_ECCCipher(const SM2CiphertextValue *cv, ECCCipher *ref);
# endif
# ifndef OPENSSL_NO_ECIES
ECIES_CIPHERTEXT_VALUE *ECIES_CIPHERTEXT_VALUE_new_from_ECCCipher(const ECCCipher *ref);
int ECIES_CIPHERTEXT_VALUE_set_ECCCipher(ECIES_CIPHERTEXT_VALUE *cv, const ECCCipher *ref);
int ECIES_CIPHERTEXT_VALUE_get_ECCCipher(const ECIES_CIPHERTEXT_VALUE *cv, ECCCipher *ref);
# endif
ECDSA_SIG *ECDSA_SIG_new_from_ECCSignature(const ECCSignature *ref);
int ECDSA_SIG_set_ECCSignature(ECDSA_SIG *sig, const ECCSignature *ref);
int ECDSA_SIG_get_ECCSignature(const ECDSA_SIG *sig, ECCSignature *ref);
ECCCipher *d2i_ECCCipher(ECCCipher **a, const unsigned char **pp, long length);
int i2d_ECCCipher(ECCCipher *a, unsigned char **pp);
ECCCipher *d2i_ECCCipher_bio(BIO *bp, ECCCipher **a);
int i2d_ECCCipher_bio(BIO *bp, ECCCipher *a);
ECCSignature *d2i_ECCSignature(ECCSignature **a, const unsigned char **pp, long length);
int i2d_ECCSignature(ECCSignature *a, unsigned char **pp);
ECCSignature *d2i_ECCSignature_bio(BIO *bp, ECCSignature **a);
int i2d_ECCSignature_bio(BIO *bp, ECCSignature *a);
# ifndef OPENSSL_NO_STDIO
ECCCipher *d2i_ECCCipher_fp(FILE *fp, ECCCipher **a);
int i2d_ECCCipher_fp(FILE *fp, ECCCipher *a);
ECCSignature *d2i_ECCSignature_fp(FILE *fp, ECCSignature **a);
int i2d_ECCSignature_fp(FILE *fp, ECCSignature *a);
# endif
# endif
#endif
/* SKF types <==> Native types */
/* SKF */
#ifndef OPENSSL_NO_SKF
# ifndef OPENSSL_NO_RSA
RSA *RSA_new_from_RSAPUBLICKEYBLOB(const RSAPUBLICKEYBLOB *blob);
RSA *RSA_new_from_RSAPRIVATEKEYBLOB(const RSAPRIVATEKEYBLOB *blob);
int RSA_set_RSAPUBLICKEYBLOB(RSA *rsa, const RSAPUBLICKEYBLOB *blob);
int RSA_set_RSAPRIVATEKEYBLOB(RSA *rsa, const RSAPRIVATEKEYBLOB *blob);
int RSA_get_RSAPUBLICKEYBLOB(RSA *rsa, RSAPUBLICKEYBLOB *blob);
RSA *RSA_new_from_RSAPRIVATEKEYBLOB(const RSAPRIVATEKEYBLOB *blob);
int RSA_set_RSAPRIVATEKEYBLOB(RSA *rsa, const RSAPRIVATEKEYBLOB *blob);
int RSA_get_RSAPRIVATEKEYBLOB(RSA *rsa, RSAPRIVATEKEYBLOB *blob);
# endif
# ifndef OPENSSL_NO_EC
EC_KEY *EC_KEY_new_from_ECCPUBLICKEYBLOB(const ECCPUBLICKEYBLOB *blob);
EC_KEY *EC_KEY_new_from_ECCPRIVATEKEYBLOB(const ECCPRIVATEKEYBLOB *blob);
int EC_KEY_set_ECCPUBLICKEYBLOB(EC_KEY *ec_key, const ECCPUBLICKEYBLOB *blob);
int EC_KEY_get_ECCPUBLICKEYBLOB(EC_KEY *ec_key, ECCPUBLICKEYBLOB *blob);
EC_KEY *EC_KEY_new_from_ECCPRIVATEKEYBLOB(const ECCPRIVATEKEYBLOB *blob);
int EC_KEY_set_ECCPRIVATEKEYBLOB(EC_KEY *ec_key, const ECCPRIVATEKEYBLOB *blob);
int EC_KEY_get_ECCPRIVATEKEYBLOB(EC_KEY *ec_key, ECCPRIVATEKEYBLOB *blob);
# ifndef OPENSSL_NO_SM2
SM2CiphertextValue *SM2CiphertextValue_new_from_ECCCIPHERBLOB(const ECCCIPHERBLOB *blob);
int SM2CiphertextValue_set_ECCCIPHERBLOB(SM2CiphertextValue *cv, const ECCCIPHERBLOB *blob);
int SM2CiphertextValue_get_ECCCIPHERBLOB(const SM2CiphertextValue *cv, ECCCIPHERBLOB *blob);
# endif
# ifndef OPENSSL_NO_ECIES
ECIES_CIPHERTEXT_VALUE *ECIES_CIPHERTEXT_VALUE_new_from_ECCCIPHERBLOB(const ECCCIPHERBLOB *blob);
int ECIES_CIPHERTEXT_VALUE_set_ECCCIPHERBLOB(ECIES_CIPHERTEXT_VALUE *cv, const ECCCIPHERBLOB *blob);
int ECIES_CIPHERTEXT_VALUE_get_ECCCIPHERBLOB(const ECIES_CIPHERTEXT_VALUE *cv, ECCCIPHERBLOB *blob);
# endif
ECDSA_SIG *ECDSA_SIG_new_from_ECCSIGNATUREBLOB(const ECCSIGNATUREBLOB *blob);
int ECDSA_SIG_get_ECCSIGNATUREBLOB(const ECDSA_SIG *sig, ECCSIGNATUREBLOB *blob);
int ECDSA_SIG_set_ECCSIGNATUREBLOB(ECDSA_SIG *sig, const ECCSIGNATUREBLOB *blob);
int ECCPRIVATEKEYBLOB_set_private_key(ECCPRIVATEKEYBLOB *blob, const BIGNUM *priv_key);
ECCCIPHERBLOB *d2i_ECCCIPHERBLOB(ECCCIPHERBLOB **a, const unsigned char **pp, long length);
int i2d_ECCCIPHERBLOB(ECCCIPHERBLOB *a, unsigned char **pp);
ECCCIPHERBLOB *d2i_ECCCIPHERBLOB_bio(BIO *bp, ECCCIPHERBLOB **a);
int i2d_ECCCIPHERBLOB_bio(BIO *bp, ECCCIPHERBLOB *a);
ECCSIGNATUREBLOB *d2i_ECCSIGNATUREBLOB(ECCSIGNATUREBLOB **a, const unsigned char **pp, long length);
int i2d_ECCSIGNATUREBLOB(ECCSIGNATUREBLOB *a, unsigned char **pp);
ECCSIGNATUREBLOB *d2i_ECCSIGNATUREBLOB_bio(BIO *bp, ECCSIGNATUREBLOB **a);
int i2d_ECCSIGNATUREBLOB_bio(BIO *fp, ECCSIGNATUREBLOB *a);
# ifndef OPENSSL_NO_STDIO
ECCCIPHERBLOB *d2i_ECCCIPHERBLOB_fp(FILE *fp, ECCCIPHERBLOB **a);
int i2d_ECCCIPHERBLOB_fp(FILE *fp, ECCCIPHERBLOB *a);
ECCSIGNATUREBLOB *d2i_ECCSIGNATUREBLOB_fp(FILE *fp, ECCSIGNATUREBLOB **a);
int i2d_ECCSIGNATUREBLOB_fp(FILE *fp, ECCSIGNATUREBLOB *a);
# endif
# endif
#endif
/* BEGIN ERROR CODES */
/*
@@ -130,178 +194,105 @@ int ERR_load_GMAPI_strings(void);
/* Error codes for the GMAPI functions. */
/* Function codes. */
# define GMAPI_F_ECDSA_SIG_GET_ECCSIGNATURE 100
# define GMAPI_F_ECDSA_SIG_GET_ECCSIGNATUREBLOB 101
# define GMAPI_F_ECDSA_SIG_NEW_FROM_ECCSIGNATURE 102
# define GMAPI_F_ECDSA_SIG_NEW_FROM_ECCSIGNATUREBLOB 103
# define GMAPI_F_ECDSA_SIG_SET_ECCSIGNATURE 104
# define GMAPI_F_ECDSA_SIG_SET_ECCSIGNATUREBLOB 105
# define GMAPI_F_EC_KEY_GET_ECCPRIVATEKEYBLOB 106
# define GMAPI_F_EC_KEY_GET_ECCPUBLICKEYBLOB 107
# define GMAPI_F_EC_KEY_GET_ECCREFPRIVATEKEY 108
# define GMAPI_F_EC_KEY_GET_ECCREFPUBLICKEY 109
# define GMAPI_F_EC_KEY_NEW_FROM_ECCPRIVATEKEYBLOB 110
# define GMAPI_F_EC_KEY_NEW_FROM_ECCPUBLICKEYBLOB 111
# define GMAPI_F_EC_KEY_NEW_FROM_ECCREFPRIVATEKEY 112
# define GMAPI_F_EC_KEY_NEW_FROM_ECCREFPUBLICKEY 113
# define GMAPI_F_EC_KEY_SET_ECCPRIVATEKEYBLOB 114
# define GMAPI_F_EC_KEY_SET_ECCPUBLICKEYBLOB 115
# define GMAPI_F_EC_KEY_SET_ECCREFPRIVATEKEY 116
# define GMAPI_F_EC_KEY_SET_ECCREFPUBLICKEY 117
# define GMAPI_F_RSA_GET_RSAPRIVATEKEYBLOB 118
# define GMAPI_F_RSA_GET_RSAPUBLICKEYBLOB 119
# define GMAPI_F_RSA_GET_RSAREFPRIVATEKEY 120
# define GMAPI_F_RSA_GET_RSAREFPUBLICKEY 121
# define GMAPI_F_RSA_NEW_FROM_RSAPRIVATEKEYBLOB 122
# define GMAPI_F_RSA_NEW_FROM_RSAPUBLICKEYBLOB 123
# define GMAPI_F_RSA_NEW_FROM_RSAREFPRIVATEKEY 124
# define GMAPI_F_RSA_NEW_FROM_RSAREFPUBLICKEY 125
# define GMAPI_F_RSA_SET_RSAPRIVATEKEYBLOB 126
# define GMAPI_F_RSA_SET_RSAPUBLICKEYBLOB 127
# define GMAPI_F_RSA_SET_RSAREFPRIVATEKEY 128
# define GMAPI_F_RSA_SET_RSAREFPUBLICKEY 129
# define GMAPI_F_SAF_BASE64_CREATEBASE64OBJ 130
# define GMAPI_F_SAF_BASE64_DECODE 131
# define GMAPI_F_SAF_BASE64_DECODEFINAL 132
# define GMAPI_F_SAF_BASE64_DECODEUPDATE 133
# define GMAPI_F_SAF_BASE64_ENCODE 134
# define GMAPI_F_SAF_BASE64_ENCODEFINAL 135
# define GMAPI_F_SAF_BASE64_ENCODEUPDATE 136
# define GMAPI_F_SAF_CREATESYMMKEYOBJ 137
# define GMAPI_F_SAF_ECCPUBLICKEYENC 138
# define GMAPI_F_SAF_ECCPUBLICKEYENCBYCERT 139
# define GMAPI_F_SAF_ECCSIGN 140
# define GMAPI_F_SAF_ECCVERIFYSIGN 141
# define GMAPI_F_SAF_ECCVERIFYSIGNBYCERT 142
# define GMAPI_F_SAF_GENECCKEYPAIR 143
# define GMAPI_F_SAF_GENERATEAGREEMENTDATAWITHECC 144
# define GMAPI_F_SAF_GENERATEKEYWITHECC 145
# define GMAPI_F_SAF_GETECCPUBLICKEY 146
# define GMAPI_F_SAF_MACFINAL 147
# define GMAPI_F_SAF_MACUPDATE 148
# define GMAPI_F_SAF_PKCS7_DECODEDIGESTEDDATA 149
# define GMAPI_F_SAF_PKCS7_ENCODEDIGESTEDDATA 150
# define GMAPI_F_SAF_SYMMDECRYPTUPDATE 151
# define GMAPI_F_SAF_SYMMENCRYPTUPDATE 152
# define GMAPI_F_SKF_CLOSEHANDLE 153
# define GMAPI_F_SKF_DECRYPT 154
# define GMAPI_F_SKF_DECRYPTFINAL 155
# define GMAPI_F_SKF_DECRYPTINIT 156
# define GMAPI_F_SKF_DECRYPTUPDATE 157
# define GMAPI_F_SKF_DIGEST 158
# define GMAPI_F_SKF_DIGESTFINAL 159
# define GMAPI_F_SKF_DIGESTINIT 160
# define GMAPI_F_SKF_DIGESTUPDATE 161
# define GMAPI_F_SKF_ENCRYPT 162
# define GMAPI_F_SKF_ENCRYPTFINAL 163
# define GMAPI_F_SKF_ENCRYPTINIT 164
# define GMAPI_F_SKF_ENCRYPTUPDATE 165
# define GMAPI_F_SKF_EXTECCDECRYPT 166
# define GMAPI_F_SKF_EXTECCENCRYPT 167
# define GMAPI_F_SKF_EXTECCSIGN 168
# define GMAPI_F_SKF_EXTECCVERIFY 169
# define GMAPI_F_SKF_EXTRSAPRIKEYOPERATION 170
# define GMAPI_F_SKF_EXTRSAPUBKEYOPERATION 171
# define GMAPI_F_SKF_GENEXTECCKEYPAIR 172
# define GMAPI_F_SKF_GENEXTRSAKEY 173
# define GMAPI_F_SKF_GENRANDOM 174
# define GMAPI_F_SKF_GETDEVINFO 175
# define GMAPI_F_SKF_GETDEVSTATE 176
# define GMAPI_F_SKF_HANDLE_GET_CBCMAC_CTX 177
# define GMAPI_F_SKF_HANDLE_GET_CIPHER 178
# define GMAPI_F_SKF_HANDLE_GET_CIPHER_CTX 179
# define GMAPI_F_SKF_HANDLE_GET_KEY 180
# define GMAPI_F_SKF_HANDLE_GET_MD_CTX 181
# define GMAPI_F_SKF_MAC 182
# define GMAPI_F_SKF_MACFINAL 183
# define GMAPI_F_SKF_MACINIT 184
# define GMAPI_F_SKF_MACUPDATE 185
# define GMAPI_F_SKF_SETSYMMKEY 186
# define GMAPI_F_SM2CIPHERTEXTVALUE_GET_ECCCIPHER 193
# define GMAPI_F_SM2CIPHERTEXTVALUE_GET_ECCCIPHERBLOB 194
# define GMAPI_F_SM2CIPHERTEXTVALUE_NEW_FROM_ECCCIPHER 195
# define GMAPI_F_SM2CIPHERTEXTVALUE_NEW_FROM_ECCCIPHERBLOB 196
# define GMAPI_F_SM2CIPHERTEXTVALUE_SET_ECCCIPHER 197
# define GMAPI_F_SM2CIPHERTEXTVALUE_SET_ECCCIPHERBLOB 198
# define GMAPI_F_SM2_CIPHERTEXT_VALUE_GET_ECCCIPHER 187
# define GMAPI_F_SM2_CIPHERTEXT_VALUE_GET_ECCCIPHERBLOB 188
# define GMAPI_F_SM2_CIPHERTEXT_VALUE_NEW_FROM_ECCCIPHER 189
# define GMAPI_F_SM2_CIPHERTEXT_VALUE_NEW_FROM_ECCCIPHERBLOB 190
# define GMAPI_F_SM2_CIPHERTEXT_VALUE_SET_ECCCIPHER 191
# define GMAPI_F_SM2_CIPHERTEXT_VALUE_SET_ECCCIPHERBLOB 192
# define GMAPI_F_D2I_ECCCIPHER 141
# define GMAPI_F_D2I_ECCCIPHERBLOB 158
# define GMAPI_F_D2I_ECCCIPHERBLOB_BIO 151
# define GMAPI_F_D2I_ECCCIPHERBLOB_FP 152
# define GMAPI_F_D2I_ECCSIGNATURE 142
# define GMAPI_F_D2I_ECCSIGNATUREBLOB 159
# define GMAPI_F_D2I_ECCSIGNATUREBLOB_BIO 160
# define GMAPI_F_D2I_ECCSIGNATUREBLOB_FP 153
# define GMAPI_F_ECCPRIVATEKEYBLOB_SET_PRIVATE_KEY 100
# define GMAPI_F_ECDSA_SIG_GET_ECCSIGNATURE 101
# define GMAPI_F_ECDSA_SIG_GET_ECCSIGNATUREBLOB 102
# define GMAPI_F_ECDSA_SIG_NEW_FROM_ECCSIGNATURE 103
# define GMAPI_F_ECDSA_SIG_NEW_FROM_ECCSIGNATUREBLOB 104
# define GMAPI_F_ECDSA_SIG_SET_ECCSIGNATURE 105
# define GMAPI_F_ECDSA_SIG_SET_ECCSIGNATUREBLOB 106
# define GMAPI_F_ECIES_CIPHERTEXT_VALUE_GET_ECCCIPHER 145
# define GMAPI_F_ECIES_CIPHERTEXT_VALUE_GET_ECCCIPHERBLOB 150
# define GMAPI_F_ECIES_CIPHERTEXT_VALUE_NEW_FROM_ECCCIPHER 146
# define GMAPI_F_ECIES_CIPHERTEXT_VALUE_NEW_FROM_ECCCIPHERBLOB 148
# define GMAPI_F_ECIES_CIPHERTEXT_VALUE_SET_ECCCIPHER 147
# define GMAPI_F_ECIES_CIPHERTEXT_VALUE_SET_ECCCIPHERBLOB 149
# define GMAPI_F_EC_KEY_GET_ECCPRIVATEKEYBLOB 107
# define GMAPI_F_EC_KEY_GET_ECCPUBLICKEYBLOB 108
# define GMAPI_F_EC_KEY_GET_ECCREFPRIVATEKEY 109
# define GMAPI_F_EC_KEY_GET_ECCREFPUBLICKEY 110
# define GMAPI_F_EC_KEY_NEW_FROM_ECCPRIVATEKEYBLOB 111
# define GMAPI_F_EC_KEY_NEW_FROM_ECCPUBLICKEYBLOB 112
# define GMAPI_F_EC_KEY_NEW_FROM_ECCREFPRIVATEKEY 113
# define GMAPI_F_EC_KEY_NEW_FROM_ECCREFPUBLICKEY 114
# define GMAPI_F_EC_KEY_SET_ECCPRIVATEKEYBLOB 115
# define GMAPI_F_EC_KEY_SET_ECCPUBLICKEYBLOB 116
# define GMAPI_F_EC_KEY_SET_ECCREFPRIVATEKEY 117
# define GMAPI_F_EC_KEY_SET_ECCREFPUBLICKEY 118
# define GMAPI_F_EVP_CIPHER_CTX_GET_SGD 119
# define GMAPI_F_EVP_CIPHER_GET_SGD 120
# define GMAPI_F_EVP_MD_GET_SGD 121
# define GMAPI_F_EVP_PKEY_GET_SGD 140
# define GMAPI_F_I2D_ECCCIPHER 143
# define GMAPI_F_I2D_ECCCIPHERBLOB 154
# define GMAPI_F_I2D_ECCCIPHERBLOB_BIO 155
# define GMAPI_F_I2D_ECCCIPHERBLOB_FP 156
# define GMAPI_F_I2D_ECCSIGNATURE 144
# define GMAPI_F_I2D_ECCSIGNATUREBLOB 161
# define GMAPI_F_I2D_ECCSIGNATUREBLOB_BIO 162
# define GMAPI_F_I2D_ECCSIGNATUREBLOB_FP 157
# define GMAPI_F_RSA_GET_RSAPRIVATEKEYBLOB 122
# define GMAPI_F_RSA_GET_RSAPUBLICKEYBLOB 123
# define GMAPI_F_RSA_GET_RSAREFPRIVATEKEY 124
# define GMAPI_F_RSA_GET_RSAREFPUBLICKEY 125
# define GMAPI_F_RSA_NEW_FROM_RSAPRIVATEKEYBLOB 126
# define GMAPI_F_RSA_NEW_FROM_RSAPUBLICKEYBLOB 127
# define GMAPI_F_RSA_NEW_FROM_RSAREFPRIVATEKEY 128
# define GMAPI_F_RSA_NEW_FROM_RSAREFPUBLICKEY 129
# define GMAPI_F_RSA_SET_RSAPRIVATEKEYBLOB 130
# define GMAPI_F_RSA_SET_RSAPUBLICKEYBLOB 131
# define GMAPI_F_RSA_SET_RSAREFPRIVATEKEY 132
# define GMAPI_F_RSA_SET_RSAREFPUBLICKEY 133
# define GMAPI_F_SM2CIPHERTEXTVALUE_GET_ECCCIPHER 134
# define GMAPI_F_SM2CIPHERTEXTVALUE_GET_ECCCIPHERBLOB 135
# define GMAPI_F_SM2CIPHERTEXTVALUE_NEW_FROM_ECCCIPHER 136
# define GMAPI_F_SM2CIPHERTEXTVALUE_NEW_FROM_ECCCIPHERBLOB 137
# define GMAPI_F_SM2CIPHERTEXTVALUE_SET_ECCCIPHER 138
# define GMAPI_F_SM2CIPHERTEXTVALUE_SET_ECCCIPHERBLOB 139
/* Reason codes. */
# define GMAPI_R_BUFFER_TOO_SMALL 100
# define GMAPI_R_CBCMAC_FAILURE 101
# define GMAPI_R_CTX_NOT_CREATED 102
# define GMAPI_R_DECODE_EC_PRIVATE_KEY_FAILED 103
# define GMAPI_R_DECODE_EC_PUBLIC_KEY_FAILED 104
# define GMAPI_R_DECRYPT_FAILED 105
# define GMAPI_R_ENCODE_CIPHERTEXT_FAILED 106
# define GMAPI_R_ENCODE_FAILED 107
# define GMAPI_R_ENCODE_RSA_PUBLIC_KEY_FAILED 108
# define GMAPI_R_ENCODE_SIGNATURE_FAILED 109
# define GMAPI_R_ENCRYPT_FAILED 110
# define GMAPI_R_FAIL 111
# define GMAPI_R_GEN_RANDOM 112
# define GMAPI_R_GEN_RSA_FAILED 113
# define GMAPI_R_GET_PRIVATE_KEY_FAILED 114
# define GMAPI_R_GET_PUBLIC_KEY_FAILED 115
# define GMAPI_R_INT_OVERFLOW 116
# define GMAPI_R_INVALID_ALGID 117
# define GMAPI_R_INVALID_ALGOR 118
# define GMAPI_R_INVALID_ARGUMENTS 119
# define GMAPI_R_INVALID_BIGNUM_LENGTH 120
# define GMAPI_R_INVALID_BLOB 121
# define GMAPI_R_INVALID_CIPHERTEXT 122
# define GMAPI_R_INVALID_CIPHERTEXT_LENGTH 123
# define GMAPI_R_INVALID_CIPHERTEXT_MAC 124
# define GMAPI_R_INVALID_CIPHERTEXT_POINT 125
# define GMAPI_R_INVALID_CIPHER_CTX_HANDLE 126
# define GMAPI_R_INVALID_CIPHETEXT_LENGTH 127
# define GMAPI_R_INVALID_CONTEXT 128
# define GMAPI_R_INVALID_DIGEST_ALGOR 129
# define GMAPI_R_INVALID_DIGEST_LENGTH 130
# define GMAPI_R_INVALID_ECC_PRIVATE_KEY 131
# define GMAPI_R_INVALID_ECC_PUBLIC_KEY 132
# define GMAPI_R_INVALID_EC_KEY 133
# define GMAPI_R_INVALID_EC_PRIVATE_KEY 134
# define GMAPI_R_INVALID_EC_PUBLIC_KEY 135
# define GMAPI_R_INVALID_FEED_BIT_LENGTH 136
# define GMAPI_R_INVALID_HANDLE 137
# define GMAPI_R_INVALID_HANDLE_ALGOR 138
# define GMAPI_R_INVALID_HANDLE_MAGIC 139
# define GMAPI_R_INVALID_HANDLE_TYPE 140
# define GMAPI_R_INVALID_HASH_HANDLE 141
# define GMAPI_R_INVALID_ID_LENGTH 142
# define GMAPI_R_INVALID_INPUT_LENGTH 143
# define GMAPI_R_INVALID_IV_LENGTH 144
# define GMAPI_R_INVALID_KEY_HANDLE 145
# define GMAPI_R_INVALID_KEY_LENGTH 146
# define GMAPI_R_INVALID_KEY_USAGE 147
# define GMAPI_R_INVALID_LENGTH 148
# define GMAPI_R_INVALID_MAC_HANDLE 149
# define GMAPI_R_INVALID_PLAINTEXT_LENGTH 150
# define GMAPI_R_INVALID_PRIVATE_KEY 151
# define GMAPI_R_INVALID_PUBLIC_KEY 152
# define GMAPI_R_INVALID_RANDOM_LENGTH 153
# define GMAPI_R_INVALID_RSA_KEY_LENGTH 154
# define GMAPI_R_INVALID_RSA_PRIVATE_KEY 155
# define GMAPI_R_INVALID_RSA_PUBLIC_KEY 156
# define GMAPI_R_INVALID_SIGNATURE 157
# define GMAPI_R_INVALID_SM2_CIPHERTEXT 158
# define GMAPI_R_INVALID_SM2_SIGNATURE 159
# define GMAPI_R_MAC_FAILURE 160
# define GMAPI_R_MALLOC_FAILED 161
# define GMAPI_R_NOT_CONVERTABLE 162
# define GMAPI_R_NO_PUBLIC_KEY 163
# define GMAPI_R_NULL_ARGUMENT 164
# define GMAPI_R_OPERATION_NOT_INITIALIZED 165
# define GMAPI_R_SAF_ERROR 166
# define GMAPI_R_SIGN_FAILED 167
# define GMAPI_R_VERIFY_NOT_PASS 168
# define GMAPI_R_DECODE_EC_PRIVATE_KEY_FAILED 101
# define GMAPI_R_DECODE_EC_PUBLIC_KEY_FAILED 102
# define GMAPI_R_ENCODE_RSA_PUBLIC_KEY_FAILED 103
# define GMAPI_R_INVALID_ALGOR 104
# define GMAPI_R_INVALID_BIGNUM_LENGTH 105
# define GMAPI_R_INVALID_CIPHERTEXT_LENGTH 106
# define GMAPI_R_INVALID_CIPHERTEXT_MAC 107
# define GMAPI_R_INVALID_CIPHERTEXT_POINT 108
# define GMAPI_R_INVALID_CIPHETEXT_LENGTH 109
# define GMAPI_R_INVALID_EC_KEY 110
# define GMAPI_R_INVALID_EC_PRIVATE_KEY 111
# define GMAPI_R_INVALID_EC_PUBLIC_KEY 112
# define GMAPI_R_INVALID_KEY_LENGTH 113
# define GMAPI_R_INVALID_PRIVATE_KEY 114
# define GMAPI_R_INVALID_PUBLIC_KEY 115
# define GMAPI_R_INVALID_RSA_KEY_LENGTH 116
# define GMAPI_R_INVALID_RSA_PRIVATE_KEY 117
# define GMAPI_R_INVALID_RSA_PUBLIC_KEY 118
# define GMAPI_R_INVALID_SIGNATURE 119
# define GMAPI_R_INVALID_SKF_CIPHERTEXT 129
# define GMAPI_R_INVALID_SKF_EC_CIPHERTEXT 128
# define GMAPI_R_INVALID_SM2_CIPHERTEXT 120
# define GMAPI_R_INVALID_SM2_CIPHERTEXT_MAC_LENGTH 127
# define GMAPI_R_INVALID_SM2_PRIVATE_KEY 121
# define GMAPI_R_INVALID_SM2_SIGNATURE 122
# define GMAPI_R_MALLOC_FAILED 123
# define GMAPI_R_NOT_CONVERTABLE 124
# define GMAPI_R_NOT_IMPLEMENTED 130
# define GMAPI_R_NOT_SUPPORTED_GMAPI_CIPHER 125
# define GMAPI_R_NOT_SUPPORTED_PKEY 126
# ifdef __cplusplus
}
# endif
#endif
#endif

View File

@@ -50,10 +50,16 @@
#ifndef HEADER_GMSAF_H
#define HEADER_GMSAF_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SAF
#include <stdio.h>
#include <openssl/sgd.h>
#include <openssl/saf.h>
#define SAF_MAX_EC_CIPHERTEXT_LENGTH 136
#ifdef __cplusplus
extern "C" {
#endif
@@ -188,3 +194,4 @@ int ERR_load_SAF_strings(void);
}
# endif
#endif
#endif

View File

@@ -50,41 +50,36 @@
#ifndef HEADER_GMSDF_H
#define HEADER_GMSDF_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SDF
#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
#define SDF_MIN_KEY_INDEX 1 /* defined by GM/T 0018 */
#define SDF_MAX_KEY_INDEX 32 /* defined by GmSSL */
#define SDF_MIN_PASSWORD_LENGTH 8 /* defined by GM/T 0018 */
#define SDF_MAX_PASSWORD_LENGTH 255 /* defined by GmSSL */
#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);
int SDF_LoadLibrary(char *so_path, char *vendor);
int SDF_UnloadLibrary(void);
int SDF_ImportKey(void *hSessionHandle, unsigned char *pucKey,
unsigned int uiKeyLength, void **phKeyHandle);
int SDF_PrintDeviceInfo(DEVICEINFO *devInfo);
int SDF_PrintRSAPublicKey(RSArefPublicKey *ref);
int SDF_PrintRSAPrivateKey(RSArefPrivateKey *ref);
int SDF_PrintECCPublicKey(ECCrefPublicKey *ref);
int SDF_PrintECCPrivateKey(ECCrefPrivateKey *ref);
int SDF_PrintECCCipher(ECCCipher *cipher);
int SDF_PrintECCSignature(ECCSignature *sig);
int SDF_GetErrorString(int err, char **str);
//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 */
/*
@@ -97,6 +92,8 @@ int ERR_load_SDF_strings(void);
/* Error codes for the SDF functions. */
/* Function codes. */
# define SDF_F_SANSEC_DECODE_ECCCIPHER 149
# define SDF_F_SANSEC_ENCODE_ECCCIPHER 150
# define SDF_F_SDF_CALCULATEMAC 100
# define SDF_F_SDF_CLOSEDEVICE 101
# define SDF_F_SDF_CLOSESESSION 102
@@ -139,6 +136,7 @@ int ERR_load_SDF_strings(void);
# define SDF_F_SDF_INTERNALPUBLICKEYOPERATION_RSA 147
# define SDF_F_SDF_INTERNALSIGN_ECC 139
# define SDF_F_SDF_INTERNALVERIFY_ECC 140
# define SDF_F_SDF_LOADLIBRARY 148
# define SDF_F_SDF_METHOD_LOAD_LIBRARY 141
# define SDF_F_SDF_OPENDEVICE 142
# define SDF_F_SDF_OPENSESSION 143
@@ -147,18 +145,121 @@ int ERR_load_SDF_strings(void);
# define SDF_F_SDF_WRITEFILE 146
/* Reason codes. */
# define SDF_R_ALGORITHM_MODE_NOT_SUPPORTED 111
# define SDF_R_ALGORITHM_NOT_SUPPORTED 112
# define SDF_R_BUFFER_TOO_SMALL 113
# define SDF_R_COMMUNICATION_FAILURE 114
# define SDF_R_DSO_LOAD_FAILURE 110
# define SDF_R_ENCRYPT_DATA_ERROR 115
# define SDF_R_ERROR 116
# define SDF_R_FILE_ALREADY_EXIST 117
# define SDF_R_FILE_NOT_EXIST 118
# define SDF_R_HARDWARE_ERROR 119
# define SDF_R_INVALID_CIPHER_ALGOR 143
# define SDF_R_INVALID_DIGEST_ALGOR 144
# define SDF_R_INVALID_FILE_OFFSET 120
# define SDF_R_INVALID_FILE_SIZE 121
# define SDF_R_INVALID_INPUT_ARGUMENT 122
# define SDF_R_INVALID_KEY 123
# define SDF_R_INVALID_KEY_LENGTH 100
# define SDF_R_INVALID_KEY_TYPE 124
# define SDF_R_INVALID_OUTPUT_ARGUMENT 125
# define SDF_R_INVALID_SANSEC_ECCCIPHER_LENGTH 207
# define SDF_R_INVALID_SDF_LIBRARY 101
# define SDF_R_INVALID_SESSION_HANDLE 102
# define SDF_R_KEY_NOT_EXIST 126
# define SDF_R_LOAD_LIBRARY_FAILURE 107
# define SDF_R_MAC_ERROR 127
# define SDF_R_METHOD_OPERATION_FAILURE 108
# define SDF_R_MULTI_STEP_OPERATION_ERROR 128
# define SDF_R_NOT_INITIALIZED 109
# define SDF_R_NOT_SUPPORTED 103
# define SDF_R_NOT_SUPPORTED_CIPHER_ALGOR 208
# define SDF_R_NOT_SUPPORTED_DIGEST_ALGOR 209
# define SDF_R_NOT_SUPPORTED_ECC_ALGOR 210
# define SDF_R_NOT_SUPPORTED_PKEY_ALGOR 211
# define SDF_R_NO_PRIVATE_KEY_ACCESS_RIGHT 129
# define SDF_R_OPEN_DEVICE_FAILURE 130
# define SDF_R_OPEN_SESSION_FAILURE 131
# define SDF_R_OPERATION_FAILED 104
# define SDF_R_OPERATION_NOT_SUPPORTED 132
# define SDF_R_PRIVATE_KEY_OPERATION_FAILURE 133
# define SDF_R_PRKERR 134
# define SDF_R_PUBLIC_KEY_OPERATION_FAILURE 135
# define SDF_R_RANDOM_GENERATION_ERROR 136
# define SDF_R_SANSEC_BASE 145
# define SDF_R_SANSEC_CARD_ALGOR_NOT_SUPPORTED 146
# define SDF_R_SANSEC_CARD_ALG_MODE_NOT_SUPPORTED 147
# define SDF_R_SANSEC_CARD_BASE 148
# define SDF_R_SANSEC_CARD_BUFFER_TOO_SMALL 149
# define SDF_R_SANSEC_CARD_COMMMUCATION_FAILED 150
# define SDF_R_SANSEC_CARD_CRYPTO_NOT_INITED 151
# define SDF_R_SANSEC_CARD_DATA_PADDING_ERROR 152
# define SDF_R_SANSEC_CARD_DATA_SIZE 153
# define SDF_R_SANSEC_CARD_DEVICE_STATUS_ERROR 154
# define SDF_R_SANSEC_CARD_DEVICE_STATUS_ERROR_05 155
# define SDF_R_SANSEC_CARD_FILE_NOT_EXIST 156
# define SDF_R_SANSEC_CARD_FILE_OFFSET_ERROR 157
# define SDF_R_SANSEC_CARD_FILE_SIZE_ERROR 158
# define SDF_R_SANSEC_CARD_HARDWARE_FAILURE 159
# define SDF_R_SANSEC_CARD_KEY_ERROR 160
# define SDF_R_SANSEC_CARD_KEY_NOT_EXIST 161
# define SDF_R_SANSEC_CARD_KEY_TYPE_ERROR 162
# define SDF_R_SANSEC_CARD_LOGIN_ERROR 163
# define SDF_R_SANSEC_CARD_LOGIN_ERROR_05 164
# define SDF_R_SANSEC_CARD_MANAGEMENT_DENYED 165
# define SDF_R_SANSEC_CARD_MANAGEMENT_DENYED_05 166
# define SDF_R_SANSEC_CARD_NOT_SUPPORTED 167
# define SDF_R_SANSEC_CARD_OPEN_DEVICE_FAILED 168
# define SDF_R_SANSEC_CARD_OPEN_SESSION_FAILED 169
# define SDF_R_SANSEC_CARD_OPERATION_DENYED 170
# define SDF_R_SANSEC_CARD_OPERATION_DENYED_05 171
# define SDF_R_SANSEC_CARD_PARAMENT_ERROR 172
# define SDF_R_SANSEC_CARD_PARAMENT_ERROR_05 173
# define SDF_R_SANSEC_CARD_PRIVATE_KEY_ACCESS_DENYED 174
# define SDF_R_SANSEC_CARD_PRIVATE_KEY_OPERATION_ERROR 175
# define SDF_R_SANSEC_CARD_PUBLIC_KEY_OPERATION_ERROR 176
# define SDF_R_SANSEC_CARD_READER_BASE 177
# define SDF_R_SANSEC_CARD_READER_CARD_INSERT 178
# define SDF_R_SANSEC_CARD_READER_CARD_INSERT_TYPE 179
# define SDF_R_SANSEC_CARD_READER_NO_CARD 180
# define SDF_R_SANSEC_CARD_READER_PIN_ERROR 181
# define SDF_R_SANSEC_CARD_SIGN_ERROR 182
# define SDF_R_SANSEC_CARD_STEP_ERROR 183
# define SDF_R_SANSEC_CARD_SYMMETRIC_ALGOR_ERROR 184
# define SDF_R_SANSEC_CARD_UNKNOW_ERROR 185
# define SDF_R_SANSEC_CARD_USERID_ERROR 186
# define SDF_R_SANSEC_CARD_USERID_ERROR_05 187
# define SDF_R_SANSEC_CARD_VERIFY_ERROR 188
# define SDF_R_SANSEC_CONFIG_ERROR 189
# define SDF_R_SANSEC_CONNECT_ERROR 190
# define SDF_R_SANSEC_FILE_ALREADY_EXIST 191
# define SDF_R_SANSEC_INVALID_AUTHENCODE 192
# define SDF_R_SANSEC_INVALID_COMMAND 193
# define SDF_R_SANSEC_INVALID_PARAMETERS 194
# define SDF_R_SANSEC_INVALID_USER 195
# define SDF_R_SANSEC_NO_AVAILABLE_CSM 196
# define SDF_R_SANSEC_NO_AVAILABLE_HSM 197
# define SDF_R_SANSEC_PROTOCOL_VERSION_ERROR 198
# define SDF_R_SANSEC_SEM_TIMEOUT 199
# define SDF_R_SANSEC_SET_SOCKET_OPTION_ERROR 200
# define SDF_R_SANSEC_SOCKET_RECV_0 201
# define SDF_R_SANSEC_SOCKET_RECV_ERROR 202
# define SDF_R_SANSEC_SOCKET_SEND_ERROR 203
# define SDF_R_SANSEC_SOCKET_TIMEOUT 204
# define SDF_R_SANSEC_SYNC_ERROR 205
# define SDF_R_SANSEC_SYNC_LOGIN_ERROR 206
# define SDF_R_SDF_METHOD_RETURN_FAILURE 105
# define SDF_R_SDF_OPERATION_FAILED 106
# define SDF_R_SIGNING_FAILURE 137
# define SDF_R_SUCCESS 138
# define SDF_R_SYMMETRIC_OPERATION_FAILURE 139
# define SDF_R_UNNOWN_ERROR 140
# define SDF_R_VERIFICATION_FAILURE 141
# define SDF_R_WRITE_FILE_FAILURE 142
# ifdef __cplusplus
}
# endif
#endif
#endif

View File

@@ -50,47 +50,64 @@
#ifndef HEADER_GMSKF_H
#define HEADER_GMSKF_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SKF
#include <stdio.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
#define SKF_DEV_STATE_ABSENT 0x00000000
#define SKF_DEV_STATE_PRESENT 0x00000001
#define SKF_DEV_STATE_UNKNOW 0x00000010
#ifndef SKF_NO_GMSSL
#define CONTAINER_TYPE_UNDEF 0
#define CONTAINER_TYPE_RSA 1
#define CONTAINER_TYPE_ECC 2
#endif
#define SKF_CONTAINER_TYPE_UNDEF 0
#define SKF_CONTAINER_TYPE_RSA 1
#define SKF_CONTAINER_TYPE_ECC 2
#define SKF_ENVELOPEDKEYBLOB_VERSION 1
#define SKF_AUTHKEY_LENGTH 16
#define SKF_AUTHRAND_LENGTH 16
#define SKF_MAX_FILE_SIZE (256*1024)
#define SKF_MAX_CERTIFICATE_SIZE (8*1024)
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
union {
ECCPUBLICKEYBLOB ecc;
RSAPUBLICKEYBLOB rsa;
} u;
} SKF_PUBLICKEYBLOB;
#define SKF_MAX_PUBLICKEYBOLB_LENGTH sizeof(SKF_PUBLICKEYBLOB)
//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);
typedef struct {
char *name;
unsigned char *buf;
int offset;
int length;
} SKF_FILE_OP_PARAMS;
ULONG DEVAPI SKF_LoadLibrary(LPSTR so_path, LPSTR vendor);
ULONG DEVAPI SKF_UnloadLibrary(void);
ULONG DEVAPI SKF_GetDevStateName(ULONG ulDevState, LPSTR *szName);
ULONG DEVAPI SKF_GetContainerTypeName(ULONG ulContainerType, LPSTR *szName);
ULONG DEVAPI SKF_GetAlgorName(ULONG ulAlgID, LPSTR *szName);
ULONG DEVAPI SKF_PrintDevInfo(DEVINFO *devInfo);
ULONG DEVAPI SKF_PrintRSAPublicKey(RSAPUBLICKEYBLOB *blob);
ULONG DEVAPI SKF_PrintRSAPrivateKey(RSAPRIVATEKEYBLOB *blob);
ULONG DEVAPI SKF_PrintECCPublicKey(ECCPUBLICKEYBLOB *blob);
ULONG DEVAPI SKF_PrintECCPrivateKey(ECCPRIVATEKEYBLOB *blob);
ULONG DEVAPI SKF_PrintECCCipher(ECCCIPHERBLOB *blob);
ULONG DEVAPI SKF_PrintECCSignature(ECCSIGNATUREBLOB *blob);
ULONG DEVAPI SKF_GetErrorString(ULONG ulError, LPSTR *szErrorStr);
ULONG DEVAPI SKF_NewECCCipher(ULONG ulCipherLen, ECCCIPHERBLOB **cipherBlob);
ULONG DEVAPI SKF_NewEnvelopedKey(ULONG ulCipherLen, ENVELOPEDKEYBLOB **envelopedKeyBlob);
/* BEGIN ERROR CODES */
/*
@@ -103,12 +120,168 @@ int ERR_load_SKF_strings(void);
/* Error codes for the SKF functions. */
/* Function codes. */
# define SKF_F_SKF_CANCELWAITFORDEVEVENT 108
# define SKF_F_SKF_CHANGEDEVAUTHKEY 109
# define SKF_F_SKF_CHANGEPIN 110
# define SKF_F_SKF_CLEARSECURESTATE 111
# define SKF_F_SKF_CLOSEAPPLICATION 112
# define SKF_F_SKF_CLOSECONTAINER 113
# define SKF_F_SKF_CLOSEHANDLE 114
# define SKF_F_SKF_CONNECTDEV 115
# define SKF_F_SKF_CREATEAPPLICATION 116
# define SKF_F_SKF_CREATECONTAINER 117
# define SKF_F_SKF_CREATEFILE 118
# define SKF_F_SKF_DECRYPT 119
# define SKF_F_SKF_DECRYPTFINAL 120
# define SKF_F_SKF_DECRYPTINIT 121
# define SKF_F_SKF_DECRYPTUPDATE 122
# define SKF_F_SKF_DELETEAPPLICATION 123
# define SKF_F_SKF_DELETECONTAINER 124
# define SKF_F_SKF_DELETEFILE 125
# define SKF_F_SKF_DEVAUTH 126
# define SKF_F_SKF_DIGEST 127
# define SKF_F_SKF_DIGESTFINAL 128
# define SKF_F_SKF_DIGESTINIT 129
# define SKF_F_SKF_DIGESTUPDATE 130
# define SKF_F_SKF_DISCONNECTDEV 131
# define SKF_F_SKF_ECCDECRYPT 184
# define SKF_F_SKF_ECCEXPORTSESSIONKEY 132
# define SKF_F_SKF_ECCSIGNDATA 133
# define SKF_F_SKF_ECCVERIFY 134
# define SKF_F_SKF_ENCRYPT 135
# define SKF_F_SKF_ENCRYPTFINAL 136
# define SKF_F_SKF_ENCRYPTINIT 137
# define SKF_F_SKF_ENCRYPTUPDATE 138
# define SKF_F_SKF_ENUMAPPLICATION 139
# define SKF_F_SKF_ENUMCONTAINER 140
# define SKF_F_SKF_ENUMDEV 141
# define SKF_F_SKF_ENUMFILES 142
# define SKF_F_SKF_EXPORTCERTIFICATE 143
# define SKF_F_SKF_EXPORTPUBLICKEY 144
# define SKF_F_SKF_EXTECCDECRYPT 145
# define SKF_F_SKF_EXTECCENCRYPT 146
# define SKF_F_SKF_EXTECCSIGN 147
# define SKF_F_SKF_EXTECCVERIFY 148
# define SKF_F_SKF_EXTRSAPRIKEYOPERATION 149
# define SKF_F_SKF_EXTRSAPUBKEYOPERATION 150
# define SKF_F_SKF_GENECCKEYPAIR 151
# define SKF_F_SKF_GENERATEAGREEMENTDATAANDKEYWITHECC 152
# define SKF_F_SKF_GENERATEAGREEMENTDATAWITHECC 153
# define SKF_F_SKF_GENERATEKEYWITHECC 154
# define SKF_F_SKF_GENEXTRSAKEY 155
# define SKF_F_SKF_GENRANDOM 156
# define SKF_F_SKF_GENRSAKEYPAIR 157
# define SKF_F_SKF_GETCONTAINERTYPE 158
# define SKF_F_SKF_GETDEVINFO 100
# define SKF_F_SKF_GETDEVSTATE 159
# define SKF_F_SKF_GETFILEINFO 160
# define SKF_F_SKF_GETPININFO 161
# define SKF_F_SKF_IMPORTCERTIFICATE 162
# define SKF_F_SKF_IMPORTECCKEYPAIR 163
# define SKF_F_SKF_IMPORTECCPRIVATEKEY 103
# define SKF_F_SKF_IMPORTRSAKEYPAIR 164
# define SKF_F_SKF_IMPORTSESSIONKEY 165
# define SKF_F_SKF_LOADLIBRARY 101
# define SKF_F_SKF_LOCKDEV 166
# define SKF_F_SKF_MAC 107
# define SKF_F_SKF_MACFINAL 167
# define SKF_F_SKF_MACINIT 168
# define SKF_F_SKF_MACUPDATE 169
# define SKF_F_SKF_METHOD_LOAD_LIBRARY 104
# define SKF_F_SKF_NEWECCCIPHER 102
# define SKF_F_SKF_NEWENVELOPEDKEY 183
# define SKF_F_SKF_OPENAPPLICATION 170
# define SKF_F_SKF_OPENCONTAINER 171
# define SKF_F_SKF_READFILE 172
# define SKF_F_SKF_RSAEXPORTSESSIONKEY 173
# define SKF_F_SKF_RSASIGNDATA 174
# define SKF_F_SKF_RSAVERIFY 175
# define SKF_F_SKF_SETLABEL 176
# define SKF_F_SKF_SETSYMMKEY 177
# define SKF_F_SKF_TRANSMIT 178
# define SKF_F_SKF_UNBLOCKPIN 179
# define SKF_F_SKF_UNLOCKDEV 180
# define SKF_F_SKF_VERIFYPIN 181
# define SKF_F_SKF_W 105
# define SKF_F_SKF_WAITFORDEVEVENT 106
# define SKF_F_SKF_WRITEFILE 182
/* Reason codes. */
# define SKF_R_APPLICATION_ALREADY_EXIST 110
# define SKF_R_APPLICATION_NOT_EXISAT 111
# define SKF_R_APPLICATION_NOT_EXIST 171
# define SKF_R_BUFFER_TOO_SMALL 112
# define SKF_R_CERTIFICATE_NOT_FOUND 113
# define SKF_R_CSP_IMPORT_PUBLIC_KEY_ERROR 114
# define SKF_R_DECRYPT_INVALID_PADDING 115
# define SKF_R_DEVICE_REMOVED 116
# define SKF_R_DIGEST_ERROR 117
# define SKF_R_DSO_LOAD_FAILURE 105
# define SKF_R_ENVELOPE_PRVATE_KEY_FAILURE 104
# define SKF_R_EXPORT_FAILED 118
# define SKF_R_FAILURE 108
# define SKF_R_FILE_ALREADY_EXIST 119
# define SKF_R_FILE_ERROR 120
# define SKF_R_FILE_NOT_EXIST 121
# define SKF_R_FUNCTION_NOT_SUPPORTED 106
# define SKF_R_HASH_NOT_EQUAL 122
# define SKF_R_IMPORT_ENVELOPED_ECC_PRIVATE_KEY_FAILURE 102
# define SKF_R_INVALID_APPLICATION_NAME 123
# define SKF_R_INVALID_CONTAINER_TYPE 103
# define SKF_R_INVALID_DIGEST_HANDLE 124
# define SKF_R_INVALID_HANDLE 125
# define SKF_R_INVALID_INPUT_LENGTH 126
# define SKF_R_INVALID_INPUT_VALUE 127
# define SKF_R_INVALID_KEY_INFO_TYPE 128
# define SKF_R_INVALID_KEY_USAGE 129
# define SKF_R_INVALID_MAC_LENGTH 130
# define SKF_R_INVALID_MODULUS_LENGTH 131
# define SKF_R_INVALID_NAME_LENGTH 132
# define SKF_R_INVALID_OBJECT 133
# define SKF_R_INVALID_PARAMETER 134
# define SKF_R_INVALID_PIN 135
# define SKF_R_INVALID_PIN_LENGTH 136
# define SKF_R_INVALID_RSA_MODULUS_LENGTH 137
# define SKF_R_INVALID_USER_TYPE 138
# define SKF_R_KEY_NOT_FOUND 139
# define SKF_R_LOAD_LIBRARY_FAILURE 101
# define SKF_R_MEMORY_ERROR 140
# define SKF_R_NOT_INITIALIZED 141
# define SKF_R_NOT_SUPPORTED_CIPHER_ALGOR 168
# define SKF_R_NOT_SUPPORTED_DIGEST_ALGOR 169
# define SKF_R_NOT_SUPPORTED_PKEY_ALGOR 170
# define SKF_R_NO_EVENT 142
# define SKF_R_NO_SPACE 143
# define SKF_R_NULL_ARGUMENT 100
# define SKF_R_OPERATION_NOT_SUPPORTED 144
# define SKF_R_PIN_INCORRECT 145
# define SKF_R_PIN_LOCKED 146
# define SKF_R_RANDOM_GENERATION_FAILED 147
# define SKF_R_READ_FILE_FAILURE 148
# define SKF_R_RSA_DECRYPTION_FAILURE 149
# define SKF_R_RSA_ENCRYPTION_FAILURE 150
# define SKF_R_RSA_KEY_GENERATION_FAILURE 151
# define SKF_R_SKF_METHOD_NOT_INITIALIZED 107
# define SKF_R_SUCCESS 152
# define SKF_R_TIMEOUT 153
# define SKF_R_UNKNOWN_ERROR 109
# define SKF_R_UNKNOWN_VENDOR 158
# define SKF_R_USER_ALREADY_LOGGED_IN 154
# define SKF_R_USER_NOT_LOGGED_IN 155
# define SKF_R_USER_PIN_NOT_INITIALIZED 156
# define SKF_R_WISEC_AUTH_BLOCKED 159
# define SKF_R_WISEC_CERTNOUSAGEERR 160
# define SKF_R_WISEC_CERTUSAGEERR 161
# define SKF_R_WISEC_CONTAINER_EXISTS 162
# define SKF_R_WISEC_CONTAINER_NOT_EXISTS 163
# define SKF_R_WISEC_DEVNOAUTH 164
# define SKF_R_WISEC_FILEATTRIBUTEERR 165
# define SKF_R_WISEC_INVALIDCONTAINERERR 166
# define SKF_R_WISEC_KEYNOUSAGEERR 167
# define SKF_R_WRITE_FILE_FAILURE 157
# ifdef __cplusplus
}
# endif
#endif
#endif

View File

@@ -50,6 +50,9 @@
#ifndef HEADER_GMSOF_H
#define HEADER_GMSOF_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SOF
#include <stdio.h>
#include <openssl/sgd.h>
#include <openssl/sof.h>
@@ -145,3 +148,4 @@ int ERR_load_SOF_strings(void);
}
# endif
#endif
#endif

View File

@@ -1,6 +1,51 @@
/* ====================================================================
* Copyright (c) 2014 - 2017 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_GMTLS_H
#define HEADER_GMTLS_H
@@ -9,33 +54,53 @@ extern "C" {
#endif
/* version */
# define GMTLS_VERSION 0x0101
# define GMTLS_VERSION_MAJOR 0x01
# define GMTLS_VERSOIN_MINOR 0x01
# define GMTLS1_VERSION 0x0100
# define GMTLS1_VERSION_MAJOR 0x01
# define GMTLS1_VERSION_MINOR 0x00
# define GMTLS1_1_VERSION 0x0101
# define GMTLS1_1_VERSION_MAJOR 0x01
# define GMTLS1_1_VERSION_MINOR 0x01
# define GMTLS_VERSION GMTLS1_1_VERSION
# define GMTLS_VERSION_MAJOR GMTLS1_1_VERSION_MAJOR
# define GMTLS_VERSOIN_MINOR GMTLS1_1_VERSION_MINOR
/* GM/T SSL-VPN CipherSuites */
# define GMTLS_CK_SM2DHE_WITH_SM1_SM3 0x0300E001
# define GMTLS_CK_SM2_WITH_SM1_SM3 0x0300E003
# define GMTLS_CK_SM9DHE_WITH_SM1_SM3 0x0300E005
# define GMTLS_CK_SM9_WITH_SM1_SM3 0x0300E007
# define GMTLS_CK_RSA_WITH_SM1_SM3 0x0300E009
# define GMTLS_CK_RSA_WITH_SM1_SHA1 0x0300E00A
# define GMTLS_CK_SM2DHE_WITH_SMS4_SM3 0x0300E011
# define GMTLS_CK_SM2_WITH_SMS4_SM3 0x0300E013
# define GMTLS_CK_SM9DHE_WITH_SMS4_SM3 0x0300E015
# define GMTLS_CK_SM9_WITH_SMS4_SM3 0x0300E017
# define GMTLS_CK_RSA_WITH_SMS4_SM3 0x0300E019
# define GMTLS_CK_RSA_WITH_SMS4_SHA1 0x0300E01A
/* SSLVPN ciphersuites from GM/T 0024-2014 Table 2 */
# define GMTLS_CK_ECDHE_SM1_SM3 0x0300E001
# define GMTLS_CK_ECC_SM1_SM3 0x0300E003
# define GMTLS_CK_IBSDH_SM1_SM3 0x0300E005
# define GMTLS_CK_IBC_SM1_SM3 0x0300E007
# define GMTLS_CK_RSA_SM1_SM3 0x0300E009
# define GMTLS_CK_RSA_SM1_SHA1 0x0300E00A
# define GMTLS_CK_ECDHE_SM4_SM3 0x0300E011
# define GMTLS_CK_ECC_SM4_SM3 0x0300E013
# define GMTLS_CK_IBSDH_SM4_SM3 0x0300E015
# define GMTLS_CK_IBC_SM4_SM3 0x0300E017
# define GMTLS_CK_RSA_SM4_SM3 0x0300E019
# define GMTLS_CK_RSA_SM4_SHA1 0x0300E01A
/* ECDHE-SM2-WITH-[SM1|SMS4|SSF33]-[SM3|SHA256] */
# define GMTLS_CK_ECDHE_SM2_WITH_SM1_SM3 0x0300E101
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_SM3 0x0300E102
# define GMTLS_CK_ECDHE_SM2_WITH_SSF33_SM3 0x0300E103
# define GMTLS_CK_ECDHE_SM2_WITH_SM1_SHA256 0x0300E104
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_SHA256 0x0300E105
# define GMTLS_CK_ECDHE_SM2_WITH_SSF33_SHA256 0x0300E106
/* ECDHE-SM2-WITH-SMS4-[GCM|CCM|CCM-8]-[SM3|SHA256] */
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_GCM_SM3 0x0300E107
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_CCM_SM3 0x0300E108
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_CCM_8_SM3 0x0300E109
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_GCM_SHA256 0x0300E10A
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_CCM_SHA256 0x0300E10B
# define GMTLS_CK_ECDHE_SM2_WITH_SMS4_CCM_8_SHA256 0x0300E10C
/* PSK ciphersuites with NULL cipher */
# define GMTLS_CK_PSK_WITH_NULL_SM3
# define GMTLS_CK_DHE_PSK_WITH_NULL_SM3 0x0300F104
# define GMTLS_CK_RSA_PSK_WITH_NULL_SM3 0x0300F108
# define GMTLS_CK_SM2_PSK_WITH_NULL_SM3 0x0300F108
# define GMTLS_CK_ECDHE_PSK_WITH_NULL_SM3 0x0300F108
# define GMTLS_CK_PSK_WITH_NULL_SM3 0x0300F001
# define GMTLS_CK_DHE_PSK_WITH_NULL_SM3 0x0300F002
# define GMTLS_CK_RSA_PSK_WITH_NULL_SM3 0x0300F003
# define GMTLS_CK_SM2_PSK_WITH_NULL_SM3 0x0300F004
# define GMTLS_CK_ECDHE_PSK_WITH_NULL_SM3 0x0300F005
/* PSK ciphersuits with SMS4 */
# define GMTLS_CK_PSK_WITH_SMS4_CBC_SM3 0x0300F101
@@ -44,41 +109,117 @@ extern "C" {
# define GMTLS_CK_DHE_PSK_WITH_SMS4_CBC_SM3 0x0300F105
# define GMTLS_CK_DHE_PSK_WITH_SMS4_GCM_SM3 0x0300F106
# define GMTLS_CK_DHE_PSK_WITH_SMS4_CCM_SM3 0x0300F107
# define GMTLS_CK_RSA_PSK_WITH_SMS4_CBC_SM3 0x0300F109
# define GMTLS_CK_RSA_PSK_WITH_SMS4_GCM_SM3 0x0300F10A
# define GMTLS_CK_RSA_PSK_WITH_SMS4_CCM_SM3 0x0300F10B
# define GMTLS_CK_ECC_PSK_WITH_SMS4_CBC_SM3 0x0300F109
# define GMTLS_CK_ECC_PSK_WITH_SMS4_GCM_SM3 0x0300F10A
# define GMTLS_CK_ECC_PSK_WITH_SMS4_CCM_SM3 0x0300F10B
# define GMTLS_CK_RSA_PSK_WITH_SMS4_CBC_SM3 0x0300F108
# define GMTLS_CK_RSA_PSK_WITH_SMS4_GCM_SM3 0x0300F109
# define GMTLS_CK_RSA_PSK_WITH_SMS4_CCM_SM3 0x0300F10A
# define GMTLS_CK_ECC_PSK_WITH_SMS4_CBC_SM3 0x0300F10B
# define GMTLS_CK_ECC_PSK_WITH_SMS4_GCM_SM3 0x0300F10C
# define GMTLS_CK_ECC_PSK_WITH_SMS4_CCM_SM3 0x0300F10D
# define GMTLS_CK_PSK_WITH_SM1_CBC_SM3 0x0300F10E
# define GMTLS_CK_PSK_WITH_SM1_GCM_SM3 0x0300F10F
# define GMTLS_CK_PSK_WITH_SM1_CCM_SM3 0x0300F110
# define GMTLS_CK_DHE_PSK_WITH_SM1_CBC_SM3 0x0300F111
# define GMTLS_CK_DHE_PSK_WITH_SM1_GCM_SM3 0x0300F112
# define GMTLS_CK_DHE_PSK_WITH_SM1_CCM_SM3 0x0300F113
# define GMTLS_CK_RSA_PSK_WITH_SM1_CBC_SM3 0x0300F114
# define GMTLS_CK_RSA_PSK_WITH_SM1_GCM_SM3 0x0300F115
# define GMTLS_CK_RSA_PSK_WITH_SM1_CCM_SM3 0x0300F116
# define GMTLS_CK_PSK_WITH_SM1_CBC_SM3 0x0300F101
# define GMTLS_CK_PSK_WITH_SM1_GCM_SM3 0x0300F102
# define GMTLS_CK_PSK_WITH_SM1_CCM_SM3 0x0300F103
# define GMTLS_CK_DHE_PSK_WITH_SM1_CBC_SM3 0x0300F105
# define GMTLS_CK_DHE_PSK_WITH_SM1_GCM_SM3 0x0300F106
# define GMTLS_CK_DHE_PSK_WITH_SM1_CCM_SM3 0x0300F107
# define GMTLS_CK_RSA_PSK_WITH_SM1_CBC_SM3 0x0300F109
# define GMTLS_CK_RSA_PSK_WITH_SM1_GCM_SM3 0x0300F10A
# define GMTLS_CK_RSA_PSK_WITH_SM1_CCM_SM3 0x0300F10B
# define GMTLS_CK_PSK_WITH_SSF33_CBC_SM3 0x0300F101
# define GMTLS_CK_PSK_WITH_SSF33_GCM_SM3 0x0300F102
# define GMTLS_CK_PSK_WITH_SSF33_CCM_SM3 0x0300F103
# define GMTLS_CK_DHE_PSK_WITH_SSF33_CBC_SM3 0x0300F105
# define GMTLS_CK_DHE_PSK_WITH_SSF33_GCM_SM3 0x0300F106
# define GMTLS_CK_DHE_PSK_WITH_SSF33_CCM_SM3 0x0300F107
# define GMTLS_CK_RSA_PSK_WITH_SSF33_CBC_SM3 0x0300F109
# define GMTLS_CK_RSA_PSK_WITH_SSF33_GCM_SM3 0x0300F10A
# define GMTLS_CK_RSA_PSK_WITH_SSF33_CCM_SM3 0x0300F10B
# define GMTLS_CK_PSK_WITH_SSF33_CBC_SM3 0x0300F117
# define GMTLS_CK_PSK_WITH_SSF33_GCM_SM3 0x0300F118
# define GMTLS_CK_PSK_WITH_SSF33_CCM_SM3 0x0300F119
# define GMTLS_CK_DHE_PSK_WITH_SSF33_CBC_SM3 0x0300F11A
# define GMTLS_CK_DHE_PSK_WITH_SSF33_GCM_SM3 0x0300F11B
# define GMTLS_CK_DHE_PSK_WITH_SSF33_CCM_SM3 0x0300F11C
# define GMTLS_CK_RSA_PSK_WITH_SSF33_CBC_SM3 0x0300F11D
# define GMTLS_CK_RSA_PSK_WITH_SSF33_GCM_SM3 0x0300F11E
# define GMTLS_CK_RSA_PSK_WITH_SSF33_CCM_SM3 0x0300F11F
/* SRP ciphersuites */
# define GMTLS_CK_SRP_SM3_WITH_SMS4_CBC_SM3
# define GMTLS_CK_SRP_SM3_WITH_SMS4_GCM_SM3
# define GMTLS_CK_SRP_SM3_WITH_SMS4_CBC_SM3
# define GMTLS_CK_SRP_SM3_WITH_SMS4_GCM_SM3
# define GMTLS_CK_SRP_SM3_WITH_SMS4_CCM_SM3
# define GMTLS_CK_SRP_SM3_WITH_SMS4_CBC_SM3 0x0300F201
# define GMTLS_CK_SRP_SM3_WITH_SMS4_GCM_SM3 0x0300F202
# define GMTLS_CK_SRP_SM3_WITH_SMS4_CCM_SM3 0x0300F203
/**********************/
/* GM/T SSL-VPN CipherSuites */
# define GMTLS_TXT_SM2DHE_WITH_SM1_SM3 "SM2DHE-WITH-SM1-SM3"
# define GMTLS_TXT_SM2_WITH_SM1_SM3 "SM2-WITH-SM1-SM3"
# define GMTLS_TXT_SM9DHE_WITH_SM1_SM3 "SM9DHE-WITH-SM1-SM3"
# define GMTLS_TXT_SM9_WITH_SM1_SM3 "SM9-WITH-SM1-SM3"
# define GMTLS_TXT_RSA_WITH_SM1_SM3 "RSA-WITH-SM1-SM3"
# define GMTLS_TXT_RSA_WITH_SM1_SHA1 "RSA-WITH-SM1-SHA1"
# define GMTLS_TXT_SM2DHE_WITH_SMS4_SM3 "SM2DHE-WITH-SMS4-SM3"
# define GMTLS_TXT_SM2_WITH_SMS4_SM3 "SM2-WITH-SMS4-SM3"
# define GMTLS_TXT_SM9DHE_WITH_SMS4_SM3 "SM9DHE-WITH-SMS4-SM3"
# define GMTLS_TXT_SM9_WITH_SMS4_SM3 "SM9-WITH-SMS4-SM3"
# define GMTLS_TXT_RSA_WITH_SMS4_SM3 "RSA-WITH-SMS4-SM3"
# define GMTLS_TXT_RSA_WITH_SMS4_SHA1 "RSA-WITH-SMS4-SHA1"
/* ECDHE-SM2-WITH-[SM1|SMS4|SSF33]-[SM3|SHA256] */
# define GMTLS_TXT_ECDHE_SM2_WITH_SM1_SM3 "ECDHE-SM2-WITH-SM1-SM3"
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_SM3 "ECDHE-SM2-WITH-SMS4-SM3"
# define GMTLS_TXT_ECDHE_SM2_WITH_SSF33_SM3 "ECDHE-SM2-WITH-SSF33-SM3"
# define GMTLS_TXT_ECDHE_SM2_WITH_SM1_SHA256 "ECDHE-SM2-WITH-SM1-SHA256"
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_SHA256 "ECDHE-SM2-WITH-SMS4-SHA256"
# define GMTLS_TXT_ECDHE_SM2_WITH_SSF33_SHA256 "ECDHE-SM2-WITH-SSF33-SHA256"
/* ECDHE-SM2-WITH-SMS4-[GCM|CCM|CCM-8]-[SM3|SHA256] */
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_GCM_SM3 "ECDHE-SM2-WITH-SMS4-GCM-SM3"
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_CCM_SM3 "ECDHE-SM2-WITH-SMS4-CCM-SM3"
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_CCM_8_SM3 "ECDHE-SM2-WITH-SMS4-CCM-8-SM3"
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_GCM_SHA256 "ECDHE-SM2-WITH-SMS4-GCM-SHA256"
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_CCM_SHA256 "ECDHE-SM2-WITH-SMS4-CCM-SHA256"
# define GMTLS_TXT_ECDHE_SM2_WITH_SMS4_CCM_8_SHA256 "ECDHE-SM2-WITH-SMS4-CCM-8-SHA256"
/* PSK ciphersuites with NULL cipher */
# define GMTLS_TXT_PSK_WITH_NULL_SM3 "PSK-WITH-NULL-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_NULL_SM3 "DHE-PSK-WITH-NULL-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_NULL_SM3 "RSA-PSK-WITH-NULL-SM3"
# define GMTLS_TXT_SM2_PSK_WITH_NULL_SM3 "SM2-PSK_WITH-NULL-SM3"
# define GMTLS_TXT_ECDHE_PSK_WITH_NULL_SM3 "ECDHE-PSK-WITH-NULL-SM3"
/* PSK ciphersuits with SMS4 */
# define GMTLS_TXT_PSK_WITH_SMS4_CBC_SM3 "PSK-WITH-SMS4-CBC-SM3"
# define GMTLS_TXT_PSK_WITH_SMS4_GCM_SM3 "PSK-WITH-SMS4-GCM-SM3"
# define GMTLS_TXT_PSK_WITH_SMS4_CCM_SM3 "PSK-WITH-SMS4-CCM-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SMS4_CBC_SM3 "DHE-PSK-WITH-SMS4-CBC-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SMS4_GCM_SM3 "DHE-PSK-WITH-SMS4-GCM-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SMS4_CCM_SM3 "DHE-PSK-WITH-SMS4-CCM-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SMS4_CBC_SM3 "RSA-PSK-WITH-SMS4-CBC-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SMS4_GCM_SM3 "RSA-PSK-WITH-SMS4-GCM-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SMS4_CCM_SM3 "RSA-PSK-WITH-SMS4-CCM-SM3"
# define GMTLS_TXT_ECC_PSK_WITH_SMS4_CBC_SM3 "ECC-PSK-WITH-SMS4-CBC-SM3"
# define GMTLS_TXT_ECC_PSK_WITH_SMS4_GCM_SM3 "ECC-PSK-WITH-SMS4-GCM-SM3"
# define GMTLS_TXT_ECC_PSK_WITH_SMS4_CCM_SM3 "ECC-PSK-WITH-SMS4-CCM-SM3"
# define GMTLS_TXT_PSK_WITH_SM1_CBC_SM3 "PSK-WITH-SM1-CBC-SM3"
# define GMTLS_TXT_PSK_WITH_SM1_GCM_SM3 "PSK-WITH-SM1-GCM-SM3"
# define GMTLS_TXT_PSK_WITH_SM1_CCM_SM3 "PSK-WITH-SM1-CCM-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SM1_CBC_SM3 "DHE-PSK-WITH-SM1-CBC-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SM1_GCM_SM3 "DHE-PSK-WITH-SM1-GCM-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SM1_CCM_SM3 "DHE-PSK-WITH-SM1-CCM-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SM1_CBC_SM3 "RSA-PSK-WITH-SM1-CBC-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SM1_GCM_SM3 "RSA-PSK-WITH-SM1-GCM-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SM1_CCM_SM3 "RSA-PSK-WITH-SM1-CCM-SM3"
# define GMTLS_TXT_PSK_WITH_SSF33_CBC_SM3 "PSK-WITH-SSF33-CBC-SM3"
# define GMTLS_TXT_PSK_WITH_SSF33_GCM_SM3 "PSK-WITH-SSF33-GCM-SM3"
# define GMTLS_TXT_PSK_WITH_SSF33_CCM_SM3 "PSK-WITH-SSF33-CCM-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SSF33_CBC_SM3 "DHE-PSK-WITH-SSF33-CBC-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SSF33_GCM_SM3 "DHE-PSK-WITH-SSF33-GCM-SM3"
# define GMTLS_TXT_DHE_PSK_WITH_SSF33_CCM_SM3 "DHE-PSK-WITH-SSF33-CCM-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SSF33_CBC_SM3 "RSA-PSK-WITH-SSF33-CBC-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SSF33_GCM_SM3 "RSA-PSK-WITH-SSF33-GCM-SM3"
# define GMTLS_TXT_RSA_PSK_WITH_SSF33_CCM_SM3 "RSA-PSK-WITH-SSF33-CCM-SM3"
/* SRP ciphersuites */
# define GMTLS_TXT_SRP_SM3_WITH_SMS4_CBC_SM3 "SRP-SM3-WITH-SMS4-CBC-SM3"
# define GMTLS_TXT_SRP_SM3_WITH_SMS4_GCM_SM3 "SRP-SM3-WITH-SMS4-GCM-SM3"
# define GMTLS_TXT_SRP_SM3_WITH_SMS4_CCM_SM3 "SRP-SM3-WITH-SMS4-CCM-SM3"
# define TLS_CT_SM2_SIGN 240

39
include/openssl/hkdf.h Normal file
View File

@@ -0,0 +1,39 @@
/*
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifndef HEADER_HKDF_H
# define HEADER_HKDF_H
#include <string.h>
#include <openssl/evp.h>
#ifdef __cplusplus
extern "C" {
#endif
unsigned char *HKDF(const EVP_MD *evp_md,
const unsigned char *salt, size_t salt_len,
const unsigned char *key, size_t key_len,
const unsigned char *info, size_t info_len,
unsigned char *okm, size_t okm_len);
unsigned char *HKDF_Extract(const EVP_MD *evp_md,
const unsigned char *salt, size_t salt_len,
const unsigned char *key, size_t key_len,
unsigned char *prk, size_t *prk_len);
unsigned char *HKDF_Expand(const EVP_MD *evp_md,
const unsigned char *prk, size_t prk_len,
const unsigned char *info, size_t info_len,
unsigned char *okm, size_t okm_len);
# ifdef __cplusplus
}
# endif
#endif

View File

@@ -50,6 +50,22 @@ extern "C" {
EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)info)
/*static*/ unsigned char *HKDF(const EVP_MD *evp_md,
const unsigned char *salt, size_t salt_len,
const unsigned char *key, size_t key_len,
const unsigned char *info, size_t info_len,
unsigned char *okm, size_t okm_len);
/*static*/ unsigned char *HKDF_Extract(const EVP_MD *evp_md,
const unsigned char *salt, size_t salt_len,
const unsigned char *key, size_t key_len,
unsigned char *prk, size_t *prk_len);
/*static*/ unsigned char *HKDF_Expand(const EVP_MD *evp_md,
const unsigned char *prk, size_t prk_len,
const unsigned char *info, size_t info_len,
unsigned char *okm, size_t okm_len);
/* BEGIN ERROR CODES */
/*
* The following lines are auto generated by the script mkerr.pl. Any changes

View File

@@ -1070,6 +1070,11 @@
#define NID_pbe_WithSHA1And40BitRC2_CBC 149
#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L
#define SN_pbe_WithSM3AndSMS4_CBC "PBE-SM3-SMS4"
#define LN_pbe_WithSM3AndSMS4_CBC "pbeWithSM3AndSMS4-CBC"
#define NID_pbe_WithSM3AndSMS4_CBC 1195
#define OBJ_pbe_WithSM3AndSMS4_CBC OBJ_pkcs12_pbeids,100L
#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L
#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L
@@ -4552,6 +4557,22 @@
#define LN_kx_sm2 "kx-sm2"
#define NID_kx_sm2 1186
#define SN_kx_sm2dhe "KxSM2DHE"
#define LN_kx_sm2dhe "kx-sm2dhe"
#define NID_kx_sm2dhe 1190
#define SN_kx_sm2_psk "KxSM2-PSK"
#define LN_kx_sm2_psk "kx-sm2-psk"
#define NID_kx_sm2_psk 1191
#define SN_kx_sm9 "KxSM9"
#define LN_kx_sm9 "kx-sm9"
#define NID_kx_sm9 1188
#define SN_kx_sm9dhe "KxSM9DHE"
#define LN_kx_sm9dhe "kx-sm9dhe"
#define NID_kx_sm9dhe 1192
#define SN_auth_rsa "AuthRSA"
#define LN_auth_rsa "auth-rsa"
#define NID_auth_rsa 1046
@@ -4588,6 +4609,10 @@
#define LN_auth_sm2 "auth-sm2"
#define NID_auth_sm2 1187
#define SN_auth_sm9 "AuthSM9"
#define LN_auth_sm9 "auth-sm9"
#define NID_auth_sm9 1189
#define SN_ecies_recommendedParameters "ecies-recommendedParameters"
#define NID_ecies_recommendedParameters 1063
#define OBJ_ecies_recommendedParameters OBJ_secg_scheme,7L
@@ -5052,6 +5077,14 @@
#define NID_zuc 1136
#define OBJ_zuc OBJ_sm_scheme,800L
#define SN_zuc_128eea3 "zuc-128eea3"
#define NID_zuc_128eea3 1193
#define OBJ_zuc_128eea3 OBJ_zuc,1L
#define SN_zuc_128eia3 "zuc-128eia3"
#define NID_zuc_128eia3 1194
#define OBJ_zuc_128eia3 OBJ_zuc,2L
#define OBJ_ibcs1 OBJ_ISO_US,1L,114334L,1L
#define SN_bfibe "bfibe"

View File

@@ -53,6 +53,9 @@
#ifndef HEADER_OTP_H
#define HEADER_OTP_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_OTP
#ifdef __cplusplus
extern "C" {
#endif
@@ -99,3 +102,4 @@ int ERR_load_OTP_strings(void);
}
# endif
#endif
#endif

View File

@@ -52,7 +52,9 @@
#ifndef HEADER_PAILLIER_H
#define HEADER_PAILLIER_H
#ifndef NO_GMSSL
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_PAILLIER
#include <openssl/bn.h>
#include <openssl/asn1.h>

View File

@@ -269,6 +269,8 @@ int ERR_load_PKCS12_strings(void);
# define PKCS12_R_MAC_SETUP_ERROR 110
# define PKCS12_R_MAC_STRING_SET_ERROR 111
# define PKCS12_R_MAC_VERIFY_FAILURE 113
# define PKCS12_R_NO_AVAIABLE_CIPHER 112
# define PKCS12_R_NO_AVAIABLE_DIGEST 122
# define PKCS12_R_PARSE_ERROR 114
# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115
# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116

View File

@@ -0,0 +1,41 @@
/* Copyright (c) 2014, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#ifndef HEADER_POLY1305_H
#define HEADER_POLY1305_H
#include <string.h>
#include <openssl/base.h>
#include <openssl/e_os2.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint8_t poly1305_state[512];
void CRYPTO_poly1305_init(poly1305_state* state,
const uint8_t key[32]);
void CRYPTO_poly1305_update(poly1305_state* state,
const uint8_t* in,
size_t in_len);
void CRYPTO_poly1305_finish(poly1305_state* state,
uint8_t mac[16]);
#if defined(__cplusplus)
} /* extern C */
#endif
#endif

View File

@@ -464,7 +464,9 @@ int ERR_load_RSA_strings(void);
# define RSA_F_CHECK_PADDING_MD 140
# define RSA_F_ENCODE_PKCS1 146
# define RSA_F_INT_RSA_VERIFY 145
# define RSA_F_MARSHAL_INTEGER 150
# define RSA_F_OLD_RSA_PRIV_DECODE 147
# define RSA_F_PARSE_PUBLIC_KEY 151
# define RSA_F_PKEY_RSA_CTRL 143
# define RSA_F_PKEY_RSA_CTRL_STR 144
# define RSA_F_PKEY_RSA_SIGN 142
@@ -476,6 +478,8 @@ int ERR_load_RSA_strings(void);
# define RSA_F_RSA_CHECK_KEY_EX 160
# define RSA_F_RSA_CMS_DECRYPT 159
# define RSA_F_RSA_ITEM_VERIFY 148
# define RSA_F_RSA_MARSHAL_PRIVATE_KEY 158
# define RSA_F_RSA_MARSHAL_PUBLIC_KEY 164
# define RSA_F_RSA_METH_DUP 161
# define RSA_F_RSA_METH_NEW 162
# define RSA_F_RSA_METH_SET1_NAME 163
@@ -506,10 +510,15 @@ int ERR_load_RSA_strings(void);
# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113
# define RSA_F_RSA_PADDING_CHECK_SSLV23 114
# define RSA_F_RSA_PADDING_CHECK_X931 128
# define RSA_F_RSA_PARSE_PRIVATE_KEY 165
# define RSA_F_RSA_PRINT 115
# define RSA_F_RSA_PRINT_FP 116
# define RSA_F_RSA_PRIVATE_KEY_FROM_BYTES 166
# define RSA_F_RSA_PRIVATE_KEY_TO_BYTES 167
# define RSA_F_RSA_PRIV_ENCODE 138
# define RSA_F_RSA_PSS_TO_CTX 155
# define RSA_F_RSA_PUBLIC_KEY_FROM_BYTES 168
# define RSA_F_RSA_PUBLIC_KEY_TO_BYTES 169
# define RSA_F_RSA_PUB_DECODE 139
# define RSA_F_RSA_SETUP_BLINDING 136
# define RSA_F_RSA_SIGN 117
@@ -520,10 +529,13 @@ int ERR_load_RSA_strings(void);
/* Reason codes. */
# define RSA_R_ALGORITHM_MISMATCH 100
# define RSA_R_BAD_ENCODING 145
# define RSA_R_BAD_E_VALUE 101
# define RSA_R_BAD_FIXED_HEADER_DECRYPT 102
# define RSA_R_BAD_PAD_BYTE_COUNT 103
# define RSA_R_BAD_RSA_PARAMETERS 152
# define RSA_R_BAD_SIGNATURE 104
# define RSA_R_BAD_VERSION 164
# define RSA_R_BLOCK_TYPE_IS_NOT_01 106
# define RSA_R_BLOCK_TYPE_IS_NOT_02 107
# define RSA_R_DATA_GREATER_THAN_MOD_LEN 108
@@ -537,6 +549,7 @@ int ERR_load_RSA_strings(void);
# define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124
# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125
# define RSA_R_D_E_NOT_CONGRUENT_TO_1 123
# define RSA_R_ENCODE_ERROR 165
# define RSA_R_FIRST_OCTET_INVALID 133
# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144
# define RSA_R_INVALID_DIGEST 157

View File

@@ -46,19 +46,14 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*/
/*
* SAF API is a crypto API with key and certificate management.
* The API is defined in the GM standard GM/T 0019-2012:
* Universal Cryptography Service Interface Specification
*/
#ifndef HEADER_SAF_H
#define HEADER_SAF_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SAF
#define SGD_MAX_COUNT 64
#define SGD_MAX_NAME_SIZE 256
#include <openssl/sgd.h>
#ifdef __cplusplus
extern "C" {
@@ -70,7 +65,7 @@ typedef struct SGD_USR_CERT_ENUMLIST_ {
unsigned char *certificate[SGD_MAX_COUNT];
unsigned int certificateLen[SGD_MAX_COUNT];
unsigned char *containerName[SGD_MAX_COUNT];
unsigned int containterNameLen[SGD_MAX_COUNT]; //correct?ß
unsigned int containterNameLen[SGD_MAX_COUNT];
unsigned int keyUsage[SGD_MAX_COUNT];
} SGD_USR_CERT_ENUMLIST;
@@ -90,13 +85,13 @@ typedef struct {
unsigned char dn_l[SGD_MAX_NAME_SIZE];
unsigned char dn_l_len[1];
unsigned char dn_o[5][SGD_MAX_NAME_SIZE];
unsigned int dn_o_len[5];
unsigned int dn_o_len[5];
unsigned char dn_ou[5][SGD_MAX_NAME_SIZE];
unsigned int dn_ou_len[5];
unsigned int dn_ou_len[5];
unsigned char dn_cn[2][SGD_MAX_NAME_SIZE];
unsigned int dn_cn_len[2];
unsigned int dn_cn_len[2];
unsigned char dn_email[2][SGD_MAX_NAME_SIZE];
unsigned int dn_email_len[2];
unsigned int dn_email_len[2];
} SGD_NAME_INFO;
int SAF_Initialize(
@@ -781,3 +776,4 @@ int SAF_SM2_DecodeEnvelopedData(
}
#endif
#endif
#endif

View File

@@ -64,6 +64,9 @@
#ifndef HEADER_SDF_H
#define HEADER_SDF_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SDF
#include <stdio.h>
#include <openssl/sgd.h>
@@ -71,8 +74,8 @@
extern "C" {
#endif
typedef struct DeviceInfo_st{
#pragma pack(1)
typedef struct /*__attribute__((packed))*/ DeviceInfo_st {
unsigned char IssuerName[40];
unsigned char DeviceName[16];
unsigned char DeviceSerial[16]; /* 8-char date +
@@ -89,18 +92,13 @@ typedef struct DeviceInfo_st{
unsigned int BufferSize;
} DEVICEINFO;
#define RSAref_MAX_BITS 2048
#define RSAref_MAX_LEN ((RSAref_MAX_BITS + 7) / 8)
#define RSAref_MAX_PBITS ((RSAref_MAX_BITS + 1) / 2)
#define RSAref_MAX_PLEN ((RSAref_MAX_PBITS + 7)/ 8)
typedef struct RSArefPublicKey_st {
typedef struct /*__attribute__((packed))*/ RSArefPublicKey_st {
unsigned int bits;
unsigned char m[RSAref_MAX_LEN];
unsigned char e[RSAref_MAX_LEN];
} RSArefPublicKey;
typedef struct RSArefPrivateKey_st {
typedef struct /*__attribute__((packed))*/ RSArefPrivateKey_st {
unsigned int bits;
unsigned char m[RSAref_MAX_LEN];
unsigned char e[RSAref_MAX_LEN];
@@ -110,53 +108,38 @@ typedef struct RSArefPrivateKey_st {
unsigned char coef[RSAref_MAX_PLEN];
} RSArefPrivateKey;
#define ECCref_MAX_BITS 512
#define ECCref_MAX_LEN ((ECCref_MAX_BITS+7) / 8)
typedef struct ECCrefPublicKey_st {
typedef struct /*__attribute__((packed))*/ ECCrefPublicKey_st {
unsigned int bits;
unsigned char x[ECCref_MAX_LEN];
unsigned char y[ECCref_MAX_LEN];
} ECCrefPublicKey;
typedef struct ECCrefPrivateKey_st {
typedef struct /*__attribute__((packed))*/ ECCrefPrivateKey_st {
unsigned int bits;
unsigned char K[ECCref_MAX_LEN];
} ECCrefPrivateKey;
typedef struct ECCCipher_st {
typedef struct /*__attribute__((packed))*/ ECCCipher_st {
unsigned char x[ECCref_MAX_LEN];
unsigned char y[ECCref_MAX_LEN];
/*
* In SM2 ciphertext the `M` is the hash result of the plaintext
* with generated Diffie-Hellman keys, so the length should be the
* digest length, for SM3 it is 256-bit which is equal to the max
* elliptic curve key length (256-bit).
*/
unsigned char M[32];
/* length of ciphertext `C` */
unsigned int L;
unsigned char C[1];
} ECCCipher;
typedef struct ECCSignature_st {
typedef struct /*__attribute__((packed))*/ ECCSignature_st {
unsigned char r[ECCref_MAX_LEN];
unsigned char s[ECCref_MAX_LEN];
} ECCSignature;
/* ENVELOPEDKEYBLOB is not used in this API, and it requires the
* ECCCIPHERBLOB and ECCPUBLICKEYBLOB defined in SKF API
*/
#if 0
typedef struct SDF_ENVELOPEDKEYBLOB {
typedef struct /*__attribute__((packed))*/ SDF_ENVELOPEDKEYBLOB {
unsigned long Version;
unsigned long ulSymmAlgID;
ECCCIPHERBLOB ECCCipehrBlob;
ECCPUBLICKEYBLOB PubKey;
ECCCipher ECCCipehrBlob;
ECCrefPublicKey PubKey;
unsigned char cbEncryptedPrivKey[64];
} ENVELOPEDKEYBLOB, *PENVELOPEDKEYBLOB;
#endif
} EnvelopedKeyBlob, *PEnvelopedKeyBlob;
#pragma pack()
int SDF_OpenDevice(
void **phDeviceHandle);
@@ -475,7 +458,7 @@ int SDF_DeleteFile(
#define SDR_OPENSESSION (SDR_BASE + 0x00000006)
#define SDR_PARDENY (SDR_BASE + 0x00000007)
#define SDR_KEYNOTEXIST (SDR_BASE + 0x00000008)
#define SDR_ALGNOTSUPPOT (SDR_BASE + 0x00000009)
#define SDR_ALGNOTSUPPORT (SDR_BASE + 0x00000009)
#define SDR_ALGMODNOTSUPPORT (SDR_BASE + 0x0000000A)
#define SDR_PKOPERR (SDR_BASE + 0x0000000B)
#define SDR_SKOPERR (SDR_BASE + 0x0000000C)
@@ -503,3 +486,4 @@ int SDF_DeleteFile(
}
#endif
#endif
#endif

View File

@@ -76,8 +76,10 @@ POSSIBILITY OF SUCH DAMAGE. */
#ifndef HEADER_SERPENT_H
#define HEADER_SERPENT_H
#include <stdint.h>
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SERPENT
#include <openssl/e_os2.h>
#define SERPENT_ROUNDS 32
#define SERPENT_BLOCK_SIZE 16
@@ -114,5 +116,5 @@ extern "C" {
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@@ -1,315 +1,428 @@
/* ====================================================================
* 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.
* ====================================================================
*/
/*
* this header file is based on the standard GM/T 0006-2012
* Cryptographic Application Identifier Criterion Specification
*/
#ifndef HEADER_SGD_H
#define HEADER_SGD_H
#include <stdint.h>
/* block cipher modes */
#define SGD_ECB 0x01
#define SGD_CBC 0x02
#define SGD_CFB 0x04
#define SGD_OFB 0x08
#define SGD_MAC 0x10
/* stream cipher modes */
#define SGD_EEA3 0x01
#define SGD_EIA3 0x02
/* ciphers */
#define SGD_SM1 0x00000100
#define SGD_SSF33 0x00000200
#define SGD_SM4 0x00000400
#define SGD_ZUC 0x00000800
/* ciphers with modes */
#define SGD_SM1_ECB (SGD_SM1|SGD_ECB)
#define SGD_SM1_CBC (SGD_SM1|SGD_CBC)
#define SGD_SM1_CFB (SGD_SM1|SGD_CFB)
#define SGD_SM1_OFB (SGD_SM1|SGD_OFB)
#define SGD_SM1_MAC (SGD_SM1|SGD_MAC)
#define SGD_SSF33_ECB (SGD_SSF33|SGD_ECB)
#define SGD_SSF33_CBC (SGD_SSF33|SGD_CBC)
#define SGD_SSF33_CFB (SGD_SSF33|SGD_CFB)
#define SGD_SSF33_OFB (SGD_SSF33|SGD_OFB)
#define SGD_SSF33_MAC (SGD_SSF33|SGD_MAC)
#define SGD_SM4_ECB (SGD_SM4|SGD_ECB)
#define SGD_SM4_CBC (SGD_SM4|SGD_CBC)
#define SGD_SM4_CFB (SGD_SM4|SGD_CFB)
#define SGD_SM4_OFB (SGD_SM4|SGD_OFB)
#define SGD_SM4_MAC (SGD_SM4|SGD_MAC)
#define SGD_ZUC_EEA3 (SGD_ZUC|SGD_EEA3)
#define SGD_ZUC_EIA3 (SGD_ZUC|SGD_EIA3)
/* public key usage */
#define SGD_PK_SIGN 0x0100
#define SGD_PK_DH 0x0200
#define SGD_PK_ENC 0x0400
/* public key types */
#define SGD_RSA 0x00010000
#define SGD_RSA_SIGN (SGD_RSA|SGD_PK_SIGN)
#define SGD_RSA_ENC (SGD_RSA|SGD_PK_ENC)
#define SGD_SM2 0x00020000
#define SGD_SM2_1 (SGD_SM2|SGD_PK_SIGN)
#define SGD_SM2_2 (SGD_SM2|SGD_PK_DH)
#define SGD_SM2_3 (SGD_SM2|SGD_PK_ENC)
/* hash */
#define SGD_SM3 0x00000001
#define SGD_SHA1 0x00000002
#define SGD_SHA256 0x00000004
#define SGD_HASH_FROM 0x00000008
#define SGD_HASH_TO 0x000000FF
/* signatue schemes */
#define SGD_SM3_RSA (SGD_SM3|SGD_RSA)
#define SGD_SHA1_RSA (SGD_SHA1|SGD_RSA)
#define SGD_SHA256_RSA (SGD_SHA256|SGD_RSA)
#define SGD_SM3_SM2 (SGD_SM3|SGD_SM2)
#define SGD_SIG_FROM 0x00040000
#define SGD_SIG_TO 0x800000FF
/* data types */
typedef char SGD_CHAR;
typedef char SGD_INT8;
typedef int16_t SGD_INT16;
typedef int32_t SGD_INT32;
typedef int64_t SGD_INT64;
typedef unsigned char SGD_UCHAR;
typedef uint8_t SGD_UINT8;
typedef uint16_t SGD_UINT16;
typedef uint32_t SGD_UINT32;
typedef uint64_t SGD_UINT64;
typedef uint32_t SGD_RV;
typedef void * SGD_OBJ;
typedef int32_t SGD_BOOL;
#define SGD_TRUE 0x00000001
#define SGD_FALSE 0x00000000
#define SGD_KEY_INDEX 0x00000101
#define SGD_SECRET_KEY 0x00000102
#define SGD_PUBLIC_KEY_SIGN 0x00000103
#define SGD_PUBLIC_KEY_ENCRYPT 0x00000104
#define SGD_PRIVATE_KEY_SIGN 0x00000105
#define SGD_PRIVATE_KEY_ENCRYPT 0x00000106
#define SGD_KEY_COMPONENT 0x00000107
#define SGD_PASSWORD 0x00000108
#define SGD_PUBLIC_KEY_CERT 0x00000109
#define SGD_ATTRIBUTE_CERT 0x1000010A
#define SGD_SIGNATURE_DATA 0x10000111
#define SGD_ENVELOPE_DATA 0x10000112
#define SGD_RANDOM_DATA 0x10000113
#define SGD_PLAIN_DATA 0x10000114
#define SGD_CIPHER_DATA 0x10000115
#define SGD_DIGEST_DATA 0x10000116
#define SGD_USER_DATA 0x10000117
/* certificate */
#define SGD_CERT_VERSION 0x00000001
#define SGD_CERT_SERIAL 0x00000002
#define SGD_CERT_ISSUER 0x00000005
#define SGD_CERT_VALID_TIME 0x00000006
#define SGD_CERT_SUBJECT 0x00000007
#define SGD_CERT_DER_PUBLIC_KEY 0x00000008
#define SGD_CERT_DER_EXTENSIONS 0x00000009
#define SGD_EXT_AUTHORITYKEYIDENTIFIER_INFO 0x00000011
#define SGD_EXT_SUBJECTKEYIDENTIFIER_INFO 0x00000012
#define SGD_EXT_KEYUSAGE_INFO 0x00000013
#define SGD_EXT_PRIVATEKEYUSAGEPERIOD_INFO 0x00000014
#define SGD_EXT_CERTIFICATEPOLICIES_INFO 0x00000015
#define SGD_EXT_POLICYMAPPINGS_INFO 0x00000016
#define SGD_EXT_BASICCONSTRAINTS_INFO 0x00000017
#define SGD_EXT_POLICYCONSTRAINTS_INFO 0x00000018
#define SGD_EXT_EXTKEYUSAGE_INFO 0x00000019
#define SGD_EXT_CRLDISTRIBUTIONPOINTS_INFO 0x0000001A
#define SGD_EXT_NETSCAPE_CERT_TYPE_INFO 0x0000001B
#define SGD_EXT_SELFDEFINED_EXTENSION_INFO 0x0000001C
#define SGD_CERT_ISSUER_CN 0x00000021
#define SGD_CERT_ISSUER_O 0x00000022
#define SGD_CERT_ISSUER_OU 0x00000023
#define SGD_CERT_SUBJECT_CN 0x00000031
#define SGD_CERT_SUBJECT_O 0x00000032
#define SGD_CERT_SUBJECT_OU 0x00000033
#define SGD_CERT_SUBJECT_EMAIL 0x00000034
#define SGD_CERT_NOTBEFORE_TIME 0x00000035
#define SGD_CERT_NOTAFTER_TIME 0x00000036
/* timestamp info */
#define SGD_TIME_OF_STAMP 0x00000201
#define SGD_CN_OF_TSSIGNER 0x00000202 /* Common Name of TS Signer */
#define SGD_ORININAL_DATA 0x00000203
#define SGD_CERT_OF_TSSSERVER 0x00000204
#define SGD_GERTCHAIN_OF_TSSERVER 0x00000205
#define SGD_SOURCE_OF_TIME 0x00000206
#define SGD_TIME_PRECISION 0x00000207
#define SGD_RESPONSE_TYPE 0x00000208
#define SGD_SUBJECT_COUNTRY_OF_TSSIGNER 0x00000209
#define SGD_SUBJECT_ORGNIZATION_OF_TSSIGNER 0x0000020A
#define SGD_SUJECT_CITY_OF_TSSIGNER 0x0000020B
#define SGD_SUBJECT_EMAIL_OF_TSSIGNER 0x0000020C
/* single sign-on */
#define SGD_SP_ID 0x00000001
#define SGD_SP_USER_ID 0x00000002
#define SGD_IDP_ID 0x00000003
#define SGD_IDP_USER_ID 0x00000004
/* data encoding */
#define SGD_ENCODING_RAW 0x00000000
#define SGD_ENCODING_DER 0x01000000
#define SGD_ENCODING_BASE64 0x02000000
#define SGD_ENCODING_PEM 0x03000000
#define SGD_ENCODING_TXT 0x04000000
/* APIs */
#define SGD_PROTOCOL_CSP 1 /* Microsoft CryptoAPI */
#define SGD_PROTOCOL_PKCS11 2 /* PKCS#11 */
#define SGD_PROTOCOL_SDS 3 /* SDF API */
#define SGD_PROTOCOL_UKEY 4 /* SKF API */
#define SGD_PROTOCOL_CNG 5 /* Microsoft CryptoAPI Next Gen */
#define SGD_PROTOCOL_GCS 6 /* */
/* certificate validation */
#define SGD_CRL_VERIFY 1
#define SGD_OCSP_VEIFY 2
/* role */
#define SGD_ROLE_SUPER_MANAGER 0x00000001
#define SGD_ROLE_MANAGER 0x00000002
#define SGD_ROLE_AUDIT_MANAGER 0x00000003
#define SGD_ROLE_AUDITOR 0x00000004
#define SGD_ROLE_OPERATOR 0x00000005
#define SGD_ROLE_USER 0x00000006
/* user operations */
#define SGD_OPERATION_SIGNIN 0x00000001
#define SGD_OPERATION_SIGNOUT 0x00000002
#define SGD_OPERATION_CREATE 0x00000003
#define SGD_OPERATION_DELETE 0x00000004
#define SGD_OPERATION_MODIFY 0x00000005
#define SGD_OPERATION_CHG_PWD 0x00000006
#define SGD_OPERATION_AUTHORIZATION 0x00000007
/* user operation results */
#define SGD_OPERATION_SUCCESS 0x00000000
/* key types */
#define SGD_MAIN_KEY 0x00000101
#define SGD_DEVICE_KEYS 0x00000102
#define SGD_USER_KEYS 0x00000103
#define SGD_KEY 0x00000104
#define SGD_SESSION_KEY 0x00000105
#define SGD_PRIKEY_PASSWD 0x00000106
#define SGD_COMPARTITION_KEY 0x00000107
/* key operations */
#define SGD_KEY_GENERATION 0x00000101
#define SGD_KEY_DISPENSE 0x00000102
#define SGD_KEY_IMPORT 0x00000103
#define SGD_KEY_EXPORT 0x00000104
#define SGD_KEY_DIVISION 0x00000105
#define SGD_KEY_COMPOSE 0x00000106
#define SGD_KEY_RENEWAL 0x00000107
#define SGD_KEY_BACKUP 0x00000108
#define SGD_KEY_RESTORE 0x00000109
#define SGD_KEY_DESTORY 0x0000010A
/* system operations */
#define SGD_SYSTEM_INIT 0x00000201
#define SGD_SYSTEM_START 0x00000202
#define SGD_SYSTEM_SHUT 0x00000203
#define SGD_SYSTEM_RESTART 0x00000204
#define SGD_SYSTEM_QUERY 0x00000205
#define SGD_SYSTEM_BACKUP 0x00000206
#define SGD_SYSTEM_RESTORE 0x00000207
/* device info */
#define SGD_DEVICE_SORT 0x00000201
#define SGD_DEVICE_TYPE 0x00000202
#define SGD_DEVICE_NAME 0x00000203
#define SGD_DEVICE_MANUFACTURER 0x00000204
#define SGD_DEVICE_HARDWARE_VERSION 0x00000205
#define SGD_DEVICE_SOFTWARE_VERSION 0x00000206
#define SGD_DEVICE_STANDARD_VERSION 0x00000207
#define SGD_DEVICE_SERIAL_NUMBER 0x00000208
#define SGD_DEVICE_SUPPORT_SYMM_ALG 0x00000209
#define SGD_DEVICE_SUPPORT_PKEY_ALG 0x0000020A
#define SGD_DEVICE_SUPPORT_HASH_ALG 0x0000020B
#define SGD_DEVICE_SUPPORT_STORAGE_SPACE 0x0000020C
#define SGD_DEVICE_SUPPORT_FREE_SPACE 0x0000020D
#define SGD_DEVICE_RUNTIME 0x0000020E
#define SGD_DEVICE_USED_TIMES 0x0000020F
#define SGD_DEVICE_LOCATION 0x00000210
#define SGD_DEVICE_DESCRIPTION 0x00000211
#define SGD_DEVICE_MANAGER_INFO 0x00000212
#define SGD_DEVICE_MAX_DATA_SIZE 0x00000213
/* device types */
#define SGD_DEVICE_SORT_SJ 0x02000000 /* Server */
#define SGD_DEVICE_SORT_SK 0x03000000 /* PCI-E Card */
#define SGD_DEVICE_SORT_SM 0x04000000 /* USB-Key and SmartCard */
/* device functionality */
#define SGD_DEVICE_SORT_FE 0x00000100 /* encryption */
#define SGD_DEVICE_SORT_FA 0x00000200 /* authentication */
#define SGD_DEVICE_SORT_FM 0x00000300 /* key management */
/* device status */
#define SGD_STATUS_INIT 0x00000201
#define SGD_STATUS_READY 0x00000202
#define SGD_STATUS_EXCEPTION 0x00000203
#endif
/* ====================================================================
* 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.
* ====================================================================
*/
/*
* this header file is based on the standard GM/T 0006-2012
* Cryptographic Application Identifier Criterion Specification
*/
#ifndef HEADER_SGD_H
#define HEADER_SGD_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_GMAPI
#include <openssl/e_os2.h>
/* block cipher modes */
#define SGD_ECB 0x01
#define SGD_CBC 0x02
#define SGD_CFB 0x04
#define SGD_OFB 0x08
#define SGD_MAC 0x10
/* stream cipher modes */
#define SGD_EEA3 0x01
#define SGD_EIA3 0x02
/* ciphers */
#define SGD_SM1 0x00000100
#define SGD_SSF33 0x00000200
#define SGD_SM4 0x00000400
#define SGD_ZUC 0x00000800
/* ciphers with modes */
#define SGD_SM1_ECB (SGD_SM1|SGD_ECB)
#define SGD_SM1_CBC (SGD_SM1|SGD_CBC)
#define SGD_SM1_CFB (SGD_SM1|SGD_CFB)
#define SGD_SM1_OFB (SGD_SM1|SGD_OFB)
#define SGD_SM1_MAC (SGD_SM1|SGD_MAC)
#define SGD_SSF33_ECB (SGD_SSF33|SGD_ECB)
#define SGD_SSF33_CBC (SGD_SSF33|SGD_CBC)
#define SGD_SSF33_CFB (SGD_SSF33|SGD_CFB)
#define SGD_SSF33_OFB (SGD_SSF33|SGD_OFB)
#define SGD_SSF33_MAC (SGD_SSF33|SGD_MAC)
#define SGD_SM4_ECB (SGD_SM4|SGD_ECB)
#define SGD_SM4_CBC (SGD_SM4|SGD_CBC)
#define SGD_SM4_CFB (SGD_SM4|SGD_CFB)
#define SGD_SM4_OFB (SGD_SM4|SGD_OFB)
#define SGD_SM4_MAC (SGD_SM4|SGD_MAC)
#define SGD_ZUC_EEA3 (SGD_ZUC|SGD_EEA3)
#define SGD_ZUC_EIA3 (SGD_ZUC|SGD_EIA3)
/* public key usage */
#define SGD_PK_SIGN 0x0100
#define SGD_PK_DH 0x0200
#define SGD_PK_ENC 0x0400
/* public key types */
#define SGD_RSA 0x00010000
#define SGD_RSA_SIGN (SGD_RSA|SGD_PK_SIGN)
#define SGD_RSA_ENC (SGD_RSA|SGD_PK_ENC)
#define SGD_SM2 0x00020000
#define SGD_SM2_1 (SGD_SM2|SGD_PK_SIGN)
#define SGD_SM2_2 (SGD_SM2|SGD_PK_DH)
#define SGD_SM2_3 (SGD_SM2|SGD_PK_ENC)
/* hash */
#define SGD_SM3 0x00000001
#define SGD_SHA1 0x00000002
#define SGD_SHA256 0x00000004
#define SGD_HASH_FROM 0x00000008
#define SGD_HASH_TO 0x000000FF
/* signatue schemes */
#define SGD_SM3_RSA (SGD_SM3|SGD_RSA)
#define SGD_SHA1_RSA (SGD_SHA1|SGD_RSA)
#define SGD_SHA256_RSA (SGD_SHA256|SGD_RSA)
#define SGD_SM3_SM2 (SGD_SM3|SGD_SM2)
#define SGD_SIG_FROM 0x00040000
#define SGD_SIG_TO 0x800000FF
/* data types */
typedef char SGD_CHAR;
typedef char SGD_INT8;
typedef int16_t SGD_INT16;
typedef int32_t SGD_INT32;
typedef int64_t SGD_INT64;
typedef unsigned char SGD_UCHAR;
typedef uint8_t SGD_UINT8;
typedef uint16_t SGD_UINT16;
typedef uint32_t SGD_UINT32;
typedef uint64_t SGD_UINT64;
typedef uint32_t SGD_RV;
typedef void * SGD_OBJ;
typedef int32_t SGD_BOOL;
#define SGD_TRUE 0x00000001
#define SGD_FALSE 0x00000000
#define SGD_KEY_INDEX 0x00000101
#define SGD_SECRET_KEY 0x00000102
#define SGD_PUBLIC_KEY_SIGN 0x00000103
#define SGD_PUBLIC_KEY_ENCRYPT 0x00000104
#define SGD_PRIVATE_KEY_SIGN 0x00000105
#define SGD_PRIVATE_KEY_ENCRYPT 0x00000106
#define SGD_KEY_COMPONENT 0x00000107
#define SGD_PASSWORD 0x00000108
#define SGD_PUBLIC_KEY_CERT 0x00000109
#define SGD_ATTRIBUTE_CERT 0x1000010A
#define SGD_SIGNATURE_DATA 0x10000111
#define SGD_ENVELOPE_DATA 0x10000112
#define SGD_RANDOM_DATA 0x10000113
#define SGD_PLAIN_DATA 0x10000114
#define SGD_CIPHER_DATA 0x10000115
#define SGD_DIGEST_DATA 0x10000116
#define SGD_USER_DATA 0x10000117
/* certificate */
#define SGD_CERT_VERSION 0x00000001
#define SGD_CERT_SERIAL 0x00000002
#define SGD_CERT_ISSUER 0x00000005
#define SGD_CERT_VALID_TIME 0x00000006
#define SGD_CERT_SUBJECT 0x00000007
#define SGD_CERT_DER_PUBLIC_KEY 0x00000008
#define SGD_CERT_DER_EXTENSIONS 0x00000009
#define SGD_EXT_AUTHORITYKEYIDENTIFIER_INFO 0x00000011
#define SGD_EXT_SUBJECTKEYIDENTIFIER_INFO 0x00000012
#define SGD_EXT_KEYUSAGE_INFO 0x00000013
#define SGD_EXT_PRIVATEKEYUSAGEPERIOD_INFO 0x00000014
#define SGD_EXT_CERTIFICATEPOLICIES_INFO 0x00000015
#define SGD_EXT_POLICYMAPPINGS_INFO 0x00000016
#define SGD_EXT_BASICCONSTRAINTS_INFO 0x00000017
#define SGD_EXT_POLICYCONSTRAINTS_INFO 0x00000018
#define SGD_EXT_EXTKEYUSAGE_INFO 0x00000019
#define SGD_EXT_CRLDISTRIBUTIONPOINTS_INFO 0x0000001A
#define SGD_EXT_NETSCAPE_CERT_TYPE_INFO 0x0000001B
#define SGD_EXT_SELFDEFINED_EXTENSION_INFO 0x0000001C
#define SGD_CERT_ISSUER_CN 0x00000021
#define SGD_CERT_ISSUER_O 0x00000022
#define SGD_CERT_ISSUER_OU 0x00000023
#define SGD_CERT_SUBJECT_CN 0x00000031
#define SGD_CERT_SUBJECT_O 0x00000032
#define SGD_CERT_SUBJECT_OU 0x00000033
#define SGD_CERT_SUBJECT_EMAIL 0x00000034
#define SGD_CERT_NOTBEFORE_TIME 0x00000035
#define SGD_CERT_NOTAFTER_TIME 0x00000036
/* timestamp info */
#define SGD_TIME_OF_STAMP 0x00000201
#define SGD_CN_OF_TSSIGNER 0x00000202 /* Common Name of TS Signer */
#define SGD_ORININAL_DATA 0x00000203
#define SGD_CERT_OF_TSSSERVER 0x00000204
#define SGD_GERTCHAIN_OF_TSSERVER 0x00000205
#define SGD_SOURCE_OF_TIME 0x00000206
#define SGD_TIME_PRECISION 0x00000207
#define SGD_RESPONSE_TYPE 0x00000208
#define SGD_SUBJECT_COUNTRY_OF_TSSIGNER 0x00000209
#define SGD_SUBJECT_ORGNIZATION_OF_TSSIGNER 0x0000020A
#define SGD_SUJECT_CITY_OF_TSSIGNER 0x0000020B
#define SGD_SUBJECT_EMAIL_OF_TSSIGNER 0x0000020C
/* single sign-on */
#define SGD_SP_ID 0x00000001
#define SGD_SP_USER_ID 0x00000002
#define SGD_IDP_ID 0x00000003
#define SGD_IDP_USER_ID 0x00000004
/* data encoding */
#define SGD_ENCODING_RAW 0x00000000
#define SGD_ENCODING_DER 0x01000000
#define SGD_ENCODING_BASE64 0x02000000
#define SGD_ENCODING_PEM 0x03000000
#define SGD_ENCODING_TXT 0x04000000
/* APIs */
#define SGD_PROTOCOL_CSP 1 /* Microsoft CryptoAPI */
#define SGD_PROTOCOL_PKCS11 2 /* PKCS#11 */
#define SGD_PROTOCOL_SDS 3 /* SDF API */
#define SGD_PROTOCOL_UKEY 4 /* SKF API */
#define SGD_PROTOCOL_CNG 5 /* Microsoft CryptoAPI Next Gen */
#define SGD_PROTOCOL_GCS 6 /* */
/* certificate validation */
#define SGD_CRL_VERIFY 1
#define SGD_OCSP_VEIFY 2
/* role */
#define SGD_ROLE_SUPER_MANAGER 0x00000001
#define SGD_ROLE_MANAGER 0x00000002
#define SGD_ROLE_AUDIT_MANAGER 0x00000003
#define SGD_ROLE_AUDITOR 0x00000004
#define SGD_ROLE_OPERATOR 0x00000005
#define SGD_ROLE_USER 0x00000006
/* user operations */
#define SGD_OPERATION_SIGNIN 0x00000001
#define SGD_OPERATION_SIGNOUT 0x00000002
#define SGD_OPERATION_CREATE 0x00000003
#define SGD_OPERATION_DELETE 0x00000004
#define SGD_OPERATION_MODIFY 0x00000005
#define SGD_OPERATION_CHG_PWD 0x00000006
#define SGD_OPERATION_AUTHORIZATION 0x00000007
/* user operation results */
#define SGD_OPERATION_SUCCESS 0x00000000
/* key types */
#define SGD_MAIN_KEY 0x00000101
#define SGD_DEVICE_KEYS 0x00000102
#define SGD_USER_KEYS 0x00000103
#define SGD_KEY 0x00000104
#define SGD_SESSION_KEY 0x00000105
#define SGD_PRIKEY_PASSWD 0x00000106
#define SGD_COMPARTITION_KEY 0x00000107
/* key operations */
#define SGD_KEY_GENERATION 0x00000101
#define SGD_KEY_DISPENSE 0x00000102
#define SGD_KEY_IMPORT 0x00000103
#define SGD_KEY_EXPORT 0x00000104
#define SGD_KEY_DIVISION 0x00000105
#define SGD_KEY_COMPOSE 0x00000106
#define SGD_KEY_RENEWAL 0x00000107
#define SGD_KEY_BACKUP 0x00000108
#define SGD_KEY_RESTORE 0x00000109
#define SGD_KEY_DESTORY 0x0000010A
/* system operations */
#define SGD_SYSTEM_INIT 0x00000201
#define SGD_SYSTEM_START 0x00000202
#define SGD_SYSTEM_SHUT 0x00000203
#define SGD_SYSTEM_RESTART 0x00000204
#define SGD_SYSTEM_QUERY 0x00000205
#define SGD_SYSTEM_BACKUP 0x00000206
#define SGD_SYSTEM_RESTORE 0x00000207
/* device info */
#define SGD_DEVICE_SORT 0x00000201
#define SGD_DEVICE_TYPE 0x00000202
#define SGD_DEVICE_NAME 0x00000203
#define SGD_DEVICE_MANUFACTURER 0x00000204
#define SGD_DEVICE_HARDWARE_VERSION 0x00000205
#define SGD_DEVICE_SOFTWARE_VERSION 0x00000206
#define SGD_DEVICE_STANDARD_VERSION 0x00000207
#define SGD_DEVICE_SERIAL_NUMBER 0x00000208
#define SGD_DEVICE_SUPPORT_SYMM_ALG 0x00000209
#define SGD_DEVICE_SUPPORT_PKEY_ALG 0x0000020A
#define SGD_DEVICE_SUPPORT_HASH_ALG 0x0000020B
#define SGD_DEVICE_SUPPORT_STORAGE_SPACE 0x0000020C
#define SGD_DEVICE_SUPPORT_FREE_SPACE 0x0000020D
#define SGD_DEVICE_RUNTIME 0x0000020E
#define SGD_DEVICE_USED_TIMES 0x0000020F
#define SGD_DEVICE_LOCATION 0x00000210
#define SGD_DEVICE_DESCRIPTION 0x00000211
#define SGD_DEVICE_MANAGER_INFO 0x00000212
#define SGD_DEVICE_MAX_DATA_SIZE 0x00000213
/* device types */
#define SGD_DEVICE_SORT_SJ 0x02000000 /* Server */
#define SGD_DEVICE_SORT_SK 0x03000000 /* PCI-E Card */
#define SGD_DEVICE_SORT_SM 0x04000000 /* USB-Key and SmartCard */
/* device functionality */
#define SGD_DEVICE_SORT_FE 0x00000100 /* encryption */
#define SGD_DEVICE_SORT_FA 0x00000200 /* authentication */
#define SGD_DEVICE_SORT_FM 0x00000300 /* key management */
/* device status */
#define SGD_STATUS_INIT 0x00000201
#define SGD_STATUS_READY 0x00000202
#define SGD_STATUS_EXCEPTION 0x00000203
/* SKF */
#ifndef WIN32
typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef long BOOL;
typedef UINT8 BYTE;
typedef UINT8 CHAR;
typedef INT16 SHORT;
typedef UINT16 USHORT;
typedef INT32 LONG;
typedef UINT32 ULONG;
typedef UINT32 UINT;
typedef UINT16 WORD;
typedef UINT32 DWORD;
typedef UINT32 FLAGS;
typedef CHAR * LPSTR;
typedef void * HANDLE;
#else
#ifndef _WINDEF_H
typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef long BOOL;
typedef UINT8 BYTE;
typedef UINT8 CHAR;
typedef INT16 SHORT;
typedef UINT16 USHORT;
typedef INT32 LONG;
typedef UINT32 ULONG;
typedef UINT32 UINT;
typedef UINT16 WORD;
typedef UINT32 DWORD;
typedef UINT32 FLAGS;
typedef CHAR * LPSTR;
typedef void * HANDLE;
#endif
#endif
typedef HANDLE DEVHANDLE;
typedef HANDLE HAPPLICATION;
typedef HANDLE HSESSION;
typedef HANDLE HCONTAINER;
#ifndef FALSE
#define FALSE 0x00000000
#endif
#ifndef TRUE
#define TRUE 0x00000001
#endif
#ifdef WIN32
#define DEVAPI __stdcall
#else
#define DEVAPI
#endif
#ifndef ADMIN_TYPE
#define ADMIN_TYPE 0
#endif
#ifndef USER_TYPE
#define USER_TYPE 1
#endif
#define MAX_RSA_MODULUS_LEN 256
#define MAX_RSA_EXPONENT_LEN 4
#define ECC_MAX_XCOORDINATE_BITS_LEN 512
#define ECC_MAX_YCOORDINATE_BITS_LEN 512
#define ECC_MAX_MODULUS_BITS_LEN 512
#define MAX_IV_LEN 32
#define MAX_FILE_NAME_SIZE 32
#define MAX_FILE_CONTAINER_NAME_SIZE 64
#define SECURE_NEVER_ACCOUNT 0x00000000
#define SECURE_ADM_ACCOUNT 0x00000001
#define SECURE_USER_ACCOUNT 0x00000010
#define SECURE_ANYONE_ACCOUNT 0x000000FF
/* SDF */
#define RSAref_MAX_BITS 2048
#define RSAref_MAX_LEN ((RSAref_MAX_BITS + 7) / 8)
#define RSAref_MAX_PBITS ((RSAref_MAX_BITS + 1) / 2)
#define RSAref_MAX_PLEN ((RSAref_MAX_PBITS + 7)/ 8)
#define ECCref_MAX_BITS 512
#define ECCref_MAX_LEN ((ECCref_MAX_BITS+7) / 8)
/* SAF */
#define SGD_MAX_COUNT 64
#define SGD_MAX_NAME_SIZE 256
/* SOF */
typedef char *BSTR;
typedef long BOOL;
#endif
#endif

View File

@@ -1,67 +0,0 @@
#ifndef HEADER_SIMON_H
#define HEADER_SIMON_H
#ifndef CIPHER_CONSTANTS
#define CIPHER_CONSTANTS
enum mode_t { ECB, CTR, CBC, CFB, OFB };
#endif
#include <stdint.h>
enum simon_cipher_config_t { simon_64_32,
simon_72_48,
simon_96_48,
simon_96_64,
simon_128_64,
simon_96_96,
simon_144_96,
simon_128_128,
simon_192_128,
simon_256_128
};
typedef struct {
enum simon_cipher_config_t cipher_cfg;
uint8_t key_size;
uint8_t block_size;
uint8_t round_limit;
uint8_t init_vector[16];
uint8_t counter[16];
uint8_t key_schedule[576];
uint8_t z_seq;
} simon_cipher;
typedef struct _bword_24{
uint32_t data: 24;
} bword_24;
typedef struct _bword_48{
uint64_t data: 48;
} bword_48;
#ifdef __cplusplus
extern "C"{
#endif
uint8_t simon_init(simon_cipher *cipher_object, enum simon_cipher_config_t cipher_cfg, enum mode_t c_mode, void *key, uint8_t *iv, uint8_t *counter);
uint8_t simon_encrypt(simon_cipher cipher_object, void *plaintext, void *ciphertext);
uint8_t simon_decrypt(simon_cipher cipher_object, void *ciphertext, void *plaintext);
void simon_encrypt32(uint8_t *key_schedule, uint8_t *plaintext, uint8_t *ciphertext);
void simon_encrypt48(uint8_t round_limit, uint8_t *key_schedule, uint8_t *plaintext, uint8_t *ciphertext);
void simon_encrypt64(uint8_t round_limit, uint8_t *key_schedule, uint8_t *plaintext, uint8_t *ciphertext);
void simon_encrypt96(uint8_t round_limit, uint8_t *key_schedule, uint8_t *plaintext, uint8_t *ciphertext);
void simon_encrypt128(uint8_t round_limit, uint8_t *key_schedule, uint8_t *plaintext, uint8_t *ciphertext);
void simon_decrypt32(uint8_t *key_schedule, uint8_t *ciphertext, uint8_t *plaintext);
void simon_decrypt48(uint8_t round_limit, uint8_t *key_schedule, uint8_t *ciphertext, uint8_t *plaintext);
void simon_decrypt64(uint8_t round_limit, uint8_t *key_schedule, uint8_t *ciphertext, uint8_t *plaintext);
void simon_decrypt96(uint8_t round_limit, uint8_t *key_schedule, uint8_t *ciphertext, uint8_t *plaintext);
void simon_decrypt128(uint8_t round_limit, uint8_t *key_schedule, uint8_t *ciphertext, uint8_t *plaintext);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -53,111 +53,22 @@
#ifndef HEADER_SKF_H
#define HEADER_SKF_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SKF
#include <openssl/sgd.h>
//FIXME: all the WIN32 types
#ifndef WIN32
typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef long BOOL;
typedef UINT8 BYTE;
typedef UINT8 CHAR;
typedef INT16 SHORT;
typedef UINT16 USHORT;
typedef INT32 LONG;
typedef UINT32 ULONG;
typedef UINT32 UINT;
typedef UINT16 WORD;
typedef UINT32 DWORD;
typedef UINT32 FLAGS;
typedef CHAR * LPSTR;
typedef void * HANDLE;
#else
#ifndef _WINDEF_H
typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef long BOOL;
typedef UINT8 BYTE;
typedef UINT8 CHAR;
typedef INT16 SHORT;
typedef UINT16 USHORT;
typedef INT32 LONG;
typedef UINT32 ULONG;
typedef UINT32 UINT;
typedef UINT16 WORD;
typedef UINT32 DWORD;
typedef UINT32 FLAGS;
typedef CHAR * LPSTR;
typedef void * HANDLE;
#endif
#endif
typedef HANDLE DEVHANDLE;
typedef HANDLE HAPPLICATION;
typedef HANDLE HSESSION;
typedef HANDLE HCONTAINER;
#ifndef FALSE
#define FALSE 0x00000000
#endif
#ifndef TRUE
#define TRUE 0x00000001
#endif
#ifdef WIN32
#define DEVAPI __stdcall
#else
#define DEVAPI
#endif
#ifndef ADMIN_TYPE
#define ADMIN_TYPE 0
#endif
#ifndef USER_TYPE
#define USER_TYPE 1
#endif
#define MAX_RSA_MODULUS_LEN 256
#define MAX_RSA_EXPONENT_LEN 4
#define ECC_MAX_XCOORDINATE_BITS_LEN 512
#define ECC_MAX_YCOORDINATE_BITS_LEN 512
#define ECC_MAX_MODULUS_BITS_LEN 512
#define MAX_IV_LEN 32
#define MAX_FILE_NAME_SIZE 32
#define MAX_FILE_CONTAINER_NAME_SIZE 64
#define SECURE_NEVER_ACCOUNT 0x00000000
#define SECURE_ADM_ACCOUNT 0x00000001
#define SECURE_USER_ACCOUNT 0x00000010
#define SECURE_ANYONE_ACCOUNT 0x000000FF
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Struct_Version{
#pragma pack(1)
typedef struct /*__attribute__((packed))*/ Struct_Version{
BYTE major;
BYTE minor;
} VERSION;
typedef struct Struct_DEVINFO {
typedef struct /*__attribute__((packed))*/ Struct_DEVINFO {
VERSION Version;
CHAR Manufacturer[64];
CHAR Issuer[64];
@@ -176,14 +87,14 @@ typedef struct Struct_DEVINFO {
BYTE Reserved[64];
} DEVINFO, *PDEVINFO;
typedef struct Struct_RSAPUBLICKEYBLOB {
typedef struct /*__attribute__((packed))*/ Struct_RSAPUBLICKEYBLOB {
ULONG AlgID;
ULONG BitLen;
BYTE Modulus[MAX_RSA_MODULUS_LEN];
BYTE PublicExponent[MAX_RSA_EXPONENT_LEN];
} RSAPUBLICKEYBLOB, *PRSAPUBLICKEYBLOB;
typedef struct Struct_RSAPRIVATEKEYBLOB {
typedef struct /*__attribute__((packed))*/ Struct_RSAPRIVATEKEYBLOB {
ULONG AlgID;
ULONG BitLen;
BYTE Modulus[MAX_RSA_MODULUS_LEN];
@@ -196,18 +107,18 @@ typedef struct Struct_RSAPRIVATEKEYBLOB {
BYTE Coefficient[MAX_RSA_MODULUS_LEN/2];
} RSAPRIVATEKEYBLOB, *PRSAPRIVATEKEYBLOB;
typedef struct Struct_ECCPUBLICKEYBLOB {
typedef struct /*__attribute__((packed))*/ Struct_ECCPUBLICKEYBLOB {
ULONG BitLen;
BYTE XCoordinate[ECC_MAX_XCOORDINATE_BITS_LEN/8];
BYTE YCoordinate[ECC_MAX_YCOORDINATE_BITS_LEN/8];
} ECCPUBLICKEYBLOB, *PECCPUBLICKEYBLOB;
typedef struct Struct_ECCPRIVATEKEYBLOB {
typedef struct /*__attribute__((packed))*/ Struct_ECCPRIVATEKEYBLOB {
ULONG BitLen;
BYTE PrivateKey[ECC_MAX_MODULUS_BITS_LEN/8];
} ECCPRIVATEKEYBLOB, *PECCPRIVATEKEYBLOB;
typedef struct Struct_ECCCIPHERBLOB {
typedef struct /*__attribute__((packed))*/ Struct_ECCCIPHERBLOB {
BYTE XCoordinate[ECC_MAX_XCOORDINATE_BITS_LEN/8];
BYTE YCoordinate[ECC_MAX_XCOORDINATE_BITS_LEN/8];
BYTE HASH[32];
@@ -215,19 +126,19 @@ typedef struct Struct_ECCCIPHERBLOB {
BYTE Cipher[1];
} ECCCIPHERBLOB, *PECCCIPHERBLOB;
typedef struct Struct_ECCSIGNATUREBLOB {
typedef struct /*__attribute__((packed))*/ Struct_ECCSIGNATUREBLOB {
BYTE r[ECC_MAX_XCOORDINATE_BITS_LEN/8];
BYTE s[ECC_MAX_XCOORDINATE_BITS_LEN/8];
} ECCSIGNATUREBLOB, *PECCSIGNATUREBLOB;
typedef struct Struct_BLOCKCIPHERPARAM {
typedef struct /*__attribute__((packed))*/ Struct_BLOCKCIPHERPARAM {
BYTE IV[MAX_IV_LEN];
ULONG IVLen;
ULONG PaddingType;
ULONG FeedBitLen;
} BLOCKCIPHERPARAM, *PBLOCKCIPHERPARAM;
typedef struct SKF_ENVELOPEDKEYBLOB {
typedef struct /*__attribute__((packed))*/ SKF_ENVELOPEDKEYBLOB {
ULONG Version;
ULONG ulSymmAlgID;
ULONG ulBits;
@@ -236,13 +147,13 @@ typedef struct SKF_ENVELOPEDKEYBLOB {
ECCCIPHERBLOB ECCCipherBlob;
} ENVELOPEDKEYBLOB, *PENVELOPEDKEYBLOB;
typedef struct Struct_FILEATTRIBUTE {
typedef struct /*__attribute__((packed))*/ Struct_FILEATTRIBUTE {
CHAR FileName[MAX_FILE_NAME_SIZE];
ULONG FileSize;
ULONG ReadRights;
ULONG WriteRights;
} FILEATTRIBUTE, *PFILEATTRIBUTE;
#pragma pack()
ULONG DEVAPI SKF_WaitForDevEvent(
LPSTR szDevName,
@@ -439,16 +350,16 @@ ULONG DEVAPI SKF_GenRandom(
BYTE *pbRandom,
ULONG ulRandomLen);
ULONG DEVAPI SKF_GenExtRSAKey(
DEVHANDLE hDev,
ULONG ulBitsLen,
RSAPRIVATEKEYBLOB *pBlob);
ULONG DEVAPI SKF_GenRSAKeyPair(
HCONTAINER hContainer,
ULONG ulBitsLen,
RSAPUBLICKEYBLOB *pBlob);
ULONG DEVAPI SKF_GenExtRSAKey(
DEVHANDLE hDev,
ULONG ulBitsLen,
RSAPRIVATEKEYBLOB *pBlob);
ULONG DEVAPI SKF_ImportRSAKeyPair(
HCONTAINER hContainer,
ULONG ulSymAlgId,
@@ -511,6 +422,13 @@ ULONG DEVAPI SKF_ECCSignData(
ULONG ulDigestLen,
ECCSIGNATUREBLOB *pSignature);
/* Extension */
ULONG DEVAPI SKF_ECCDecrypt(
HCONTAINER hContainer,
ECCCIPHERBLOB *pCipherBlob,
BYTE *pbPlainText,
ULONG *pulPlainTextLen);
ULONG DEVAPI SKF_ECCVerify(
DEVHANDLE hDev,
ECCPUBLICKEYBLOB *pECCPubKeyBlob,
@@ -741,9 +659,11 @@ ULONG DEVAPI SKF_CloseHandle(
#define SAR_FILE_ALREADY_EXIST 0x0A00002F
#define SAR_NO_ROOM 0x0A000030
#define SAR_FILE_NOT_EXIST 0x0A000031
#define SAR_REACH_MAX_CONTAINER_COUNT 0x0A000032
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@@ -50,6 +50,9 @@
#ifndef HEADER_SM2_H
#define HEADER_SM2_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SM2
#include <openssl/ec.h>
#include <openssl/err.h>
#include <openssl/evp.h>
@@ -68,7 +71,7 @@ extern "C" {
#define SM2_MAX_ID_LENGTH (SM2_MAX_ID_BITS/8)
#define SM2_DEFAULT_ID_GMT09 "1234567812345678"
#define SM2_DEFAULT_ID_GMSSL "anonym@gmssl.org"
#define SM2_DEFAULT_ID SM2_DEFAULT_ID_GMSSL
#define SM2_DEFAULT_ID SM2_DEFAULT_ID_GMT09
#define SM2_DEFAULT_ID_LENGTH (sizeof(SM2_DEFAULT_ID) - 1)
#define SM2_DEFAULT_ID_BITS (SM2_DEFAULT_ID_LENGTH * 8)
#define SM2_DEFAULT_ID_DIGEST_LENGTH SM3_DIGEST_LENGTH
@@ -83,6 +86,9 @@ int SM2_compute_message_digest(const EVP_MD *id_md, const EVP_MD *msg_md,
/* SM2 digital signature */
#define SM2_MAX_SIGNATURE_LENGTH 96
int SM2_sign_setup(EC_KEY *ec_key, BN_CTX *ctx, BIGNUM **a, BIGNUM **b);
ECDSA_SIG *SM2_do_sign_ex(const unsigned char *dgst, int dgstlen,
const BIGNUM *a, const BIGNUM *b, EC_KEY *ec_key);
@@ -102,6 +108,7 @@ int SM2_verify(int type, const unsigned char *dgst, int dgstlen,
#define SM2_MIN_PLAINTEXT_LENGTH 0
#define SM2_MAX_PLAINTEXT_LENGTH 1024
#define SM2_CIPHERTEXT_LENGTH(len) ((len)+256)
typedef struct SM2CiphertextValue_st SM2CiphertextValue;
DECLARE_ASN1_FUNCTIONS(SM2CiphertextValue)
@@ -124,8 +131,15 @@ int SM2_decrypt(int type, const unsigned char *in, size_t inlen,
#define SM2_decrypt_with_recommended(in,inlen,out,outlen,ec_key) \
SM2_decrypt(NID_sm3,in,inlen,out,outlen,ec_key)
int SM2CiphertextValue_size(const EC_GROUP *group, int inlen);
/* SM2 Key Exchange */
int SM2_compute_share_key(unsigned char *out, size_t *outlen,
const EC_POINT *peer_ephem, EC_KEY *ephem,
const EC_POINT *peer_pk, const unsigned char *peer_z, size_t peer_zlen,
const unsigned char *z, size_t zlen, EC_KEY *sk, int initiator);
typedef struct sm2_kap_ctx_st SM2_KAP_CTX;
int SM2_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
@@ -144,6 +158,7 @@ int SM2_KAP_final_check(SM2_KAP_CTX *ctx, const unsigned char *checksum,
size_t checksumlen);
void SM2_KAP_CTX_cleanup(SM2_KAP_CTX *ctx);
/* EC_KEY_METHOD */
const EC_KEY_METHOD *EC_KEY_GmSSL(void);
void EC_KEY_set_default_secg_method(void);
@@ -176,52 +191,69 @@ void EC_KEY_METHOD_get_decrypt(EC_KEY_METHOD *meth,
unsigned char *out, size_t *outlen, EC_KEY *ec_key));
#define EVP_PKEY_CTX_set_ec_sign_type(ctx, type) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
EVP_PKEY_OP_VERIFY|EVP_PKEY_OP_VERIFYCTX, \
EVP_PKEY_CTRL_EC_SIGN_TYPE, type, NULL)
#define EVP_PKEY_CTRL_EC_SCHEME (EVP_PKEY_ALG_CTRL + 11)
#define EVP_PKEY_CTRL_SIGNER_ID (EVP_PKEY_ALG_CTRL + 12)
#define EVP_PKEY_CTRL_GET_SIGNER_ID (EVP_PKEY_ALG_CTRL + 13)
#define EVP_PKEY_CTRL_GET_SIGNER_ZID (EVP_PKEY_ALG_CTRL + 14)
#define EVP_PKEY_CTRL_EC_ENCRYPT_PARAM (EVP_PKEY_ALG_CTRL + 15)
#define EVP_PKEY_CTX_get_ec_sign_type(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
EVP_PKEY_OP_VERIFY|EVP_PKEY_OP_VERIFYCTX, \
EVP_PKEY_CTRL_EC_SIGN_TYPE, -2, NULL)
#define EVP_PKEY_CTX_set_ec_enc_type(ctx, type) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_ENCRYPT|EVP_PKEY_OP_DECRYPT, \
EVP_PKEY_CTRL_EC_ENC_TYPE, type, NULL)
#define EVP_PKEY_CTX_get_ec_enc_type(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_ENCRYPT|EVP_PKEY_OP_DECRYPT, \
EVP_PKEY_CTRL_EC_ENC_TYPE, -2, NULL)
#define EVP_PKEY_CTX_set_ec_dh_type(ctx, type) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_DH_TYPE, type, NULL)
#define EVP_PKEY_CTX_get_ec_dh_type(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_DH_TYPE, -2, NULL);
#define EVP_PKEY_CTX_set_sm2_id(ctx, type) \
#ifndef OPENSSL_NO_MACRO
#define EVP_PKEY_CTX_set_ec_scheme(ctx, scheme) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
EVP_PKEY_OP_VERIFY|EVP_PKEY_OP_VERIFYCTX| \
EVP_PKEY_OP_DERIVE, type, NULL)
EVP_PKEY_OP_ENCRYPT|EVP_PKEY_OP_DECRYPT| \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_SCHEME, scheme, NULL)
#define EVP_PKEY_CTX_get_ec_scheme(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
EVP_PKEY_OP_VERIFY|EVP_PKEY_OP_VERIFYCTX| \
EVP_PKEY_OP_ENCRYPT|EVP_PKEY_OP_DECRYPT| \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_EC_SCHEME, -2, NULL)
#define EVP_PKEY_CTRL_EC_SIGN_TYPE (EVP_PKEY_ALG_CTRL + 11)
#define EVP_PKEY_CTRL_GET_EC_SIGN_TYPE (EVP_PKEY_ALG_CTRL + 12)
#define EVP_PKEY_CTRL_EC_ENC_TYPE (EVP_PKEY_ALG_CTRL + 13)
#define EVP_PKEY_CTRL_GET_EC_ENC_TYPE (EVP_PKEY_ALG_CTRL + 14)
#define EVP_PKEY_CTRL_EC_DH_TYPE (EVP_PKEY_ALG_CTRL + 15)
#define EVP_PKEY_CTRL_GET_EC_DH_TYPE (EVP_PKEY_ALG_CTRL + 16)
#define EVP_PKEY_CTX_set_signer_id(ctx, id) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
EVP_PKEY_OP_VERIFY|EVP_PKEY_OP_VERIFYCTX| \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_SIGNER_ID, 0, (void *)id)
#define EVP_PKEY_CTX_get_signer_id(ctx, pid) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
EVP_PKEY_OP_VERIFY|EVP_PKEY_OP_VERIFYCTX| \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_SIGNER_ID, 0, (void *)pid)
#define EVP_PKEY_CTX_get_signer_zid(ctx, pzid) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_SIGN|EVP_PKEY_OP_SIGNCTX| \
EVP_PKEY_OP_VERIFY|EVP_PKEY_OP_VERIFYCTX| \
EVP_PKEY_OP_DERIVE, \
EVP_PKEY_CTRL_GET_SIGNER_ZID, 0, (void *)pzid)
#define EVP_PKEY_CTX_set_ec_encrypt_param(ctx, param) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_ENCRYPT|EVP_PKEY_OP_DECRYPT, \
EVP_PKEY_CTRL_EC_ENCRYPT_PARAM, param, NULL)
#define EVP_PKEY_CTX_get_ec_encrypt_param(ctx) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \
EVP_PKEY_OP_ENCRYPT|EVP_PKEY_OP_DECRYPT, \
EVP_PKEY_CTRL_EC_ENCRYPT_PARAM, -2, NULL)
#else
int EVP_PKEY_CTX_set_ec_scheme(EVP_PKEY_CTX *ctx, int scheme);
int EVP_PKEY_CTX_get_ec_scheme(EVP_PKEY_CTX *ctx, int scheme);
int EVP_PKEY_CTX_set_signer_id(EVP_PKEY_CTX *ctx, const char *id);
int EVP_PKEY_CTX_get_signer_id(EVP_PKEY_CTX *ctx, char **pid);
int EVP_PKEY_CTX_get_signer_zid(EVP_PKEY_CTX *ctx, unsigned char **pzid);
int EVP_PKEY_CTX_set_ec_encrypt_param(EVP_PKEY_CTX *ctx, int param);
int EVP_PKEY_CTX_get_ec_encrypt_param(EVP_PKEY_CTX *ctx);
#endif
/* BEGIN ERROR CODES */
@@ -265,3 +297,4 @@ int ERR_load_SM2_strings(void);
}
# endif
#endif
#endif

View File

@@ -1,5 +1,5 @@
/* ====================================================================
* Copyright (c) 2014 - 2016 The GmSSL Project. All rights reserved.
* Copyright (c) 2014 - 2017 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
@@ -50,15 +50,18 @@
#ifndef HEADER_SM3_H
#define HEADER_SM3_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SM3
#define SM3_DIGEST_LENGTH 32
#define SM3_BLOCK_SIZE 64
#define SM3_CBLOCK (SM3_BLOCK_SIZE)
#define SM3_HMAC_SIZE (SM3_DIGEST_LENGTH)
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <openssl/e_os2.h>
#ifdef __cplusplus
extern "C" {
@@ -95,3 +98,4 @@ void sm3_hmac(const unsigned char *data, size_t data_len,
}
#endif
#endif
#endif

View File

@@ -50,11 +50,17 @@
#ifndef HEADER_SM9_H
#define HEADER_SM9_H
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SM9
#include <openssl/bn.h>
#include <openssl/ec.h>
#include <openssl/evp.h>
#include <openssl/asn1.h>
/* set the same value as sm2 */
#define SM9_MAX_ID_BITS 65535
#define SM9_MAX_ID_LENGTH (SM9_MAX_ID_BITS/8)
#ifdef __cplusplus
extern "C" {
@@ -62,6 +68,7 @@ extern "C" {
typedef struct SM9PublicParameters_st SM9PublicParameters;
typedef struct SM9MasterSecret_st SM9MasterSecret;
typedef struct SM9PublicKey_st SM9PublicKey;
typedef struct SM9PrivateKey_st SM9PrivateKey;
typedef struct SM9Ciphertext_st SM9Ciphertext;
typedef struct SM9Signature_st SM9Signature;
@@ -74,6 +81,24 @@ SM9PrivateKey *SM9_extract_private_key(SM9PublicParameters *mpk,
SM9MasterSecret *msk,
const char *id, size_t idlen);
SM9PublicKey *SM9_extract_sign_public_key(SM9PublicParameters *mpk,
const char *id, size_t idlen);
SM9PublicKey *SM9_extract_exch_public_key(SM9PublicParameters *mpk,
const char *id, size_t idlen);
SM9PublicKey *SM9_extract_enc_public_key(SM9PublicParameters *mpk,
const char *id, size_t idlen);
SM9PublicKey *SM9PrivateKey_get_public_key(SM9PublicParameters *mpk,
SM9PrivateKey *sk);
int SM9PrivateKey_get_gmtls_public_key(SM9PublicParameters *mpk,
SM9PrivateKey *sk, unsigned char pub_key[1024]);
int SM9PublicKey_get_gmtls_encoded(SM9PublicParameters *mpk,
SM9PublicKey *pk, unsigned char encoded[1024]);
typedef struct {
const EVP_MD *kdf_md;
const EVP_CIPHER *enc_cipher;
@@ -82,6 +107,11 @@ typedef struct {
const EVP_MD *hmac_md;
} SM9EncParameters;
SM9Ciphertext *SM9_do_encrypt_ex(SM9PublicParameters *mpk,
const SM9EncParameters *encparams,
const unsigned char *in, size_t inlen,
SM9PublicKey *pk);
SM9Ciphertext *SM9_do_encrypt(SM9PublicParameters *mpk,
const SM9EncParameters *encparams,
const unsigned char *in, size_t inlen,
@@ -94,6 +124,12 @@ int SM9_do_decrypt(SM9PublicParameters *mpk,
SM9PrivateKey *sk,
const char *id, size_t idlen);
int SM9_encrypt_ex(SM9PublicParameters *mpk,
const SM9EncParameters *encparams,
const unsigned char *in, size_t inlen,
unsigned char *out, size_t *outlen,
SM9PublicKey *pk);
int SM9_encrypt(SM9PublicParameters *mpk,
const SM9EncParameters *encparams,
const unsigned char *in, size_t inlen,
@@ -107,6 +143,11 @@ int SM9_decrypt(SM9PublicParameters *mpk,
SM9PrivateKey *sk,
const char *id, size_t idlen);
int SM9_encrypt_with_recommended_ex(SM9PublicParameters *mpk,
const unsigned char *in, size_t inlen,
unsigned char *out, size_t *outlen,
SM9PublicKey *pk);
int SM9_encrypt_with_recommended(SM9PublicParameters *mpk,
const unsigned char *in, size_t inlen,
unsigned char *out, size_t *outlen,
@@ -118,10 +159,17 @@ int SM9_decrypt_with_recommended(SM9PublicParameters *mpk,
SM9PrivateKey *sk,
const char *id, size_t idlen);
int SM9_signature_size(SM9PublicParameters *mpk);
SM9Signature *SM9_do_sign(SM9PublicParameters *mpk,
const unsigned char *dgst, size_t dgstlen,
SM9PrivateKey *sk);
int SM9_do_verify_ex(SM9PublicParameters *mpk,
const unsigned char *dgst, size_t dgstlen,
const SM9Signature *sig,
SM9PublicKey *pk);
int SM9_do_verify(SM9PublicParameters *mpk,
const unsigned char *dgst, size_t dgstlen,
const SM9Signature *sig,
@@ -132,14 +180,30 @@ int SM9_sign(SM9PublicParameters *mpk,
unsigned char *sig, size_t *siglen,
SM9PrivateKey *sk);
int SM9_verify_ex(SM9PublicParameters *mpk,
const unsigned char *dgst, size_t dgstlen,
const unsigned char *sig, size_t siglen,
SM9PublicKey *pk);
int SM9_verify(SM9PublicParameters *mpk,
const unsigned char *dgst, size_t dgstlen,
const unsigned char *sig, size_t siglen,
const char *id, size_t idlen);
SM9PublicKey *SM9_generate_key_exchange(SM9PublicParameters *mpk,
const char *peer_id, size_t peer_idlen, BIGNUM **r);
int SM9_compute_share_key(SM9PublicParameters *mpk,
unsigned char *out, size_t *outlen,
const char *peer_id, size_t peer_idlen, SM9PublicKey *peer_exch,
const char *id, size_t idlen, SM9PublicKey *exch,
SM9PrivateKey *sk, int initiator);
DECLARE_ASN1_FUNCTIONS(SM9PublicParameters)
DECLARE_ASN1_FUNCTIONS(SM9MasterSecret)
DECLARE_ASN1_FUNCTIONS(SM9PrivateKey)
DECLARE_ASN1_FUNCTIONS(SM9PublicKey)
DECLARE_ASN1_FUNCTIONS(SM9Ciphertext)
DECLARE_ASN1_FUNCTIONS(SM9Signature)
@@ -203,3 +267,4 @@ int ERR_load_SM9_strings(void);
}
# endif
#endif
#endif

View File

@@ -51,7 +51,7 @@
#define HEADER_SMS4_H
#include <openssl/opensslconf.h>
#ifndef NO_GMSSL
#ifndef OPENSSL_NO_SMS4
#define SMS4_KEY_LENGTH 16
#define SMS4_BLOCK_SIZE 16
@@ -59,7 +59,7 @@
#define SMS4_NUM_ROUNDS 32
#include <sys/types.h>
#include <stdint.h>
#include <openssl/e_os2.h>
#include <string.h>
@@ -128,6 +128,3 @@ void sms4_ede_decrypt_16blocks(sms4_ede_key_t *key, const unsigned char *in, uns
#endif
#endif
#endif

View File

@@ -46,15 +46,14 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*/
/* This header file is from "GM/T 0020-2012 Certificate Application
* Integrated Service Interface Specification"
*/
#ifndef HEADER_SOF_H
#define HEADER_SOF_H
typedef char *BSTR;
typedef long BOOL;
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SOF
#include <openssl/sgd.h>
#ifdef __cplusplus
extern "C" {
@@ -158,9 +157,8 @@ BSTR SOF_GetTimeStampInfo(BSTR tsResponseData, short type);
#define SOR_CTLNotFound 0x0B000420
#define SOR_AppNotFound 0x0B000421
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@@ -46,67 +46,46 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*/
#ifndef SPECK_H
#define SPECK_H
#ifndef HEADER_SPECK_H
#define HEADER_SPECK_H
#define SPECK_TYPE16 uint16_t
#define SPECK_ROUNDS16 22
#define SPECK_KEY_LEN16 4
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_SPECK
#define SPECK_ROUNDS16 22
#define SPECK_KEY_LEN16 4
#define SPECK_TYPE32 uint32_t
#define SPECK_ROUNDS32 27
#define SPECK_KEY_LEN32 4
#define SPECK_ROUNDS32 27
#define SPECK_KEY_LEN32 4
#define SPECK_TYPE64 uint64_t
#define SPECK_ROUNDS64 34
#define SPECK_KEY_LEN64 4
#define SPECK_ROUNDS64 34
#define SPECK_KEY_LEN64 4
#define ROR16(x, r) ((x >> r) | (x << ((sizeof(SPECK_TYPE16) * 8) - r)))//循环右移
#define ROL16(x, r) ((x << r) | (x >> ((sizeof(SPECK_TYPE16) * 8) - r)))//循环左移
#define ROR32(x, r) ((x >> r) | (x << ((sizeof(SPECK_TYPE32) * 8) - r)))//循环右移
#define ROL32(x, r) ((x << r) | (x >> ((sizeof(SPECK_TYPE32) * 8) - r)))//循环左移
#define ROR64(x, r) ((x >> r) | (x << ((sizeof(SPECK_TYPE64) * 8) - r)))//循环右移
#define ROL64(x, r) ((x << r) | (x >> ((sizeof(SPECK_TYPE64) * 8) - r)))//循环左移
#define R16(x, y, k) (x = ROR16(x, 7), x += y, x ^= k, y = ROL16(y, 2), y ^= x)
#define RR16(x, y, k) (y ^= x, y = ROR16(y, 2), x ^= k, x -= y, x = ROL16(x, 7))
#define R32(x, y, k) (x = ROR32(x, 8), x += y, x ^= k, y = ROL32(y, 3), y ^= x)
#define RR32(x, y, k) (y ^= x, y = ROR32(y, 3), x ^= k, x -= y, x = ROL32(x, 8))
#define R64(x, y, k) (x = ROR64(x, 8), x += y, x ^= k, y = ROL64(y, 3), y ^= x)
#define RR64(x, y, k) (y ^= x, y = ROR64(y, 3), x ^= k, x -= y, x = ROL64(x, 8))
#include <sys/types.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <openssl/e_os2.h>
#ifdef __cplusplus
extern "C" {
#endif
void speck_set_encrypt_key16(SPECK_TYPE16 const user[SPECK_KEY_LEN16], SPECK_TYPE16 key[SPECK_ROUNDS16]);
void speck_set_decrypt_key16(SPECK_TYPE16 const user[SPECK_KEY_LEN16], SPECK_TYPE16 key[SPECK_ROUNDS16]);
void speck_expand16(SPECK_TYPE16 const K[SPECK_KEY_LEN16], SPECK_TYPE16 S[SPECK_ROUNDS16]);
void speck_encrypt16(SPECK_TYPE16 const pt[2], SPECK_TYPE16 ct[2], SPECK_TYPE16 const K[SPECK_ROUNDS16]);
void speck_decrypt16(SPECK_TYPE16 const ct[2], SPECK_TYPE16 pt[2], SPECK_TYPE16 const K[SPECK_ROUNDS16]);
void speck_set_encrypt_key16(const uint16_t user[SPECK_KEY_LEN16], uint16_t key[SPECK_ROUNDS16]);
void speck_set_decrypt_key16(uint16_t const user[SPECK_KEY_LEN16], uint16_t key[SPECK_ROUNDS16]);
void speck_encrypt16(const uint16_t pt[2], uint16_t ct[2], const uint16_t K[SPECK_ROUNDS16]);
void speck_decrypt16(const uint16_t ct[2], uint16_t pt[2], const uint16_t K[SPECK_ROUNDS16]);
void speck_set_encrypt_key32(SPECK_TYPE32 const user[SPECK_KEY_LEN32], SPECK_TYPE32 key[SPECK_ROUNDS32]);
void speck_set_decrypt_key32(SPECK_TYPE32 const user[SPECK_KEY_LEN32], SPECK_TYPE32 key[SPECK_ROUNDS32]);
void speck_expand32(SPECK_TYPE32 const K[SPECK_KEY_LEN32], SPECK_TYPE32 S[SPECK_ROUNDS32]);
void speck_encrypt32(SPECK_TYPE32 const pt[2], SPECK_TYPE32 ct[2], SPECK_TYPE32 const K[SPECK_ROUNDS32]);
void speck_decrypt32(SPECK_TYPE32 const ct[2], SPECK_TYPE32 pt[2], SPECK_TYPE32 const K[SPECK_ROUNDS32]);
void speck_set_encrypt_key32(const uint32_t user[SPECK_KEY_LEN32], uint32_t key[SPECK_ROUNDS32]);
void speck_set_decrypt_key32(const uint32_t user[SPECK_KEY_LEN32], uint32_t key[SPECK_ROUNDS32]);
void speck_encrypt32(const uint32_t pt[2], uint32_t ct[2], const uint32_t K[SPECK_ROUNDS32]);
void speck_decrypt32(const uint32_t ct[2], uint32_t pt[2], const uint32_t K[SPECK_ROUNDS32]);
void speck_set_encrypt_key64(SPECK_TYPE64 const user[SPECK_KEY_LEN64], SPECK_TYPE64 key[SPECK_ROUNDS64]);
void speck_set_decrypt_key64(SPECK_TYPE64 const user[SPECK_KEY_LEN64], SPECK_TYPE64 key[SPECK_ROUNDS64]);
void speck_expand64(SPECK_TYPE64 const K[SPECK_KEY_LEN64], SPECK_TYPE64 S[SPECK_ROUNDS64]);
void speck_encrypt64(SPECK_TYPE64 const pt[2], SPECK_TYPE64 ct[2], SPECK_TYPE64 const K[SPECK_ROUNDS64]);
void speck_decrypt64(SPECK_TYPE64 const ct[2], SPECK_TYPE64 pt[2], SPECK_TYPE64 const K[SPECK_ROUNDS64]);
void speck_set_encrypt_key64(const uint64_t user[SPECK_KEY_LEN64], uint64_t key[SPECK_ROUNDS64]);
void speck_set_decrypt_key64(const uint64_t user[SPECK_KEY_LEN64], uint64_t key[SPECK_ROUNDS64]);
void speck_encrypt64(const uint64_t pt[2], uint64_t ct[2], const uint64_t K[SPECK_ROUNDS64]);
void speck_decrypt64(const uint64_t ct[2], uint64_t pt[2], const uint64_t K[SPECK_ROUNDS64]);
#ifdef __cplusplus
}
#endif
#endif
#endif

View File

@@ -112,7 +112,10 @@ extern "C" {
# define SSL_TXT_kGOST "kGOST"
# define SSL_TXT_kSRP "kSRP"
# define SSL_TXT_kSM2 "kSM2"
# define SSL_TXT_kSM2DHE "kSM2DHE"
# define SSL_TXT_kSM2PSK "kSM2PSK"
# define SSL_TXT_kSM9 "kSM9"
# define SSL_TXT_kSM9DHE "kSM9DHE"
# define SSL_TXT_aRSA "aRSA"
# define SSL_TXT_aDSS "aDSS"
@@ -126,6 +129,7 @@ extern "C" {
# define SSL_TXT_aGOST "aGOST"
# define SSL_TXT_aSRP "aSRP"
# define SSL_TXT_aSM2 "aSM2"
# define SSL_TXT_aSM9 "aSM9"
# define SSL_TXT_DSS "DSS"
# define SSL_TXT_DH "DH"
@@ -140,6 +144,8 @@ extern "C" {
# define SSL_TXT_ECDSA "ECDSA"
# define SSL_TXT_PSK "PSK"
# define SSL_TXT_SRP "SRP"
# define SSL_TXT_SM2 "SM2"
# define SSL_TXT_SM9 "SM9"
# define SSL_TXT_DES "DES"
# define SSL_TXT_3DES "3DES"
@@ -181,6 +187,7 @@ extern "C" {
# define SSL_TXT_TLSV1 "TLSv1"
# define SSL_TXT_TLSV1_1 "TLSv1.1"
# define SSL_TXT_TLSV1_2 "TLSv1.2"
# define SSL_TXT_GMTLSV1 "GMTLSv1"
# define SSL_TXT_GMTLSV1_1 "GMTLSv1.1"
# define SSL_TXT_ALL "ALL"
@@ -360,6 +367,10 @@ typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx);
# define SSL_OP_NO_DTLSv1 0x04000000U
# define SSL_OP_NO_DTLSv1_2 0x08000000U
# ifndef OPENSSL_NO_GMTLS_METHOD
# define SSL_OP_NO_GMTLS 0x10000000U
# endif
# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\
SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2)
# define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1|SSL_OP_NO_DTLSv1_2)
@@ -1032,6 +1043,14 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
/* fatal */
# define SSL_AD_INAPPROPRIATE_FALLBACK TLS1_AD_INAPPROPRIATE_FALLBACK
# define SSL_AD_NO_APPLICATION_PROTOCOL TLS1_AD_NO_APPLICATION_PROTOCOL
# ifndef OPENSSL_NO_GMTLS_METHOD
# define SSL_AD_UNSUPPORTED_SITE2SITE GMTLS_AD_UNSUPPORTED_SITE2SITE
# define SSL_AD_NO_AREA GMTLS_AD_NO_AREA
# define SSL_AD_UNSUPPORTED_AREATYPE GMTLS_AD_UNSUPPORTED_AREATYPE
# define SSL_AD_BAD_IBCPARAM GMTLS_AD_BAD_IBCPARAM
# define SSL_AD_UNSUPPORTED_IBCPARAM GMTLS_AD_UNSUPPORTED_IBCPARAM
# define SSL_AD_IDENTITY_NEED GMTLS_AD_IDENTITY_NEED
# endif
# define SSL_ERROR_NONE 0
# define SSL_ERROR_SSL 1
# define SSL_ERROR_WANT_READ 2
@@ -1421,6 +1440,9 @@ void SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick,
size_t *len);
__owur int SSL_copy_session_id(SSL *to, const SSL *from);
__owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s);
#ifndef OPENSSL_NO_GMTLS_METHOD
__owur X509 *SSL_SESSION_get0_peer_extra(SSL_SESSION *s);
#endif
__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,
unsigned int sid_ctx_len);
__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid,
@@ -1639,6 +1661,12 @@ __owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */
__owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */
__owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */
#ifndef OPENSSL_NO_GMTLS_METHOD
__owur const SSL_METHOD *GMTLS_method(void); /* GMTLSv1.1 */
__owur const SSL_METHOD *GMTLS_server_method(void); /* GMTLSv1.1 */
__owur const SSL_METHOD *GMTLS_client_method(void); /* GMTLSv1.1 */
#endif
__owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);
__owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
__owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s);
@@ -2092,6 +2120,42 @@ int ERR_load_SSL_strings(void);
# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST 385
# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 370
# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 386
# define SSL_F_GMTLS_ADD_CERT_CHAIN 435
# define SSL_F_GMTLS_CONSTRUCT_CKE_RSA 461
# define SSL_F_GMTLS_CONSTRUCT_CKE_SM2 430
# define SSL_F_GMTLS_CONSTRUCT_CKE_SM2DHE 438
# define SSL_F_GMTLS_CONSTRUCT_CKE_SM9 431
# define SSL_F_GMTLS_CONSTRUCT_CKE_SM9DHE 432
# define SSL_F_GMTLS_CONSTRUCT_CLIENT_CERTIFICATE 439
# define SSL_F_GMTLS_CONSTRUCT_CLIENT_KEY_EXCHANGE 440
# define SSL_F_GMTLS_CONSTRUCT_SERVER_CERTIFICATE 436
# define SSL_F_GMTLS_CONSTRUCT_SERVER_KEY_EXCHANGE 427
# define SSL_F_GMTLS_CONSTRUCT_SKE_RSA 447
# define SSL_F_GMTLS_CONSTRUCT_SKE_SM2 448
# define SSL_F_GMTLS_CONSTRUCT_SKE_SM2DHE 449
# define SSL_F_GMTLS_CONSTRUCT_SKE_SM9 450
# define SSL_F_GMTLS_CONSTRUCT_SM2DHE_PARAMS 451
# define SSL_F_GMTLS_CONSTRUCT_SM9_PARAMS 452
# define SSL_F_GMTLS_NEW_CERT_PACKET 453
# define SSL_F_GMTLS_OUTPUT_CERT_CHAIN 437
# define SSL_F_GMTLS_OUTPUT_IBCS_PARAM 441
# define SSL_F_GMTLS_PROCESS_CKE_RSA 462
# define SSL_F_GMTLS_PROCESS_CKE_SM2 426
# define SSL_F_GMTLS_PROCESS_CKE_SM2DHE 442
# define SSL_F_GMTLS_PROCESS_CKE_SM9 433
# define SSL_F_GMTLS_PROCESS_CKE_SM9DHE 434
# define SSL_F_GMTLS_PROCESS_CLIENT_CERTIFICATE 454
# define SSL_F_GMTLS_PROCESS_CLIENT_KEY_EXCHANGE 443
# define SSL_F_GMTLS_PROCESS_KEY_EXCHANGE 429
# define SSL_F_GMTLS_PROCESS_SERVER_CERTIFICATE 444
# define SSL_F_GMTLS_PROCESS_SERVER_CERTS 455
# define SSL_F_GMTLS_PROCESS_SERVER_KEY_EXCHANGE 445
# define SSL_F_GMTLS_PROCESS_SKE_RSA 456
# define SSL_F_GMTLS_PROCESS_SKE_SM2 457
# define SSL_F_GMTLS_PROCESS_SKE_SM2DHE 458
# define SSL_F_GMTLS_PROCESS_SKE_SM9 459
# define SSL_F_GMTLS_PROCESS_SM9_PARAMS 460
# define SSL_F_GMTLS_SM2_DERIVE 463
# define SSL_F_OPENSSL_INIT_SSL 342
# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION 417
# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION 418
@@ -2239,6 +2303,7 @@ int ERR_load_SSL_strings(void);
# define SSL_F_TLS_CONSTRUCT_CKE_GOST 406
# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE 407
# define SSL_F_TLS_CONSTRUCT_CKE_RSA 409
# define SSL_F_TLS_CONSTRUCT_CKE_SM2 425
# define SSL_F_TLS_CONSTRUCT_CKE_SRP 410
# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE 355
# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO 356
@@ -2276,6 +2341,7 @@ int ERR_load_SSL_strings(void);
# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE 367
# define SSL_F_TLS_PROCESS_SERVER_DONE 368
# define SSL_F_TLS_PROCESS_SERVER_HELLO 369
# define SSL_F_TLS_PROCESS_SERVER_KEY_EXCHANGE 446
# define SSL_F_TLS_PROCESS_SKE_DHE 419
# define SSL_F_TLS_PROCESS_SKE_ECDHE 420
# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE 421
@@ -2294,6 +2360,7 @@ int ERR_load_SSL_strings(void);
# define SSL_R_BAD_DH_VALUE 102
# define SSL_R_BAD_DIGEST_LENGTH 111
# define SSL_R_BAD_ECC_CERT 304
# define SSL_R_BAD_ECPKPARAMETERS 109
# define SSL_R_BAD_ECPOINT 306
# define SSL_R_BAD_HANDSHAKE_LENGTH 332
# define SSL_R_BAD_HELLO_REQUEST 105
@@ -2302,6 +2369,7 @@ int ERR_load_SSL_strings(void);
# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116
# define SSL_R_BAD_RSA_ENCRYPT 119
# define SSL_R_BAD_SIGNATURE 123
# define SSL_R_BAD_SM2_ENCRYPT 101
# define SSL_R_BAD_SRP_A_LENGTH 347
# define SSL_R_BAD_SRP_PARAMETERS 371
# define SSL_R_BAD_SRTP_MKI_VALUE 352
@@ -2370,6 +2438,7 @@ int ERR_load_SSL_strings(void);
# define SSL_R_INAPPROPRIATE_FALLBACK 373
# define SSL_R_INCONSISTENT_COMPRESSION 340
# define SSL_R_INCONSISTENT_EXTMS 104
# define SSL_R_INVALID_CERT_CHAIN 112
# define SSL_R_INVALID_COMMAND 280
# define SSL_R_INVALID_COMPRESSION_ALGORITHM 341
# define SSL_R_INVALID_CONFIGURATION_NAME 113
@@ -2390,9 +2459,11 @@ int ERR_load_SSL_strings(void);
# define SSL_R_MISSING_RSA_CERTIFICATE 168
# define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169
# define SSL_R_MISSING_RSA_SIGNING_CERT 170
# define SSL_R_MISSING_SM2_ENC_CERTIFICATE 108
# define SSL_R_MISSING_SRP_PARAM 358
# define SSL_R_MISSING_TMP_DH_KEY 171
# define SSL_R_MISSING_TMP_ECDH_KEY 311
# define SSL_R_NOT_IMPLEMENTED 110
# define SSL_R_NO_CERTIFICATES_RETURNED 176
# define SSL_R_NO_CERTIFICATE_ASSIGNED 177
# define SSL_R_NO_CERTIFICATE_SET 179
@@ -2428,6 +2499,7 @@ int ERR_load_SSL_strings(void);
# define SSL_R_PSK_IDENTITY_NOT_FOUND 223
# define SSL_R_PSK_NO_CLIENT_CB 224
# define SSL_R_PSK_NO_SERVER_CB 225
# define SSL_R_RANDOM_GENERATOR_ERROR 114
# define SSL_R_READ_BIO_NOT_SET 211
# define SSL_R_READ_TIMEOUT_EXPIRED 312
# define SSL_R_RECORD_LENGTH_MISMATCH 213
@@ -2472,9 +2544,9 @@ int ERR_load_SSL_strings(void);
# define SSL_R_SSL_SECTION_NOT_FOUND 136
# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301
# define SSL_R_SSL_SESSION_ID_CONFLICT 302
# define SSL_R_SSL_SESSION_ID_TOO_LONG 408
# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273
# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303
# define SSL_R_SSL_SESSION_ID_TOO_LONG 408
# define SSL_R_SSL_SESSION_VERSION_MISMATCH 210
# define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049
# define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050

195
include/openssl/thread.h Normal file
View File

@@ -0,0 +1,195 @@
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 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 acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS 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 AUTHOR OR 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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.] */
#ifndef OPENSSL_HEADER_THREAD_H
#define OPENSSL_HEADER_THREAD_H
#include <sys/types.h>
#include <openssl/base.h>
#include <openssl/e_os2.h>
#include <openssl/crypto.h>
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(OPENSSL_NO_THREADS)
typedef struct crypto_mutex_st {
char padding; /* Empty structs have different sizes in C and C++. */
} CRYPTO_MUTEX;
#elif defined(OPENSSL_WINDOWS)
/* CRYPTO_MUTEX can appear in public header files so we really don't want to
* pull in windows.h. It's statically asserted that this structure is large
* enough to contain a Windows SRWLOCK by thread_win.c. */
typedef union crypto_mutex_st {
void *handle;
} CRYPTO_MUTEX;
#elif defined(__MACH__) && defined(__APPLE__)
typedef pthread_rwlock_t CRYPTO_MUTEX;
#else
/* It is reasonable to include pthread.h on non-Windows systems, however the
* |pthread_rwlock_t| that we need is hidden under feature flags, and we can't
* ensure that we'll be able to get it. It's statically asserted that this
* structure is large enough to contain a |pthread_rwlock_t| by
* thread_pthread.c. */
typedef union crypto_mutex_st {
double alignment;
uint8_t padding[3*sizeof(int) + 5*sizeof(unsigned) + 16 + 8];
} CRYPTO_MUTEX;
#endif
/* CRYPTO_refcount_t is the type of a reference count.
*
* Since some platforms use C11 atomics to access this, it should have the
* _Atomic qualifier. However, this header is included by C++ programs as well
* as C code that might not set -std=c11. So, in practice, it's not possible to
* do that. Instead we statically assert that the size and native alignment of
* a plain uint32_t and an _Atomic uint32_t are equal in refcount_c11.c. */
typedef uint32_t CRYPTO_refcount_t;
/* Deprecated functions.
*
* Historically, OpenSSL required callers to provide locking callbacks.
* BoringSSL is thread-safe by default, but some old code calls these functions
* and so no-op implementations are provided. */
/* These defines do nothing but are provided to make old code easier to
* compile. */
#define CRYPTO_LOCK 1
#define CRYPTO_UNLOCK 2
#define CRYPTO_READ 4
#define CRYPTO_WRITE 8
/* CRYPTO_num_locks returns one. (This is non-zero that callers who allocate
* sizeof(lock) times this value don't get zero and then fail because malloc(0)
* returned NULL.) */
//OPENSSL_EXPORT int CRYPTO_num_locks(void);
#if 0
/* CRYPTO_set_locking_callback does nothing. */
OPENSSL_EXPORT void CRYPTO_set_locking_callback(
void (*func)(int mode, int lock_num, const char *file, int line));
/* CRYPTO_set_add_lock_callback does nothing. */
OPENSSL_EXPORT void CRYPTO_set_add_lock_callback(int (*func)(
int *num, int amount, int lock_num, const char *file, int line));
/* CRYPTO_get_locking_callback returns NULL. */
OPENSSL_EXPORT void (*CRYPTO_get_locking_callback(void))(int mode, int lock_num,
const char *file,
int line);
/* CRYPTO_get_lock_name returns a fixed, dummy string. */
OPENSSL_EXPORT const char *CRYPTO_get_lock_name(int lock_num);
/* CRYPTO_THREADID_set_callback returns one. */
OPENSSL_EXPORT int CRYPTO_THREADID_set_callback(
void (*threadid_func)(CRYPTO_THREADID *threadid));
/* CRYPTO_THREADID_set_numeric does nothing. */
OPENSSL_EXPORT void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id,
unsigned long val);
/* CRYPTO_THREADID_set_pointer does nothing. */
OPENSSL_EXPORT void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
/* CRYPTO_THREADID_current does nothing. */
OPENSSL_EXPORT void CRYPTO_THREADID_current(CRYPTO_THREADID *id);
/* CRYPTO_set_id_callback does nothing. */
OPENSSL_EXPORT void CRYPTO_set_id_callback(unsigned long (*func)(void));
typedef struct {
int references;
struct CRYPTO_dynlock_value *data;
} CRYPTO_dynlock;
/* CRYPTO_set_dynlock_create_callback does nothing. */
OPENSSL_EXPORT void CRYPTO_set_dynlock_create_callback(
struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file,
int line));
/* CRYPTO_set_dynlock_lock_callback does nothing. */
OPENSSL_EXPORT void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(
int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
/* CRYPTO_set_dynlock_destroy_callback does nothing. */
OPENSSL_EXPORT void CRYPTO_set_dynlock_destroy_callback(
void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l,
const char *file, int line));
/* CRYPTO_get_dynlock_create_callback returns NULL. */
OPENSSL_EXPORT struct CRYPTO_dynlock_value *(
*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line);
/* CRYPTO_get_dynlock_lock_callback returns NULL. */
OPENSSL_EXPORT void (*CRYPTO_get_dynlock_lock_callback(void))(
int mode, struct CRYPTO_dynlock_value *l, const char *file, int line);
/* CRYPTO_get_dynlock_destroy_callback returns NULL. */
OPENSSL_EXPORT void (*CRYPTO_get_dynlock_destroy_callback(void))(
struct CRYPTO_dynlock_value *l, const char *file, int line);
#endif
#if defined(__cplusplus)
} /* extern C */
#endif
#endif /* OPENSSL_HEADER_THREAD_H */

View File

@@ -187,12 +187,19 @@ extern "C" {
# define TLSEXT_signature_rsa 1
# define TLSEXT_signature_dsa 2
# define TLSEXT_signature_ecdsa 3
# ifndef OPENSSL_NO_GMTLS
# define TLSEXT_signature_sm2sign 7
# endif
# define TLSEXT_signature_gostr34102001 237
# define TLSEXT_signature_gostr34102012_256 238
# define TLSEXT_signature_gostr34102012_512 239
/* Total number of different signature algorithms */
# define TLSEXT_signature_num 7
# ifndef OPENSSL_NO_GMTLS
# define TLSEXT_signature_num 8
# else
# define TLSEXT_signature_num 7
# endif
# define TLSEXT_hash_none 0
# define TLSEXT_hash_md5 1
@@ -201,13 +208,20 @@ extern "C" {
# define TLSEXT_hash_sha256 4
# define TLSEXT_hash_sha384 5
# define TLSEXT_hash_sha512 6
# ifndef OPENSSL_NO_GMTLS
# define TLSEXT_hash_sm3 7
# endif
# define TLSEXT_hash_gostr3411 237
# define TLSEXT_hash_gostr34112012_256 238
# define TLSEXT_hash_gostr34112012_512 239
/* Total number of different digest algorithms */
# define TLSEXT_hash_num 10
# ifndef OPENSSL_NO_GMTLS
# define TLSEXT_hash_num 11
# else
# define TLSEXT_hash_num 10
# endif
/* Flag set for unrecognised algorithms */
# define TLSEXT_nid_unknown 0x1000000

View File

@@ -20,9 +20,15 @@
# include <openssl/stack.h>
# include <openssl/asn1.h>
# include <openssl/safestack.h>
# include <openssl/rsa.h>
# include <openssl/dsa.h>
# include <openssl/dh.h>
# ifndef OPENSSL_NO_RSA
# include <openssl/rsa.h>
# endif
# ifndef OPENSSL_NO_DSA
# include <openssl/dsa.h>
# endif
# ifndef OPENSSL_NO_DH
# include <openssl/dh.h>
# endif
# ifdef __cplusplus
extern "C" {
# endif

View File

@@ -26,15 +26,25 @@
# include <openssl/asn1.h>
# include <openssl/safestack.h>
# include <openssl/ec.h>
# include <openssl/paillier.h>
# if OPENSSL_API_COMPAT < 0x10100000L
# include <openssl/rsa.h>
# include <openssl/dsa.h>
# include <openssl/dh.h>
# ifndef OPENSSL_NO_PAILLIER
# include <openssl/paillier.h>
# endif
# include <openssl/sha.h>
# if OPENSSL_API_COMPAT < 0x10100000L
# ifndef OPENSSL_NO_RSA
# include <openssl/rsa.h>
# endif
# ifndef OPENSSL_NO_DSA
# include <openssl/dsa.h>
# endif
# ifndef OPENSSL_NO_DH
# include <openssl/dh.h>
# endif
# endif
# ifndef OPENSSL_NO_SHA
# include <openssl/sha.h>
# endif
#ifdef __cplusplus
extern "C" {

View File

@@ -50,8 +50,11 @@
#ifndef HEADER_ZUC_H
#define HEADER_ZUC_H
#include <stdint.h>
#include <openssl/opensslconf.h>
#ifndef OPENSSL_NO_ZUC
#include <stdlib.h>
#include <openssl/e_os2.h>
#ifdef __cplusplus
extern "C" {
@@ -62,10 +65,8 @@ typedef struct {
uint32_t state[22];
} zuc_key_t;
/*
void zuc_set_key(zuc_key_t *key, const unsigned char *user_key, const unsigned char *iv);
void zuc_generate_keystream(zuc_key_t *key, size_t nwords, uint32_t *words);
*/
typedef struct {
zuc_key_t key;
@@ -73,16 +74,14 @@ typedef struct {
size_t buflen;
} zuc_ctx_t;
/*
void zuc_ctx_init(zuc_ctx_t *ctx, const unsigned char *user_key, const unsigned char *iv);
void zuc_encrypt(zuc_ctx_t *ctx, size_t len, const unsigned char *in, unsigned char *out);
#define zuc_decrypt(ctx,len,in,out) zuc_encrypt(ctx,len,in,out)
*/
#define EEA3_MIN_BITS 1
#define EEA3_MAX_BITS 65504
#define EEA3_MIN_BYTES ((EEA3_MIN_BITS + 7)/8)
#define EEA3_MAX_BYTES ((EEA3_MAX_BITS + 7)/8)
#define ZUC_128EEA3_MIN_BITS 1
#define ZUC_128EEA3_MAX_BITS 65504
#define ZUC_128EEA3_MIN_BYTES ((ZUC_128EEA3_MIN_BITS + 7)/8)
#define ZUC_128EEA3_MAX_BYTES ((ZUC_128EEA3_MAX_BITS + 7)/8)
typedef struct {
zuc_ctx_t zuc;
@@ -90,17 +89,17 @@ typedef struct {
/* maybe buffer */
} eea3_ctx_t;
/*
void eea3_init(eea3_ctx_t *ctx, const unsigned char *user_key, uint32_t count, uint32_t bearer, int direction);
void eea3_encrypt(eea3_ctx_t *ctx, size_t len, const unsigned char *in, unsigned char *out);
void zuc_128eea3_init(zuc_128eea3_t *eea3, const unsigned char *user_key,
uint32_t count, uint32_t bearer, int direction);
void zuc_128eea3_encrypt(zuc_128eea3_t *ctx, size_t len,
const unsigned char *in, unsigned char *out);
#define eea3_decrypt(ctx,len,in,out) eea3_encrypt(ctx,len,in,out)
void eea3(const unsigned char *key, uint32_t count, uint32_t bearer, int direction,
size_t len, const unsigned char *in, unsigned char *out);
*/
void eea3(const unsigned char *key, uint32_t count, uint32_t bearer,
int direction, size_t len, const unsigned char *in, unsigned char *out);
#define EIA3_MIN_BYTES EEA3_MIN_BYTES
#define EIA3_MAX_BYTES EEA3_MAX_BYTES
#define EIA3_MAC_SIZE 4
#define ZUC_128EIA3_MIN_BYTES EEA3_MIN_BYTES
#define ZUC_128EIA3_MAX_BYTES EEA3_MAX_BYTES
#define ZUC_128EIA3_MAC_SIZE 4
typedef struct {
zuc_ctx_t zuc;
@@ -108,15 +107,17 @@ typedef struct {
/* maybe buffer */
} eia3_ctx_t;
/*
void eia3_init(eia3_ctx_t *ctx, const unsigned char *user_key, uint32_t count, uint32_t bearer, int direction);
void eia3_update(eia3_ctx_t *ctx, const unsigned char *data, size_t datalen);
void eia3_final(eia3_ctx_t *ctx, uint32_t *mac);
void eia3(const unsigned char *key, uint32_t count, uint32_t bearer, int direction,
const unsigned char *data, size_t len, uint32_t *mac);
*/
void zuc_128eia3_init(zuc_128eia3_t *eia3, const unsigned char *user_key,
uint32_t count, uint32_t bearer, int direction);
void zuc_128eia3_update(zuc_128eia3_t *eia3, const unsigned char *data,
size_t datalen);
void zuc_128eia3_final(zuc_128eia3_t *eia3, uint32_t *mac);
void zuc_128eia3(const unsigned char *key, uint32_t count, uint32_t bearer,
int direction, const unsigned char *data, size_t len, uint32_t *mac);
#ifdef __cplusplus
}
#endif
#endif
#endif