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 "huks_adapter_diff_impl.h"
17 #include "hal_error.h"
18 #include "hc_log.h"
19 #include "hks_api.h"
20 #include "hks_type.h"
21 #include "mbedtls_ec_adapter.h"
22
InitHks(void)23 int32_t InitHks(void)
24 {
25 LOGI("[HUKS]: HksInitialize enter.");
26 int32_t res = HksInitialize();
27 LOGI("[HUKS]: HksInitialize quit. [Res]: %d", res);
28 if (res != HKS_SUCCESS) {
29 LOGE("[HUKS]: HksInitialize fail. [Res]: %d", res);
30 }
31 return res;
32 }
33
HashToPointX25519(const Uint8Buff * hash,Uint8Buff * outEcPoint)34 int32_t HashToPointX25519(const Uint8Buff *hash, Uint8Buff *outEcPoint)
35 {
36 int32_t res = MbedtlsHashToPoint25519(hash, outEcPoint);
37 if (res != 0) {
38 LOGE("Hks hashToPoint failed, res: %d", res);
39 return HAL_FAILED;
40 }
41
42 return HAL_SUCCESS;
43 }