Bo Lv | 72d0e90 | 2023-01-02 14:27:34 +0000 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ |
| 2 | /* |
| 3 | * Copyright (c) 2019 Amlogic, Inc. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #ifndef __STORAGEKEY_H__ |
| 7 | #define __STORAGEKEY_H__ |
| 8 | |
| 9 | |
| 10 | /* storage key interface */ |
| 11 | /** |
| 12 | *1.amlkey_init: init storage key |
| 13 | * return ok 0, fail not 0 |
| 14 | */ |
| 15 | extern int32_t amlkey_init(uint8_t *seed, uint32_t len); |
| 16 | |
| 17 | /** |
| 18 | *2. amlkey_isexsit: query key, already programmed ? |
| 19 | * return: exsit 1, non 0 |
| 20 | */ |
| 21 | extern int32_t amlkey_isexsit(const uint8_t * name); |
| 22 | |
| 23 | /** |
| 24 | * 3. query if the key is secure |
| 25 | * return secure 1, non 0; |
| 26 | */ |
| 27 | extern int32_t amlkey_issecure(const uint8_t * name); |
| 28 | |
| 29 | /** |
| 30 | * 4. amlkey_size: actual bytes of key value |
| 31 | * return actual size. |
| 32 | */ |
| 33 | extern ssize_t amlkey_size(const uint8_t *name); |
| 34 | |
| 35 | /** |
| 36 | *5. amlkey_read: read non-secure key in bytes. |
| 37 | * return actual size read back; 0 means read failed! |
| 38 | */ |
| 39 | extern ssize_t amlkey_read(const uint8_t *name, |
| 40 | uint8_t *buffer, uint32_t len); |
| 41 | |
| 42 | /** |
| 43 | * 6. amlkey_write: write secure/non-secure key in bytes. |
| 44 | * return actual size write down. 0 means write failed! |
| 45 | */ |
| 46 | extern ssize_t amlkey_write(const uint8_t *name, |
| 47 | uint8_t *buffer, uint32_t len, uint32_t secure); |
| 48 | |
| 49 | /** |
| 50 | * 7. get the hash value of programmed secure key | 32bytes length, sha256 |
| 51 | * return success 0, fail -1 |
| 52 | */ |
| 53 | extern int32_t amlkey_hash_4_secure(const uint8_t * name, uint8_t * hash); |
| 54 | |
| 55 | /** |
| 56 | * 8. amlkey_del: del key by name |
| 57 | * return success 0, fail non-0. |
| 58 | */ |
| 59 | extern int32_t amlkey_del(const uint8_t * name); |
| 60 | |
| 61 | |
| 62 | #endif /* __STORAGEKEY_H__ */ |