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 "hks_bn_exp_mod_test_c.h"
17
TestValue()18 int32_t TestValue()
19 {
20 HKS_TEST_LOG_I("test value");
21 uint8_t bufX[HKS_TEST_8] = { 0, 0, 0, 0, 0, 0, 0, 0x40 };
22 uint8_t bufA[HKS_TEST_8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
23 uint8_t bufE[HKS_TEST_2] = { 0, 2 };
24 uint8_t bufN[HKS_TEST_8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
25 uint8_t tmpBufX[HKS_TEST_8] = {0};
26 struct HksBlob tmpX = { HKS_TEST_8, tmpBufX };
27 struct HksBlob tmpA = { HKS_TEST_8, bufA };
28 struct HksBlob tmpE = { HKS_TEST_2, bufE };
29 struct HksBlob tmpN = { HKS_TEST_8, bufN };
30 int32_t ret = HksBnExpModRun(&tmpX, &tmpA, &tmpE, &tmpN, 1);
31 for (int i = 0; i < HKS_TEST_8; ++i) {
32 HKS_TEST_LOG_I("%x, %x", tmpBufX[i], bufX[i]);
33 HKS_TEST_ASSERT(tmpBufX[i] == bufX[i]);
34 }
35 return ret;
36 }
37