mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 00:46:17 +08:00
Remove some ciphers
This commit is contained in:
@@ -1,148 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* Boneh-Boyen Identity-Based Encryption (BB1-IBE)
|
||||
* see [RFC 5091](https://tools.ietf.org/html/rfc5091)
|
||||
* Identity-Based Cryptography Standard (IBCS) #1:
|
||||
* Supersingular Curve Implementations of the BF and BB1 Cryptosystems
|
||||
*/
|
||||
|
||||
#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>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/fppoint.h>
|
||||
|
||||
#define BB1IBE_VERSION 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct BB1PublicParameters_st BB1PublicParameters;
|
||||
typedef struct BB1MasterSecret_st BB1MasterSecret;
|
||||
typedef struct BB1PrivateKeyBlock_st BB1PrivateKeyBlock;
|
||||
typedef struct BB1CiphertextBlock_st BB1CiphertextBlock;
|
||||
|
||||
|
||||
int BB1IBE_setup(const EC_GROUP *group, const EVP_MD *md,
|
||||
BB1PublicParameters **mpk, BB1MasterSecret **msk);
|
||||
BB1PrivateKeyBlock *BB1IBE_extract_private_key(BB1PublicParameters *mpk,
|
||||
BB1MasterSecret *msk, const char *id, size_t idlen);
|
||||
BB1CiphertextBlock *BB1IBE_do_encrypt(BB1PublicParameters *mpk,
|
||||
const unsigned char *in, size_t inlen,
|
||||
const char *id, size_t idlen);
|
||||
int BB1IBE_do_decrypt(BB1PublicParameters *mpk,
|
||||
const BB1CiphertextBlock *in, unsigned char *out, size_t *outlen,
|
||||
BB1PrivateKeyBlock *sk);
|
||||
int BB1IBE_encrypt(BB1PublicParameters *mpk,
|
||||
const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen,
|
||||
const char *id, size_t idlen);
|
||||
int BB1IBE_decrypt(BB1PublicParameters *mpk,
|
||||
const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen,
|
||||
BB1PrivateKeyBlock *sk);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(BB1MasterSecret)
|
||||
DECLARE_ASN1_FUNCTIONS(BB1PublicParameters)
|
||||
DECLARE_ASN1_FUNCTIONS(BB1PrivateKeyBlock)
|
||||
DECLARE_ASN1_FUNCTIONS(BB1CiphertextBlock)
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_BB1IBE_strings(void);
|
||||
|
||||
/* Error codes for the BB1IBE functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BB1IBE_F_BB1CIPHERTEXTBLOCK_HASH_TO_RANGE 100
|
||||
# define BB1IBE_F_BB1IBE_DECRYPT 101
|
||||
# define BB1IBE_F_BB1IBE_DOUBLE_HASH 102
|
||||
# define BB1IBE_F_BB1IBE_DO_DECRYPT 103
|
||||
# define BB1IBE_F_BB1IBE_DO_ENCRYPT 104
|
||||
# define BB1IBE_F_BB1IBE_ENCRYPT 105
|
||||
# define BB1IBE_F_BB1IBE_EXTRACT_PRIVATE_KEY 106
|
||||
# define BB1IBE_F_BB1IBE_SETUP 107
|
||||
|
||||
/* Reason codes. */
|
||||
# define BB1IBE_R_BB1CIPHERTEXT_INVALID_MAC 100
|
||||
# define BB1IBE_R_BB1IBE_HASH_FAILURE 101
|
||||
# define BB1IBE_R_BUFFER_TOO_SMALL 102
|
||||
# define BB1IBE_R_COMPUTE_OUTLEN_FAILURE 103
|
||||
# define BB1IBE_R_COMPUTE_TATE_FAILURE 104
|
||||
# define BB1IBE_R_D2I_FAILURE 105
|
||||
# define BB1IBE_R_DECRYPT_FAILURE 106
|
||||
# define BB1IBE_R_DOUBLE_HASH_FAILURE 107
|
||||
# define BB1IBE_R_ENCRYPT_FAILURE 108
|
||||
# define BB1IBE_R_I2D_FAILURE 109
|
||||
# define BB1IBE_R_INVALID_INPUT 110
|
||||
# define BB1IBE_R_INVALID_MD 111
|
||||
# define BB1IBE_R_INVALID_OUTPUT_BUFFER 112
|
||||
# define BB1IBE_R_INVALID_TYPE1CURVE 113
|
||||
# define BB1IBE_R_NOT_NAMED_CURVE 114
|
||||
# define BB1IBE_R_PARSE_PAIRING 115
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,146 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* Boneh-Franklin Identity-Based Encryption (BF-IBE)
|
||||
* see [RFC 5091](https://tools.ietf.org/html/rfc5091)
|
||||
* Identity-Based Cryptography Standard (IBCS) #1:
|
||||
* Supersingular Curve Implementations of the BF and BB1 Cryptosystems
|
||||
*/
|
||||
|
||||
#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>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/fppoint.h>
|
||||
|
||||
#define BFIBE_VERSION 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BFPublicParameters_st BFPublicParameters;
|
||||
typedef struct BFMasterSecret_st BFMasterSecret;
|
||||
typedef struct BFPrivateKeyBlock_st BFPrivateKeyBlock;
|
||||
typedef struct BFCiphertextBlock_st BFCiphertextBlock;
|
||||
|
||||
int BFIBE_setup(const EC_GROUP *group, const EVP_MD *md,
|
||||
BFPublicParameters **mpk, BFMasterSecret **msk);
|
||||
BFPrivateKeyBlock *BFIBE_extract_private_key(BFPublicParameters *mpk,
|
||||
BFMasterSecret *msk, const char *id, size_t idlen);
|
||||
BFCiphertextBlock *BFIBE_do_encrypt(BFPublicParameters *mpk,
|
||||
const unsigned char *in, size_t inlen,
|
||||
const char *id, size_t idlen);
|
||||
int BFIBE_do_decrypt(BFPublicParameters *mpk,
|
||||
const BFCiphertextBlock *in,
|
||||
unsigned char *out, size_t *outlen,
|
||||
BFPrivateKeyBlock *sk);
|
||||
int BFIBE_encrypt(BFPublicParameters *mpk,
|
||||
const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen,
|
||||
const char *id, size_t idlen);
|
||||
int BFIBE_decrypt(BFPublicParameters *mpk,
|
||||
const unsigned char *in, size_t inlen,
|
||||
unsigned char *out, size_t *outlen,
|
||||
BFPrivateKeyBlock *sk);
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS(BFPublicParameters)
|
||||
DECLARE_ASN1_FUNCTIONS(BFMasterSecret)
|
||||
DECLARE_ASN1_FUNCTIONS(BFPrivateKeyBlock)
|
||||
DECLARE_ASN1_FUNCTIONS(BFCiphertextBlock)
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_BFIBE_strings(void);
|
||||
|
||||
/* Error codes for the BFIBE functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define BFIBE_F_BFIBE_DECRYPT 100
|
||||
# define BFIBE_F_BFIBE_DO_DECRYPT 101
|
||||
# define BFIBE_F_BFIBE_DO_ENCRYPT 102
|
||||
# define BFIBE_F_BFIBE_ENCRYPT 103
|
||||
# define BFIBE_F_BFIBE_EXTRACT_PRIVATE_KEY 104
|
||||
# define BFIBE_F_BFIBE_SETUP 105
|
||||
|
||||
/* Reason codes. */
|
||||
# define BFIBE_R_BFIBE_CIPHERTEXT_FAILURE 100
|
||||
# define BFIBE_R_BUFFER_TOO_SMALL 101
|
||||
# define BFIBE_R_COMPUTE_OUTLEN_FAILURE 102
|
||||
# define BFIBE_R_D2I_FAILURE 103
|
||||
# define BFIBE_R_DECRYPT_FAILURE 104
|
||||
# define BFIBE_R_ENCRYPT_FAILURE 105
|
||||
# define BFIBE_R_HASH_BYTES_FAILURE 106
|
||||
# define BFIBE_R_I2D_FAILURE 107
|
||||
# define BFIBE_R_INVALID_BFIBE_HASHFUNC 108
|
||||
# define BFIBE_R_INVALID_CIPHERTEXT 109
|
||||
# define BFIBE_R_INVALID_TYPE1CURVE 110
|
||||
# define BFIBE_R_KDF_FAILURE 111
|
||||
# define BFIBE_R_NOT_NAMED_CURVE 112
|
||||
# define BFIBE_R_PARSE_CURVE_FAILURE 113
|
||||
# define BFIBE_R_PARSE_MPK_FAILURE 114
|
||||
# define BFIBE_R_PARSE_PAIRING 115
|
||||
# define BFIBE_R_RAND_FAILURE 116
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,96 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#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);
|
||||
void BN_GFP2_free(BN_GFP2 *a);
|
||||
int BN_GFP2_copy(BN_GFP2 *r, const BN_GFP2 *a);
|
||||
int BN_GFP2_one(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_GFP2_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_GFP2_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);
|
||||
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
|
||||
@@ -1,68 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#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
|
||||
@@ -1,94 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* 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
|
||||
@@ -1,67 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#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
|
||||
@@ -1,99 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* 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_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
|
||||
@@ -1,74 +0,0 @@
|
||||
/* ====================================================================
|
||||
* 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
|
||||
@@ -94,12 +94,9 @@ typedef struct err_state_st {
|
||||
# define ERR_LIB_ASYNC 51
|
||||
# define ERR_LIB_KDF 52
|
||||
# define ERR_LIB_KDF2 53
|
||||
# define ERR_LIB_FFX 54
|
||||
# define ERR_LIB_PAILLIER 55
|
||||
# define ERR_LIB_OTP 57
|
||||
# define ERR_LIB_GMAPI 58
|
||||
# define ERR_LIB_BFIBE 59
|
||||
# define ERR_LIB_BB1IBE 60
|
||||
# define ERR_LIB_SM9 61
|
||||
# define ERR_LIB_SDF 63
|
||||
# define ERR_LIB_SKF 64
|
||||
@@ -144,12 +141,9 @@ typedef struct err_state_st {
|
||||
# define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define KDF2err(f,r) ERR_PUT_error(ERR_LIB_KDF2,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define FFXerr(f,r) ERR_PUT_error(ERR_LIB_FFX,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define PAILLIERerr(f,r) ERR_PUT_error(ERR_LIB_PAILLIER,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define OTPerr(f,r) ERR_PUT_error(ERR_LIB_OTP,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define GMAPIerr(f,r) ERR_PUT_error(ERR_LIB_GMAPI,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define BFIBEerr(f,r) ERR_PUT_error(ERR_LIB_BFIBE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define BB1IBEerr(f,r) ERR_PUT_error(ERR_LIB_BB1IBE,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SM2err(f,r) ERR_PUT_error(ERR_LIB_SM2,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SM9err(f,r) ERR_PUT_error(ERR_LIB_SM9,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
# define SDFerr(f,r) ERR_PUT_error(ERR_LIB_SDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
|
||||
@@ -203,12 +197,9 @@ typedef struct err_state_st {
|
||||
# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */
|
||||
# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */
|
||||
# define ERR_R_KDF2_LIB ERR_LIB_KDF2/* 53 */
|
||||
# define ERR_R_FFX_LIB ERR_LIB_FFX/* 54 */
|
||||
# define ERR_R_PAILLIER_LIB ERR_LIB_PAILLIER/* 55 */
|
||||
# define ERR_R_OTP_LIB ERR_LIB_OTP/* 57 */
|
||||
# define ERR_R_GMAPI_LIB ERR_LIB_GMAPI/* 58 */
|
||||
# define ERR_R_BFIBE_LIB ERR_LIB_BFIBE/* 59 */
|
||||
# define ERR_R_BB1IBE_LIB ERR_LIB_BB1IBE/* 60 */
|
||||
# define ERR_R_SM2_LIB ERR_LIB_SM2/* 66 */
|
||||
# define ERR_R_SM9_LIB ERR_LIB_SM9/* 61 */
|
||||
# define ERR_R_SDF_LIB ERR_LIB_SDF/* 63 */
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2015 - 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_FFX_H
|
||||
#define HEADER_FFX_H
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
||||
#define FFX_MIN_DIGITS 6
|
||||
#define FFX_MAX_DIGITS 18
|
||||
#define FFX_MIN_TWEAKLEN 4
|
||||
#define FFX_MAX_TWEAKLEN 11
|
||||
#define FFX_NUM_ROUNDS 10
|
||||
|
||||
#define FFX_TYPE_BINARY 0x04
|
||||
#define FFX_TYPE_KEYWORD 0x05
|
||||
#define FFX_TYPE_PASSWORD 0x08
|
||||
#define FFX_TYPE_TEXT 0x09
|
||||
#define FFX_TYPE_INTEGER 0x0a
|
||||
#define FFX_TYPE_DIGITS 0x00
|
||||
#define FFX_TYPE_CELLPHONE 0x01
|
||||
#define FFX_TYPE_BANKCARD 0x02
|
||||
#define FFX_TYPE_IDCARD 0x03
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct FFX_CTX_st FFX_CTX;
|
||||
|
||||
FFX_CTX *FFX_CTX_new(void);
|
||||
void FFX_CTX_free(FFX_CTX *ctx);
|
||||
int FFX_init(FFX_CTX *ctx, const EVP_CIPHER *cipher,
|
||||
const unsigned char *key, int flag);
|
||||
int FFX_encrypt(FFX_CTX *ctx, const char *in, char *out, size_t iolen,
|
||||
unsigned char *tweak, size_t tweaklen);
|
||||
int FFX_decrypt(FFX_CTX *ctx, const char *in, char *out, size_t iolen,
|
||||
unsigned char *tweak, size_t tweaklen);
|
||||
int FFX_compute_luhn(const char *in, size_t inlen);
|
||||
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
* The following lines are auto generated by the script mkerr.pl. Any changes
|
||||
* made after this point may be overwritten when the script is next run.
|
||||
*/
|
||||
|
||||
int ERR_load_FFX_strings(void);
|
||||
|
||||
/* Error codes for the FFX functions. */
|
||||
|
||||
/* Function codes. */
|
||||
# define FFX_F_FFX_DECRYPT 100
|
||||
# define FFX_F_FFX_ENCRYPT 101
|
||||
# define FFX_F_FFX_INIT 102
|
||||
|
||||
/* Reason codes. */
|
||||
# define FFX_R_ENCRYPT_INIT_FAILURE 100
|
||||
# define FFX_R_INVALID_BLOCK_SIZE 101
|
||||
# define FFX_R_INVALID_CIPHER_MODE 102
|
||||
# define FFX_R_INVALID_INPUT_DIGIT 103
|
||||
# define FFX_R_INVALID_INPUT_LENGTH 104
|
||||
# define FFX_R_INVALID_TWEAK_LENGTH 105
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
@@ -1,77 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
/*
|
||||
* 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
|
||||
@@ -1,119 +0,0 @@
|
||||
/* ====================================================================
|
||||
* 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
/**
|
||||
Copyright © 2015 Odzhan
|
||||
Copyright © 2008 Daniel Otte
|
||||
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. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
THIS SOFTWARE IS PROVIDED BY AUTHORS "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 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_SERPENT_H
|
||||
#define HEADER_SERPENT_H
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_SERPENT
|
||||
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#define SERPENT_ROUNDS 32
|
||||
#define SERPENT_BLOCK_SIZE 16
|
||||
#define SERPENT_KEY256 32
|
||||
|
||||
#define SERPENT_ENCRYPT 0
|
||||
#define SERPENT_DECRYPT 1
|
||||
|
||||
#define SERPENT_IP 0
|
||||
#define SERPENT_FP 1
|
||||
|
||||
typedef union _serpent_blk_t {
|
||||
uint8_t b[SERPENT_BLOCK_SIZE];
|
||||
uint32_t w[SERPENT_BLOCK_SIZE / 4];
|
||||
uint64_t q[SERPENT_BLOCK_SIZE / 2];
|
||||
} serpent_blk;
|
||||
|
||||
typedef uint32_t serpent_subkey_t[4];
|
||||
|
||||
typedef struct {
|
||||
serpent_subkey_t x[SERPENT_ROUNDS + 1];
|
||||
} serpent_key_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void serpent_set_encrypt_key(serpent_key_t *key, const unsigned char *user_key);
|
||||
void serpent_set_decrypt_key(serpent_key_t *key, const unsigned char *user_key);
|
||||
void serpent_encrypt(const void *in, void *out, serpent_key_t *key);
|
||||
void serpent_decrypt(const void *in, void *out, serpent_key_t *key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,170 +0,0 @@
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2016 The GmSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project.
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* 4. The name "GmSSL Project" must not be used to endorse or promote
|
||||
* products derived from this software without prior written
|
||||
* permission. For written permission, please contact
|
||||
* guanzhi1980@gmail.com.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "GmSSL"
|
||||
* nor may "GmSSL" appear in their names without prior written
|
||||
* permission of the GmSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the GmSSL Project
|
||||
* (http://gmssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
#ifndef HEADER_SOF_H
|
||||
#define HEADER_SOF_H
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_SOF
|
||||
|
||||
#include <openssl/sgd.h>
|
||||
|
||||
typedef char * SOF_BSTR;
|
||||
typedef long SOF_LONG;
|
||||
typedef short SOF_SHORT;
|
||||
typedef SOF_LONG SOF_BOOL;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
SOF_BSTR SOF_GetVersion(void);
|
||||
SOF_LONG SOF_SetSignMethod(SOF_LONG SignMethod);
|
||||
SOF_LONG SOF_GetSignMethod(void);
|
||||
SOF_LONG SOF_SetEncryptMethod(SOF_LONG EncryptMethod);
|
||||
SOF_LONG SOF_GetEncryptMethod(void);
|
||||
SOF_BSTR SOF_GetUserList(void);
|
||||
SOF_BSTR SOF_ExportUserCert(SOF_BSTR ContainerName);
|
||||
SOF_BOOL SOF_Login(SOF_BSTR ContainerName, SOF_BSTR PassWd);
|
||||
SOF_LONG SOF_GetPinRetryCount(SOF_BSTR ContainerName);
|
||||
SOF_BOOL SOF_ChangePassWd(SOF_BSTR ContainerName, SOF_BSTR OldPassWd, SOF_BSTR NewPassWd);
|
||||
SOF_BSTR SOF_ExportExchangeUserCert(SOF_BSTR ContainerName);
|
||||
SOF_BSTR SOF_GetCertInfo(SOF_BSTR Base64EncodeCert, SOF_SHORT Type);
|
||||
SOF_BSTR SOF_GetCertInfoByOid(SOF_BSTR Base64EncodeCert, SOF_BSTR Oid);
|
||||
SOF_BSTR SOF_GetDeviceInfo(SOF_BSTR ContainerName, SOF_LONG Type);
|
||||
SOF_LONG SOF_ValidateCert(SOF_BSTR Base64EncodeCert);
|
||||
SOF_BSTR SOF_SignData(SOF_BSTR ContainerName, SOF_BSTR InData);
|
||||
SOF_BOOL SOF_VerifySignedData(SOF_BSTR Base64EncodeCert, SOF_BSTR InData, SOF_BSTR SignValue);
|
||||
SOF_BSTR SOF_SignFile(SOF_BSTR ContainerName, SOF_BSTR InFile);
|
||||
SOF_BOOL SOF_VerifySignedFile(SOF_BSTR Base64EncodeCert, SOF_BSTR InFile, SOF_BSTR SignValue);
|
||||
SOF_BSTR SOF_EncryptData(SOF_BSTR Base64EncodeCert, SOF_BSTR InData);
|
||||
SOF_BSTR SOF_DecryptData(SOF_BSTR ContainerName, SOF_BSTR InData);
|
||||
SOF_BOOL SOF_EncryptFile(SOF_BSTR Base64EncodeCert, SOF_BSTR InFile, SOF_BSTR OutFile);
|
||||
SOF_BOOL SOF_DecryptFile(SOF_BSTR ContainerName, SOF_BSTR InFile, SOF_BSTR OutFile);
|
||||
SOF_BSTR SOF_SignMessage(SOF_SHORT flag, SOF_BSTR ContainerName, SOF_BSTR InData);
|
||||
SOF_BOOL SOF_VerifySignedMessage(SOF_BSTR MessageData, SOF_BSTR InData);
|
||||
SOF_BSTR SOF_GetInfoFromSignedMessage(SOF_BSTR SignedMessage, SOF_SHORT Type);
|
||||
SOF_BSTR SOF_SignDataXML(SOF_BSTR ContainerName, SOF_BSTR InData);
|
||||
SOF_BOOL SOF_VerifySignedDataXML(SOF_BSTR InData);
|
||||
SOF_BSTR SOF_GetXMLSignatureInfo(SOF_BSTR XMLSignedData, SOF_SHORT Type);
|
||||
SOF_BSTR SOF_GenRandom(SOF_SHORT RandomLen);
|
||||
SOF_LONG SOF_GetLastError(void);
|
||||
|
||||
SOF_LONG SOF_SetCertTrustList(SOF_BSTR CTLAltName, SOF_BSTR CTLContent, SOF_SHORT CTLContentLen);
|
||||
SOF_BSTR SOF_GetCertTrustListAltNames(void);
|
||||
SOF_BSTR SOF_GetCertTrustList(SOF_BSTR CTLAltName);
|
||||
SOF_LONG SOF_DelCertTrustList(SOF_BSTR CTLAltName);
|
||||
SOF_LONG SOF_InitCertAppPolicy(SOF_BSTR PolicyName);
|
||||
SOF_BSTR SOF_GetServerCertificate(SOF_SHORT CertUsage);
|
||||
SOF_BSTR SOF_SignMessageDetach(SOF_BSTR InData);
|
||||
SOF_LONG SOF_VerifySignedMessageDetach(SOF_BSTR InData, SOF_BSTR SignedMessage);
|
||||
SOF_BSTR SOF_CreateTimeStampRequest(SOF_BSTR InData);
|
||||
SOF_BSTR SOF_CreateTimeStampResponse(SOF_BSTR TimeStampRequest);
|
||||
SOF_LONG SOF_VerifyTimeStamp(SOF_BSTR InData, SOF_BSTR tsResponseData);
|
||||
SOF_BSTR SOF_GetTimeStampInfo(SOF_BSTR tsResponseData, SOF_SHORT type);
|
||||
|
||||
#define SOR_OK 0x00000000
|
||||
#define SOR_UnknownErr 0x0B000001
|
||||
#define SOR_NotSupportYetErr 0x0B000002
|
||||
#define SOR_FileErr 0x0B000003
|
||||
#define SOR_ProviderTypeErr 0x0B000004
|
||||
#define SOR_LoadProviderErr 0x0B000005
|
||||
#define SOR_LoadDevMngApiErr 0x0B000006
|
||||
#define SOR_AlgoTypeErr 0x0B000007
|
||||
#define SOR_NameLenErr 0x0B000008
|
||||
#define SOR_KeyUsageErr 0x0B000009
|
||||
#define SOR_ModulusLenErr 0x0B000010
|
||||
#define SOR_NotInitializeErr 0x0B000011
|
||||
#define SOR_ObjErr 0x0B000012
|
||||
#define SOR_MemoryErr 0x0B000100
|
||||
#define SOR_TimeoutErr 0x0B000101
|
||||
#define SOR_IndataLenErr 0x0B000200
|
||||
#define SOR_IndataErr 0x0B000201
|
||||
#define SOR_GenRandErr 0x0B000300
|
||||
#define SOR_HashObjErr 0x0B000301
|
||||
#define SOR_HashErr 0x0B000302
|
||||
#define SOR_GenRsaKeyErr 0x0B000303
|
||||
#define SOR_RsaModulusLenErr 0x0B000304
|
||||
#define SOR_CspImprtPubKeyErr 0x0B000305
|
||||
#define SOR_RsaEncErr 0x0B000306
|
||||
#define SOR_RsaDecErr 0x0B000307
|
||||
#define SOR_HashNotEqualErr 0x0B000308
|
||||
#define SOR_KeyNotFountErr 0x0B000309
|
||||
#define SOR_CertNotFountErr 0x0B000310
|
||||
#define SOR_NotExportErr 0x0B000311
|
||||
#define SOR_VerifyPolicyErr 0x0B000312
|
||||
#define SOR_DecryptPadErr 0x0B000400
|
||||
#define SOR_MacLenErr 0x0B000401
|
||||
#define SOR_KeyInfoTypeErr 0x0B000402
|
||||
#define SOR_NullPointerErr 0x0B000403
|
||||
#define SOR_AppNotFoundErr 0x0B000404
|
||||
#define SOR_CertEncodeErr 0x0B000405
|
||||
#define SOR_CertInvalidErr 0x0B000406
|
||||
#define SOR_CertHasExpiredErr 0x0B000407
|
||||
#define SOR_CertRevokedErr 0x0B000408
|
||||
#define SOR_SignDataErr 0x0B000409
|
||||
#define SOR_VerifySignDataErr 0x0B000410
|
||||
#define SOR_ReadFileErr 0x0B000411
|
||||
#define SOR_WriteFileErr 0x0B000412
|
||||
#define SOR_SecretSegmentErr 0x0B000413
|
||||
#define SOR_SecretRecoverErr 0x0B000414
|
||||
#define SOR_EncryptDataErr 0x0B000415
|
||||
#define SOR_DecryptDataErr 0x0B000416
|
||||
#define SOR_PKCS7EncodeErr 0x0B000417
|
||||
#define SOR_XMLEncodeErr 0x0B000418
|
||||
#define SOR_ParameterNotSupportErr 0x0B000419
|
||||
#define SOR_CTLNotFound 0x0B000420
|
||||
#define SOR_AppNotFound 0x0B000421
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,91 +0,0 @@
|
||||
/* ====================================================================
|
||||
* 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_SPECK_H
|
||||
#define HEADER_SPECK_H
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_SPECK
|
||||
|
||||
#define SPECK_ROUNDS16 22
|
||||
#define SPECK_KEY_LEN16 4
|
||||
|
||||
#define SPECK_ROUNDS32 27
|
||||
#define SPECK_KEY_LEN32 4
|
||||
|
||||
#define SPECK_ROUNDS64 34
|
||||
#define SPECK_KEY_LEN64 4
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <openssl/e_os2.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
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(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(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
|
||||
Reference in New Issue
Block a user