1 /*
2 * Copyright (c) 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 #include "cf_ability.h"
17
18 #include "cf_adapter_cert_openssl.h"
19 #include "cf_adapter_extension_openssl.h"
20 #include "cf_cert_adapter_ability_define.h"
21 #include "cf_extension_adapter_ability_define.h"
22 #include "cf_log.h"
23 #include "cf_magic.h"
24
25 static CfCertAdapterAbilityFunc g_certAdapterFunc = {
26 .base.type = CF_MAGIC(CF_MAGIC_TYPE_ADAPTER_FUNC, CF_OBJ_TYPE_CERT),
27 .adapterCreate = CfOpensslCreateCert,
28 .adapterDestory = CfOpensslDestoryCert,
29 .adapterVerify = CfOpensslVerifyCert,
30 .adapterGetItem = CfOpensslGetCertItem,
31 };
32
33 static CfExtensionAdapterAbilityFunc g_extensionAdapterFunc = {
34 .base.type = CF_MAGIC(CF_MAGIC_TYPE_ADAPTER_FUNC, CF_OBJ_TYPE_EXTENSION),
35 .adapterCreate = CfOpensslCreateExtension,
36 .adapterDestory = CfOpensslDestoryExtension,
37 .adapterGetOids = CfOpensslGetOids,
38 .adapterGetEntry = CfOpensslGetEntry,
39 .adapterGetItem = CfOpensslGetExtensionItem,
40 .adapterCheckCA = CfOpensslCheckCA,
41 };
42
LoadAdapterAbility(void)43 __attribute__((constructor)) static void LoadAdapterAbility(void)
44 {
45 CF_LOG_I("enter load adapter ability");
46 (void)RegisterAbility(CF_ABILITY(CF_ABILITY_TYPE_ADAPTER, CF_OBJ_TYPE_CERT), &g_certAdapterFunc.base);
47 (void)RegisterAbility(CF_ABILITY(CF_ABILITY_TYPE_ADAPTER, CF_OBJ_TYPE_EXTENSION), &g_extensionAdapterFunc.base);
48 }
49
50