1 /* 2 * Copyright (C) 2022 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_SIGNATURE_H 17 #define HCF_SIGNATURE_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include "algorithm_parameter.h" 22 #include "result.h" 23 #include "key_pair.h" 24 25 typedef struct HcfSign HcfSign; 26 27 struct HcfSign { 28 HcfObjectBase base; 29 30 HcfResult (*init)(HcfSign *self, HcfParamsSpec *params, HcfPriKey *privateKey); 31 32 HcfResult (*update)(HcfSign *self, HcfBlob *data); 33 34 HcfResult (*sign)(HcfSign *self, HcfBlob *data, HcfBlob *returnSignatureData); 35 36 const char *(*getAlgoName)(HcfSign *self); 37 }; 38 39 typedef struct HcfVerify HcfVerify; 40 41 struct HcfVerify { 42 HcfObjectBase base; 43 44 HcfResult (*init)(HcfVerify *self, HcfParamsSpec *params, HcfPubKey *publicKey); 45 46 HcfResult (*update)(HcfVerify *self, HcfBlob *data); 47 48 bool (*verify)(HcfVerify *self, HcfBlob *data, HcfBlob *signatureData); 49 50 const char *(*getAlgoName)(HcfVerify *self); 51 }; 52 53 #ifdef __cplusplus 54 extern "C" { 55 #endif 56 57 HcfResult HcfSignCreate(const char *algoName, HcfSign **returnObj); 58 59 HcfResult HcfVerifyCreate(const char *algoName, HcfVerify **returnObj); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif 66