mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 17:06:25 +08:00
147 lines
5.7 KiB
C
147 lines
5.7 KiB
C
/* ====================================================================
|
|
* 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
|