]>
git.ipfire.org Git - thirdparty/openssl.git/blob - include/crypto/sm2.h
e3278a31e6c6ab2093e421863c212142ce1853a7
2 * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright 2017 Ribose Inc. All Rights Reserved.
4 * Ported from Ribose contributions from Botan.
6 * Licensed under the Apache License 2.0 (the "License"). You may not use
7 * this file except in compliance with the License. You can obtain a copy
8 * in the file LICENSE in the source distribution or at
9 * https://www.openssl.org/source/license.html
12 #ifndef OSSL_CRYPTO_SM2_H
13 # define OSSL_CRYPTO_SM2_H
16 # include <openssl/opensslconf.h>
18 # ifndef OPENSSL_NO_SM2
20 # include <openssl/ec.h>
21 # include "crypto/types.h"
23 int ossl_sm2_key_private_check(const EC_KEY
*eckey
);
25 /* The default user id as specified in GM/T 0009-2012 */
26 # define SM2_DEFAULT_USERID "1234567812345678"
28 int ossl_sm2_compute_z_digest(uint8_t *out
,
35 * SM2 signature operation. Computes Z and then signs H(Z || msg) using SM2
37 ECDSA_SIG
*ossl_sm2_do_sign(const EC_KEY
*key
,
41 const uint8_t *msg
, size_t msg_len
);
43 int ossl_sm2_do_verify(const EC_KEY
*key
,
45 const ECDSA_SIG
*signature
,
48 const uint8_t *msg
, size_t msg_len
);
51 * SM2 signature generation.
53 int ossl_sm2_internal_sign(const unsigned char *dgst
, int dgstlen
,
54 unsigned char *sig
, unsigned int *siglen
,
58 * SM2 signature verification.
60 int ossl_sm2_internal_verify(const unsigned char *dgst
, int dgstlen
,
61 const unsigned char *sig
, int siglen
,
67 int ossl_sm2_ciphertext_size(const EC_KEY
*key
, const EVP_MD
*digest
,
68 size_t msg_len
, size_t *ct_size
);
70 int ossl_sm2_plaintext_size(const EC_KEY
*key
, const EVP_MD
*digest
,
71 size_t msg_len
, size_t *pt_size
);
73 int ossl_sm2_encrypt(const EC_KEY
*key
,
75 const uint8_t *msg
, size_t msg_len
,
76 uint8_t *ciphertext_buf
, size_t *ciphertext_len
);
78 int ossl_sm2_decrypt(const EC_KEY
*key
,
80 const uint8_t *ciphertext
, size_t ciphertext_len
,
81 uint8_t *ptext_buf
, size_t *ptext_len
);
83 const unsigned char *ossl_sm2_algorithmidentifier_encoding(int md_nid
,
85 # endif /* OPENSSL_NO_SM2 */