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