VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.7/include/crypto/sm2.h@ 97371

最後變更 在這個檔案從97371是 94082,由 vboxsync 提交於 3 年 前

libs/openssl-3.0.1: started applying and adjusting our OpenSSL changes to 3.0.1. bugref:10128

檔案大小: 2.9 KB
 
1/*
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.
5 *
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
10 */
11
12#ifndef OSSL_CRYPTO_SM2_H
13# define OSSL_CRYPTO_SM2_H
14# pragma once
15
16# include <openssl/opensslconf.h>
17
18# if !defined(OPENSSL_NO_SM2) && !defined(FIPS_MODULE)
19
20# include <openssl/ec.h>
21# include "crypto/types.h"
22
23int ossl_sm2_key_private_check(const EC_KEY *eckey);
24
25/* The default user id as specified in GM/T 0009-2012 */
26# define SM2_DEFAULT_USERID "1234567812345678"
27
28int ossl_sm2_compute_z_digest(uint8_t *out,
29 const EVP_MD *digest,
30 const uint8_t *id,
31 const size_t id_len,
32 const EC_KEY *key);
33
34/*
35 * SM2 signature operation. Computes Z and then signs H(Z || msg) using SM2
36 */
37ECDSA_SIG *ossl_sm2_do_sign(const EC_KEY *key,
38 const EVP_MD *digest,
39 const uint8_t *id,
40 const size_t id_len,
41 const uint8_t *msg, size_t msg_len);
42
43int ossl_sm2_do_verify(const EC_KEY *key,
44 const EVP_MD *digest,
45 const ECDSA_SIG *signature,
46 const uint8_t *id,
47 const size_t id_len,
48 const uint8_t *msg, size_t msg_len);
49
50/*
51 * SM2 signature generation.
52 */
53int ossl_sm2_internal_sign(const unsigned char *dgst, int dgstlen,
54 unsigned char *sig, unsigned int *siglen,
55 EC_KEY *eckey);
56
57/*
58 * SM2 signature verification.
59 */
60int ossl_sm2_internal_verify(const unsigned char *dgst, int dgstlen,
61 const unsigned char *sig, int siglen,
62 EC_KEY *eckey);
63
64/*
65 * SM2 encryption
66 */
67int ossl_sm2_ciphertext_size(const EC_KEY *key, const EVP_MD *digest,
68 size_t msg_len, size_t *ct_size);
69
70int ossl_sm2_plaintext_size(const unsigned char *ct, size_t ct_size,
71 size_t *pt_size);
72
73int ossl_sm2_encrypt(const EC_KEY *key,
74 const EVP_MD *digest,
75 const uint8_t *msg, size_t msg_len,
76 uint8_t *ciphertext_buf, size_t *ciphertext_len);
77
78int ossl_sm2_decrypt(const EC_KEY *key,
79 const EVP_MD *digest,
80 const uint8_t *ciphertext, size_t ciphertext_len,
81 uint8_t *ptext_buf, size_t *ptext_len);
82
83const unsigned char *ossl_sm2_algorithmidentifier_encoding(int md_nid,
84 size_t *len);
85# endif /* OPENSSL_NO_SM2 */
86#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette