YashanDB CRYPT_VERIFY函数

CRYPT_VERIFY函数以expr3为签名者需要提供的公钥、以expr4为签名公钥的算法类型、以expr5为签名者的签名ID对expr1的数据和expr2的签名进行验签,返回验签的结果TRUE或FALSE。

返回结果为TRUE表示验签通过,为FALSE则表示验签失败。

本函数遵循如下规则:

  • expr1数据只支持VARCHAR/CHAR类型。

  • expr2是CRYPT_SIGN函数的输出结果。

  • expr3是HEX格式的签名公钥,可以通过CRYPT_KEY函数创建相应的公私钥对。若不指定则函数报错。

  • expr4是验签的算法类型,目前仅支持SM2类型的签名和验签。

  • expr1或expr2为null时验签失败,返回FALSE。

示例

SELECT CRYPT_KEY('sm2') FROM dual;

CRYPT_KEY('SM2')                                                 
---------------------------------------------------------------- 
PUBLIC:7CB4E274EC64D0AC2BBEC9641731E3A88BF1959572BCDB19C7A3574FC0A6C0DEF3F12B4273F1085EFA96E22415869358EA04DC49590E3464DF6DC85898E38271;PRIVATE:7048688F3345C89E90F5B1E99DED97B5901A01F1C650A99CA752088E1CE22CAA 


SELECT CRYPT_SIGN('how are you? I am fine, thank you', '7048688F3345C89E90F5B1E99DED97B5901A01F1C650A99CA752088E1CE22CAA', 'sm2', 'lilei') signature FROM dual;

SIGNATURE                                                        
---------------------------------------------------------------- 
3046022100B8D8BF5A2E44575BE2B02AC0BE904867D61A605981E5AE324FF79A47C68C55DA022100B6F690EC9DBC64C68AEBF46D0A4383D99D12B516BF297E7A248AD2B9624709D7

    
SELECT CRYPT_VERIFY('how are you? I am fine, thank you', '3046022100B8D8BF5A2E44575BE2B02AC0BE904867D61A605981E5AE324FF79A47C68C55DA022100B6F690EC9DBC64C68AEBF46D0A4383D99D12B516BF297E7A248AD2B9624709D7', '7CB4E274EC64D0AC2BBEC9641731E3A88BF1959572BCDB19C7A3574FC0A6C0DEF3F12B4273F1085EFA96E22415869358EA04DC49590E3464DF6DC85898E38271', 'sm2', 'lilei') verify_result FROM dual;

VERIFY_RESULT 
------------- 
true         


SELECT CRYPT_VERIFY('how are you? I am fine, thank you', '3046022100B8D8BF5A2E44575BE2B02AC0BE904867D61A605981E5AE324FF79A47C68C55DA022100B6F690EC9DBC64C68AEBF46D0A4383D99D12B516BF297E7A248AD2B9624709D7', '7CB4E274EC64D0AC2BBEC9641731E3A88BF1959572BCDB19C7A3574FC0A6C0DEF3F12B4273F1085EFA96E22415869358EA04DC49590E3464DF6DC85898E38271', 'sm2', 'hanmeimei') verify_result FROM dual;

VERIFY_RESULT 
------------- 
false        
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ /** * @defgroup crypt * @brief crypto module */ /** * @defgroup crypt_algid * @ingroup crypt * @brief id of algorithms */ #ifndef CRYPT_ALGID_H #define CRYPT_ALGID_H #include "bsl_obj.h" #ifdef __cplusplus extern "C" { #endif // __cplusplus /** * @ingroup crypt_algid * * RAND algorithm ID */ typedef enum { CRYPT_RAND_SHA1 = BSL_CID_RAND_SHA1, CRYPT_RAND_SHA224 = BSL_CID_RAND_SHA224, CRYPT_RAND_SHA256 = BSL_CID_RAND_SHA256, CRYPT_RAND_SHA384 = BSL_CID_RAND_SHA384, CRYPT_RAND_SHA512 = BSL_CID_RAND_SHA512, CRYPT_RAND_HMAC_SHA1 = BSL_CID_RAND_HMAC_SHA1, CRYPT_RAND_HMAC_SHA224 = BSL_CID_RAND_HMAC_SHA224, CRYPT_RAND_HMAC_SHA256 = BSL_CID_RAND_HMAC_SHA256, CRYPT_RAND_HMAC_SHA384 = BSL_CID_RAND_HMAC_SHA384, CRYPT_RAND_HMAC_SHA512 = BSL_CID_RAND_HMAC_SHA512, CRYPT_RAND_AES128_CTR = BSL_CID_RAND_AES128_CTR, CRYPT_RAND_AES192_CTR = BSL_CID_RAND_AES192_CTR, CRYPT_RAND_AES256_CTR = BSL_CID_RAND_AES256_CTR, CRYPT_RAND_AES128_CTR_DF = BSL_CID_RAND_AES128_CTR_DF, CRYPT_RAND_AES192_CTR_DF = BSL_CID_RAND_AES192_CTR_DF, CRYPT_RAND_AES256_CTR_DF = BSL_CID_RAND_AES256_CTR_DF, CRYPT_RAND_SM3 = BSL_CID_RAND_SM3, CRYPT_RAND_SM4_CTR_DF = BSL_CID_RAND_SM4_CTR_DF, CRYPT_RAND_ALGID_MAX = BSL_CID_UNKNOWN } CRYPT_RAND_AlgId; /** * @ingroup crypt_algid * * Hash algorithm ID */ typedef enum { CRYPT_MD_MD5 = BSL_CID_MD5, CRYPT_MD_SHA1 = BSL_CID_SHA1, CRYPT_MD_SHA224 = BSL_CID_SHA224, CRYPT_MD_SHA256 = BSL_CID_SHA256, CRYPT_MD_SHA384 = BSL_CID_SHA384, CRYPT_MD_SHA512 = BSL_CID_SHA512, CRYPT_MD_SHA3_224 = BSL_CID_SHA3_224, CRYPT_MD_SHA3_256 = BSL_CID_SHA3_256, CRYPT_MD_SHA3_384 = BSL_CID_SHA3_384, CRYPT_MD_SHA3_512 = BSL_CID_SHA3_512, CRYPT_MD_SHAKE128 = BSL_CID_SHAKE128, CRYPT_MD_SHAKE256 = BSL_CID_SHAKE256, CRYPT_MD_SM3 = BSL_CID_SM3, CRYPT_MD_MAX = BSL_CID_UNKNOWN } CRYPT_MD_AlgId; /** * @ingroup crypt_algid * * MAC algorithm ID */ typedef enum { CRYPT_MAC_HMAC_MD5 = BSL_CID_HMAC_MD5, CRYPT_MAC_HMAC_SHA1 = BSL_CID_HMAC_SHA1, CRYPT_MAC_HMAC_SHA224 = BSL_CID_HMAC_SHA224, CRYPT_MAC_HMAC_SHA256 = BSL_CID_HMAC_SHA256, CRYPT_MAC_HMAC_SHA384 = BSL_CID_HMAC_SHA384, CRYPT_MAC_HMAC_SHA512 = BSL_CID_HMAC_SHA512, CRYPT_MAC_HMAC_SHA3_224 = BSL_CID_HMAC_SHA3_224, CRYPT_MAC_HMAC_SHA3_256 = BSL_CID_HMAC_SHA3_256, CRYPT_MAC_HMAC_SHA3_384 = BSL_CID_HMAC_SHA3_384, CRYPT_MAC_HMAC_SHA3_512 = BSL_CID_HMAC_SHA3_512, CRYPT_MAC_HMAC_SM3 = BSL_CID_HMAC_SM3, CRYPT_MAC_CMAC_AES128 = BSL_CID_CMAC_AES128, CRYPT_MAC_CMAC_AES192 = BSL_CID_CMAC_AES192, CRYPT_MAC_CMAC_AES256 = BSL_CID_CMAC_AES256, CRYPT_MAC_CMAC_SM4 = BSL_CID_CMAC_SM4, CRYPT_MAC_CBC_MAC_SM4 = BSL_CID_CBC_MAC_SM4, CRYPT_MAC_GMAC_AES128 = BSL_CID_GMAC_AES128, CRYPT_MAC_GMAC_AES192 = BSL_CID_GMAC_AES192, CRYPT_MAC_GMAC_AES256 = BSL_CID_GMAC_AES256, CRYPT_MAC_SIPHASH64 = BSL_CID_SIPHASH64, CRYPT_MAC_SIPHASH128 = BSL_CID_SIPHASH128, CRYPT_MAC_MAX = BSL_CID_UNKNOWN } CRYPT_MAC_AlgId; /** * @ingroup crypt_algid * * Asymmetric algorithm ID */ typedef enum { CRYPT_PKEY_DSA = BSL_CID_DSA, CRYPT_PKEY_ED25519 = BSL_CID_ED25519, CRYPT_PKEY_X25519 = BSL_CID_X25519, CRYPT_PKEY_RSA = BSL_CID_RSA, CRYPT_PKEY_DH = BSL_CID_DH, CRYPT_PKEY_ECDSA = BSL_CID_ECDSA, CRYPT_PKEY_ECDH = BSL_CID_ECDH, CRYPT_PKEY_SM2 = BSL_CID_SM2DSA, CRYPT_PKEY_PAILLIER = BSL_CID_PAILLIER, CRYPT_PKEY_ELGAMAL = BSL_CID_ELGAMAL, CRYPT_PKEY_SLH_DSA = BSL_CID_SLH_DSA, CRYPT_PKEY_ML_KEM = BSL_CID_ML_KEM, CRYPT_PKEY_ML_DSA = BSL_CID_ML_DSA, CRYPT_PKEY_HYBRID_KEM = BSL_CID_HYBRID_KEM, CRYPT_PKEY_XMSS = BSL_CID_XMSS, CRYPT_PKEY_MAX = BSL_CID_UNKNOWN } CRYPT_PKEY_AlgId; /** * @ingroup cipher_algid * @brief Symmetric algorithm mode ID * * There is a mapping relationship with the g_ealCipherMethod list. Attention any modification must be synchronized. */ typedef enum { CRYPT_CIPHER_AES128_CBC = BSL_CID_AES128_CBC, CRYPT_CIPHER_AES192_CBC = BSL_CID_AES192_CBC, CRYPT_CIPHER_AES256_CBC = BSL_CID_AES256_CBC, CRYPT_CIPHER_AES128_CTR = BSL_CID_AES128_CTR, CRYPT_CIPHER_AES192_CTR = BSL_CID_AES192_CTR, CRYPT_CIPHER_AES256_CTR = BSL_CID_AES256_CTR, CRYPT_CIPHER_AES128_ECB = BSL_CID_AES128_ECB, CRYPT_CIPHER_AES192_ECB = BSL_CID_AES192_ECB, CRYPT_CIPHER_AES256_ECB = BSL_CID_AES256_ECB, CRYPT_CIPHER_AES128_XTS = BSL_CID_AES128_XTS, CRYPT_CIPHER_AES256_XTS = BSL_CID_AES256_XTS, CRYPT_CIPHER_AES128_CCM = BSL_CID_AES128_CCM, CRYPT_CIPHER_AES192_CCM = BSL_CID_AES192_CCM, CRYPT_CIPHER_AES256_CCM = BSL_CID_AES256_CCM, CRYPT_CIPHER_AES128_GCM = BSL_CID_AES128_GCM, CRYPT_CIPHER_AES192_GCM = BSL_CID_AES192_GCM, CRYPT_CIPHER_AES256_GCM = BSL_CID_AES256_GCM, CRYPT_CIPHER_CHACHA20_POLY1305 = BSL_CID_CHACHA20_POLY1305, CRYPT_CIPHER_SM4_XTS = BSL_CID_SM4_XTS, CRYPT_CIPHER_SM4_CBC = BSL_CID_SM4_CBC, CRYPT_CIPHER_SM4_ECB = BSL_CID_SM4_ECB, CRYPT_CIPHER_SM4_CTR = BSL_CID_SM4_CTR, CRYPT_CIPHER_SM4_GCM = BSL_CID_SM4_GCM, CRYPT_CIPHER_SM4_CFB = BSL_CID_SM4_CFB, CRYPT_CIPHER_SM4_OFB = BSL_CID_SM4_OFB, CRYPT_CIPHER_AES128_CFB = BSL_CID_AES128_CFB, CRYPT_CIPHER_AES192_CFB = BSL_CID_AES192_CFB, CRYPT_CIPHER_AES256_CFB = BSL_CID_AES256_CFB, CRYPT_CIPHER_AES128_OFB = BSL_CID_AES128_OFB, CRYPT_CIPHER_AES192_OFB = BSL_CID_AES192_OFB, CRYPT_CIPHER_AES256_OFB = BSL_CID_AES256_OFB, CRYPT_CIPHER_MAX = BSL_CID_UNKNOWN, } CRYPT_CIPHER_AlgId; /** * @ingroup crypt_algid * * Parameter ID of an asymmetric algorithm. The most significant 16 bits indicate the algorithm ID, * and the least significant 16 bits map the ID definition of the algorithm LowLevel. */ typedef enum { CRYPT_DH_RFC2409_768 = BSL_CID_DH_RFC2409_768, CRYPT_DH_RFC2409_1024 = BSL_CID_DH_RFC2409_1024, CRYPT_DH_RFC3526_1536 = BSL_CID_DH_RFC3526_1536, CRYPT_DH_RFC3526_2048 = BSL_CID_DH_RFC3526_2048, CRYPT_DH_RFC3526_3072 = BSL_CID_DH_RFC3526_3072, CRYPT_DH_RFC3526_4096 = BSL_CID_DH_RFC3526_4096, CRYPT_DH_RFC3526_6144 = BSL_CID_DH_RFC3526_6144, CRYPT_DH_RFC3526_8192 = BSL_CID_DH_RFC3526_8192, CRYPT_DH_RFC7919_2048 = BSL_CID_DH_RFC7919_2048, CRYPT_DH_RFC7919_3072 = BSL_CID_DH_RFC7919_3072, CRYPT_DH_RFC7919_4096 = BSL_CID_DH_RFC7919_4096, CRYPT_DH_RFC7919_6144 = BSL_CID_DH_RFC7919_6144, CRYPT_DH_RFC7919_8192 = BSL_CID_DH_RFC7919_8192, CRYPT_ECC_NISTP224 = BSL_CID_NIST_PRIME224, CRYPT_ECC_NISTP256 = BSL_CID_PRIME256V1, CRYPT_ECC_NISTP384 = BSL_CID_SECP384R1, CRYPT_ECC_NISTP521 = BSL_CID_SECP521R1, CRYPT_ECC_BRAINPOOLP256R1 = BSL_CID_ECC_BRAINPOOLP256R1, CRYPT_ECC_BRAINPOOLP384R1 = BSL_CID_ECC_BRAINPOOLP384R1, CRYPT_ECC_BRAINPOOLP512R1 = BSL_CID_ECC_BRAINPOOLP512R1, CRYPT_ECC_SM2 = BSL_CID_SM2PRIME256, CRYPT_HYBRID_X25519_MLKEM512 = BSL_CID_X25519_MLKEM512, CRYPT_HYBRID_X25519_MLKEM768 = BSL_CID_X25519_MLKEM768, CRYPT_HYBRID_X25519_MLKEM1024 = BSL_CID_X25519_MLKEM1024, CRYPT_HYBRID_ECDH_NISTP256_MLKEM512 = BSL_CID_ECDH_NISTP256_MLKEM512, CRYPT_HYBRID_ECDH_NISTP256_MLKEM768 = BSL_CID_ECDH_NISTP256_MLKEM768, CRYPT_HYBRID_ECDH_NISTP256_MLKEM1024 = BSL_CID_ECDH_NISTP256_MLKEM1024, CRYPT_HYBRID_ECDH_NISTP384_MLKEM512 = BSL_CID_ECDH_NISTP384_MLKEM512, CRYPT_HYBRID_ECDH_NISTP384_MLKEM768 = BSL_CID_ECDH_NISTP384_MLKEM768, CRYPT_HYBRID_ECDH_NISTP384_MLKEM1024 = BSL_CID_ECDH_NISTP384_MLKEM1024, CRYPT_HYBRID_ECDH_NISTP521_MLKEM512 = BSL_CID_ECDH_NISTP521_MLKEM512, CRYPT_HYBRID_ECDH_NISTP521_MLKEM768 = BSL_CID_ECDH_NISTP521_MLKEM768, CRYPT_HYBRID_ECDH_NISTP521_MLKEM1024 = BSL_CID_ECDH_NISTP521_MLKEM1024, CRYPT_MLDSA_TYPE_MLDSA_44 = BSL_CID_ML_DSA_44, CRYPT_MLDSA_TYPE_MLDSA_65 = BSL_CID_ML_DSA_65, CRYPT_MLDSA_TYPE_MLDSA_87 = BSL_CID_ML_DSA_87, CRYPT_KEM_TYPE_MLKEM_512 = BSL_CID_ML_KEM_512, CRYPT_KEM_TYPE_MLKEM_768 = BSL_CID_ML_KEM_768, CRYPT_KEM_TYPE_MLKEM_1024 = BSL_CID_ML_KEM_1024, CRYPT_SLH_DSA_SHA2_128S = BSL_CID_SLH_DSA_SHA2_128S, CRYPT_SLH_DSA_SHAKE_128S = BSL_CID_SLH_DSA_SHAKE_128S, CRYPT_SLH_DSA_SHA2_128F = BSL_CID_SLH_DSA_SHA2_128F, CRYPT_SLH_DSA_SHAKE_128F = BSL_CID_SLH_DSA_SHAKE_128F, CRYPT_SLH_DSA_SHA2_192S = BSL_CID_SLH_DSA_SHA2_192S, CRYPT_SLH_DSA_SHAKE_192S = BSL_CID_SLH_DSA_SHAKE_192S, CRYPT_SLH_DSA_SHA2_192F = BSL_CID_SLH_DSA_SHA2_192F, CRYPT_SLH_DSA_SHAKE_192F = BSL_CID_SLH_DSA_SHAKE_192F, CRYPT_SLH_DSA_SHA2_256S = BSL_CID_SLH_DSA_SHA2_256S, CRYPT_SLH_DSA_SHAKE_256S = BSL_CID_SLH_DSA_SHAKE_256S, CRYPT_SLH_DSA_SHA2_256F = BSL_CID_SLH_DSA_SHA2_256F, CRYPT_SLH_DSA_SHAKE_256F = BSL_CID_SLH_DSA_SHAKE_256F, CRYPT_XMSS_SHA2_10_256 = BSL_CID_XMSS_SHA2_10_256, CRYPT_XMSS_SHA2_16_256 = BSL_CID_XMSS_SHA2_16_256, CRYPT_XMSS_SHA2_20_256 = BSL_CID_XMSS_SHA2_20_256, CRYPT_XMSS_SHA2_10_512 = BSL_CID_XMSS_SHA2_10_512, CRYPT_XMSS_SHA2_16_512 = BSL_CID_XMSS_SHA2_16_512, CRYPT_XMSS_SHA2_20_512 = BSL_CID_XMSS_SHA2_20_512, CRYPT_XMSS_SHAKE_10_256 = BSL_CID_XMSS_SHAKE_10_256, CRYPT_XMSS_SHAKE_16_256 = BSL_CID_XMSS_SHAKE_16_256, CRYPT_XMSS_SHAKE_20_256 = BSL_CID_XMSS_SHAKE_20_256, CRYPT_XMSS_SHAKE_10_512 = BSL_CID_XMSS_SHAKE_10_512, CRYPT_XMSS_SHAKE_16_512 = BSL_CID_XMSS_SHAKE_16_512, CRYPT_XMSS_SHAKE_20_512 = BSL_CID_XMSS_SHAKE_20_512, CRYPT_XMSS_SHA2_10_192 = BSL_CID_XMSS_SHA2_10_192, CRYPT_XMSS_SHA2_16_192 = BSL_CID_XMSS_SHA2_16_192, CRYPT_XMSS_SHA2_20_192 = BSL_CID_XMSS_SHA2_20_192, CRYPT_XMSS_SHAKE256_10_256 = BSL_CID_XMSS_SHAKE256_10_256, CRYPT_XMSS_SHAKE256_16_256 = BSL_CID_XMSS_SHAKE256_16_256, CRYPT_XMSS_SHAKE256_20_256 = BSL_CID_XMSS_SHAKE256_20_256, CRYPT_XMSS_SHAKE256_10_192 = BSL_CID_XMSS_SHAKE256_10_192, CRYPT_XMSS_SHAKE256_16_192 = BSL_CID_XMSS_SHAKE256_16_192, CRYPT_XMSS_SHAKE256_20_192 = BSL_CID_XMSS_SHAKE256_20_192, CRYPT_XMSSMT_SHA2_20_2_256 = BSL_CID_XMSSMT_SHA2_20_2_256, CRYPT_XMSSMT_SHA2_20_4_256 = BSL_CID_XMSSMT_SHA2_20_4_256, CRYPT_XMSSMT_SHA2_40_2_256 = BSL_CID_XMSSMT_SHA2_40_2_256, CRYPT_XMSSMT_SHA2_40_4_256 = BSL_CID_XMSSMT_SHA2_40_4_256, CRYPT_XMSSMT_SHA2_40_8_256 = BSL_CID_XMSSMT_SHA2_40_8_256, CRYPT_XMSSMT_SHA2_60_3_256 = BSL_CID_XMSSMT_SHA2_60_3_256, CRYPT_XMSSMT_SHA2_60_6_256 = BSL_CID_XMSSMT_SHA2_60_6_256, CRYPT_XMSSMT_SHA2_60_12_256 = BSL_CID_XMSSMT_SHA2_60_12_256, CRYPT_XMSSMT_SHA2_20_2_512 = BSL_CID_XMSSMT_SHA2_20_2_512, CRYPT_XMSSMT_SHA2_20_4_512 = BSL_CID_XMSSMT_SHA2_20_4_512, CRYPT_XMSSMT_SHA2_40_2_512 = BSL_CID_XMSSMT_SHA2_40_2_512, CRYPT_XMSSMT_SHA2_40_4_512 = BSL_CID_XMSSMT_SHA2_40_4_512, CRYPT_XMSSMT_SHA2_40_8_512 = BSL_CID_XMSSMT_SHA2_40_8_512, CRYPT_XMSSMT_SHA2_60_3_512 = BSL_CID_XMSSMT_SHA2_60_3_512, CRYPT_XMSSMT_SHA2_60_6_512 = BSL_CID_XMSSMT_SHA2_60_6_512, CRYPT_XMSSMT_SHA2_60_12_512 = BSL_CID_XMSSMT_SHA2_60_12_512, CRYPT_XMSSMT_SHAKE_20_2_256 = BSL_CID_XMSSMT_SHAKE_20_2_256, CRYPT_XMSSMT_SHAKE_20_4_256 = BSL_CID_XMSSMT_SHAKE_20_4_256, CRYPT_XMSSMT_SHAKE_40_2_256 = BSL_CID_XMSSMT_SHAKE_40_2_256, CRYPT_XMSSMT_SHAKE_40_4_256 = BSL_CID_XMSSMT_SHAKE_40_4_256, CRYPT_XMSSMT_SHAKE_40_8_256 = BSL_CID_XMSSMT_SHAKE_40_8_256, CRYPT_XMSSMT_SHAKE_60_3_256 = BSL_CID_XMSSMT_SHAKE_60_3_256, CRYPT_XMSSMT_SHAKE_60_6_256 = BSL_CID_XMSSMT_SHAKE_60_6_256, CRYPT_XMSSMT_SHAKE_60_12_256 = BSL_CID_XMSSMT_SHAKE_60_12_256, CRYPT_XMSSMT_SHAKE_20_2_512 = BSL_CID_XMSSMT_SHAKE_20_2_512, CRYPT_XMSSMT_SHAKE_20_4_512 = BSL_CID_XMSSMT_SHAKE_20_4_512, CRYPT_XMSSMT_SHAKE_40_2_512 = BSL_CID_XMSSMT_SHAKE_40_2_512, CRYPT_XMSSMT_SHAKE_40_4_512 = BSL_CID_XMSSMT_SHAKE_40_4_512, CRYPT_XMSSMT_SHAKE_40_8_512 = BSL_CID_XMSSMT_SHAKE_40_8_512, CRYPT_XMSSMT_SHAKE_60_3_512 = BSL_CID_XMSSMT_SHAKE_60_3_512, CRYPT_XMSSMT_SHAKE_60_6_512 = BSL_CID_XMSSMT_SHAKE_60_6_512, CRYPT_XMSSMT_SHAKE_60_12_512 = BSL_CID_XMSSMT_SHAKE_60_12_512, CRYPT_XMSSMT_SHA2_20_2_192 = BSL_CID_XMSSMT_SHA2_20_2_192, CRYPT_XMSSMT_SHA2_20_4_192 = BSL_CID_XMSSMT_SHA2_20_4_192, CRYPT_XMSSMT_SHA2_40_2_192 = BSL_CID_XMSSMT_SHA2_40_2_192, CRYPT_XMSSMT_SHA2_40_4_192 = BSL_CID_XMSSMT_SHA2_40_4_192, CRYPT_XMSSMT_SHA2_40_8_192 = BSL_CID_XMSSMT_SHA2_40_8_192, CRYPT_XMSSMT_SHA2_60_3_192 = BSL_CID_XMSSMT_SHA2_60_3_192, CRYPT_XMSSMT_SHA2_60_6_192 = BSL_CID_XMSSMT_SHA2_60_6_192, CRYPT_XMSSMT_SHA2_60_12_192 = BSL_CID_XMSSMT_SHA2_60_12_192, CRYPT_XMSSMT_SHAKE256_20_2_256 = BSL_CID_XMSSMT_SHAKE256_20_2_256, CRYPT_XMSSMT_SHAKE256_20_4_256 = BSL_CID_XMSSMT_SHAKE256_20_4_256, CRYPT_XMSSMT_SHAKE256_40_2_256 = BSL_CID_XMSSMT_SHAKE256_40_2_256, CRYPT_XMSSMT_SHAKE256_40_4_256 = BSL_CID_XMSSMT_SHAKE256_40_4_256, CRYPT_XMSSMT_SHAKE256_40_8_256 = BSL_CID_XMSSMT_SHAKE256_40_8_256, CRYPT_XMSSMT_SHAKE256_60_3_256 = BSL_CID_XMSSMT_SHAKE256_60_3_256, CRYPT_XMSSMT_SHAKE256_60_6_256 = BSL_CID_XMSSMT_SHAKE256_60_6_256, CRYPT_XMSSMT_SHAKE256_60_12_256 = BSL_CID_XMSSMT_SHAKE256_60_12_256, CRYPT_XMSSMT_SHAKE256_20_2_192 = BSL_CID_XMSSMT_SHAKE256_20_2_192, CRYPT_XMSSMT_SHAKE256_20_4_192 = BSL_CID_XMSSMT_SHAKE256_20_4_192, CRYPT_XMSSMT_SHAKE256_40_2_192 = BSL_CID_XMSSMT_SHAKE256_40_2_192, CRYPT_XMSSMT_SHAKE256_40_4_192 = BSL_CID_XMSSMT_SHAKE256_40_4_192, CRYPT_XMSSMT_SHAKE256_40_8_192 = BSL_CID_XMSSMT_SHAKE256_40_8_192, CRYPT_XMSSMT_SHAKE256_60_3_192 = BSL_CID_XMSSMT_SHAKE256_60_3_192, CRYPT_XMSSMT_SHAKE256_60_6_192 = BSL_CID_XMSSMT_SHAKE256_60_6_192, CRYPT_XMSSMT_SHAKE256_60_12_192 = BSL_CID_XMSSMT_SHAKE256_60_12_192, CRYPT_PKEY_PARAID_MAX = BSL_CID_UNKNOWN } CRYPT_PKEY_ParaId; /** * @ingroup crypt_algid * * Elliptic Curve Point Encoding Format */ typedef enum { CRYPT_POINT_COMPRESSED, CRYPT_POINT_UNCOMPRESSED, /**< default format. */ CRYPT_POINT_HYBRID, CRYPT_POINT_MAX } CRYPT_PKEY_PointFormat; /** * @ingroup crypt_algid * * KDF algorithm ID */ typedef enum { CRYPT_KDF_SCRYPT = BSL_CID_SCRYPT, CRYPT_KDF_PBKDF2 = BSL_CID_PBKDF2, CRYPT_KDF_KDFTLS12 = BSL_CID_KDFTLS12, CRYPT_KDF_HKDF = BSL_CID_HKDF, CRYPT_KDF_MAX = BSL_CID_UNKNOWN } CRYPT_KDF_AlgId; #ifdef __cplusplus } #endif // __cplusplus #endif // CRYPT_ALGID_H /* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef CRYPT_RSA_H #define CRYPT_RSA_H #include "hitls_build.h" #ifdef HITLS_CRYPTO_RSA #include <stdlib.h> #include <stdint.h> #include "crypt_local_types.h" #include "bsl_params.h" #ifdef __cplusplus extern "C" { #endif /* __cpluscplus */ #define RSA_MIN_MODULUS_BITS 1024 #define RSA_MAX_MODULUS_BITS 16384 #define RSA_SMALL_MODULUS_BYTES (3072 / 8) #define RSA_MAX_PUBEXP_BYTES (64 / 8) #define RSA_MIN_MODULUS_LEN (RSA_MIN_MODULUS_BITS / 8) #define RSA_MAX_MODULUS_LEN (RSA_MAX_MODULUS_BITS / 8) /* RSA */ typedef struct RSA_Ctx CRYPT_RSA_Ctx; typedef struct RSA_Para CRYPT_RSA_Para; /* RSA method */ /** * @ingroup rsa * @brief Allocate rsa context memory space. * * @retval (CRYPT_RSA_Ctx *) Pointer to the memory space of the allocated context * @retval NULL Invalid null pointer. */ CRYPT_RSA_Ctx *CRYPT_RSA_NewCtx(void); // create key structure /** * @ingroup rsa * @brief Allocate rsa context memory space. * * @param libCtx [IN] Library context * * @retval (CRYPT_RSA_Ctx *) Pointer to the memory space of the allocated context * @retval NULL Invalid null pointer. */ CRYPT_RSA_Ctx *CRYPT_RSA_NewCtxEx(void *libCtx); /** * @ingroup rsa * @brief Copy the RSA context. After the duplication is complete, call the CRYPT_RSA_FreeCtx to release the memory. * * @param ctx [IN] RSA context * * @return CRYPT_RSA_Ctx Rsa context pointer * If the operation fails, a null value is returned. */ CRYPT_RSA_Ctx *CRYPT_RSA_DupCtx(CRYPT_RSA_Ctx *keyCtx); /** * @ingroup rsa * @brief Create rsa key parameter structure * * @param para [IN] RSA External parameter * * @retval (CRYPT_RSA_Para *) Pointer to the allocated memory space of the structure * @retval NULL Invalid null pointer. */ CRYPT_RSA_Para *CRYPT_RSA_NewParaEx(const BSL_Param *para); /** * @ingroup rsa * @brief Release rsa key parameter structure * * @param para [IN] Storage pointer in the parameter structure to be released. The parameter is set NULL by the invoker. */ void CRYPT_RSA_FreePara(CRYPT_RSA_Para *para); /** * @ingroup rsa * @brief release rsa key context structure * * @param ctx [IN] Pointer to the context structure to be released. The ctx is set NULL by the invoker. */ void CRYPT_RSA_FreeCtx(CRYPT_RSA_Ctx *ctx); /** * @ingroup rsa * @brief Set the data of the key parameter structure to the key structure. * * @param ctx [OUT] Key structure for which related parameters need to be set * @param para [IN] Key parameter structure * * @retval CRYPT_NULL_INPUT Invalid null pointer input. * @retval CRYPT_RSA_ERR_KEY_BITS The expected key length does not meet the requirements. * @retval CRYPT_RSA_ERR_E_VALUE The expected value of e does not meet the requirements. * @retval CRYPT_MEM_ALLOC_FAIL internal memory allocation error * @retval CRYPT_SUCCESS set successfully. */ int32_t CRYPT_RSA_SetPara(CRYPT_RSA_Ctx *ctx, const CRYPT_RsaPara *para); /** * @ingroup rsa * @brief Obtain the valid length of the key. * * @param ctx [IN] Structure from which the key length is expected to be obtained * * @retval 0: The input is incorrect or the corresponding key structure does not have a valid key length. * @retval uint32_t: Valid key length */ uint32_t CRYPT_RSA_GetBits(const CRYPT_RSA_Ctx *ctx); #ifdef HITLS_CRYPTO_RSA_GEN /** * @ingroup rsa * @brief Generate the RSA key pair. * * @param ctx [IN/OUT] rsa context structure * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_KEY_BITS The value of e in the context structure does not meet the requirements. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval BN error An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The key pair is successfully generated. */ int32_t CRYPT_RSA_Gen(CRYPT_RSA_Ctx *ctx); #endif #if defined(HITLS_CRYPTO_RSA_ENCRYPT) || defined(HITLS_CRYPTO_RSA_VERIFY) || defined(HITLS_CRYPTO_RSA_SIGN) /** * @ingroup rsa * @brief RSA public key encryption * * @param ctx [IN] RSA context structure * @param input [IN] Information to be encrypted * @param inputLen [IN] Length of the information to be encrypted * @param out [OUT] Pointer to the encrypted information output. * @param outLen [IN/OUT] Pointer to the length of the encrypted information. * Before being transferred, the value must be set to the maximum length of the array. * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_NO_KEY_INFO does not contain the key information. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval CRYPT_SECUREC_FAIL A security function error occurs. * @retval BN error An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS encryption succeeded. */ int32_t CRYPT_RSA_PubEnc(const CRYPT_RSA_Ctx *ctx, const uint8_t *input, uint32_t inputLen, uint8_t *out, uint32_t *outLen); #endif /** * @ingroup rsa * @brief RSA private key decryption * * @param ctx [IN] RSA context structure * @param input [IN] Information to be decrypted * @param inputLen [IN] Length of the information to be decrypted * @param out [OUT] Pointer to the decrypted information output. * @param outLen [IN/OUT] Pointer to the length of the decrypted information. * Before being transferred, the value must be set to the maximum length of the array. * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_ERR_DEC_BITS Incorrect length of the encrypted private key. * @retval CRYPT_RSA_NO_KEY_INFO does not contain the key information. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval CRYPT_SECUREC_FAIL A security function error occurs. * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS Decrypted Successfully */ int32_t CRYPT_RSA_PrvDec(const CRYPT_RSA_Ctx *ctx, const uint8_t *input, uint32_t inputLen, uint8_t *out, uint32_t *outLen); /** * @ingroup rsa * @brief RSA Set the private key information. * * @param ctx [OUT] rsa context structure * @param prv [IN] Private key data * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_KEY_BITS The key length does not meet the requirements. * @retval CRYPT_RSA_NO_KEY_INFO does not contain the key information. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The private key is successfully set. */ int32_t CRYPT_RSA_SetPrvKey(CRYPT_RSA_Ctx *ctx, const CRYPT_RsaPrv *prv); /** * @ingroup rsa * @brief RSA Set the public key information. * * @param ctx [OUT] RSA context structure * @param pub [IN] Public key data * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_KEY_BITS The key length does not meet the requirements. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The public key is successfully set. */ int32_t CRYPT_RSA_SetPubKey(CRYPT_RSA_Ctx *ctx, const CRYPT_RsaPub *pub); /** * @ingroup rsa * @brief RSA Obtain the private key information. * * @param ctx [IN] RSA context structure * @param prv [OUT] Private key data * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The private key is obtained successfully. */ int32_t CRYPT_RSA_GetPrvKey(const CRYPT_RSA_Ctx *ctx, CRYPT_RsaPrv *prv); /** * @ingroup rsa * @brief RSA Obtain the public key information. * * @param ctx [IN] RSA context structure * @param pub [OUT] Public key data * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The public key is obtained successfully. */ int32_t CRYPT_RSA_GetPubKey(const CRYPT_RSA_Ctx *ctx, CRYPT_RsaPub *pub); #ifdef HITLS_BSL_PARAMS /** * @ingroup rsa * @brief RSA Set the private key information. * * @param ctx [OUT] rsa context structure * @param para [IN] Private key data * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_KEY_BITS The key length does not meet the requirements. * @retval CRYPT_RSA_NO_KEY_INFO does not contain the key information. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The private key is successfully set. */ int32_t CRYPT_RSA_SetPrvKeyEx(CRYPT_RSA_Ctx *ctx, const BSL_Param *para); /** * @ingroup rsa * @brief RSA Set the public key information. * * @param ctx [OUT] RSA context structure * @param para [IN] Public key data * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_KEY_BITS The key length does not meet the requirements. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The public key is successfully set. */ int32_t CRYPT_RSA_SetPubKeyEx(CRYPT_RSA_Ctx *ctx, const BSL_Param *para); /** * @ingroup rsa * @brief RSA Obtain the private key information. * * @param ctx [IN] RSA context structure * @param para [OUT] Private key data * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The private key is obtained successfully. */ int32_t CRYPT_RSA_GetPrvKeyEx(const CRYPT_RSA_Ctx *ctx, BSL_Param *para); /** * @ingroup rsa * @brief RSA Obtain the public key information. * * @param ctx [IN] RSA context structure * @param para [OUT] Public key data * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS The public key is obtained successfully. */ int32_t CRYPT_RSA_GetPubKeyEx(const CRYPT_RSA_Ctx *ctx, BSL_Param *para); /** * @ingroup rsa * @brief Set the data of the key parameter structure to the key structure. * * @param ctx [OUT] Key structure for which related parameters need to be set * @param para [IN] Key parameter structure * * @retval CRYPT_NULL_INPUT Invalid null pointer input. * @retval CRYPT_RSA_ERR_KEY_BITS The expected key length does not meet the requirements. * @retval CRYPT_RSA_ERR_E_VALUE The expected value of e does not meet the requirements. * @retval CRYPT_MEM_ALLOC_FAIL internal memory allocation error * @retval CRYPT_SUCCESS set successfully. */ int32_t CRYPT_RSA_SetParaEx(CRYPT_RSA_Ctx *ctx, const BSL_Param *para); #endif int32_t CRYPT_RSA_Ctrl(CRYPT_RSA_Ctx *ctx, int32_t opt, void *val, uint32_t len); #ifdef HITLS_CRYPTO_RSA_BSSA #ifdef HITLS_CRYPTO_RSA_SIGN /** * @ingroup RSA * @brief RSA blind operation for blind signature * * @param ctx [IN] RSA Context structure * @param algId [IN] hash Id for input * @param input [IN] Message to be blinded * @param inputLen [IN] Length of input message * @param out [OUT] Blinded message * @param outLen [OUT] Length of blinded message * * @retval CRYPT_SUCCESS on success * For other error codes, see crypt_errno.h. */ int32_t CRYPT_RSA_Blind(CRYPT_RSA_Ctx *ctx, int32_t algId, const uint8_t *input, uint32_t inputLen, uint8_t *out, uint32_t *outLen); #endif #ifdef HITLS_CRYPTO_RSA_VERIFY /** * @ingroup RSA * @brief RSA unblind operation for blind signature * * @param ctx [IN] RSA Context structure * @param input [IN] Blind signature to be unblinded * @param inputLen [IN] Length of blind signature * @param out [OUT] Final unblinded signature * @param outLen [OUT] Length of unblinded signature * * @retval CRYPT_SUCCESS on success * For other error codes, see crypt_errno.h. */ int32_t CRYPT_RSA_UnBlind(const CRYPT_RSA_Ctx *ctx, const uint8_t *input, uint32_t inputLen, uint8_t *out, uint32_t *outLen); #endif #endif #ifdef HITLS_CRYPTO_RSA_EMSA_PSS #if defined(HITLS_CRYPTO_RSA_SIGN) || defined(HITLS_CRYPTO_RSA_BSSA) /** * @ingroup rsa * @brief Set the PSS for the original data. * * @param ctx [IN] CRYPT_RSA_Ctx * @param hashMethod [IN] pss Required Hash Method * @param mgfMethod [IN] pss Internal hash method required by the mgf. * @param saltLen [IN] Length of the input salt. * @param data [IN] Original data * @param dataLen [IN] Length of the original data * @param pad [OUT] pss Output buffer * @param padLen [OUT] Maximum length of the array output by the PSS. * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_PSS_SALT_DATA The salt value does not meet the requirements. * @retval CRYPT_RSA_ERR_KEY_BITS The key length does not meet the requirements. * @retval CRYPT_RSA_ERR_PSS_SALT_LEN The salt length does not meet the requirements. * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH The length of the reserved buffer is insufficient. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval CRYPT_SUCCESS Succeeded in setting the PSS. */ int32_t CRYPT_RSA_SetPss(CRYPT_RSA_Ctx *ctx, const EAL_MdMethod *hashMethod, const EAL_MdMethod *mgfMethod, uint32_t saltLen, const uint8_t *data, uint32_t dataLen, uint8_t *pad, uint32_t padLen); #endif // HITLS_CRYPTO_RSA_SIGN || HITLS_CRYPTO_RSA_BSSA #ifdef HITLS_CRYPTO_RSA_VERIFY /** * @ingroup rsa * @brief Compare the original data from the PSS. * * @param ctx [IN] CRYPT_RSA_Ctx * @param hashMethod [IN] pss Required the hash method * @param mgfMethod [IN] pss Internal hash method required by the mgf. * @param saltLen [IN] Salt value length * @param data [IN] Original data * @param dataLen [IN] Length of the original data * @param pad [IN] Data after PSS is set. * @param padLen [IN] Data length after PSS is set. * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_ERR_PSS_SALT_DATA The salt value does not meet the requirements. * @retval CRYPT_RSA_ERR_PSS_SALT_LEN The salt length does not meet the requirements. * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH The length required for padding does not match the input parameter. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval CRYPT_SUCCESS pss comparison succeeded. */ int32_t CRYPT_RSA_VerifyPss(CRYPT_RSA_Ctx *ctx, const EAL_MdMethod *hashMethod, const EAL_MdMethod *mgfMethod, uint32_t saltLen, const uint8_t *data, uint32_t dataLen, const uint8_t *pad, uint32_t padLen); #endif // HITLS_CRYPTO_RSA_VERIFY #endif // HITLS_CRYPTO_RSA_EMSA_PSS #ifdef HITLS_CRYPTO_RSA_EMSA_PKCSV15 /** * @ingroup rsa * @brief Set pkcsv1.5 padding. * * @param hashId [IN] the hash method required by pkcsv1.5 setting. * @param data [IN] Original data * @param dataLen [IN] Length of the original data * @param pad [OUT] Pointer to the array for receiving the padding. * @param padLen [IN] Array length for receiving padding. * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_NO_KEY_INFO The key information is insufficient. * @retval CRYPT_SECUREC_FAIL The security function fails. * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH The length required by the padding does not match the input parameter. * @retval CRYPT_RSA_ERR_INPUT_VALUE The hash algorithm ID is not supported. * @retval CRYPT_SUCCESS The pkcsv1.5 padding is successfully set. */ int32_t CRYPT_RSA_SetPkcsV15Type1(CRYPT_MD_AlgId hashId, const uint8_t *data, uint32_t dataLen, uint8_t *pad, uint32_t padLen); #ifdef HITLS_CRYPTO_RSA_VERIFY /** * @ingroup rsa * @brief Verify pkcsv1.5 padding. * * @param hashId [IN] the hash method corresponding to pkcsv1.5 verification. * @param pad [IN] Data after padding * @param padLen [IN] Data length after padding * @param data [IN] Original data * @param dataLen [IN] Length of the original data * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_ERR_PKCSV15_SALT_DATA Incorrect padding value. * @retval CRYPT_SECUREC_FAIL Security Function Failure * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH The length required for padding does not match the input parameter. * @retval CRYPT_RSA_ERR_INPUT_VALUE The hash algorithm ID is not supported. * @retval CRYPT_SUCCESS Verify pkcsv1.5 is padded successfully. */ int32_t CRYPT_RSA_VerifyPkcsV15Type1(CRYPT_MD_AlgId hashId, const uint8_t *pad, uint32_t padLen, const uint8_t *data, uint32_t dataLen); #endif // HITLS_CRYPTO_RSA_VERIFY #endif // HITLS_CRYPTO_RSA_EMSA_PKCSV15 #if defined(HITLS_CRYPTO_RSA_SIGN) || defined(HITLS_CRYPTO_RSA_VERIFY) /** * @ingroup rsa * @brief Obtain the maximum length of RSA signature data. * * @param ctx [IN] Maximum length of the RSA signature data that is expected to be obtained * * @retval 0 The input is incorrect or the corresponding key structure does not contain valid key information. * @retval uint32_t Maximum length of the signature data */ uint32_t CRYPT_RSA_GetSignLen(const CRYPT_RSA_Ctx *ctx); #endif #ifdef HITLS_CRYPTO_RSA_VERIFY int32_t CRYPT_RSA_VerifyData(CRYPT_RSA_Ctx *ctx, const uint8_t *data, uint32_t dataLen, const uint8_t *sign, uint32_t signLen); int32_t CRYPT_RSA_Verify(CRYPT_RSA_Ctx *ctx, int32_t algId, const uint8_t *data, uint32_t dataLen, const uint8_t *sign, uint32_t signLen); #endif #ifdef HITLS_CRYPTO_RSA_SIGN int32_t CRYPT_RSA_SignData(CRYPT_RSA_Ctx *ctx, const uint8_t *data, uint32_t dataLen, uint8_t *sign, uint32_t *signLen); int32_t CRYPT_RSA_Sign(CRYPT_RSA_Ctx *ctx, int32_t algId, const uint8_t *data, uint32_t dataLen, uint8_t *sign, uint32_t *signLen); #endif #ifdef HITLS_CRYPTO_RSA_ENCRYPT /** * @ingroup rsa * @brief RSA public key encryption * * @param ctx [IN] RSA context structure * @param data [IN] Information to be encrypted * @param dataLen [IN] Length of the information to be encrypted * @param out [OUT] Pointer to the encrypted information output. * @param outLen [OUT] Pointer to the length of the encrypted information * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_NO_KEY_INFO does not contain the key information. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH Outbuf Insufficient * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval CRYPT_SECUREC_FAIL A safe function error occurs. * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_EAL_ALG_NOT_SUPPORT does not register the encryption method. * @retval CRYPT_SUCCESS encryption succeeded. */ int32_t CRYPT_RSA_Encrypt(CRYPT_RSA_Ctx *ctx, const uint8_t *data, uint32_t dataLen, uint8_t *out, uint32_t *outLen); #endif #ifdef HITLS_CRYPTO_RSA_DECRYPT /** * @ingroup rsa * @brief RSA private key decryption * * @param ctx [IN] RSA context structure * @param data [IN] Information to be decrypted * @param dataLen [IN] Length of the information to be decrypted * @param out [OUT] Pointer to the output information after decryption. * @param outLen [OUT] Pointer to the length of the decrypted information * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_NO_KEY_INFO does not contain the key information. * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH Outbuf Insufficient * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval CRYPT_SECUREC_FAIL A security function error occurs. * @retval CRYPT_EAL_ALG_NOT_SUPPORT does not register the decryption method. * @retval BN error. An error occurs in the internal BigNum operation. * @retval CRYPT_SUCCESS Decryption succeeded. */ int32_t CRYPT_RSA_Decrypt(CRYPT_RSA_Ctx *ctx, const uint8_t *data, uint32_t dataLen, uint8_t *out, uint32_t *outLen); #endif #ifdef HITLS_CRYPTO_RSA_VERIFY /** * @ingroup rsa * @brief RSA public key decryption * * @param ctx [IN] RSA context structure * @param data [IN] Information to be decrypted * @param dataLen [IN] Length of the information to be decrypted * @param out [OUT] Pointer to the output information after decryption. * @param outLen [IN/OUT] Pointer to the length of the decrypted information. * Before being transferred, the value must be set to the maximum length of the array. * * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_NO_KEY_INFO does not contain the key information. * @retval CRYPT_RSA_PAD_NO_SET_ERROR The padding type is not set. * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH The space is insufficient after decryption. * @retval CRYPT_RSA_ERR_INPUT_VALUE The input parameter does not meet the requirements. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval Other error codes, for example, the CRYPT_RSA_UnPackPkcsV15Type1 de-padding function. * @retval CRYPT_SUCCESS Decrypted Successfully */ int32_t CRYPT_RSA_Recover(CRYPT_RSA_Ctx *ctx, const uint8_t *data, uint32_t dataLen, uint8_t *out, uint32_t *outLen); #endif /** * @ingroup rsa * @brief RSA compare the public key * * @param a [IN] RSA context structure * @param b [IN] RSA context structure * * @retval CRYPT_SUCCESS is the same * @retval CRYPT_NULL_INPUT Invalid null pointer input * @retval CRYPT_RSA_NO_KEY_INFO No public key * @retval CRYPT_RSA_PUBKEY_NOT_EQUAL Public Keys are not equal */ int32_t CRYPT_RSA_Cmp(const CRYPT_RSA_Ctx *a, const CRYPT_RSA_Ctx *b); #ifdef HITLS_CRYPTO_RSAES_OAEP #ifdef HITLS_CRYPTO_RSA_ENCRYPT /** * @ingroup rsa * @brief oaep padding * * @param hashMethod [IN] Hash method. Only sha1, sha244, sha256, sha384, and sha512 are supported. * @param mgfMethod [IN] Hash method required by mgf * @param in [IN] Original data * @param inLen [IN] Original data length * @param param [IN] oaep parameter, which can be null * @param paramLen [IN] oaep Parameter length * @param pad [IN] Data after padding * @param padLen [IN] Data length after padding * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_SECUREC_FAIL A security function error occurs. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * @retval CRYPT_RSA_BUFF_LEN_NOT_ENOUGH Outbuf Insufficient * */ int32_t CRYPT_RSA_SetPkcs1Oaep(CRYPT_RSA_Ctx *ctx, const uint8_t *in, uint32_t inLen, uint8_t *pad, uint32_t padLen); #endif // HITLS_CRYPTO_RSA_ENCRYPT #ifdef HITLS_CRYPTO_RSA_DECRYPT /** * @ingroup rsa * @brief Verify the oaep padding. * * @param pad [IN] oaep parameter, which can be null * @param in [IN] Data after padding * @param inLen [IN] Data length after padding * @param param [IN] oaep parameter, which can be null * @param paramLen [IN] oaep Parameter length * @param msg [IN] Data after the de-padding * @param msgLen [IN/OUT] The input parameter is the length of the msg buffer, * and the output parameter is the length of the msg after the de-padding. * * @retval CRYPT_NULL_INPUT Error null pointer input * @retval CRYPT_RSA_ERR_INPUT_VALUE The entered value does not meet the calculation conditions. * @retval CRYPT_SECUREC_FAIL A security function error occurs. * @retval CRYPT_MEM_ALLOC_FAIL Memory allocation failure * */ int32_t CRYPT_RSA_VerifyPkcs1Oaep(RSA_PadingPara *pad, const uint8_t *in, uint32_t inLen, const uint8_t *param, uint32_t paramLen, uint8_t *msg, uint32_t *msgLen); #endif // HITLS_CRYPTO_RSA_DECRYPT #endif // HITLS_CRYPTO_RSAES_OAEP #if defined(HITLS_CRYPTO_RSA_ENCRYPT) && \ (defined(HITLS_CRYPTO_RSAES_PKCSV15_TLS) || defined(HITLS_CRYPTO_RSAES_PKCSV15)) int32_t CRYPT_RSA_SetPkcsV15Type2(void *libCtx, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t outLen); #endif #ifdef HITLS_CRYPTO_RSA_DECRYPT #ifdef HITLS_CRYPTO_RSAES_PKCSV15 int32_t CRYPT_RSA_VerifyPkcsV15Type2(const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen); #endif #ifdef HITLS_CRYPTO_RSAES_PKCSV15_TLS int32_t CRYPT_RSA_VerifyPkcsV15Type2TLS(const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen); #endif #endif // HITLS_CRYPTO_RSA_DECRYPT /** * @ingroup rsa * @brief rsa get security bits * * @param ctx [IN] rsa Context structure * * @retval security bits */ int32_t CRYPT_RSA_GetSecBits(const CRYPT_RSA_Ctx *ctx); #ifdef HITLS_CRYPTO_RSA_CHECK /** * @ingroup rsa * @brief check the key pair consistency * * @param checkType [IN] check type * @param pkey1 [IN] rsa key context structure * @param pkey2 [IN] rsa key context structure * * @retval CRYPT_SUCCESS check success. * Others. For details, see error code in errno. */ int32_t CRYPT_RSA_Check(uint32_t checkType, const CRYPT_RSA_Ctx *pkey1, const CRYPT_RSA_Ctx *pkey2); #endif // HITLS_CRYPTO_RSA_CHECK #ifdef HITLS_CRYPTO_PROVIDER /** * @ingroup RSA * @brief RSA import key * * @param ctx [IN/OUT] RSA context structure * @param params [IN] parameters */ int32_t CRYPT_RSA_Import(CRYPT_RSA_Ctx *ctx, const BSL_Param *params); /** * @ingroup RSA * @brief RSA export key * * @param ctx [IN] RSA context structure * @param params [IN/OUT] key parameters */ int32_t CRYPT_RSA_Export(const CRYPT_RSA_Ctx *ctx, BSL_Param *params); #endif // HITLS_CRYPTO_PROVIDER #ifdef __cplusplus } #endif #endif // HITLS_CRYPTO_RSA #endif // CRYPT_RSA_H 这是头文件以及rsa的源代码,请根据这些来编写上述的demo
09-07
/* * This file is part of the openHiTLS project. * * openHiTLS is licensed under the Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * * http://license.coscl.org.cn/MulanPSL2 * * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ /** * @defgroup crypt_errno * @ingroup crypt * @brief error number module of crypto module */ #ifndef CRYPT_ERRNO_H #define CRYPT_ERRNO_H #ifdef __cplusplus extern "C" { #endif /** * @ingroup crypt_errno * @brief Return success */ #define CRYPT_SUCCESS 0 /** * @ingroup crypt_errno * * CRYPTO module return value. */ enum CRYPT_ERROR { CRYPT_NULL_INPUT = 0x01010001, /**< Null pointer input error, bufferLen is 0. */ CRYPT_SECUREC_FAIL, /**< Security function returns an error. */ CRYPT_MEM_ALLOC_FAIL, /**< Failed to apply for memory. */ CRYPT_NO_REGIST_RAND, /**< The global random number is not registered.*/ CRYPT_ERR_ALGID, /**< Incorrect algorithm ID. */ CRYPT_INVALID_ARG, /**< Invalid input parameter. */ CRYPT_NOT_SUPPORT, /**< unsupported operation. */ CRYPT_INCONSISTENT_OPERATION, /**< Inconsistent operation. */ CRYPT_INVALID_KEY, /**< invalid key. */ CRYPT_PAIRWISE_CHECK_FAIL, /**< key-pair check failed. */ CRYPT_BN_BUFF_LEN_NOT_ENOUGH = 0x01020001, /**< Insufficient buffer length. */ CRYPT_BN_SPACE_NOT_ENOUGH, /**< Insufficient big number space. */ CRYPT_BN_BITS_TOO_MAX, /**< The maximum bit limit is exceeded of the big number. */ CRYPT_BN_RAND_GEN_FAIL, /**< Failed to generate the random number. */ CRYPT_BN_OPTIMIZER_STACK_FULL, /**< Optimizer stack is full. */ CRYPT_BN_NO_NEGATIVE_ZERO, /**< The big number is set to a positive number only. */ CRYPT_BN_ERR_RAND_ZERO, /**< Generates a random number smaller than 0. */ CRYPT_BN_ERR_RAND_NEGATIVE, /**< Generate a negative random number. */ CRYPT_BN_ERR_RAND_TOP_BOTTOM, /**< The top or bottom is invalid during random number generation. */ CRYPT_BN_ERR_RAND_BITS_NOT_ENOUGH, /**< The bit is too small during random number generation. */ CRYPT_BN_OPTIMIZER_GET_FAIL, /**< Failed to obtain the space from the optimizer. */ CRYPT_BN_ERR_DIVISOR_ZERO, /**< The divisor cannot be 0. */ CRYPT_BN_ERR_EXP_NO_NEGATIVE, /**< The value of exponent cannot be negative. */ CRYPT_BN_MONT_BASE_TOO_MAX, /**< Montgomery module exponentiation base is too large. */ CRYPT_BN_NOR_GEN_PRIME, /**< Prime Number Generation Failure. */ CRYPT_BN_NOR_CHECK_PRIME, /**< prime number check failed. */ CRYPT_BN_ERR_GCD_NO_ZERO, /**< The maximum common divisor cannot contain 0. */ CRYPT_BN_ERR_NO_INVERSE, /**< Cannot obtain the inverse module. */ CRYPT_BN_ERR_SQRT_PARA, /**< The parameter is incorrect when modulus square root. */ CRYPT_BN_ERR_LEGENDE_DATA, /**< Failed to find a specific number for z to p's Legendre sign (z|p) equal to -1 when calculating the square root. */ CRYPT_BN_ERR_NO_SQUARE_ROOT, /**< The square root cannot be found. */ CRYPT_BN_ERR_MASKCOPY_LEN, /**< Data lengths are inconsistent when data is copied with masks. */ CRYPT_BN_ERR_QUICK_MODDATA, /**< Uses the BN_ModNistEccMul and BN_ModNistEccSqr interfaces, the module data is not supported. */ CRYPT_BN_FLAG_INVALID, /**< Invalid big number flag. */ CRYPT_BN_CONVERT_INPUT_INVALID, /**< Invalid input parameter of big number strings. */ CRYPT_BN_NOT_SUPPORT_EXTENSION, /**< The big number does not support dynamic extension. */ CRYPT_BN_INPUT_INVALID, /**< Invalid external big number input. */ CRYPT_BN_BITS_INVALID, /**< The bits of the big number exceeds the limit. */ CRYPT_BN_ERR_SWAP_LEN, /**< Data lengths are inconsistent when data is swapped with masks. */ CRYPT_RSA_BUFF_LEN_NOT_ENOUGH = 0x01030001, /**< The buffer length is insufficient. */ CRYPT_RSA_NO_KEY_INFO, /**< Lacks valid key information. */ CRYPT_RSA_ERR_KEY_BITS, /**< Incorrect key length. */ CRYPT_RSA_ERR_E_VALUE, /**< The value of parameter e is incorrect. */ CRYPT_RSA_NOR_KEYGEN_FAIL, /**< Key generation failure, it's normal error. */ CRYPT_RSA_NOR_VERIFY_FAIL, /**< Failed to verify the signature. it's normal error. */ CRYPT_RSA_ERR_ENC_BITS, /**< Incorrect length of the encrypted plaintext of the public key. */ CRYPT_RSA_ERR_DEC_BITS, /**< Incorrect length of the decrypted ciphertext of the private key. */ CRYPT_RSA_ERR_PSS_SALT_LEN, /**< Incorrect salt length of the PSS operation. */ CRYPT_RSA_ERR_PSS_SALT_DATA, /**< PSS operation salt data error, failed to compare the salt extracted during signature verification with the user's input. */ CRYPT_RSA_ERR_PKCSV15_SALT_LEN, /**< Incorrect salt length of the PKCSV15 operation. */ CRYPT_RSA_ERR_PKCSV15_SALT_DATA, /**< PKCSV15 salt data error. */ CRYPT_RSA_ERR_INPUT_VALUE, /**< Some special values, which are used as input errors. */ CRYPT_RSA_ERR_MD_ALGID, /**< The hash ID of the input parameter is incorrect when the pkcs1.5 padding mode is set. */ CRYPT_RSA_PAD_NO_SET_ERROR, /**< Padding information is not set when using RSA key for signature verification. */ CRYPT_RSA_CTRL_NOT_SUPPORT_ERROR, /**< The Ctrl type is not supported When RSA is used for Ctrl. */ CRYPT_RSA_SET_SALT_NOT_PSS_ERROR, /**< When the padding type of the key is not pss, and set the salt information, return failure. */ CRYPT_RSA_SET_EMS_PKCSV15_LEN_ERROR,/**< Sets the PKCSV15 padding information, the length of the input data is incorrect and return failure. */ CRYPT_RSA_SET_EMS_PSS_LEN_ERROR, /**< Sets the PSS padding information, the length of the input data is incorrect, and return failure. */ CRYPT_RSA_SET_RSAES_OAEP_LEN_ERROR, /**< Sets the OAEP padding information, the length of the input data is incorrect and return failure. */ CRYPT_RSA_SET_FLAG_LEN_ERROR, /**< The length of the input data is incorrect and return failure When sets the flag. */ CRYPT_RSA_FLAG_NOT_SUPPORT_ERROR, /**< Unsupported flag. */ CRYPT_RSA_ERR_SALT_LEN, /**< Salt length error. */ CRYPT_RSA_ERR_ALGID, /**< The hash ID of the input parameter is incorrect or conflict occurs when sets the signature, signature verification, and padding parameters. */ CRYPT_RSA_ERR_GEN_SALT, /**< An error is returned when salt information fails to be generated during PSS signature. */ CRYPT_RSA_ERR_ENC_INPUT_NOT_ENOUGH, /**< The plaintext length is too short for RSA NO PAD encryption. */ CRYPT_RSA_ERR_DATA_LEN, /**< Incorrect encryption length. */ CRYPT_RSA_ERR_PAD_NUM, /**< Incorrect padding length. */ CRYPT_RSA_PUBKEY_NOT_EQUAL, /**< RSA public keys are not equal. */ CRYPT_RSA_KEYPAIRWISE_CONSISTENCY_FAILURE, /**< RSA pair-wise consistency failure. */ CRYPT_RSA_ERR_BLIND_TYPE, /**< Invalid RSA blinding type. Only RSA-BSSA is currently supported. */ CRYPT_RSA_ERR_NO_BLIND_INFO, /**< RSA blinding information is missing. The blind/unblind operation requires previous blinding parameters. */ CRYPT_RSA_ERR_NO_PUBKEY_INFO, /**< The rsa pub key is missing. */ CRYPT_RSA_PADDING_NOT_SUPPORTED, /**< The specified RSA padding mode is not supported in blinding. */ CRYPT_RSA_ERR_BSSA_PARAM, /**< The param of bssa is not invalid. */ CRYPT_RSA_GET_SALT_LEN_ERROR, /**< The input length of getting salt-len is incorrect. */ CRYPT_RSA_GET_SALT_NOT_PSS_ERROR, /**< When the padding type of the key is not pss, and get the salt len. */ CRYPT_RSA_ERR_PSS_PARAMS, /**< The parameter is error when the padding type of the key is pss. */ CRYPT_RSA_ERR_NO_PRVKEY_INFO, /**< The rsa prv key is missing. */ CRYPT_RSA_ERR_INVALID_PRVKEY, /**< The private key is invalid. */ CRYPT_EAL_BUFF_LEN_NOT_ENOUGH = 0x01040001, /**< Insufficient buffer length. */ CRYPT_EAL_BUFF_LEN_TOO_LONG, /**< Insufficient buffer length. */ CRYPT_EAL_ERR_ALGID, /**< Incorrect algorithm ID. */ CRYPT_EAL_ALG_NOT_SUPPORT, /**< Algorithm not supported, algorithm behavior not supported. */ CRYPT_EAL_ERR_NEW_PARA_FAIL, /**< Failed to generate parameters. */ CRYPT_EAL_ERR_RAND_WORKING, /**< DRBG is in the working state. */ CRYPT_EAL_ERR_RAND_NO_WORKING, /**< DRBG is not working. */ CRYPT_EAL_ERR_METH_NULL_MEMBER, /**< The method variable member is NULL. */ CRYPT_EAL_ERR_GLOBAL_DRBG_NULL, /**< The global DRBG is null. */ CRYPT_EAL_ERR_DRBG_REPEAT_INIT, /**< DRBG is initialized repeatedly. */ CRYPT_EAL_ERR_DRBG_INIT_FAIL, /**< DRBG initialization failure. */ CRYPT_EAL_ERR_STATE, /**< The usage process is incorrect. For example, run the update command without running the init command. For details, see related algorithms. */ CRYPT_EAL_CIPHER_DATA_ERROR, /**< Data error occurs when unpadding the decrypted data. For X923, the last bit is the length of the original data, and the rest data is 0, if this requirement is not met, an error is reported. For pkcs, all padding data is (the length of the padding data - the length of the original data), if this requirement is not met,an error will be reported. For ISO7816, the first bit of padding data is 0x80, and the other bits are 0, if this requirement is not met, an error will be reported. */ CRYPT_EAL_PADDING_NOT_SUPPORT, /**< Unsupported padding. */ CRYPT_EAL_CIPHER_CTRL_ERROR, /**< CRYPT_EAL_CipherCtrl interface unsupported CTRL type. */ CRYPT_EAL_CIPHER_FINAL_WITH_AEAD_ERROR, /**< An error occurs when the final operation is performed on the AEAD algorithm. */ CRYPT_EAL_PKEY_CTRL_ERROR, /**< When the CRYPT_EAL_PkeyCtrl interface performs CTRL, the function is not supported or the input length is incorrect. */ CRYPT_EAL_MAC_CTRL_TYPE_ERROR, /**< When the CRYPT_EAL_PkeyCtrl interface performs CTRL, the function is not supported or the input length is incorrect. */ CRYPT_EAL_PKEY_DUP_ERROR, /**< Pkey context duplicate failure. */ CRYPT_EAL_PKEY_CMP_DIFF_KEY_TYPE, /**< Pkey comparison failure: different algorithm types. */ CRYPT_EAL_ERR_PART_OVERLAP, /**< Some memory overlap. */ CRYPT_EAL_INTO_TYPE_NOT_SUPPORT, /**< The info type is not supported. */ CRYPT_EAL_ALG_ASM_NOT_SUPPORT, /**< Algorithm assembly is not supported. */ CRYPT_EAL_CIPHER_ERR_NEWCTX, CRYPT_EAL_PKEY_CHECK_ERROR, /**< Pkey check failure. */ CRYPT_EAL_MD_METH_NULL, CRYPT_SHA2_INPUT_OVERFLOW = 0x01050001, /**< The length of the input data exceeds the maximum processing range of SHA2. */ CRYPT_SHA2_OUT_BUFF_LEN_NOT_ENOUGH, /**< The length of the buffer that storing the output result is insufficient. */ CRYPT_DRBG_ERR_STATE = 0x01060001, /**< DRBG status error. */ CRYPT_DRBG_FAIL_GET_ENTROPY, /**< Failed to obtain the entropy. */ CRYPT_DRBG_FAIL_GET_NONCE, /**< Failed to obtain the nonce. */ CRYPT_DRBG_ALG_NOT_SUPPORT, /**< Does not support the given algorithm. */ CRYPT_DRBG_INVALID_LEN, /**< Incorrect data length. */ CRYPT_DRBG_PARAM_ERROR, /**< Incorrect input parameter. */ CRYPT_CURVE25519_NO_PUBKEY = 0x01080001, /**< No public key. */ CRYPT_CURVE25519_NO_PRVKEY, /**< No private key. */ CRYPT_CURVE25519_KEYLEN_ERROR, /**< Incorrect key length. */ CRYPT_CURVE25519_SIGNLEN_ERROR, /**< Incorrect signature length. */ CRYPT_CURVE25519_HASH_METH_ERROR, /**< Hash method is not SHA512. */ CRYPT_CURVE25519_VERIFY_FAIL, /**< Signature verification fails due to incorrect signature. */ CRYPT_CURVE25519_NO_HASH_METHOD, /**< Hash method not set. */ CRYPT_CURVE25519_UNSUPPORTED_CTRL_OPTION, /**< Unsupported mode of operation. */ CRYPT_CURVE25519_KEY_COMPUTE_FAILED, /**< Failed to generate the shared key. */ CRYPT_CURVE25519_INVALID_PUBKEY, /**< Invalid public key. */ CRYPT_CURVE25519_PUBKEY_NOT_EQUAL, /**< Public keys are not equal. */ CRYPT_CURVE25519_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_CURVE25519_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_SHA1_INPUT_OVERFLOW = 0x01090001, /**< The length of the input data exceeds the maximum processing range of SHA1. */ CRYPT_SHA1_OUT_BUFF_LEN_NOT_ENOUGH, /**< The length of the buffer that storing the output result is insufficient. */ CRYPT_ENTROPY_RCT_FAILURE = 0x010A0001, /**< RCT detection fails, restart the entropy source. */ CRYPT_ENTROPY_APT_FAILURE, /**< APT detection fails, restart the entropy source. */ CRYPT_ENTROPY_CONDITION_FAILURE, /**< Processing method error after invoking. */ CRYPT_ENTROPY_RANGE_ERROR, /**< Entropy source generation range error */ CRYPT_ENTROPY_ECF_ALG_ERROR, /**< Entropy source conditioning algorithm is incorrect. */ CRYPT_ENTROPY_ECF_IS_ERROR, /**< Entropy source conditioning is incorrect. */ CRYPT_ENTROPY_ES_CREATE_ERROR, /**< Entropy pool creation error. */ CRYPT_ENTROPY_ES_STATE_ERROR, /**< Incorrect entropy pool status. */ CRYPT_ENTROPY_ES_CTRL_ERROR, /**< Incorrect entropy pool settings. */ CRYPT_ENTROPY_ES_NO_NS, /**< No available noise source in the entropy pool. */ CRYPT_ENTROPY_ES_NS_NOT_FOUND, /**< Noise source not found. */ CRYPT_ENTROPY_ES_DUP_NS, /**< Noise source Repetition. */ CRYPT_ENTROPY_ES_NS_NOT_AVA, /**< Noise source not available. */ CRYPT_ENTROPY_ES_NS_FULL, /**< Noise source list is full. */ CRYPT_ENTROPY_ES_CF_NOT_SUPPORT, /**< Nonditioning function not supported. */ CRYPT_ENTROPY_ES_CF_ERROR, /**< Nonditioning function error. */ CRYPT_ENTROPY_ES_ENTROPY_NOT_ENOUGH, /**< Not getting enough entropy. */ CRYPT_ENTROPY_ES_POOL_ERROR, /**< Entropy pool error. */ CRYPT_ENTROPY_ES_POOL_INSUFFICIENT, /**< Entropy pool capacity is insufficient. */ CRYPT_ENTROPY_CTRL_INVALID_PARAM, /**< Entropy invalid parameter. */ CRYPT_DSA_BUFF_LEN_NOT_ENOUGH = 0x010B0001, /**< Insufficient buffer length. */ CRYPT_DSA_ERR_KEY_PARA, /**< Incorrect key parameter data. */ CRYPT_DSA_ERR_KEY_INFO, /**< Incorrect key information. */ CRYPT_DSA_VERIFY_FAIL, /**< Verification failure. */ CRYPT_DSA_ERR_TRY_CNT, /**< Key generation and signature fail to be generated within the specified number of attempts. */ CRYPT_DSA_DECODE_FAIL, /**< Data decoding fails, the data does not meet the decoding requirements. */ CRYPT_DSA_UNSUPPORTED_CTRL_OPTION, /**< Unsupported mode of operation. */ CRYPT_DSA_PARA_ERROR, /**< The value of the key parameter does not meet the requirements. The ctx command does not contain necessary parameter information. */ CRYPT_DSA_PUBKEY_NOT_EQUAL, /**< Public keys are not equal. */ CRYPT_DSA_PARA_NOT_EQUAL, /**< Key parameters are not equal. */ CRYPT_DSA_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_DSA_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_HMAC_OUT_BUFF_LEN_NOT_ENOUGH = 0x010C0001, /**< The length of the buffer that storing the output result is insufficient. */ CRYPT_HMAC_ERR_UNSUPPORTED_CTRL_OPTION, /**< Unsupport the control type. */ CRYPT_HMAC_ERR_NO_MD_LIB_CTX, /**< MD library context not set. */ CRYPT_HMAC_PARAM_ERROR, /**< Incorrect input parameter. */ CRYPT_DH_BUFF_LEN_NOT_ENOUGH = 0x010D0001, /**< The buffer length is insufficient. */ CRYPT_DH_PARA_ERROR, /**< The value of the key parameter does not meet the requirements, the ctx command does not contain necessary parameter information. */ CRYPT_DH_KEYINFO_ERROR, /**< The value of the public and private keys do not meet the requirements, the ctx does not contain the necessary public and private keys. */ CRYPT_DH_RAND_GENERATE_ERROR, /**< Key generation fails within the specified number of attempts. */ CRYPT_DH_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_DH_UNSUPPORTED_CTRL_OPTION, /**< Unsupported mode of operation. */ CRYPT_DH_CREATE_PARA_FAIL, /**< Failed to create the p, q, and g parameters of the DH algorithm. */ CRYPT_DH_PUBKEY_NOT_EQUAL, /**< Public keys are not equal. */ CRYPT_DH_PARA_NOT_EQUAL, /**< DH key parameters are not equal. */ CRYPT_DH_SET_FLAG_LEN_ERROR, /**< The length of the input data is incorrect and return failure when setting the flag. */ CRYPT_DH_FLAG_NOT_SUPPORT_ERROR, /**< Unsupported flag. */ CRYPT_DH_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_CHACHA20_KEYLEN_ERROR = 0x010E0001, /**< The key length input is incorrect during key setting. */ CRYPT_CHACHA20_NONCELEN_ERROR, /**< The length of the input nounce is incorrect when you set the nounce. */ CRYPT_CHACHA20_COUNTLEN_ERROR, /**< The length of the input count is incorrect when you set the count. */ CRYPT_CHACHA20_NO_KEYINFO, /**< Lack of valid key information during encryption and decryption. */ CRYPT_CHACHA20_NO_NONCEINFO, /**< Lack of valid nounce information during encryption and decryption. */ CRYPT_CHACHA20_CTRLTYPE_ERROR, /**< The input type is not supported when the ctrl interface is used. */ CRYPT_AES_ERR_KEYLEN = 0x010F0001, /**< Incorrect key length. */ CRYPT_MODES_TAGLEN_ERROR = 0x01100001, /**< In AEAD mode, the length of the TAG is incorrect when the tag is obtained and verified. */ CRYPT_MODES_IVLEN_ERROR, /**< The length of the input IV is incorrect when setting the IV. */ CRYPT_MODES_KEYUSE_TOOMANY_TIME, /**< In GCM mode, the number of times that a key can be used for encryption and decryption is limited. When the number of times that a key is used exceeds the limit, an error is reported. */ CRYPT_MODES_CRYPTLEN_OVERFLOW, /**< In AEAD mode, the length of the plaintext or ciphertext input for a single encryption exceeds the limit. */ CRYPT_MODES_CTRL_TAGLEN_ERROR, /**< In GCM or CCM mode, the length of the input parameter or the length of the input parameter data is incorrect when the ctrl interface is used to set the tag length. */ CRYPT_MODES_AAD_REPEAT_SET_ERROR, /**< In the AEAD mode, the AAD information is set repeatedly. */ CRYPT_MODE_BUFF_LEN_NOT_ENOUGH, /**< The buffer length is insufficient. */ CRYPT_MODE_ERR_INPUT_LEN, /**< The function input length is not the expected length. */ CRYPT_MODES_CTRL_TYPE_ERROR, /**< The input type is not supported when the ctrl interface is used. */ CRYPT_MODES_AAD_IS_SET_ERROR, /**< In ccm mode, an error is returned when the tagLen and msgLen are set after the aad is set. */ CRYPT_MODES_MSGLEN_OVERFLOW, /**< In ccm mode, the length of the input message during encryption and decryption exceeds the set msgLen. */ CRYPT_MODES_CTRL_MSGLEN_ERROR, /**< In ccm mode, When the ctrl interface is used to set the msg length, the input parameter length or the input parameter data length is incorrect. (This specification is affected by ivLen.) */ CRYPT_MODES_MSGLEN_LEFT_ERROR, /**< In ccm mode, when the ctrl interface is used to obtain the tag, the length of the encrypted and decrypted messages does not reach the configured number. As a result, an error occurs. */ CRYPT_MODES_ERR_KEYLEN, /**< Incorrect key length set. */ CRYPT_MODES_ERR_KEY, /**< Incorrect key set. */ CRYPT_MODES_ERR_FEEDBACKSIZE, /**< The operation are not support by the algorithm on which the pattern depends on. */ CRYPT_MODES_METHODS_NOT_SUPPORT, /**< Mode depends does not support the behavior. */ CRYPT_MODES_FEEDBACKSIZE_NOT_SUPPORT, /**< The algorithm does not support the setting of feedbacksize. */ CRYPT_MODES_PADDING_NOT_SUPPORT, /**< Unsupported padding. */ CRYPT_HKDF_DKLEN_OVERFLOW = 0x01110001, /**< The length of the derived key exceeds the maximum. */ CRYPT_HKDF_NOT_SUPPORTED, /**< Unsupport HKDF algorithm. */ CRYPT_HKDF_PARAM_ERROR, /**< Incorrect input parameter. */ CRYPT_HKDF_ERR_MAC_ID_NOT_SET, /**< Mac id not set. */ CRYPT_HKDF_ERR_MAC_METH, /**< Mac method err. */ CRYPT_CMAC_OUT_BUFF_LEN_NOT_ENOUGH = 0x01120001, /**< The length of the buffer that storing the output result is insufficient. */ CRYPT_CMAC_INPUT_OVERFLOW, /**< The input length exceeds the limit. As a result, the integer type is reversed. */ CRYPT_CMAC_ERR_UNSUPPORTED_CTRL_OPTION, /**< Unsupport the control type. */ CRYPT_GMAC_ERR_UNSUPPORTED_CTRL_OPTION, /**< Unsupport the control type. */ CRYPT_SCRYPT_PARAM_ERROR = 0x01130001, /**< Incorrect input parameter. */ CRYPT_SCRYPT_NOT_SUPPORTED, /**< Unsupport the SCRYPT algorithm. */ CRYPT_SCRYPT_DATA_TOO_MAX, /**< The data calculated by the SCRYPT algorithm is too large. */ CRYPT_PBKDF2_PARAM_ERROR = 0x01150001, /**< Incorrect input parameter. */ CRYPT_PBKDF2_NOT_SUPPORTED, /**< Does not support the PBKDF2 algorithm. */ CRYPT_PBKDF2_ERR_MAC_METH, /**< Mac method err. */ CRYPT_PBKDF2_ERR_MAC_ID_NOT_SET, /**< Mac id not set. */ CRYPT_ECC_POINT_AT_INFINITY = 0x01160001, /**< Point at infinity. */ CRYPT_ECC_POINT_NOT_ON_CURVE, /**< Point is not on the curve. */ CRYPT_ECC_POINT_ERR_CURVE_ID, /**< Curve ID is inconsistent or incorrect. */ CRYPT_ECC_POINT_WINDOW_TOO_MAX, /**< Window is too max. */ CRYPT_ECC_POINT_NOT_EQUAL, /**< The two points are not equal. */ CRYPT_ECC_POINT_BLIND_WITH_ZERO, /**< The random number generated during point salting is 0. */ CRYPT_ECC_POINT_NOT_AFFINE, /**< Point is not affine coordinates. */ CRYPT_ECC_NOT_SUPPORT, /**< This function is not supported. */ CRYPT_ECC_POINT_MUL_ERR_K_LEN, /** The scalar length exceeds the curve specification when using the dot multiplication function */ CRYPT_ECC_BUFF_LEN_NOT_ENOUGH, /**< Insufficient buffer length. */ CRYPT_ECC_ERR_POINT_FORMAT, /**< The encoding format input during point encoding is incorrect. */ CRYPT_ECC_ERR_POINT_CODE, /**< Incorrect point code information. */ CRYPT_ECC_PKEY_ERR_UNSUPPORTED_CTRL_OPTION, /**< Unsupport the control type. */ CRYPT_ECC_PKEY_ERR_EMPTY_KEY, /**< Key is null. */ CRYPT_ECC_PKEY_ERR_INVALID_POINT_FORMAT, /**< Invalid dot format. */ CRYPT_ECC_PKEY_ERR_CTRL_LEN, /**< Control input parameter is incorrect. */ CRYPT_ECC_PKEY_ERR_INVALID_PRIVATE_KEY, /**< Invalid private key. */ CRYPT_ECC_PKEY_ERR_INVALID_PUBLIC_KEY, /**< Invalid public key. */ CRYPT_ECC_PKEY_ERR_TRY_CNT, /**< Key generation or generater signature fail within the specified number of attempts. */ CRYPT_ECC_PKEY_ERR_SIGN_LEN, /**< Invalid sign length */ CRYPT_ECC_ERR_PARA, /**< Incorrect curve parameter. */ CRYPT_ECC_INVERSE_INPUT_ZERO, /** Modulo inverse input is 0. */ CRYPT_ECC_KEY_PUBKEY_NOT_EQUAL, /**< ECC public keys are not equal. */ CRYPT_ECC_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_ECC_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_SHA3_OUT_BUFF_LEN_NOT_ENOUGH = 0x01170001, /**< Insufficient buffer length for storing output results. */ CRYPT_SHA3_INVALID_STATE, /**< Invalid state. */ CRYPT_ECDH_ERR_UNSUPPORT_CURVE_TYPE = 0x01180001, /**< Unsupported curve type. */ CRYPT_ECDH_ERR_EMPTY_KEY, /**< Key is null. */ CRYPT_ECDH_ERR_INVALID_COFACTOR, /**< Invalid cofactor value. */ CRYPT_ECDH_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_ECDH_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_ECDSA_ERR_EMPTY_KEY = 0x01190001, /**< Key is NULL. */ CRYPT_ECDSA_ERR_TRY_CNT, /**< Key generation and generate signature fail within the specified number of attempts. */ CRYPT_ECDSA_VERIFY_FAIL, /**< Verification failure. */ CRYPT_ECDSA_ERR_UNSUPPORTED_CTRL_OPTION, /**< Unsupport the control type. */ CRYPT_ECDSA_BUFF_LEN_NOT_ENOUGH, /**< BUFF insufficient length. */ CRYPT_ECDSA_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_ECDSA_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_SM3_INPUT_OVERFLOW = 0x011A0001, /**< The length of the input data exceeds the maximum processing range of the SM3. */ CRYPT_SM3_OUT_BUFF_LEN_NOT_ENOUGH, /**< The length of the buffer that storing the output result is insufficient. */ CRYPT_SM4_ERR_IV_LEN = 0x011B0001, /**< Wrong key length set. */ CRYPT_SM4_ERR_MSG_LEN, /**< Wrong data length is set. */ CRYPT_SM4_ERR_KEY_LEN, /**< Wrong key length is set. */ CRYPT_SM4_UNSAFE_KEY, /**< DataKey is the same as tweakKey. */ CRYPT_MD5_INPUT_OVERFLOW = 0x011D0001, /**< The length of the input data exceeds the maximum processing range of the MD5. */ CRYPT_MD5_OUT_BUFF_LEN_NOT_ENOUGH, /**< The length of the buffer that storing the output result is insufficient. */ CRYPT_MD_ERR_NEWCTX, /**< create md ctx failed. */ CRYPT_SM2_BUFF_LEN_NOT_ENOUGH = 0x01200001, /**< Insufficient buffer length. */ CRYPT_SM2_NO_PUBKEY, /**< SM2 the public key is not set. */ CRYPT_SM2_NO_PRVKEY, /**< SM2 The private key is not set. */ CRYPT_SM2_ERR_EMPTY_KEY, /**< SM2 key is null. */ CRYPT_SM2_ERR_TRY_CNT, /**< Key generation and generate signature fail within the specified number of attempts. */ CRYPT_SM2_VERIFY_FAIL, /**< verification failure. */ CRYPT_SM2_ERR_UNSUPPORTED_CTRL_OPTION, /**< Unsupported control type. */ CRYPT_SM2_ERR_NO_HASH_METHOD, /**< No hash method information. */ CRYPT_SM2_USERID_NOT_SET, /**< Unset userID. */ CRYPT_SM2_R_NOT_SET, /**< The peer R value is not set. */ CRYPT_SM2_INVALID_SERVER_TYPE, /**< The user is neither the initiator nor the recipient. */ CRYPT_SM2_ERR_CTRL_LEN, /**< Incorrect ctrl length. */ CRYPT_SM2_DECRYPT_FAIL, /**< Decryption failure. */ CRYPT_SM2_ERR_DATA_LEN, /**< Incorrect data length. */ CRYPT_SM2_ERR_GET_S, /**< Failed to obtain the checksum. */ CRYPT_SM2_ERR_S_NOT_SET, /**< Unset checksum. */ CRYPT_SM2_EXCH_VERIFY_FAIL, /**< Key Negotiation Failure. */ CRYPT_SM2_DECODE_FAIL, /**< Data decoding fails, the data does not meet the decoding requirements. */ CRYPT_SM2_ID_TOO_LARGE, /**< User id to large. */ CRYPT_SM2_K_REPEAT_SET_ERROR, /**< the random k is set repeatedly*/ CRYPT_SM2_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_SM2_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_KDFTLS12_NOT_SUPPORTED = 0x01210001, /**< Unsupport the KDFTLS12 algorithm. */ CRYPT_KDFTLS12_PARAM_ERROR, /**< Incorrect input parameter. */ CRYPT_KDFTLS12_ERR_MAC_METH, /**< Mac method err. */ CRYPT_KDFTLS12_ERR_MAC_ID_NOT_SET, /**< Mac id not set. */ CRYPT_SIPHASH_OUT_BUFF_LEN_NOT_ENOUGH = 0x01220001, /**< The buffer size for storing the output result is insufficient. */ CRYPT_SIPHASH_INPUT_OVERFLOW, CRYPT_SIPHASH_ERR_UNSUPPORTED_CTRL_OPTION, /**< Unsupport the control type. */ CRYPT_CBC_MAC_ERR_CTRL_LEN = 0x01240001, CRYPT_CBC_MAC_ERR_UNSUPPORTED_CTRL_OPTION, CRYPT_CBC_MAC_PADDING_NOT_SET, CRYPT_CBC_MAC_PADDING_NOT_SUPPORT, CRYPT_CBC_MAC_OUT_BUFF_LEN_NOT_ENOUGH, CRYPT_SEED_POOL_NEW_ERROR = 0x01290001, /**< The length of the key input is incorrect when setting the key. */ CRYPT_SEED_POOL_STATE_ERROR, /**< Incorrect seed pool status. */ CRYPT_SEED_POOL_ES_LIST_FULL, /**< The number of entropy sources exceeds the upper limit. */ CRYPT_SEED_POOL_NO_SUFFICIENT_ENTROPY, /**< The seed pool cannot provide sufficient entropy. */ CRYPT_SEED_POOL_NO_ENTROPY_SOURCE, /**< The seed pool has no entropy source. */ CRYPT_SEED_POOL_NO_ENTROPY_OBTAINED, /**< No entropy data is obtained from the seed pool. */ CRYPT_SEED_POOL_NOT_MEET_REQUIREMENT, /**< The entropy data does not meet the requirements. */ CRYPT_ENTROPY_CTX_CREATE_FAILED, /**< Failed to create the handle for obtaining the entropy. */ CRYPT_MLKEM_KEYLEN_ERROR = 0x01300001, /**< Incorrect input data length. */ CRYPT_MLKEM_LEN_NOT_ENOUGH, /**<The buffer size of output is insufficient. */ CRYPT_MLKEM_KEY_NOT_SET, /**<The encaps or decaps key not set. */ CRYPT_MLKEM_KEYINFO_NOT_SET, /**<The algorithm not set. */ CRYPT_MLKEM_KEY_NOT_EQUAL, /**< The MLKEM keys are not equal. */ CRYPT_MLKEM_CTRL_NOT_SUPPORT, /**< The Ctrl type is not supported.*/ CRYPT_MLKEM_CTRL_INIT_REPEATED, /**< The CTX cannot be initialized repeatedly.*/ CRYPT_MLKEM_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_MLKEM_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_HPKE_ERR_GEN_ASYM_KEY = 0x01310001, /**< HPKE Generate asymmetric key error. */ CRYPT_HPKE_ERR_AEAD_TAG, /**< Failed to verify AEAD tag when decrypt. */ CRYPT_HPKE_ERR_CALL, /**< It is not appropriate to call this function. */ CRYPT_HPKE_FAILED_FETCH_CIPHER, /**< Failed to fetch cipher. */ CRYPT_HPKE_FAILED_FETCH_PKEY, /**< Failed to fetch pkey. */ CRYPT_HPKE_FAILED_FETCH_KDF, /**< Failed to fetch kdf. */ CRYPT_DECODE_ASN1_BUFF_NUM_NOT_ENOUGH = 0x01320001, /**< The input number of BSL_ANS1_Buffer is not enough. */ CRYPT_DECODE_UNSUPPORTED_PUBKEY_TYPE, /**< Unsupported pubkey type */ CRYPT_DECODE_UNSUPPORTED_PKCS8_TYPE, /**< Unsupported pkcs8 type */ CRYPT_DECODE_PKCS8_INVALID_ALGO_PARAM, /**< pkcs8 has no valid algorithm parameters */ CRYPT_DECODE_UNKNOWN_OID, /**< Unknown OID */ CRYPT_DECODE_ASN1_BUFF_FAILED, /**< decode asn1 buffer failed. */ CRYPT_DECODE_NO_SUPPORT_TYPE, /**< decode no support key type. */ CRYPT_DECODE_NO_SUPPORT_FORMAT, /**< decode no support key format. */ CRYPT_DECODE_PKCS8_INVALID_ITER, /**< pkcs8 invalid iter num */ CRYPT_DECODE_PKCS8_INVALID_KEYLEN, /**< pkcs8 invalid keylen */ CRYPT_DECODE_ERR_RSSPSS_GET_ANY_TAG, /**< decode rsapss param failed. */ CRYPT_DECODE_ERR_RSSPSS, /**< decode rsapss param failed. */ CRYPT_DECODE_ERR_RSSPSS_MD, /**< rsapss md is invalid. */ CRYPT_DECODE_ERR_RSSPSS_MGF1MD, /**< rsapss mgf1md is invalid. */ CRYPT_DECODE_ERR_RSSPSS_TRAILER, /**< rsapss trailer field is invalid. */ CRYPT_DECODE_PKCS7_INVALIDE_ENCRYPTDATA_TYPE, /**< Invaild pkcs7-encryptedData. */ CRYPT_DECODE_UNSUPPORTED_PKCS7_TYPE, /**< Unsupported pkcs7 type */ CRYPT_DECODE_UNSUPPORTED_ENCRYPT_TYPE, /**< Unsupported encrypt type */ CRYPT_DECODE_BUFF_NOT_ENOUGH, /**< The input buffer space is not enough */ CRYPT_DECODE_ASN1_BUFF_LEN_ZERO, /**< The decoding length of asn1 buffer is zero. */ CRYPT_DECODE_ERR_NO_DECODER, /**< No decoder found. */ CRYPT_DECODE_ERR_NO_USABLE_DECODER, /**< No decoder found. */ CRYPT_DECODE_RETRY, /**< Retry decode. */ CRYPT_DECODE_ERR_CURR_NODE_NOT_FOUND, /**< Current node not found. */ CRYPT_DECODE_ERR_NO_KEY_TYPE, /**< No key type found. */ CRYPT_DECODE_ERR_KEY_TYPE_NOT_MATCH, /**< Key type not match. */ CRYPT_ENCODE_NO_SUPPORT_TYPE = 0x01330001, /**< encode no support key type. */ CRYPT_ENCODE_NO_SUPPORT_FORMAT, /**< encode no support key format. */ CRYPT_ENCODE_ERR_RSA_PAD, /**< rsa pad err. */ CRYPT_ENCODE_BUFF_NOT_ENOUGH, /**< The input buffer space is not enough */ CRYPT_ENCODE_ERR_SIGN_LEN_OVERFLOW, /**< The r and s length is too large. */ CRYPT_ENCODE_ERR_SM2_ENCRYPT_DATA_LEN_OVERFLOW, /**< The sm2 encrypt data length is too large. */ CRYPT_DECODE_PRINT_UNSUPPORT_ALG = 0x01340001, /**< Failed to print unsupported alg. */ CRYPT_DECODE_PRINT_NO_KEY, /**< Failed to print key. */ CRYPT_DECODE_PRINT_KEYBITS, /**< Failed to print key bist. */ CRYPT_DECODE_PRINT_MODULUS, /**< Failed to print modulus. */ CRYPT_DECODE_PRINT_EXPONENT, /**< Failed to print exponent. */ CRYPT_DECODE_PRINT_RSAPSS_PARA, /**< Failed to print rsapss para. */ CRYPT_DECODE_PRINT_ECC_PUB, /**< Failed to print ecc pubkey. */ CRYPT_DECODE_PRINT_ECC_OID, /**< Failed to print ecc oid. */ CRYPT_PROVIDER_ERR_UNEXPECTED_IMPL = 0x01350001, /**< Unexpected impl */ CRYPT_PROVIDER_ERR_IMPL_NULL, CRYPT_PROVIDER_NOT_FOUND, /**< Provider not found. */ CRYPT_PROVIDER_NOT_SUPPORT, CRYPT_PROVIDER_ERR_ATTRIBUTE, CRYPT_PROVIDER_INVALID_LIB_CTX, CRYPT_MLDSA_KEYINFO_NOT_SET = 0x01360001, /**< The algorithm not set. */ CRYPT_MLDSA_CTRL_NOT_SUPPORT, /**< The Ctrl type is not supported. */ CRYPT_MLDSA_PAD_TOO_LONG, /**< The pad is too long. */ CRYPT_MLDSA_KEYLEN_ERROR, /**< Incorrect input data length. */ CRYPT_MLDSA_SIGN_DATA_ERROR, /**< Invalid signature value. */ CRYPT_MLDSA_VERIFY_FAIL, /**< Failed to verify the signature. */ CRYPT_MLDSA_KEY_NOT_SET, /**< The public key or private not set. */ CRYPT_MLDSA_LEN_NOT_ENOUGH, /**< The buffer size of output is insufficient. */ CRYPT_MLDSA_KEY_NOT_EQUAL, /**< The MLDSA keys are not equal. */ CRYPT_MLDSA_CTRL_INIT_REPEATED, /**< The CTX cannot be initialized repeatedly.*/ CRYPT_MLDSA_SET_KEY_FAILED, /**< Failed to set the key. */ CRYPT_MLDSA_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_MLDSA_INVALID_PRVKEY, /**< Invalid private key. */ CRYPT_MLDSA_INVALID_PUBKEY, /**< Invalid public key. */ CRYPT_ELGAMAL_BUFF_LEN_NOT_ENOUGH = 0x01370001, /**< The buffer length is insufficient. */ CRYPT_ELGAMAL_NO_KEY_INFO, /**< Lacks valid key information. */ CRYPT_ELGAMAL_ERR_KEY_BITS, /**< Incorrect key length. */ CRYPT_ELGAMAL_ERR_ENC_BITS, /**< Incorrect length of the encrypted plaintext of the public key. */ CRYPT_ELGAMAL_ERR_DEC_BITS, /**< Incorrect length of the decrypted ciphertext of the private key. */ CRYPT_ELGAMAL_ERR_KEY_KBITS, /**< Incorrect key length. */ CRYPT_ELGAMAL_ERR_KEY_BITS_KBITS, /**< Incorrect key length. */ CRYPT_ELGAMAL_ERR_ENC_KBITS, /**< Incorrect length of the encrypted plaintext of the public key. */ CRYPT_ELGAMAL_ERR_DEC_KBITS, /**< Incorrect length of the decrypted ciphertext of the private key. */ CRYPT_ELGAMAL_ERR_INPUT_VALUE, /**< Some special values, which are used as input errors. */ CRYPT_ELGAMAL_CTRL_NOT_SUPPORT_ERROR, /**< The Ctrl type is not supported When elgamal is used for Ctrl. */ CRYPT_SLHDSA_ERR_INVALID_ALGID = 0x01380001, /**< The algorithm id is invalid. */ CRYPT_SLHDSA_ERR_INVALID_SIG_LEN, /**< The signature length is invalid. */ CRYPT_SLHDSA_ERR_INVALID_KEYLEN, /**< The key length is invalid. */ CRYPT_SLHDSA_ERR_SIG_LEN_NOT_ENOUGH, /**< The signature length is not enough. */ CRYPT_SLHDSA_ERR_HYPERTREE_VERIFY_FAIL, /**< Hypertree verify failed. */ CRYPT_SLHDSA_ERR_PREHASH_ID_NOT_SUPPORTED, /**< Prehash id is not supported. */ CRYPT_SLHDSA_ERR_CONTEXT_LEN_OVERFLOW, /**< Context length is overflow. */ CRYPT_SLHDSA_PAIRWISE_CHECK_FAIL, /**< The public and private keys are inconsistent. */ CRYPT_SLHDSA_ERR_NO_PUBKEY, /**< No public key. */ CRYPT_SLHDSA_ERR_NO_PRVKEY, /**< No private key. */ CRYPT_PAILLIER_BUFF_LEN_NOT_ENOUGH = 0x01390001, /**< The buffer length is insufficient. */ CRYPT_PAILLIER_NO_KEY_INFO, /**< Lacks valid key information. */ CRYPT_PAILLIER_ERR_KEY_BITS, /**< Incorrect key length. */ CRYPT_PAILLIER_ERR_ENC_BITS, /**< Incorrect length of the encrypted plaintext of the public key. */ CRYPT_PAILLIER_ERR_DEC_BITS, /**< Incorrect length of the decrypted ciphertext of the private key. */ CRYPT_PAILLIER_ERR_INPUT_VALUE, /**< Some special values, which are used as input errors. */ CRYPT_PAILLIER_CTRL_NOT_SUPPORT_ERROR, /**< The Ctrl type is not supported When paillier is used for Ctrl. */ CRYPT_XMSS_ERR_INVALID_ALGID = 0x013A0001, /**< The algorithm id is invalid. */ CRYPT_XMSS_ERR_INVALID_SIG_LEN, /**< The signature length is invalid. */ CRYPT_XMSS_ERR_INVALID_KEYLEN, /**< The key length is invalid. */ CRYPT_XMSS_ERR_KEY_EXPIRED, /**< The key has expired. */ CRYPT_CMVP_COMMON_ERR = 0x013B0001, /**< Common error in CMVP selftest. */ CRYPT_CMVP_ERR_INTEGRITY, /**< Integrity error in CMVP selftest. */ CRYPT_CMVP_RANDOMNESS_ERR, /**< Randomness error in CMVP selftest. */ CRYPT_CMVP_ERR_ALGO_SELFTEST, /**< Algorithm selftest error in CMVP selftest. */ CRYPT_CMVP_ERR_PAIRWISETEST, /**< Pairwise test error in CMVP selftest. */ CRYPT_CMVP_ERR_PARAM_CHECK, /**< Parameter check error in CMVP selftest. */ }; #ifdef __cplusplus } #endif #endif // CRYPT_ERRNO_H /home/wsk/Desktop/openhitls/testcode/demo/RSA-2048.c: In function ‘main’: /home/wsk/Desktop/openhitls/testcode/demo/RSA-2048.c:46:35: error: ‘CRYPT_CTRL_SET_RSA_MODULUS_BITS’ undeclared (first use in this function); did you mean ‘CRYPT_CTRL_GET_ECC_ORDER_BITS’? 46 | ret = CRYPT_EAL_PkeyCtrl(ctx, CRYPT_CTRL_SET_RSA_MODULUS_BITS, NULL, 2048); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | CRYPT_CTRL_GET_ECC_ORDER_BITS /home/wsk/Desktop/openhitls/testcode/demo/RSA-2048.c:46:35: note: each undeclared identifier is reported only once for each function it appears in [ 80%] Built target sm2sign [ 88%] Built target ecdh make[2]: *** [CMakeFiles/RSA-2048.dir/build.make:82: CMakeFiles/RSA-2048.dir/RSA-2048.c.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:227: CMakeFiles/RSA-2048.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 96%] Built target sm2enc make: *** [Makefile:103: all] Error 2
09-07
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值