2021-10-18 01:54:19 +03:00
|
|
|
#pragma once
|
2022-03-03 12:48:56 +03:00
|
|
|
|
|
|
|
#include "base.h"
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
#include <furi.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keeloq
|
|
|
|
* https://ru.wikipedia.org/wiki/KeeLoq
|
|
|
|
* https://phreakerclub.com/forum/showthread.php?t=1094
|
|
|
|
*
|
|
|
|
*/
|
2021-11-17 16:52:06 +03:00
|
|
|
#define KEELOQ_NLF 0x3A5C742E
|
2021-10-18 01:54:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* KeeLoq learning types
|
|
|
|
* https://phreakerclub.com/forum/showthread.php?t=67
|
|
|
|
*/
|
2021-11-17 16:52:06 +03:00
|
|
|
#define KEELOQ_LEARNING_UNKNOWN 0u
|
|
|
|
#define KEELOQ_LEARNING_SIMPLE 1u
|
|
|
|
#define KEELOQ_LEARNING_NORMAL 2u
|
|
|
|
#define KEELOQ_LEARNING_SECURE 3u
|
2022-01-21 16:55:09 +03:00
|
|
|
#define KEELOQ_LEARNING_MAGIC_XOR_TYPE_1 4u
|
2022-04-09 00:29:15 +03:00
|
|
|
#define KEELOQ_LEARNING_FAAC 5u
|
2022-09-22 18:01:54 +03:00
|
|
|
#define KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_1 6u
|
2022-10-28 18:03:31 +03:00
|
|
|
#define KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_2 7u
|
|
|
|
#define KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_3 8u
|
2021-10-18 01:54:19 +03:00
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
/**
|
|
|
|
* Simple Learning Encrypt
|
2021-10-18 01:54:19 +03:00
|
|
|
* @param data - 0xBSSSCCCC, B(4bit) key, S(10bit) serial&0x3FF, C(16bit) counter
|
|
|
|
* @param key - manufacture (64bit)
|
2022-03-03 12:48:56 +03:00
|
|
|
* @return keeloq encrypt data
|
2021-10-18 01:54:19 +03:00
|
|
|
*/
|
|
|
|
uint32_t subghz_protocol_keeloq_common_encrypt(const uint32_t data, const uint64_t key);
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
/**
|
|
|
|
* Simple Learning Decrypt
|
2022-03-03 12:48:56 +03:00
|
|
|
* @param data - keeloq encrypt data
|
2021-10-18 01:54:19 +03:00
|
|
|
* @param key - manufacture (64bit)
|
|
|
|
* @return 0xBSSSCCCC, B(4bit) key, S(10bit) serial&0x3FF, C(16bit) counter
|
|
|
|
*/
|
|
|
|
uint32_t subghz_protocol_keeloq_common_decrypt(const uint32_t data, const uint64_t key);
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
/**
|
|
|
|
* Normal Learning
|
2021-10-18 01:54:19 +03:00
|
|
|
* @param data - serial number (28bit)
|
|
|
|
* @param key - manufacture (64bit)
|
|
|
|
* @return manufacture for this serial number (64bit)
|
|
|
|
*/
|
|
|
|
uint64_t subghz_protocol_keeloq_common_normal_learning(uint32_t data, const uint64_t key);
|
2021-11-17 16:52:06 +03:00
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
/**
|
|
|
|
* Secure Learning
|
2021-11-17 16:52:06 +03:00
|
|
|
* @param data - serial number (28bit)
|
2022-01-21 16:55:09 +03:00
|
|
|
* @param seed - seed number (32bit)
|
2021-11-17 16:52:06 +03:00
|
|
|
* @param key - manufacture (64bit)
|
|
|
|
* @return manufacture for this serial number (64bit)
|
|
|
|
*/
|
|
|
|
uint64_t
|
2022-01-21 16:55:09 +03:00
|
|
|
subghz_protocol_keeloq_common_secure_learning(uint32_t data, uint32_t seed, const uint64_t key);
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
/**
|
|
|
|
* Magic_xor_type1 Learning
|
2022-01-21 16:55:09 +03:00
|
|
|
* @param data - serial number (28bit)
|
|
|
|
* @param xor - magic xor (64bit)
|
|
|
|
* @return manufacture for this serial number (64bit)
|
|
|
|
*/
|
|
|
|
uint64_t subghz_protocol_keeloq_common_magic_xor_type1_learning(uint32_t data, uint64_t xor);
|
2022-04-09 00:29:15 +03:00
|
|
|
|
|
|
|
/** Faac SLH (Spa) Learning
|
|
|
|
* @param seed - seed number (32bit)
|
|
|
|
* @param key - mfkey (64bit)
|
|
|
|
* @return man_learning for this fix number (64bit)
|
|
|
|
*/
|
2022-04-09 15:15:36 +03:00
|
|
|
uint64_t subghz_protocol_keeloq_common_faac_learning(const uint32_t seed, const uint64_t key);
|
2022-09-22 18:01:54 +03:00
|
|
|
|
|
|
|
/** Magic_serial_type1 Learning
|
|
|
|
* @param data - serial number (28bit)
|
|
|
|
* @param man - magic man (64bit)
|
|
|
|
* @return manufacture for this serial number (64bit)
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint64_t subghz_protocol_keeloq_common_magic_serial_type1_learning(uint32_t data, uint64_t man);
|
2022-10-28 17:31:41 +03:00
|
|
|
|
|
|
|
/** Magic_serial_type2 Learning
|
|
|
|
* @param data - btn+serial number (32bit)
|
|
|
|
* @param man - magic man (64bit)
|
|
|
|
* @return manufacture for this serial number (64bit)
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint64_t subghz_protocol_keeloq_common_magic_serial_type2_learning(uint32_t data, uint64_t man);
|
|
|
|
|
|
|
|
/** Magic_serial_type3 Learning
|
|
|
|
* @param data - btn+serial number (32bit)
|
|
|
|
* @param man - magic man (64bit)
|
|
|
|
* @return manufacture for this serial number (64bit)
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint64_t subghz_protocol_keeloq_common_magic_serial_type3_learning(uint32_t data, uint64_t man);
|