SEcube open-source SDK
L1.h
Go to the documentation of this file.
1 
10 #ifndef L1_H /* guard for header inclusion */
11 #define L1_H
12 
13 #include "../L0/L0.h"
14 #include "L1 Base/L1_base.h"
18 
19 class L1 : private L0, public LoginLogoutApi, public SecurityApi, public UtilityApi {
20 private:
21  L1Base base;
22  uint8_t index; // this is used only by SEkey to support multiple SEcube connected to the same host computer (default value 255)
23  void SessionInit();
24  //overriding
25  void PrepareSessionBufferForChallenge(uint8_t* cc1, uint8_t* cc2, uint16_t access);
26  void TXRXData(uint16_t cmd, uint16_t reqLen, uint16_t cmdFlags, uint16_t* respLen);
27  void Se3PayloadCryptoInit();
28  void Se3PayloadEncrypt(uint16_t flags, uint8_t* iv, uint8_t* data, uint16_t nBlocks, uint8_t* auth);
29  void Se3PayloadDecrypt(uint16_t flags, const uint8_t* iv, uint8_t* data, uint16_t nBlocks, const uint8_t* auth);
30  void L1Config(uint16_t type, uint16_t op, uint8_t* value);
31  //security api private methods
32  void KeyList(uint16_t maxKeys, uint16_t skip, se3Key* keyArray, uint16_t* count);
33 public:
34  L1();
35  L1(uint8_t index);
36  ~L1();
37  //LOGIN-LOGOUT API
38  void L1Login(const uint8_t* pin, uint16_t access, bool force);
39  void L1Logout();
40  void L1LogoutForced();
41  bool L1GetSessionLoggedIn(){ return this->base.GetSessionLoggedIn(); }
42  se3_access_type L1GetAccessType();
43  //SECURITY API
44  void L1CryptoSetTime(uint32_t devTime);
45  void L1CryptoInit(uint16_t algorithm, uint16_t mode, uint32_t keyId, uint32_t* sessId);
46  void L1CryptoUpdate(uint32_t sessId, uint16_t flags, uint16_t data1Len, uint8_t* data1, uint16_t data2Len, uint8_t* data2, uint16_t* dataOutLen, uint8_t* dataOut);
47  void L1Encrypt(size_t dataInLen, uint8_t* dataIn, size_t* dataOutLen, uint8_t* dataOut, uint16_t algorithm, uint16_t mode, uint32_t keyId);
48  void L1Decrypt(size_t dataInLen, uint8_t* dataIn, size_t* dataOutLen, uint8_t* dataOut, uint16_t algorithm, uint16_t mode, uint32_t keyId);
49  void L1Digest(size_t dataInLen, uint8_t* dataIn, size_t* dataOutLen, uint8_t* dataOut, uint16_t algorithm);
50  void L1GetAlgorithms(uint16_t maxAlgorithms, uint16_t skip, se3Algo* algorithmsArray, uint16_t* count);
51  void L1SetAdminPIN(uint8_t* pin);
52  void L1SetUserPIN(uint8_t* pin);
53  void L1KeyEdit(se3Key* k, uint16_t op);
54  void L1KeyList(uint16_t maxKeys, uint16_t skip, se3Key* keyArray, uint16_t* count);
55  bool L1FindKey(uint32_t keyId);
56  //other functionalities
57  void SelectSession(uint8_t sPtr);
58  void L1FactoryInit(uint8_t* serialno);
59  uint8_t *GetDeviceSerialNumber(){return this->GetDeviceSn();}
60  // these functions were added to implement SEkey, they must not be used elsewhere
61  bool L1SEkeyInfo(std::string& id, std::string& name, uint8_t mode);
62  bool L1GetKeyEnc(uint32_t key_id, uint32_t k2, uint8_t *key_data, uint16_t key_len);
63  void L1SEkeyMaintenance(uint8_t *buffer, uint16_t *buflen);
64  bool L1DeleteKey(uint32_t key_id);
65  bool L1DeleteAllKeys(std::vector<uint32_t>& keep);
66  bool L1InsertKey(uint32_t key_id, uint16_t key_len, uint32_t dec_id, uint8_t *key_data);
67 };
68 
69 #endif /* L1_H */
login_logout_api.h
Prototypes of the LOGIN LOGOUT API.
B5_Aes256_Update
int32_t B5_Aes256_Update(B5_tAesCtx *ctx, uint8_t *encData, uint8_t *clrData, int16_t nBlk)
Encrypt/Decrypt data based on the status of current AES context.
Definition: aes256.cpp:1268
B5_HmacSha256_Update
int32_t B5_HmacSha256_Update(B5_tHmacSha256Ctx *ctx, const uint8_t *data, int32_t dataLen)
Compute the HMAC-SHA256 algorithm on input data depending on the current status of the HMAC-SHA256 co...
Definition: sha256.c:374
security_api.h
Prototypes of the SECURITY API.
B5_AES_256
#define B5_AES_256
Definition: aes256.h:42
B5_AES256_CBC_ENC
#define B5_AES256_CBC_ENC
Definition: aes256.h:59
B5_AES256_CBC_DEC
#define B5_AES256_CBC_DEC
Definition: aes256.h:60
se3Algo_
SEcube Algorithm structure.
Definition: L1_base.h:69
B5_AES_IV_SIZE
#define B5_AES_IV_SIZE
Definition: aes256.h:45
B5_Aes256_SetIV
int32_t B5_Aes256_SetIV(B5_tAesCtx *ctx, const uint8_t *IV)
Set the IV for the current AES context.
Definition: aes256.cpp:1245
se3Key_
SEcube Key structure.
Definition: L1_base.h:77
L1.h
Prototype of the L1 library.
B5_HmacSha256_Init
int32_t B5_HmacSha256_Init(B5_tHmacSha256Ctx *ctx, const uint8_t *Key, int16_t keySize)
Initialize the HMAC-SHA256 context.
Definition: sha256.c:321
B5_AES_BLK_SIZE
#define B5_AES_BLK_SIZE
Definition: aes256.h:46
B5_HmacSha256_Finit
int32_t B5_HmacSha256_Finit(B5_tHmacSha256Ctx *ctx, uint8_t *rDigest)
De-initialize the current HMAC-SHA256 context.
Definition: sha256.c:398
L1_base.h
Prototypes of the L1Base library.
utility_api.h
Prototypes of the UTILITY API.
B5_Aes256_Init
int32_t B5_Aes256_Init(B5_tAesCtx *ctx, const uint8_t *Key, int16_t keySize, uint8_t aesMode)
Initialize the AES context.
Definition: aes256.cpp:1193