1 // Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
2 //
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 #include "hal/systimer_hal.h"
16 #include "hal/ds_hal.h"
17 #include "hal/ds_ll.h"
18
ds_hal_start(void)19 void ds_hal_start(void)
20 {
21 ds_ll_start();
22 }
23
ds_hal_finish(void)24 void ds_hal_finish(void)
25 {
26 ds_ll_finish();
27 }
28
ds_hal_configure_iv(const uint32_t * iv)29 void ds_hal_configure_iv(const uint32_t *iv)
30 {
31 ds_ll_configure_iv(iv);
32 }
33
ds_hal_write_message(const uint8_t * msg,size_t size)34 void ds_hal_write_message(const uint8_t *msg, size_t size)
35 {
36 ds_ll_write_message(msg, size);
37 }
38
ds_hal_write_private_key_params(const uint8_t * key_params)39 void ds_hal_write_private_key_params(const uint8_t *key_params)
40 {
41 ds_ll_write_private_key_params(key_params);
42 }
43
ds_hal_start_sign(void)44 void ds_hal_start_sign(void)
45 {
46 ds_ll_start_sign();
47 }
48
ds_hal_busy(void)49 bool ds_hal_busy(void)
50 {
51 return ds_ll_busy();
52 }
53
ds_hal_read_result(uint8_t * result,size_t size)54 ds_signature_check_t ds_hal_read_result(uint8_t *result, size_t size)
55 {
56 ds_signature_check_t check_result = ds_ll_check_signature();
57
58 if (check_result == DS_SIGNATURE_OK || check_result == DS_SIGNATURE_PADDING_FAIL) {
59 ds_ll_read_result(result, size);
60 }
61
62 return check_result;
63 }
64