blob: be3c80387e8a073911e65d14aa74638df9ee7803 [file] [log] [blame]
Bo Lv72d0e902023-01-02 14:27:34 +00001/* 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 */
15extern 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 */
21extern 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 */
27extern int32_t amlkey_issecure(const uint8_t * name);
28
29/**
30 * 4. amlkey_size: actual bytes of key value
31 * return actual size.
32 */
33extern 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 */
39extern 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 */
46extern 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 */
53extern 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 */
59extern int32_t amlkey_del(const uint8_t * name);
60
61
62#endif /* __STORAGEKEY_H__ */