• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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  * Description: security api for romboot. \n
16  *
17  */
18 
19 #ifndef DRV_ROM_CIPHER_H
20 #define DRV_ROM_CIPHER_H
21 
22 int drv_rom_cipher_init(void);
23 int drv_rom_cipher_deinit(void);
24 
25 /* support data_length not 64 bytes aligned. */
26 int drv_rom_cipher_sha256(const unsigned char *data, unsigned int data_length, unsigned char *hash,
27     unsigned int hash_length);
28 
29 int drv_rom_cipher_get_randnum(unsigned int *randnum);
30 
31 /* ecc verify. */
32 typedef struct {
33     unsigned char *x;
34     unsigned char *y;
35     unsigned int length;
36 } drv_rom_cipher_ecc_point;
37 
38 typedef struct {
39     unsigned int length;
40     unsigned char *data;
41 } drv_rom_cipher_data;
42 
43 typedef struct {
44     unsigned char  *r;
45     unsigned char  *s;
46     unsigned int length;
47 } drv_rom_cipher_ecc_sig;
48 
49 int drv_rom_cipher_pke_bp256r_verify(const drv_rom_cipher_ecc_point *pub_key, const drv_rom_cipher_data *hash,
50     const drv_rom_cipher_ecc_sig *sig);
51 #endif