mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 08:56:17 +08:00
Add new EC/SM2 API
This commit is contained in:
@@ -1367,6 +1367,7 @@ void EC_KEY_METHOD_get_verify(EC_KEY_METHOD *meth,
|
||||
|
||||
DEFINE_STACK_OF(EC_KEY)
|
||||
STACK_OF(EC_KEY) *EC_KEY_split(EC_KEY *ec_key, int k, int n);
|
||||
EC_KEY *EC_KEY_merge(STACK_OF(EC_KEY) *ec_keys);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
@@ -1385,6 +1386,9 @@ int ERR_load_EC_strings(void);
|
||||
# define EC_F_D2I_ECPKPARAMETERS 103
|
||||
# define EC_F_D2I_ECPRIVATEKEY 104
|
||||
# define EC_F_DO_EC_KEY_PRINT 105
|
||||
# define EC_F_ECAHE_CIPHERTEXT_SIZE 286
|
||||
# define EC_F_ECAHE_DECRYPT 287
|
||||
# define EC_F_ECAHE_ENCRYPT 288
|
||||
# define EC_F_ECDH_CMS_DECRYPT 106
|
||||
# define EC_F_ECDH_CMS_SET_SHARED_INFO 107
|
||||
# define EC_F_ECDH_COMPUTE_KEY 108
|
||||
@@ -1493,6 +1497,7 @@ int ERR_load_EC_strings(void);
|
||||
# define EC_F_EC_KEY_CHECK_KEY 208
|
||||
# define EC_F_EC_KEY_COPY 209
|
||||
# define EC_F_EC_KEY_GENERATE_KEY 210
|
||||
# define EC_F_EC_KEY_MERGE 285
|
||||
# define EC_F_EC_KEY_NEW_METHOD 211
|
||||
# define EC_F_EC_KEY_OCT2PRIV 212
|
||||
# define EC_F_EC_KEY_PRINT_FP 213
|
||||
|
||||
74
include/openssl/ecahe.h
Normal file
74
include/openssl/ecahe.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 - 2019 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_ECAHE_H
|
||||
#define HEADER_ECAHE_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/asn1t.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ECAHE_CIPHERTEXT_st ECAHE_CIPHERTEXT;
|
||||
DECLARE_ASN1_FUNCTIONS(ECAHE_CIPHERTEXT)
|
||||
|
||||
int ECAHE_do_encrypt(ECAHE_CIPHERTEXT *c, const BIGNUM *m, EC_KEY *pk);
|
||||
int ECAHE_do_decrypt(BIGNUM *m, const ECAHE_CIPHERTEXT *c, EC_KEY *sk);
|
||||
int ECAHE_ciphertext_add(ECAHE_CIPHERTEXT *r, const ECAHE_CIPHERTEXT *a, const ECAHE_CIPHERTEXT *b, EC_KEY *pk);
|
||||
int ECAHE_ciphertext_sub(ECAHE_CIPHERTEXT *r, const ECAHE_CIPHERTEXT *a, const ECAHE_CIPHERTEXT *b, EC_KEY *pk);
|
||||
int ECAHE_ciphertext_neg(ECAHE_CIPHERTEXT *r, const ECAHE_CIPHERTEXT *a, EC_KEY *pk);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -41,9 +41,9 @@ extern "C" {
|
||||
*/
|
||||
# define OPENSSL_VERSION_NUMBER 0x1010004fL
|
||||
# ifdef OPENSSL_FIPS
|
||||
# define OPENSSL_VERSION_TEXT "GmSSL 2.5.0 - OpenSSL 1.1.0d-fips 24 Feb 2019"
|
||||
# define OPENSSL_VERSION_TEXT "GmSSL 2.5.0 - OpenSSL 1.1.0d-fips 28 Feb 2019"
|
||||
# else
|
||||
# define OPENSSL_VERSION_TEXT "GmSSL 2.5.0 - OpenSSL 1.1.0d 24 Feb 2019"
|
||||
# define OPENSSL_VERSION_TEXT "GmSSL 2.5.0 - OpenSSL 1.1.0d 28 Feb 2019"
|
||||
# endif
|
||||
|
||||
/*-
|
||||
|
||||
@@ -245,6 +245,22 @@ void EC_KEY_METHOD_get_decrypt(EC_KEY_METHOD *meth,
|
||||
EVP_PKEY_OP_ENCRYPT|EVP_PKEY_OP_DECRYPT, \
|
||||
EVP_PKEY_CTRL_EC_ENCRYPT_PARAM, -2, NULL)
|
||||
|
||||
typedef struct SM2_COSIGNER1_SHARE_st SM2_COSIGNER1_SHARE;
|
||||
typedef struct SM2_COSIGNER2_SHARE_st SM2_COSIGNER2_SHARE;
|
||||
typedef struct SM2_COSIGNER1_PROOF_st SM2_COSIGNER1_PROOF;
|
||||
typedef struct SM2_COSIGNER2_PROOF_st SM2_COSIGNER2_PROOF;
|
||||
DECLARE_ASN1_FUNCTIONS(SM2_COSIGNER1_SHARE)
|
||||
DECLARE_ASN1_FUNCTIONS(SM2_COSIGNER2_SHARE)
|
||||
DECLARE_ASN1_FUNCTIONS(SM2_COSIGNER1_PROOF)
|
||||
DECLARE_ASN1_FUNCTIONS(SM2_COSIGNER2_PROOF)
|
||||
|
||||
/* the following API not finished */
|
||||
SM2_COSIGNER1_SHARE *SM2_cosigner1_setup(BIGNUM **k1, EC_KEY *ec_key, PAILLIER *pk);
|
||||
SM2_COSIGNER2_SHARE *SM2_cosigner2_setup(const SM2_COSIGNER1_SHARE *s1, BIGNUM **k2, EC_KEY *ec_key, PAILLIER *pk);
|
||||
SM2_COSIGNER1_PROOF *SM2_cosigner1_generate_proof(EC_KEY *ec_key, PAILLIER *pk);
|
||||
SM2_COSIGNER2_PROOF *SM2_cosigner2_generate_proof(EC_KEY *ec_key, PAILLIER *pk);
|
||||
ECDSA_SIG *SM2_cosigner1_generate_signature(EC_KEY *ec_key, PAILLIER *pk);
|
||||
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
@@ -261,6 +277,11 @@ int ERR_load_SM2_strings(void);
|
||||
# define SM2_F_O2I_SM2CIPHERTEXTVALUE 108
|
||||
# define SM2_F_SM2CIPHERTEXTVALUE_SIZE 109
|
||||
# define SM2_F_SM2_CIPHERTEXT_SIZE 110
|
||||
# define SM2_F_SM2_COSIGNER1_GENERATE_PROOF 111
|
||||
# define SM2_F_SM2_COSIGNER1_GENERATE_SIGNATURE 112
|
||||
# define SM2_F_SM2_COSIGNER1_SETUP 113
|
||||
# define SM2_F_SM2_COSIGNER2_GENERATE_PROOF 114
|
||||
# define SM2_F_SM2_COSIGNER2_SETUP 115
|
||||
# define SM2_F_SM2_DECRYPT 100
|
||||
# define SM2_F_SM2_DO_DECRYPT 101
|
||||
# define SM2_F_SM2_DO_ENCRYPT 102
|
||||
@@ -283,6 +304,7 @@ int ERR_load_SM2_strings(void);
|
||||
# define SM2_R_KDF_FAILURE 109
|
||||
# define SM2_R_MISSING_PARAMETERS 111
|
||||
# define SM2_R_NEED_NEW_SETUP_VALUES 112
|
||||
# define SM2_R_NOT_IMPLEMENTED 115
|
||||
# define SM2_R_PLAINTEXT_TOO_LONG 114
|
||||
# define SM2_R_RANDOM_NUMBER_GENERATION_FAILED 113
|
||||
|
||||
|
||||
Reference in New Issue
Block a user