mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 08:56:17 +08:00
add extra ec
This commit is contained in:
@@ -510,6 +510,7 @@ int ERR_load_BN_strings(void);
|
||||
# define BN_F_BN_BLINDING_UPDATE 103
|
||||
# define BN_F_BN_BN2DEC 104
|
||||
# define BN_F_BN_BN2HEX 105
|
||||
# define BN_F_BN_BN2SOLINAS 138
|
||||
# define BN_F_BN_COMPUTE_WNAF 142
|
||||
# define BN_F_BN_CTX_GET 116
|
||||
# define BN_F_BN_CTX_NEW 106
|
||||
@@ -528,6 +529,20 @@ int ERR_load_BN_strings(void);
|
||||
# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135
|
||||
# define BN_F_BN_GF2M_MOD_SQR 136
|
||||
# define BN_F_BN_GF2M_MOD_SQRT 137
|
||||
# define BN_F_BN_GFP2_ADD 147
|
||||
# define BN_F_BN_GFP2_CANONICAL 148
|
||||
# define BN_F_BN_GFP2_CMP 149
|
||||
# define BN_F_BN_GFP2_COPY 150
|
||||
# define BN_F_BN_GFP2_DIV_BN 151
|
||||
# define BN_F_BN_GFP2_INV 152
|
||||
# define BN_F_BN_GFP2_IS_ZERO 153
|
||||
# define BN_F_BN_GFP2_MUL 154
|
||||
# define BN_F_BN_GFP2_NEW 155
|
||||
# define BN_F_BN_GFP2_ONE 156
|
||||
# define BN_F_BN_GFP2_SET_BN 157
|
||||
# define BN_F_BN_GFP2_SUB 158
|
||||
# define BN_F_BN_GFP2_ZERO 159
|
||||
# define BN_F_BN_HASH_TO_RANGE 160
|
||||
# define BN_F_BN_LSHIFT 145
|
||||
# define BN_F_BN_MOD_EXP2_MONT 118
|
||||
# define BN_F_BN_MOD_EXP_MONT 109
|
||||
@@ -545,6 +560,7 @@ int ERR_load_BN_strings(void);
|
||||
# define BN_F_BN_RAND_RANGE 122
|
||||
# define BN_F_BN_RSHIFT 146
|
||||
# define BN_F_BN_SET_WORDS 144
|
||||
# define BN_F_BN_SOLINAS2BN 161
|
||||
# define BN_F_BN_USUB 115
|
||||
|
||||
/* Reason codes. */
|
||||
@@ -552,6 +568,7 @@ int ERR_load_BN_strings(void);
|
||||
# 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_ENCODING_ERROR 104
|
||||
@@ -560,6 +577,8 @@ int ERR_load_BN_strings(void);
|
||||
# define BN_R_INVALID_LENGTH 106
|
||||
# define BN_R_INVALID_RANGE 115
|
||||
# define BN_R_INVALID_SHIFT 119
|
||||
# define BN_R_INVALID_SOLINAS 121
|
||||
# define BN_R_INVALID_SOLINAS_PARAMETERS 122
|
||||
# define BN_R_NOT_A_SQUARE 111
|
||||
# define BN_R_NOT_INITIALIZED 107
|
||||
# define BN_R_NO_INVERSE 108
|
||||
|
||||
98
include/openssl/bn_gfp2.h
Normal file
98
include/openssl/bn_gfp2.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_GFP2_H
|
||||
#define HEADER_BN_GFP2_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* element a in GF(p^2), where a = a0 + a1 * i, i^2 == -1 */
|
||||
typedef struct {
|
||||
BIGNUM *a0;
|
||||
BIGNUM *a1;
|
||||
} BN_GFP2;
|
||||
|
||||
BN_GFP2 *BN_GFP2_new(void);
|
||||
int BN_GFP2_copy(BN_GFP2 *r, const BN_GFP2 *a);
|
||||
int BN_GFP2_zero(BN_GFP2 *a);
|
||||
int BN_GFP2_is_zero(const BN_GFP2 *a);
|
||||
int BN_GFP2_equ(const BN_GFP2 *a, const BN_GFP2 *b);
|
||||
int BN_GF2P_add(BN_GFP2 *r, const BN_GFP2 *a, const BN_GFP2 *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_sub(BN_GFP2 *r, const BN_GFP2 *a, const BN_GFP2 *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_mul(BN_GFP2 *r, const BN_GFP2 *a, const BN_GFP2 *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_sqr(BN_GFP2 *r, const BN_GFP2 *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_inv(BN_GFP2 *r, const BN_GFP2 *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_div(BN_GFP2 *r, const BN_GFP2 *a, const BN_GFP2 *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_exp(BN_GFP2 *r, const BN_GFP2 *a, const BIGNUM *k, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_set_bn(BN_GFP2 *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GF2P_add_bn(BN_GFP2 *r, const BN_GFP2 *a, const BIGNUM *b, const BIGNUM *p,BN_CTX *ctx);
|
||||
int BN_GFP2_sub_bn(BN_GFP2 *r, const BN_GFP2 *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_mul_bn(BN_GFP2 *r, const BN_GFP2 *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_GFP2_div_bn(BN_GFP2 *r, const BN_GFP2 *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx);
|
||||
void BN_GFP2_free(BN_GFP2 *a);
|
||||
|
||||
int BN_bn2gfp2(const BIGNUM *bn, BN_GFP2 *gfp2, const BIGNUM *p, BN_CTX *ctx);
|
||||
int BN_gfp22bn(const BN_GFP2 *gfp2, BIGNUM *bn, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
/*
|
||||
* Canonical a = a0 + a1 * i
|
||||
* If order is 0 then output a0, a1, else output a1, a0, |a0| = |a1| = |p|.
|
||||
*/
|
||||
int BN_GFP2_canonical(const BN_GFP2 *a, unsigned char *out, size_t *outlen,
|
||||
int order, const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
68
include/openssl/bn_hash.h
Normal file
68
include/openssl/bn_hash.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_HASH_H
|
||||
#define HEADER_BN_HASH_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* hash input bytes to bignum in range [0, p - 1] */
|
||||
int BN_hash_to_range(const EVP_MD *md,
|
||||
BIGNUM **bn, const void *in, size_t inlen,
|
||||
const BIGNUM *p, BN_CTX *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
94
include/openssl/bn_solinas.h
Normal file
94
include/openssl/bn_solinas.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* Solinas Prime (prime number with low weight)
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BN_SOLINAS_H
|
||||
#define HEADER_BN_SOLINAS_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* solinas prime = 2^a + s * 2^b + c */
|
||||
typedef struct {
|
||||
int a;
|
||||
int b;
|
||||
int s;
|
||||
int c;
|
||||
} BN_SOLINAS;
|
||||
|
||||
int BN_bn2solinas(const BIGNUM *bn, BN_SOLINAS *solinas);
|
||||
int BN_solinas2bn(const BN_SOLINAS *solinas, BIGNUM *bn);
|
||||
int BN_is_solinas(const BIGNUM *bn);
|
||||
|
||||
/*
|
||||
* the following Solinas primes are from
|
||||
* "Solinas primes of small weight for fixed sizes"
|
||||
* https://eprint.iacr.org/2010/058.pdf
|
||||
*
|
||||
* 2^192 - 2^16 - 1
|
||||
* 2^192 - 2^64 - 1
|
||||
* 2^224 - 2^96 + 1
|
||||
* 2^256 - 2^168 + 1
|
||||
* 2^384 - 2^80 + 1
|
||||
* 2^512 - 2^32 + 1
|
||||
* 2^512 - 2^32 - 1
|
||||
* 2^1024 - 2^424 - 1
|
||||
* 2^1024 - 2^856 + 1
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1451,6 +1451,7 @@ int ERR_load_EC_strings(void);
|
||||
# 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
|
||||
@@ -1458,11 +1459,15 @@ int ERR_load_EC_strings(void);
|
||||
# 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
|
||||
@@ -1482,11 +1487,13 @@ int ERR_load_EC_strings(void);
|
||||
# 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
|
||||
@@ -1501,6 +1508,7 @@ int ERR_load_EC_strings(void);
|
||||
# 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
|
||||
@@ -1549,6 +1557,9 @@ int ERR_load_EC_strings(void);
|
||||
# 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
|
||||
|
||||
/* Reason codes. */
|
||||
# define EC_R_ASN1_ERROR 115
|
||||
@@ -1578,6 +1589,7 @@ int ERR_load_EC_strings(void);
|
||||
# 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
|
||||
@@ -1609,6 +1621,9 @@ int ERR_load_EC_strings(void);
|
||||
# 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
|
||||
|
||||
67
include/openssl/ec_hash.h
Normal file
67
include/openssl/ec_hash.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_EC_HASH_H
|
||||
#define HEADER_EC_HASH_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ec.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* hash string s to elliptic curve point */
|
||||
int EC_POINT_hash2point(const EC_GROUP *group, const EVP_MD *md,
|
||||
const char *s, size_t slen, EC_POINT *point, BN_CTX *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
100
include/openssl/ec_type1.h
Normal file
100
include/openssl/ec_type1.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* type1curve is supersingular curve E: y^2 = x^3 + 1 (mod p) over prime field.
|
||||
* p = 11 (mod 12)
|
||||
* a = 0
|
||||
* b = 1
|
||||
* G = (x, y)
|
||||
* n is the order of (x, y)
|
||||
* h = (p + 1)/n
|
||||
*/
|
||||
|
||||
#ifndef HEADER_EC_TYPE1_H
|
||||
#define HEADER_EC_TYPE1_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/bn_gfp2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
EC_GROUP *EC_GROUP_generate_typ1curve(const BIGNUM *order, BN_CTX *ctx);
|
||||
|
||||
EC_GROUP *EC_GROUP_new_type1curve(const BIGNUM *p, const BIGNUM *x,
|
||||
const BIGNUM *y, const BIGNUM *order, BN_CTX *ctx);
|
||||
|
||||
EC_GROUP *EC_GROUP_new_type1curve_ex(const BIGNUM *p, const BIGNUM *a,
|
||||
const BIGNUM *b, const unsigned char *point, size_t pointlen,
|
||||
const BIGNUM *order, const BIGNUM *cofactor, BN_CTX *bn_ctx);
|
||||
|
||||
int EC_GROUP_is_type1curve(const EC_GROUP *group, BN_CTX *ctx);
|
||||
|
||||
BN_GFP2 *EC_GROUP_get_type1curve_zeta(const EC_GROUP *group, BN_CTX *ctx);
|
||||
|
||||
BIGNUM *EC_GROUP_get_type1curve_eta(const EC_GROUP *group, BN_CTX *ctx);
|
||||
|
||||
/* compute tate pairing e(P, Q) over type1curve */
|
||||
int EC_type1curve_tate(const EC_GROUP *group, BN_GFP2 *r,
|
||||
const EC_POINT *P, const EC_POINT *Q, BN_CTX *ctx);
|
||||
|
||||
/* compute tate pairing ratio e(P1, Q1)/e(P2, Q2) over type1curve*/
|
||||
int EC_type1curve_tate_ratio(const EC_GROUP *group, BN_GFP2 *r,
|
||||
const EC_POINT *P1, const EC_POINT *Q1, const EC_POINT *P2,
|
||||
const EC_POINT *Q2, BN_CTX *bn_ctx);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
77
include/openssl/fppoint.h
Normal file
77
include/openssl/fppoint.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* FpPoint is the affine coordinates presentation of point over E/F_p
|
||||
* this data struct is used by pairing schemes over type1 curve
|
||||
*/
|
||||
|
||||
#ifndef HEADER_FPPOINT_H
|
||||
#define HEADER_FPPOINT_H
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/bn_gfp2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct fppoint_st {
|
||||
BIGNUM *x;
|
||||
BIGNUM *y;
|
||||
} FpPoint;
|
||||
DECLARE_ASN1_FUNCTIONS(FpPoint)
|
||||
|
||||
int EC_POINT_cmp_fppoint(const EC_GROUP *group,
|
||||
const EC_POINT *point, const FpPoint *fppoint, BN_CTX *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user