13 #include "../../L0/L0 Base/L0_base.h"
14 #include "../Crypto Libraries/aes256.h"
15 #include "../../L0/L0_error_manager.h"
16 #include "../Crypto Libraries/pbkdf2.h"
17 #include "../L1_error_manager.h"
19 #include "../L1_enumerations.h"
24 #ifndef B5_SHA256_DIGEST_SIZE
25 #define B5_SHA256_DIGEST_SIZE 32
28 #define B5_AES256_CBC_ENC 4
29 #define B5_AES256_CBC_DEC 5
30 #ifndef B5_AES_BLK_SIZE
31 #define B5_AES_BLK_SIZE 16
38 typedef enum se3_access_type_ {
40 SE3_ACCESS_USER = 100,
41 SE3_ACCESS_ADMIN = 1000,
42 SE3_ACCESS_MAX = 0xFFFF
45 typedef struct se3PayloadCryptoctx_ {
48 B5_tHmacSha256Ctx hmac;
50 uint8_t auth[B5_SHA256_DIGEST_SIZE];
51 } se3PayloadCryptoctx;
56 uint8_t token[L1Parameters::Size::TOKEN];
57 uint8_t key[L1Parameters::Size::KEY];
58 uint8_t buf[L0Communication::Parameter::COMM_N * L0Communication::Parameter::COMM_BLOCK];
63 se3PayloadCryptoctx cryptoctx;
64 bool cryptoctx_initialized;
65 se3_access_type access_type;
70 uint8_t name[L1Crypto::AlgorithmInfoSize::NAME_SIZE];
83 uint8_t name[L1Key::Size::MAX_NAME];
88 std::vector<se3Session> s;
95 void SwitchToSession(uint8_t sPtr);
97 void InitializeSession(uint8_t nSessions);
99 void FillSessionBuffer(uint8_t* data,
size_t offset,
size_t len);
101 void FillSessionBuffer(
size_t offset,
size_t len);
102 uint8_t* GetSessionBuffer();
103 bool GetSessionLoggedIn();
104 void SetSessionLoggedIn(
bool logged);
105 se3_access_type GetSessionAccessType();
106 void SetSessionAccessType(se3_access_type access);
107 bool GetSessionCryptoInitialized();
108 B5_tAesCtx* GetSessionCryptoctxAesenc();
109 B5_tAesCtx* GetSessionCryptoctxAesdec();
110 void SetSessionCryptoctxHmacKey(uint8_t* keys,
size_t offset,
size_t len);
111 uint8_t* GetSessionCryptoctxHmacKey();
112 B5_tHmacSha256Ctx* GetSessionCryptoctxHmac();
113 void SetCryptoctxInizialized(
bool init);
114 uint8_t* GetSessionKey();
115 uint8_t* GetSessionToken();
116 void SetSessionToken(
size_t offset,
size_t len);
117 uint8_t* GetSessionCryptoctxAuth();
118 void ReadSessionBuffer(uint8_t* retData,
size_t offset,
size_t len);
119 bool CompareSessionBuf(uint8_t* cmpData,
size_t offset,
size_t len);