xref: /openbsd-src/lib/libcrypto/sm2/sm2_local.h (revision 3e6ba5886cbe4cc72928d4b2589ebe61df798adc)
1 /*	$OpenBSD: sm2_local.h,v 1.3 2023/07/28 15:50:33 tb Exp $ */
2 /*
3  * Copyright (c) 2017, 2019 Ribose Inc
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef HEADER_SM2_LOCAL_H
19 #define HEADER_SM2_LOCAL_H
20 
21 #include <openssl/ec.h>
22 
23 __BEGIN_HIDDEN_DECLS
24 
25 int sm2_compute_userid_digest(uint8_t *out, const EVP_MD *digest,
26 	const uint8_t *uid, size_t uid_len, const EC_KEY *key);
27 
28 /*
29  * SM2 signature operation. Computes ZA (user id digest) and then signs
30  * H(ZA || msg) using SM2
31  */
32 ECDSA_SIG *sm2_do_sign(const EC_KEY *key, const EVP_MD *digest,
33 	const uint8_t *uid, size_t uid_len, const uint8_t *msg, size_t msg_len);
34 
35 int sm2_do_verify(const EC_KEY *key, const EVP_MD *digest,
36 	const ECDSA_SIG *signature, const uint8_t *uid, size_t uid_len,
37 	const uint8_t *msg, size_t msg_len);
38 
39 __END_HIDDEN_DECLS
40 
41 #endif /* !HEADER_SM2_LOCAL_H */
42