1 /* 2 * Copyright (C) 2024 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 specific data of SM2 ciphertext. 30 * @param mode - indicates the arrangement mode of the SM2 ciphertext. 31 * @param output - the SM2 ciphertext in ASN.1 format. 32 * @return Returns the status code of the execution. 33 * @since 12 34 * @version 1.0 35 */ 36 HcfResult HcfGenCipherTextBySpec(Sm2CipherTextSpec *spec, const char *mode, HcfBlob *output); 37 /** 38 * @brief Get the specific data from the SM2 ciphertext in ASN.1 format. 39 * 40 * @param input - indicates the SM2 ciphertext in ASN.1 format. 41 * @param mode - indicates the arrangement mode of the SM2 ciphertext. 42 * @param returnSpc - the specific data of SM2 ciphertext. 43 * @return Returns the status code of the execution. 44 * @since 12 45 * @version 1.0 46 */ 47 HcfResult HcfGetCipherTextSpec(HcfBlob *input, const char *mode, Sm2CipherTextSpec **returnSpc); 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 #endif 54