• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022-2023 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 #include "signature.h"
25 
26 #define OPENSSL_RSA_SIGN_CLASS "OPENSSL.RSA.SIGN"
27 
28 #define OPENSSL_RSA_VERIFY_CLASS "OPENSSL.RSA.VERIFY"
29 
30 typedef struct HcfSignSpi HcfSignSpi;
31 
32 struct HcfSignSpi {
33     HcfObjectBase base;
34 
35     HcfResult (*engineInit)(HcfSignSpi *self, HcfParamsSpec *params, HcfPriKey *privateKey);
36 
37     HcfResult (*engineUpdate)(HcfSignSpi *self, HcfBlob *data);
38 
39     HcfResult (*engineSign)(HcfSignSpi *self, HcfBlob *data, HcfBlob *returnSignatureData);
40 
41     HcfResult (*engineSetSignSpecInt)(HcfSignSpi *self, SignSpecItem item, int32_t saltLen);
42 
43     HcfResult (*engineGetSignSpecString)(HcfSignSpi *self, SignSpecItem item, char **returnString);
44 
45     HcfResult (*engineGetSignSpecInt)(HcfSignSpi *self, SignSpecItem item, int32_t *returnInt);
46 };
47 
48 typedef struct HcfVerifySpi HcfVerifySpi;
49 
50 struct HcfVerifySpi {
51     HcfObjectBase base;
52 
53     HcfResult (*engineInit)(HcfVerifySpi *self, HcfParamsSpec *params, HcfPubKey *publicKey);
54 
55     HcfResult (*engineUpdate)(HcfVerifySpi *self, HcfBlob *data);
56 
57     bool (*engineVerify)(HcfVerifySpi *self, HcfBlob *data, HcfBlob *signatureData);
58 
59     HcfResult (*engineSetVerifySpecInt)(HcfVerifySpi *self, SignSpecItem item, int32_t saltLen);
60 
61     HcfResult (*engineGetVerifySpecString)(HcfVerifySpi *self, SignSpecItem item, char **returnString);
62 
63     HcfResult (*engineGetVerifySpecInt)(HcfVerifySpi *self, SignSpecItem item, int32_t *returnInt);
64 };
65 
66 #endif
67