Stated making SLH algorithm

This commit is contained in:
r3df0xx
2022-04-09 00:29:15 +03:00
parent cc68dd585b
commit 683680fd97
3 changed files with 75 additions and 17 deletions

View File

@@ -81,4 +81,21 @@ inline uint64_t
subghz_protocol_keeloq_common_magic_xor_type1_learning(uint32_t data, uint64_t xor) {
data &= 0x0FFFFFFF;
return (((uint64_t)data << 32) | data) ^ xor;
}
/** Faac SLH (Spa) Learning
* @param data - fix number (32bit)
* @param seed - seed number (32bit)
* @param key - mfkey (64bit)
* @return man_learning for this fix number (64bit)
*/
inline uint64_t
subghz_protocol_keeloq_common_faac_learning(uint32_t data, uint32_t seed, const uint32_t key) {
uint32_t k1, k2;
uint16_t hs = seed >> 16;
uint32_t lsb = (uint32_t)hs << 16 | 0x544D;
k1 = subghz_protocol_keeloq_common_encrypt(seed, key);
k2 = subghz_protocol_keeloq_common_encrypt(lsb, key);
return ((uint64_t)k1 << 32) | k2;
}