blob: 81f1c7cd433ca55133cbb165a9f71f36d3131467
1 | /* |
2 | * \file amlkey_if.h |
3 | * \brief APIs of secure key for users |
4 | * |
5 | * \version 1.0.0 |
6 | * \date 15/07/10 |
7 | * \author Sam.Wu <yihui.wu@amlgic.com> |
8 | * |
9 | * Copyright (c) 2015 Amlogic. All Rights Reserved. |
10 | * |
11 | */ |
12 | #ifndef __AMLKEY_IF_H__ |
13 | #define __AMLKEY_IF_H__ |
14 | |
15 | #define AMLKEY_NAME_LEN_MAX (80) |
16 | //1.init |
17 | int32_t amlkey_init(uint8_t *seed, uint32_t len, int encrypt_type); |
18 | |
19 | //2. query if the key already programmed, exsit 1, non 0 |
20 | int32_t amlkey_isexsit(const uint8_t * name); |
21 | |
22 | //3. query attr, key must exsit before those functions were called. |
23 | //3.1 whether the prgrammed key is secure, secure 1, non 0 |
24 | int32_t amlkey_issecure(const uint8_t * name); |
25 | //3.2 whether the prgrammed key is encrypt, encrypt 1, non 0 |
26 | int32_t amlkey_isencrypt(const uint8_t * name); |
27 | |
28 | //4. actual bytes of key value |
29 | ssize_t amlkey_size(const uint8_t *name); |
30 | |
31 | //5. read non-secure key in bytes, return byets readback actully. |
32 | ssize_t amlkey_read(const uint8_t *name, uint8_t *buffer, uint32_t len) ; |
33 | |
34 | //6.write key with attribute in bytes , return byets readback actully |
35 | //attr: bit0: secure/non-secure; |
36 | // bit8: encrypt/non-encrypt |
37 | #define UNIFYKEY_ATTR_SECURE_MASK (1<<0) |
38 | #define UNIFYKEY_ATTR_ENCRYPT_MASK (1<<8) |
39 | ssize_t amlkey_write(const uint8_t *name, uint8_t *buffer, uint32_t len, uint32_t attr); |
40 | |
41 | //7. get the hash value of programmed secure key | 32bytes length, sha256 |
42 | int32_t amlkey_hash_4_secure(const uint8_t * name, uint8_t * hash); |
43 | |
44 | #endif// #ifndef __AMLKEY_IF_H__ |
45 | |
46 |