aboutsummaryrefslogtreecommitdiff
path: root/lib/sec_library/include/sec_crypto_sm2.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sec_library/include/sec_crypto_sm2.h')
-rwxr-xr-xlib/sec_library/include/sec_crypto_sm2.h99
1 files changed, 49 insertions, 50 deletions
diff --git a/lib/sec_library/include/sec_crypto_sm2.h b/lib/sec_library/include/sec_crypto_sm2.h
index 17be90b3..db04880b 100755
--- a/lib/sec_library/include/sec_crypto_sm2.h
+++ b/lib/sec_library/include/sec_crypto_sm2.h
@@ -77,7 +77,7 @@ typedef void (*sc_sm2_callback_t)(sc_sm2_event_e event);
\brief Initialize SM2.
\param[in] sm2 sm2 handle to operate.
\param[in] idx device id
- \return \ref uint32_t
+ \return Error code \ref uint32_t
*/
uint32_t sc_sm2_init(sc_sm2_t *sm2, uint32_t idx);
@@ -91,14 +91,13 @@ void sc_sm2_uninit(sc_sm2_t *sm2);
/**
\brief sm2 get capability.
\param[in] sm2 Operate handle.
- \return \ref uint32_t
+ \return Error code \ref uint32_t
*/
-uint32_t sc_sm2_config(sc_sm2_t *sm2, sc_sm2_cipher_order_e co,
- sc_sm2_endian_mode_e endian);
+uint32_t sc_sm2_config(sc_sm2_t *sm2, sc_sm2_cipher_order_e co, sc_sm2_endian_mode_e endian);
/**
\brief Attach the callback handler to SM2
- \param[in] sm2 Operate handle.
+ \param[in] sm2 Operate handle.
\param[in] cb Callback function
\param[in] arg User can define it by himself as callback's param
\return Error code \ref uint32_t
@@ -114,91 +113,92 @@ void sc_sm2_detach_callback(sc_sm2_t *sm2);
/**
\brief sm2 get capability.
\param[in] sm2 Operate handle.
- \param[out] cap Pointer of sc_sm2_capabilities_t.
- \return \ref uint32_t
+ \param[out] cap Pointer of sc_sm2_capabilities_t.
+ \return Error code \ref uint32_t
*/
uint32_t sc_sm2_get_capabilities(sc_sm2_t *sm2, sc_sm2_capabilities_t *cap);
-uint32_t sc_sm2_check_keypair(sc_sm2_t *sm2, uint8_t pubkey[65],
- uint8_t prikey[32]);
+/**
+ \brief check whether the public key and private key are a pair.
+ \param[in] sm2 sm2 handle to operate.
+ \param[in] private Pointer to the sm2 private key, alloc by caller.
+ \param[in] public Pointer to the sm2 public key, alloc by caller.
+ \return Error code \ref uint32_t
+*/
+uint32_t sc_sm2_check_keypair(sc_sm2_t *sm2, uint8_t pubkey[65], uint8_t prikey[32]);
/**
\brief generate sm2 key.
\param[in] sm2 sm2 handle to operate.
\param[out] private Pointer to the sm2 private key, alloc by caller.
- \param[out] public Pointer to the sm2 public key, alloc by caller.
- \return \ref uint32_t
+ \param[out] public Pointer to the sm2 public key, alloc by caller.
+ \return Error code \ref uint32_t
*/
uint32_t sc_sm2_gen_key(sc_sm2_t *sm2, uint8_t pubkey[65], uint8_t prikey[32]);
/**
\brief sm2 sign
- \param[in] sm2 sm2 handle to operate.
+ \param[in] sm2 sm2 handle to operate.
\param[in] d Pointer to the digest.
\param[out] privkey Pointer to the private key
- \param[out] s Pointer to the signature
- \return \ref uint32_t
+ \param[out] s Pointer to the signature
+ \return Error code \ref uint32_t
*/
-uint32_t sc_sm2_sign(sc_sm2_t *sm2, uint8_t d[32], uint8_t prikey[32],
- uint8_t s[64]);
+uint32_t sc_sm2_sign(sc_sm2_t *sm2, uint8_t d[32], uint8_t prikey[32], uint8_t s[64]);
/**
\brief sm2 sign
- \param[in] sm2 sm2 handle to operate.
+ \param[in] sm2 sm2 handle to operate.
\param[in] d Pointer to the digest.
\param[out] privkey Pointer to the private key
- \param[out] s Pointer to the signature
- \return \ref uint32_t
+ \param[out] s Pointer to the signature
+ \return Error code \ref uint32_t
*/
-uint32_t sc_sm2_sign_async(sc_sm2_t *sm2, uint8_t d[32], uint8_t prikey[32],
- uint8_t s[64]);
+uint32_t sc_sm2_sign_async(sc_sm2_t *sm2, uint8_t d[32], uint8_t prikey[32], uint8_t s[64]);
/* TODO */
/**
\brief sm2 verify
- \param[in] sm2 sm2 handle to operate.
+ \param[in] sm2 sm2 handle to operate.
\param[in] d Pointer to the digest.
\param[out] privkey Pointer to the private key
- \param[out] s Pointer to the signature
+ \param[out] s Pointer to the signature
\return verify result
*/
-bool sc_sm2_verify(sc_sm2_t *sm2, uint8_t d[32], uint8_t pubkey[65],
- uint8_t s[64]);
+bool sc_sm2_verify(sc_sm2_t *sm2, uint8_t d[32], uint8_t pubkey[65], uint8_t s[64]);
/**
\brief sm2 verify
- \param[in] sm2 sm2 handle to operate.
+ \param[in] sm2 sm2 handle to operate.
\param[in] d Pointer to the digest.
\param[out] privkey Pointer to the private key
- \param[out] s Pointer to the signature
+ \param[out] s Pointer to the signature
\return verify result
*/
-bool sc_sm2_verify_async(sc_sm2_t *sm2, uint8_t d[32], uint8_t pubkey[65],
- uint8_t s[64]);
+bool sc_sm2_verify_async(sc_sm2_t *sm2, uint8_t d[32], uint8_t pubkey[65], uint8_t s[64]);
/**
\brief sm2 encrypto
- \param[in] sm2 sm2 handle to operate.
- \param[in] plain Pointer to the plaintext.
- \param[in] PlainByteLen plaintext len
- \param[in] pubKey public key.
- \param[out] cipher Pointer to the chipher
- \param[out] cipher_byte_len Pointer to the chipher len.
- \return uint32_t
+ \param[in] sm2 sm2 handle to operate.
+ \param[in] plain Pointer to the plaintext.
+ \param[in] PlainByteLen plaintext len
+ \param[in] pubKey public key.
+ \param[out] cipher Pointer to the chipher
+ \param[out] cipher_byte_len Pointer to the chipher len.
+ \return Error code \ref uint32_t
*/
uint32_t sc_sm2_encrypt(sc_sm2_t *sm2, uint8_t *plain, uint32_t plain_len,
- uint8_t pubKey[65], uint8_t *cipher,
- uint32_t *cipher_len);
+ uint8_t pubKey[65], uint8_t *cipher, uint32_t *cipher_len);
/**
\brief sm2 encrypto
- \param[in] sm2 sm2 handle to operate.
- \param[in] cipher Pointer to the chipher
- \param[in] CipherByteLen chipher len.
- \param[in] prikey private key.
- \param[out] plain Pointer to the plaintext.
- \param[out] PlainByteLen plaintext len
- \return uint32_t
+ \param[in] sm2 sm2 handle to operate.
+ \param[in] cipher Pointer to the chipher
+ \param[in] CipherByteLen chipher len.
+ \param[in] prikey private key.
+ \param[out] plain Pointer to the plaintext.
+ \param[out] PlainByteLen plaintext len
+ \return Error code \ref uint32_t
*/
uint32_t sc_sm2_decrypt(sc_sm2_t *sm2, uint8_t *cipher, uint32_t cipher_len,
uint8_t prikey[32], uint8_t *plain,
@@ -207,7 +207,7 @@ uint32_t sc_sm2_decrypt(sc_sm2_t *sm2, uint8_t *cipher, uint32_t cipher_len,
/**
\brief sm2 key exchange
\param[in] sm2 sm2 handle to operate.
- \return uint32_t
+ \return Error code \ref uint32_t
*/
uint32_t sc_sm2_exchangekey(sc_sm2_t *sm2, sc_sm2_exchange_role_e role,
uint8_t *da, uint8_t *pb, uint8_t *ra1, uint8_t *ra,
@@ -218,7 +218,7 @@ uint32_t sc_sm2_exchangekey(sc_sm2_t *sm2, sc_sm2_exchange_role_e role,
/**
\brief sm2 key exchange get Z.
\param[in] sm2 sm2 handle to operate.
- \return uint32_t
+ \return Error code \ref uint32_t
*/
uint32_t sc_sm2_getZ(sc_sm2_t *sm2, uint8_t *id, uint32_t id_len,
uint8_t pubkey[65], uint8_t z[32]);
@@ -226,10 +226,9 @@ uint32_t sc_sm2_getZ(sc_sm2_t *sm2, uint8_t *id, uint32_t id_len,
/**
\brief sm2 key exchange get E
\param[in] sm2 sm2 handle to operate.
- \return uint32_t
+ \return Error code \ref uint32_t
*/
-uint32_t sc_sm2_getE(sc_sm2_t *sm2, uint8_t *m, uint32_t len, uint8_t z[32],
- uint8_t e[32]);
+uint32_t sc_sm2_getE(sc_sm2_t *sm2, uint8_t *m, uint32_t len, uint8_t z[32], uint8_t e[32]);
/**
\brief Get SM2 state.