• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 HKS_OPENSSL_ENGINE_H
17 #define HKS_OPENSSL_ENGINE_H
18 
19 #include <openssl/ossl_typ.h>
20 #include <stdint.h>
21 
22 #include "hks_type.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define HKS_OPENSSL_SUCCESS    1     /* openssl return 1: success */
29 #define HKS_OPENSSL_ERROR_LEN 128
30 #define BIT_NUM_OF_UINT8 8
31 #define AFTER_HASH_LEN_16 16
32 #define AFTER_HASH_LEN_20 20
33 #define AFTER_HASH_LEN_28 28
34 #define AFTER_HASH_LEN_32 32
35 #define AFTER_HASH_LEN_48 48
36 #define AFTER_HASH_LEN_64 64
37 
38 void HksLogOpensslError(void);
39 
40 int32_t HksOpensslCheckBlob(const struct HksBlob *blob);
41 
42 const EVP_MD *GetOpensslAlg(uint32_t alg);
43 
44 const EVP_MD *GetOpensslAlgFromLen(uint32_t len);
45 
46 // Note: `out` memory will be allocated, you MUST free out->data after using.
47 int32_t GetBnBinpadFromPkey(const EVP_PKEY *pkey, const char *keyName, struct HksBlob *out);
48 
49 #ifdef __cplusplus
50 }
51 #endif
52 
53 #endif /* HKS_OPENSSL_ENGINE_H */
54