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_SPI_H 17 #define HCF_SIGNATURE_SPI_H 18 19 #include <stdbool.h> 20 #include "algorithm_parameter.h" 21 #include "pri_key.h" 22 #include "pub_key.h" 23 #include "result.h" 24 25 #define OPENSSL_RSA_SIGN_CLASS "OPENSSL.RSA.SIGN" 26 27 #define OPENSSL_RSA_VERIFY_CLASS "OPENSSL.RSA.VERIFY" 28 29 typedef struct HcfSignSpi HcfSignSpi; 30 31 struct HcfSignSpi { 32 HcfObjectBase base; 33 34 HcfResult (*engineInit)(HcfSignSpi *self, HcfParamsSpec *params, HcfPriKey *privateKey); 35 36 HcfResult (*engineUpdate)(HcfSignSpi *self, HcfBlob *data); 37 38 HcfResult (*engineSign)(HcfSignSpi *self, HcfBlob *data, HcfBlob *returnSignatureData); 39 }; 40 41 typedef struct HcfVerifySpi HcfVerifySpi; 42 43 struct HcfVerifySpi { 44 HcfObjectBase base; 45 46 HcfResult (*engineInit)(HcfVerifySpi *self, HcfParamsSpec *params, HcfPubKey *publicKey); 47 48 HcfResult (*engineUpdate)(HcfVerifySpi *self, HcfBlob *data); 49 50 bool (*engineVerify)(HcfVerifySpi *self, HcfBlob *data, HcfBlob *signatureData); 51 }; 52 53 #endif 54