-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathencryption.h
More file actions
71 lines (48 loc) · 2.19 KB
/
Copy pathencryption.h
File metadata and controls
71 lines (48 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef __ENCRYPTION_H
#define __ENCRYPTION_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "structs.h"
extern struct SecurityConfig securityConfig;
extern struct EncryptionSession encryptionSession;
extern bool encryptionInitialized;
void encryption_init(void);
bool isEncryptionEnabled(void);
bool isAuthenticated(void);
void clearEncryptionSession(void);
bool checkEncryptionSessionTimeout(void);
void updateEncryptionSessionActivity(void);
bool handleAuthenticate(uint8_t* data, uint16_t len,
uint8_t* p_response, uint16_t* p_response_len);
void getCurrentNonce(uint8_t* nonce);
void incrementNonceCounter(void);
bool verifyNonceReplay(uint8_t* nonce);
bool decryptCommand(uint8_t* ciphertext, uint16_t ciphertext_len,
uint8_t* plaintext, uint16_t* plaintext_len,
uint8_t* nonce_full, uint8_t* auth_tag,
uint16_t command_header);
bool encryptResponse(uint8_t* plaintext, uint16_t plaintext_len,
uint8_t* ciphertext, uint16_t* ciphertext_len,
uint8_t* nonce, uint8_t* auth_tag);
bool aes_cmac(const uint8_t key[16], const uint8_t* msg, size_t msg_len,
uint8_t tag[16]);
bool aes_ecb_encrypt(const uint8_t key[16], const uint8_t in[16],
uint8_t out[16]);
bool aes_ccm_encrypt(const uint8_t key[16],
const uint8_t* nonce, size_t nonce_len,
const uint8_t* aad, size_t aad_len,
const uint8_t* plaintext, size_t plaintext_len,
uint8_t* ciphertext,
uint8_t* tag, size_t tag_len);
bool aes_ccm_decrypt(const uint8_t key[16],
const uint8_t* nonce, size_t nonce_len,
const uint8_t* aad, size_t aad_len,
const uint8_t* ciphertext, size_t ciphertext_len,
uint8_t* plaintext,
const uint8_t* tag, size_t tag_len);
void secure_random(uint8_t* output, size_t len);
bool constantTimeCompare(const uint8_t* a, const uint8_t* b, size_t len);
void secureEraseConfig(bool reboot_after);
void checkResetPin(void);
#endif // __ENCRYPTION_H