SEcube
SEcube Open Source Library - Device
se3c1.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "se3c0.h"
10 #include "se3c1def.h"
11 #include "se3_memory.h"
12 #include "se3_keys.h"
13 
14 // ---- records ----
15 
16 enum {
18 };
19 
21 typedef struct SE3_RECORD_INFO_ {
22  uint16_t read_access;
23  uint16_t write_access;
25 
26 enum {
30 };
31 
40 bool se3c1_record_set(uint16_t type, const uint8_t* data);
41 
49 bool se3c1_record_get(uint16_t type, uint8_t* data);
50 
51 
52 // ---- crypto ----
53 
54 enum {
55  SE3_SESSIONS_BUF = (32*1024),
57 };
58 
60 extern uint8_t se3_sessions_buf[SE3_SESSIONS_BUF];
61 
63 extern uint8_t* se3_sessions_index[SE3_SESSIONS_MAX];
64 
66 typedef uint16_t(*se3_crypto_init_handler)(
67  se3_flash_key* key, uint16_t mode, uint8_t* ctx);
68 
70 typedef uint16_t(*se3_crypto_update_handler)(
71  uint8_t* ctx, uint16_t flags,
72  uint16_t datain1_len, const uint8_t* datain1,
73  uint16_t datain2_len, const uint8_t* datain2,
74  uint16_t* dataout_len, uint8_t* dataout);
75 
77 typedef struct se3_algo_descriptor_ {
80  uint16_t size;
81  char display_name[16];
82  uint16_t display_type;
83  uint16_t display_block_size;
84  uint16_t display_key_size;
86 
88 extern se3_algo_descriptor L1d_algo_table[SE3_ALGO_MAX];
89 
90 // ---- L1 structures ----
91 
93 typedef struct SE3_LOGIN_STATUS_ {
94  bool y;
95  uint16_t access;
96  uint16_t challenge_access;
97  union {
98  uint8_t token[SE3_L1_TOKEN_SIZE];
99  uint8_t challenge[SE3_L1_CHALLENGE_SIZE];
100  };
101  uint8_t key[SE3_L1_KEY_SIZE];
105 
107 typedef struct SE3_L1_GLOBALS_ {
108  SE3_LOGIN_STATUS login;
109  SE3_RECORD_INFO records[SE3_RECORD_MAX];
110  se3_mem sessions;
111  uint16_t sessions_algo[SE3_SESSIONS_MAX];
113 
118 void se3c1_login_cleanup();
119 
121 void se3c1_init();
122 
124 extern SE3_L1_GLOBALS se3c1;
se3_crypto_init_handler init
L1_crypto_init function.
Definition: se3c1.h:78
uint16_t read_access
required access level for read
Definition: se3c1.h:22
bool y
logged in
Definition: se3c1.h:94
Record information.
Definition: se3c1.h:21
struct SE3_L1_GLOBALS_ SE3_L1_GLOBALS
L1 globals structure.
This file contains defines to be used both for L1 and L0 functions.
algorithm descriptor type
Definition: se3c1.h:77
L0 structures and functions.
struct se3_algo_descriptor_ se3_algo_descriptor
algorithm descriptor type
uint8_t * se3_sessions_index[SE3_SESSIONS_MAX]
Definition: se3c1.c:12
bool se3c1_record_get(uint16_t type, uint8_t *data)
Read record.
Definition: se3c1.c:121
void se3c1_init()
Initialize L1 structures.
Definition: se3c1.c:154
uint16_t display_block_size
block size for the algorithm list API
Definition: se3c1.h:83
uint16_t display_type
type for the algorithm list API
Definition: se3c1.h:82
L1 login status data.
Definition: se3c1.h:93
bool cryptoctx_initialized
context initialized flag
Definition: se3c1.h:103
uint16_t(* se3_crypto_update_handler)(uint8_t *ctx, uint16_t flags, uint16_t datain1_len, const uint8_t *datain1, uint16_t datain2_len, const uint8_t *datain2, uint16_t *dataout_len, uint8_t *dataout)
L1_crypto_update function type.
Definition: se3c1.h:70
bool se3c1_record_set(uint16_t type, const uint8_t *data)
Write record.
Definition: se3c1.c:82
Definition: se3_common.h:68
struct SE3_LOGIN_STATUS_ SE3_LOGIN_STATUS
L1 login status data.
struct SE3_RECORD_INFO_ SE3_RECORD_INFO
Record information.
session buffer size
Definition: se3c1.h:55
uint16_t display_key_size
key size for the algorithm list API
Definition: se3c1.h:84
Memory management (session allocator)
maximum number of sessions
Definition: se3c1.h:56
Key management.
SE3_L1_GLOBALS se3c1
L1 globals.
Definition: se3c1.c:13
Flash key structure.
Definition: se3_keys.h:22
uint16_t size
context size size
Definition: se3c1.h:80
uint16_t access
access level
Definition: se3c1.h:95
uint16_t write_access
required access level for write
Definition: se3c1.h:23
record.type field size
Definition: se3c1.h:27
uint16_t(* se3_crypto_init_handler)(se3_flash_key *key, uint16_t mode, uint8_t *ctx)
L1_crypto_init function type.
Definition: se3c1.h:66
se3_payload_cryptoctx cryptoctx
context for protocol encryption
Definition: se3c1.h:102
uint8_t se3_sessions_buf[SE3_SESSIONS_BUF]
Definition: se3c1.c:11
uint16_t challenge_access
access level of the last offered challenge
Definition: se3c1.h:96
void se3c1_login_cleanup()
Clear login session data.
Definition: se3c1.c:135
record.data field offset
Definition: se3c1.h:29
flash node type: record
Definition: se3c1.h:17
record.type field offset
Definition: se3c1.h:28
se3_algo_descriptor L1d_algo_table[SE3_ALGO_MAX]
Definition: se3c1.c:22
L1 globals structure.
Definition: se3c1.h:107
memory allocator structure
Definition: se3_memory.h:11
se3_crypto_update_handler update
L1_crypto_update function.
Definition: se3c1.h:79