mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Add SM2_VERIFY_CTX
This commit is contained in:
@@ -139,6 +139,8 @@ typedef struct {
|
||||
int sm2_fast_sign_pre_compute(SM2_SIGN_PRE_COMP pre_comp[32]);
|
||||
int sm2_fast_sign(const sm2_z256_t fast_private, SM2_SIGN_PRE_COMP *pre_comp,
|
||||
const uint8_t dgst[32], SM2_SIGNATURE *sig);
|
||||
int sm2_fast_verify(const SM2_Z256_POINT point_table[16],
|
||||
const uint8_t dgst[32], const SM2_SIGNATURE *sig);
|
||||
|
||||
|
||||
#define SM2_MIN_SIGNATURE_SIZE 8
|
||||
@@ -175,18 +177,29 @@ typedef struct {
|
||||
sm2_z256_t fast_sign_private;
|
||||
SM2_SIGN_PRE_COMP pre_comp[SM2_SIGN_PRE_COMP_COUNT];
|
||||
unsigned int num_pre_comp;
|
||||
|
||||
// verify public point table, P, 2P, ..., 16P
|
||||
SM2_Z256_POINT public_point_table[16];
|
||||
} SM2_SIGN_CTX;
|
||||
|
||||
_gmssl_export int sm2_sign_init(SM2_SIGN_CTX *ctx, const SM2_KEY *key, const char *id, size_t idlen);
|
||||
_gmssl_export int sm2_sign_update(SM2_SIGN_CTX *ctx, const uint8_t *data, size_t datalen);
|
||||
_gmssl_export int sm2_sign_finish(SM2_SIGN_CTX *ctx, uint8_t *sig, size_t *siglen);
|
||||
_gmssl_export int sm2_sign_reset(SM2_SIGN_CTX *ctx);
|
||||
int sm2_sign_finish_fixlen(SM2_SIGN_CTX *ctx, size_t siglen, uint8_t *sig);
|
||||
|
||||
_gmssl_export int sm2_verify_init(SM2_SIGN_CTX *ctx, const SM2_KEY *key, const char *id, size_t idlen);
|
||||
_gmssl_export int sm2_verify_update(SM2_SIGN_CTX *ctx, const uint8_t *data, size_t datalen);
|
||||
_gmssl_export int sm2_verify_finish(SM2_SIGN_CTX *ctx, const uint8_t *sig, size_t siglen);
|
||||
typedef struct {
|
||||
SM3_CTX sm3_ctx;
|
||||
SM3_CTX saved_sm3_ctx;
|
||||
SM2_KEY key;
|
||||
SM2_Z256_POINT public_point_table[16];
|
||||
} SM2_VERIFY_CTX;
|
||||
|
||||
_gmssl_export int sm2_verify_init(SM2_VERIFY_CTX *ctx, const SM2_KEY *key, const char *id, size_t idlen);
|
||||
_gmssl_export int sm2_verify_update(SM2_VERIFY_CTX *ctx, const uint8_t *data, size_t datalen);
|
||||
_gmssl_export int sm2_verify_finish(SM2_VERIFY_CTX *ctx, const uint8_t *sig, size_t siglen);
|
||||
_gmssl_export int sm2_verify_reset(SM2_VERIFY_CTX *ctx);
|
||||
|
||||
_gmssl_export int sm2_sign_ctx_reset(SM2_SIGN_CTX *ctx);
|
||||
|
||||
/*
|
||||
SM2Cipher ::= SEQUENCE {
|
||||
|
||||
@@ -110,9 +110,12 @@ void sm2_z256_point_sub_affine(SM2_Z256_POINT *R, const SM2_Z256_POINT *A, const
|
||||
int sm2_z256_point_affine_print(FILE *fp, int fmt, int ind, const char *label, const SM2_Z256_AFFINE_POINT *P);
|
||||
|
||||
void sm2_z256_point_mul_generator(SM2_Z256_POINT *R, const uint64_t k[4]);
|
||||
void sm2_z256_point_mul_pre_compute(const SM2_Z256_POINT *P, SM2_Z256_POINT T[16]);
|
||||
void sm2_z256_point_mul_ex(SM2_Z256_POINT *R, const uint64_t k[4], const SM2_Z256_POINT P_table[16]);
|
||||
void sm2_z256_point_mul(SM2_Z256_POINT *R, const uint64_t k[4], const SM2_Z256_POINT *P);
|
||||
void sm2_z256_point_mul_sum(SM2_Z256_POINT *R, const uint64_t t[4], const SM2_Z256_POINT *P, const uint64_t s[4]);
|
||||
|
||||
|
||||
const uint64_t *sm2_z256_prime(void);
|
||||
const uint64_t *sm2_z256_order(void);
|
||||
const uint64_t *sm2_z256_order_minus_one(void);
|
||||
|
||||
Reference in New Issue
Block a user