Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
proto_crypto.cpp
Go to the documentation of this file.
1/// @file proto_crypto.cpp
2/// @brief Cryptographic helpers for the IO-Homecontrol protocol.
3
4// The AES helper intentionally mirrors the byte-level structure of the algorithm.
5// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
6
7#include "proto_crypto.h"
8
9#include <esp_random.h>
10#include <cstring>
11
12namespace esphome {
13namespace home_io_control {
14namespace crypto {
15
16namespace {
17
18// This is a small self-contained AES-128 implementation derived from the standard
19// Rijndael/AES algorithm as specified in FIPS-197. It was added here to avoid a
20// build-time dependency on ESP-IDF/mbedTLS linkage from ESPHome's generated "src"
21// component.
22
23// Forward substitution box defined by AES. Each input byte is replaced by its
24// corresponding non-linear S-box value during SubBytes.
25const uint8_t AES_SBOX[256] = {
26 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9,
27 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F,
28 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07,
29 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3,
30 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58,
31 0xCF, 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3,
32 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC, 0x5F,
33 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88,
34 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC,
35 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A,
36 0xAE, 0x08, 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, 0x70,
37 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11,
38 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42,
39 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16,
40};
41
42// Inverse substitution box defined by AES. This is required for the inverse
43// cipher path used by AES-128 decryption.
44const uint8_t AES_INV_SBOX[256] = {
45 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39,
46 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2,
47 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76,
48 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC,
49 0x5D, 0x65, 0xB6, 0x92, 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D,
50 0x84, 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C,
51 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41, 0x4F,
52 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85,
53 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62,
54 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD,
55 0x5A, 0xF4, 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, 0x60,
56 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D,
57 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6,
58 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D,
59};
60
61// AES round constants used only by the key schedule. Each non-zero entry is the
62// Rcon value for one expansion round; entry 0 is unused and kept as padding so
63// the round index can be used directly.
64const uint8_t AES_RCON[11] = {0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36};
65
66/// Multiply two bytes in AES's GF(2^8) finite field (used by MixColumns).
67/// @param value First operand.
68/// @param factor Second operand (usually 0x02 or 0x03).
69/// @return Product in the field.
70uint8_t aes_mul(uint8_t value, uint8_t factor) {
71 uint8_t result = 0;
72 while (factor != 0) {
73 if ((factor & 1U) != 0)
74 result ^= value;
75 bool const high_bit = (value & 0x80U) != 0;
76 value <<= 1;
77 if (high_bit)
78 value ^= 0x1BU;
79 factor >>= 1;
80 }
81 return result;
82}
83
84/// Add round key to state (AES AddRoundKey step).
85/// @param state Current AES state (16 bytes).
86/// @param round_keys Expanded key schedule.
87/// @param round Round index (0 for initial, 10 for final).
88void aes_add_round_key(uint8_t *state, const uint8_t *round_keys, uint8_t round) {
89 const uint8_t *round_key = &round_keys[round * AES_BLOCK_SIZE];
90 for (uint8_t i = 0; i < AES_BLOCK_SIZE; i++)
91 state[i] ^= round_key[i];
92}
93
94/// AES SubBytes: apply S‑box to every byte of the state.
95/// @param state 16‑byte state buffer.
96void aes_sub_bytes(uint8_t *state) {
97 for (uint8_t i = 0; i < AES_BLOCK_SIZE; i++)
98 state[i] = AES_SBOX[state[i]];
99}
100
101/// AES Inverse SubBytes (uses inverse S‑box).
102/// @param state 16‑byte state buffer.
103void aes_inv_sub_bytes(uint8_t *state) {
104 for (uint8_t i = 0; i < AES_BLOCK_SIZE; i++)
105 state[i] = AES_INV_SBOX[state[i]];
106}
107
108/// AES ShiftRows: cyclically shift rows 1‑3 left by their row index.
109/// @param state 16‑byte state buffer (4×4 matrix).
110void aes_shift_rows(uint8_t *state) {
111 uint8_t tmp[AES_BLOCK_SIZE];
112 memcpy(tmp, state, AES_BLOCK_SIZE);
113 state[0] = tmp[0];
114 state[4] = tmp[4];
115 state[8] = tmp[8];
116 state[12] = tmp[12];
117 state[1] = tmp[5];
118 state[5] = tmp[9];
119 state[9] = tmp[13];
120 state[13] = tmp[1];
121 state[2] = tmp[10];
122 state[6] = tmp[14];
123 state[10] = tmp[2];
124 state[14] = tmp[6];
125 state[3] = tmp[15];
126 state[7] = tmp[3];
127 state[11] = tmp[7];
128 state[15] = tmp[11];
129}
130
131/// AES InvShiftRows: inverse cyclic shift of rows.
132/// @param state 16‑byte state buffer.
133void aes_inv_shift_rows(uint8_t *state) {
134 uint8_t tmp[AES_BLOCK_SIZE];
135 memcpy(tmp, state, AES_BLOCK_SIZE);
136 state[0] = tmp[0];
137 state[4] = tmp[4];
138 state[8] = tmp[8];
139 state[12] = tmp[12];
140 state[1] = tmp[13];
141 state[5] = tmp[1];
142 state[9] = tmp[5];
143 state[13] = tmp[9];
144 state[2] = tmp[10];
145 state[6] = tmp[14];
146 state[10] = tmp[2];
147 state[14] = tmp[6];
148 state[3] = tmp[7];
149 state[7] = tmp[11];
150 state[11] = tmp[15];
151 state[15] = tmp[3];
152}
153
154/// AES MixColumns: mix each column with GF(2^8) multiplication.
155/// @param state 16‑byte state buffer (treated as 4 columns).
156void aes_mix_columns(uint8_t *state) {
157 for (uint8_t column = 0; column < 4; column++) {
158 uint8_t *col = &state[column * 4];
159 uint8_t const a0 = col[0];
160 uint8_t const a1 = col[1];
161 uint8_t const a2 = col[2];
162 uint8_t const a3 = col[3];
163 col[0] = aes_mul(a0, 0x02) ^ aes_mul(a1, 0x03) ^ a2 ^ a3;
164 col[1] = a0 ^ aes_mul(a1, 0x02) ^ aes_mul(a2, 0x03) ^ a3;
165 col[2] = a0 ^ a1 ^ aes_mul(a2, 0x02) ^ aes_mul(a3, 0x03);
166 col[3] = aes_mul(a0, 0x03) ^ a1 ^ a2 ^ aes_mul(a3, 0x02);
167 }
168}
169
170/// AES InvMixColumns: inverse mix each column.
171/// @param state 16‑byte state buffer.
172void aes_inv_mix_columns(uint8_t *state) {
173 for (uint8_t column = 0; column < 4; column++) {
174 uint8_t *col = &state[column * 4];
175 uint8_t const a0 = col[0];
176 uint8_t const a1 = col[1];
177 uint8_t const a2 = col[2];
178 uint8_t const a3 = col[3];
179 col[0] = aes_mul(a0, 0x0E) ^ aes_mul(a1, 0x0B) ^ aes_mul(a2, 0x0D) ^ aes_mul(a3, 0x09);
180 col[1] = aes_mul(a0, 0x09) ^ aes_mul(a1, 0x0E) ^ aes_mul(a2, 0x0B) ^ aes_mul(a3, 0x0D);
181 col[2] = aes_mul(a0, 0x0D) ^ aes_mul(a1, 0x09) ^ aes_mul(a2, 0x0E) ^ aes_mul(a3, 0x0B);
182 col[3] = aes_mul(a0, 0x0B) ^ aes_mul(a1, 0x0D) ^ aes_mul(a2, 0x09) ^ aes_mul(a3, 0x0E);
183 }
184}
185
186/// Expand a 16‑byte AES key into an 11‑round key schedule (176 bytes).
187/// @param key Input 16‑byte key.
188/// @param round_keys Output buffer (must be 176 bytes).
189void aes_expand_key(const uint8_t key[AES_KEY_SIZE], uint8_t round_keys[176]) {
190 memcpy(round_keys, key, AES_KEY_SIZE);
191 uint8_t bytes_generated = AES_KEY_SIZE;
192 uint8_t rcon_index = 1;
193 uint8_t temp[4];
194
195 while (bytes_generated < 176) {
196 for (uint8_t i = 0; i < 4; i++)
197 temp[i] = round_keys[bytes_generated - 4 + i];
198 if ((bytes_generated % AES_KEY_SIZE) == 0) {
199 uint8_t const rotated = temp[0];
200 temp[0] = AES_SBOX[temp[1]] ^ AES_RCON[rcon_index++];
201 temp[1] = AES_SBOX[temp[2]];
202 temp[2] = AES_SBOX[temp[3]];
203 temp[3] = AES_SBOX[rotated];
204 }
205 for (uint8_t const value : temp) {
206 round_keys[bytes_generated] = round_keys[bytes_generated - AES_KEY_SIZE] ^ value;
207 bytes_generated++;
208 }
209 }
210}
211
212/// Perform one AES‑128 encryption block (full 10 rounds).
213/// @param in 16‑byte plaintext.
214/// @param key 16‑byte AES key.
215/// @param out Output: 16‑byte ciphertext.
216/// @return true on success.
217bool aes128_encrypt_block(const uint8_t in[AES_BLOCK_SIZE], const uint8_t key[AES_KEY_SIZE],
218 uint8_t out[AES_BLOCK_SIZE]) {
219 uint8_t state[AES_BLOCK_SIZE];
220 uint8_t round_keys[176];
221 memcpy(state, in, AES_BLOCK_SIZE);
222 aes_expand_key(key, round_keys);
223
224 aes_add_round_key(state, round_keys, 0);
225 for (uint8_t round = 1; round < 10; round++) {
226 aes_sub_bytes(state);
227 aes_shift_rows(state);
228 aes_mix_columns(state);
229 aes_add_round_key(state, round_keys, round);
230 }
231 aes_sub_bytes(state);
232 aes_shift_rows(state);
233 aes_add_round_key(state, round_keys, 10);
234 memcpy(out, state, AES_BLOCK_SIZE);
235 return true;
236}
237
238/// Perform one AES‑128 decryption block (full 10 inverse rounds).
239/// @param in 16‑byte ciphertext.
240/// @param key 16‑byte AES key.
241/// @param out Output: 16‑byte plaintext.
242/// @return true on success.
243bool aes128_decrypt_block(const uint8_t in[AES_BLOCK_SIZE], const uint8_t key[AES_KEY_SIZE],
244 uint8_t out[AES_BLOCK_SIZE]) {
245 uint8_t state[AES_BLOCK_SIZE];
246 uint8_t round_keys[176];
247 memcpy(state, in, AES_BLOCK_SIZE);
248 aes_expand_key(key, round_keys);
249
250 aes_add_round_key(state, round_keys, 10);
251 for (int round = 9; round >= 1; round--) {
252 aes_inv_shift_rows(state);
253 aes_inv_sub_bytes(state);
254 aes_add_round_key(state, round_keys, static_cast<uint8_t>(round));
255 aes_inv_mix_columns(state);
256 }
257 aes_inv_shift_rows(state);
258 aes_inv_sub_bytes(state);
259 aes_add_round_key(state, round_keys, 0);
260 memcpy(out, state, AES_BLOCK_SIZE);
261 return true;
262}
263
264} // namespace
265
266/// Proprietary checksum algorithm used in IV construction.
267/// This is NOT a standard CRC - it's a custom accumulator used by the IO-Homecontrol
268/// protocol to mix frame data into the initialization vector for AES encryption.
269void compute_checksum(uint8_t byte, uint8_t &c1, uint8_t &c2) {
270 uint8_t const tmp = byte ^ c2;
271 c2 = ((c1 & 0x7F) << 1) & 0xFF;
272 if ((c1 & 0x80) == 0) {
273 if (tmp >= 128)
274 c2 |= 1;
275 c1 = c2;
276 c2 = (tmp << 1) & 0xFF;
277 return;
278 }
279 if (tmp >= 128)
280 c2 |= 1;
281 c1 = c2 ^ 0x55;
282 c2 = ((tmp << 1) ^ 0x5B) & 0xFF;
283}
284
285/// Construct the 16-byte initialization vector (IV) for AES encryption.
286/// Layout: [bytes 0-7: frame data or 0x55 padding] [bytes 8-9: checksums] [bytes 10-15: challenge]
287/// The IV binds the HMAC to both the frame content and the random challenge,
288/// preventing replay attacks.
289void construct_iv(const uint8_t *data, uint8_t len, const uint8_t challenge[HMAC_SIZE], uint8_t iv[IV_SIZE]) {
290 memset(iv, 0, IV_SIZE);
291 uint8_t c1 = 0;
292 uint8_t c2 = 0;
293 for (uint8_t i = 0; i < len; i++) {
294 compute_checksum(data[i], c1, c2);
295 if (i < 8)
296 iv[i] = data[i];
297 }
298 // Pad remaining bytes 0-7 with 0x55 if data is shorter than 8 bytes.
299 for (uint8_t i = len; i < 8; i++)
300 iv[i] = IV_PADDING;
301 iv[8] = c1;
302 iv[9] = c2;
303 memcpy(&iv[10], challenge, HMAC_SIZE);
304}
305
306/// AES-128 ECB encrypt a single 16-byte block.
307bool aes128_encrypt(const uint8_t in[AES_BLOCK_SIZE], const uint8_t key[AES_KEY_SIZE], uint8_t out[AES_BLOCK_SIZE]) {
308 return aes128_encrypt_block(in, key, out);
309}
310
311bool aes128_decrypt(const uint8_t in[AES_BLOCK_SIZE], const uint8_t key[AES_KEY_SIZE], uint8_t out[AES_BLOCK_SIZE]) {
312 return aes128_decrypt_block(in, key, out);
313}
314
315/// Create a 6-byte HMAC for authentication (proprietary IO-Homecontrol scheme).
316/// See proto_crypto.h for full parameter documentation and construction details.
317bool create_hmac(const uint8_t *data, uint8_t len, const uint8_t challenge[HMAC_SIZE], const uint8_t key[AES_KEY_SIZE],
318 uint8_t hmac[HMAC_SIZE]) {
319 uint8_t iv[IV_SIZE];
320 construct_iv(data, len, challenge, iv);
321 uint8_t encrypted[AES_BLOCK_SIZE];
322 if (!aes128_encrypt(iv, key, encrypted))
323 return false;
324 // Truncate 16-byte AES output to 6 bytes.
325 memcpy(hmac, encrypted, HMAC_SIZE);
326 return true;
327}
328
329/// Verify a received HMAC using constant-time comparison.
330/// Full documentation in proto_crypto.h.
331bool verify_hmac(const uint8_t *data, uint8_t len, const uint8_t hmac[HMAC_SIZE], const uint8_t challenge[HMAC_SIZE],
332 const uint8_t key[AES_KEY_SIZE]) {
333 uint8_t expected[HMAC_SIZE];
334 if (!create_hmac(data, len, challenge, key, expected))
335 return false;
336 // Constant‑time comparison: OR all difference bytes.
337 uint8_t diff = 0;
338 for (uint8_t i = 0; i < HMAC_SIZE; i++) {
339 diff |= hmac[i] ^ expected[i];
340 }
341 return diff == 0;
342}
343
344/// Encrypt or decrypt a system key during pairing.
345/// The system key is XORed with AES(IV, TRANSFER_KEY) - the same operation encrypts and decrypts.
346/// The TRANSFER_KEY is a hardcoded key known to all IO-Homecontrol devices.
347bool crypt_key(const uint8_t *data, uint8_t len, const uint8_t challenge[HMAC_SIZE], const uint8_t in[AES_KEY_SIZE],
348 uint8_t out[AES_KEY_SIZE]) {
349 uint8_t iv[IV_SIZE];
350 construct_iv(data, len, challenge, iv);
351 uint8_t enc_iv[AES_BLOCK_SIZE];
352 if (!aes128_encrypt(iv, TRANSFER_KEY, enc_iv))
353 return false;
354 for (int i = 0; i < AES_KEY_SIZE; i++)
355 out[i] = in[i] ^ enc_iv[i];
356 return true;
357}
358
359/// Generate 6 random bytes for a challenge using the ESP32 hardware RNG.
360void generate_challenge(uint8_t out[HMAC_SIZE]) {
361 for (int i = 0; i < HMAC_SIZE; i++)
362 out[i] = static_cast<uint8_t>(esp_random() & 0xFF);
363}
364
365} // namespace crypto
366} // namespace home_io_control
367} // namespace esphome
368
369// NOLINTEND(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)
void compute_checksum(uint8_t byte, uint8_t &c1, uint8_t &c2)
Proprietary checksum algorithm used in IV construction.
void generate_challenge(uint8_t out[HMAC_SIZE])
Generate 6 random bytes for a challenge using the ESP32 hardware RNG.
bool create_hmac(const uint8_t *data, uint8_t len, const uint8_t challenge[HMAC_SIZE], const uint8_t key[AES_KEY_SIZE], uint8_t hmac[HMAC_SIZE])
Create a 6-byte HMAC for authentication (proprietary IO-Homecontrol scheme).
bool aes128_decrypt(const uint8_t in[AES_BLOCK_SIZE], const uint8_t key[AES_KEY_SIZE], uint8_t out[AES_BLOCK_SIZE])
AES‑128 ECB decrypt a single 16‑byte block.
bool verify_hmac(const uint8_t *data, uint8_t len, const uint8_t hmac[HMAC_SIZE], const uint8_t challenge[HMAC_SIZE], const uint8_t key[AES_KEY_SIZE])
Verify a received HMAC using constant-time comparison.
void construct_iv(const uint8_t *data, uint8_t len, const uint8_t challenge[HMAC_SIZE], uint8_t iv[IV_SIZE])
Construct the 16-byte initialization vector (IV) for AES encryption.
bool aes128_encrypt(const uint8_t in[AES_BLOCK_SIZE], const uint8_t key[AES_KEY_SIZE], uint8_t out[AES_BLOCK_SIZE])
AES-128 ECB encrypt a single 16-byte block.
bool crypt_key(const uint8_t *data, uint8_t len, const uint8_t challenge[HMAC_SIZE], const uint8_t in[AES_KEY_SIZE], uint8_t out[AES_KEY_SIZE])
Encrypt or decrypt a system key during pairing.
static constexpr uint8_t AES_BLOCK_SIZE
AES block size.
Definition proto_frame.h:84
static constexpr uint8_t TRANSFER_KEY[AES_KEY_SIZE]
The transfer key is a hardcoded key used ONLY during pairing to obfuscate the system key during over-...
static constexpr uint8_t HMAC_SIZE
Authentication HMAC is 6 bytes (truncated AES output).
Definition proto_frame.h:82
static constexpr uint8_t AES_KEY_SIZE
AES-128 key size.
Definition proto_frame.h:83
static constexpr uint8_t IV_PADDING
Padding byte used in IV construction.
Definition proto_frame.h:86
static constexpr uint8_t IV_SIZE
Initialization vector size for AES.
Definition proto_frame.h:85
Cryptographic helpers for the IO‑Homecontrol protocol.