1 /* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HCF_SM2_CRYPTO_UTIL_H 17 #define HCF_SM2_CRYPTO_UTIL_H 18 19 #include "result.h" 20 #include "sm2_crypto_params.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /** 27 * @brief Generate the SM2 ciphertext in ASN.1 format according to the specific data. 28 * 29 * @param spec - indicates the EC signature data spec.. 30 * @param output - indicates the signature data in DER format. 31 * @return Returns the status code of the execution. 32 * @since 20 33 * @version 1.0 34 */ 35 HcfResult HcfGenEcSignatureDataBySpec(Sm2EcSignatureDataSpec *spec, HcfBlob *output); 36 /** 37 * @brief Get the specific data from the SM2 ciphertext in ASN.1 format. 38 * 39 * @param input - indicates the signature data in DER format. 40 * @param returnSpc - indicates the EC signature data spec.. 41 * @return Returns the status code of the execution. 42 * @since 20 43 * @version 1.0 44 */ 45 HcfResult HcfGenEcSignatureSpecByData(HcfBlob *input, Sm2EcSignatureDataSpec **returnSpc); 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 #endif 52