- NAME
- SYNOPSIS
- DESCRIPTION
- RETURN VALUES
- CONFORMING TO
- SEE ALSO
- COPYRIGHT

# NAME

SM9_setup, SM9_generate_master_secret, SM9_extract_public_parameters, SM9_extract_private_key, SM9_extract_public_key - SM9 Algorithm

# SYNOPSIS

     #include <openssl/sm9.h>

     int SM9_setup(int pairing, int scheme, int hash1,
            SM9PublicParameters **mpk, SM9MasterSecret **msk);

     SM9MasterSecret *SM9_generate_master_secret(int pairing, int scheme, int hash1);
     SM9PublicParameters *SM9_extract_public_parameters(SM9MasterSecret *msk);

     SM9PrivateKey *SM9_extract_private_key(SM9MasterSecret *msk,
            const char *id, size_t idlen);

     SM9PublicKey *SM9_extract_public_key(SM9PublicParameters *mpk,
            const char *id, size_t idlen);

# DESCRIPTION

SM9_setup() calls SM9_generate_master_secret() and SM9_extract_public_parameters() to set up public parameters and master key for a later usage of SM9 system.

SM9_setup()通过调用SM9_generate_master_secret()和SM9_extract_public_parameters()来设置SM9系统的公共参数和主密钥，以备之后使用。

SM9_generate_master_secret() generates a new SM9MasterSecret structure and set its parameters including pairing type, helper functions, master secret value and master public point.

SM9_generate_master_secret()产生一个新的SM9MasterSecret结构，并为它设置双线性对类型、主密钥等参数值。

SM9_extract_public_parameters() allocates an empty SM9PublicParameters structure and copies some parameters from the given SM9MasterSecret structure.

SM9_extract_public_parameters()分配一个空的SM9PublicParameters结构，并从给定的SM9MasterSecret结构中拷贝部分变量值。

SM9_extract_private_key() and SM9_extract_public_key() both call SM9_MASTER_KEY_extract_key() (but using a different identifier) to generate public or private key for SM9.

SM9_extract_private_key()和SM9_extract_public_key()都调用SM9_MASTER_KEY_extract_key()生成一个SM9_KEY结构，但通过一个标识位区别生成的是公钥还是私钥。

# RETURN VALUES

SM9_setup() returns 1 on success or 0 on failure.

SM9_setup()如果执行成功则返回1，失败返回0。

SM9_generate_master_secret() returns a pointer to an allocated SM9MasterSecret structure or NULL on error.

SM9_generate_master_secret()返回一个指向已分配的SM9MasterSecret结构的指针。如果发生错误则返回NULL。

SM9_extract_public_parameters() returns a pointer to an allocated SM9PublicParameters structure or NULL on error.

SM9_extract_public_parameters()返回一个指向已分配的SM9PublicParameters结构的指针。如果发生错误则返回NULL。

SM9_extract_private_key() and SM9_extract_public_key() return a pointer to an allocated SM9_KEY structure or NULL on error.

SM9_extract_private_key()和SM9_extract_public_key()返回一个指向已分配的SM9_KEY结构的指针。如果发生错误则返回NULL。

# CONFORMING TO

GM/T 0044-2016 SM9 Identification Cryptographic Algorithm

# SEE ALSO

EVP_DigestInit(3)

# COPYRIGHT

Copyright 2014-2019 The GmSSL Project. All Rights Reserved.

Licensed under the GmSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at http://gmssl.org/license.html.