keeeloq update

This commit is contained in:
MX 2022-09-22 18:01:54 +03:00
parent de6ff1d9c9
commit e13edc2f70
No known key found for this signature in database
GPG Key ID: 6C4C311DFD4B4AB5
4 changed files with 101 additions and 47 deletions

View File

@ -1,48 +1,51 @@
Filetype: Flipper SubGhz Keystore File Filetype: Flipper SubGhz Keystore File
Version: 0 Version: 0
Encryption: 1 Encryption: 1
IV: F2 D4 F5 5A B3 CC 3F 21 28 3A AF ED D1 EB 73 DF IV: 2A 34 F1 5A AF 6F F5 1A 83 A6 1E DA DE B7 3D F1
BBFA4D79A73C384D6E07E717F761F32A625F28AA1DB2261B8B19A18261E30AB6 06B63DF24AE073A2F2B19C55CA9E8364FBECD26E49C551990153F6513BDE5267
CE4004AB56111B0B3D486770705FAD8BD616A80957EA2C537BAF1FD09E552DA3 6139C78C74C341EB7474085CF1D047BD6FB005F80A72AF3EF3F89D58EF5DF500
F974561612C9C751237C64D978F706B41873FDBE38851306574F436CB02D9ECA D85F11689020ECA47FBE9C2B67EE41A81E1F06DE2A35AF958965E3ECE29EA701
E29CAB7C2C2D9853D0F4DF69F582562E8182234E78B355540F6FE3F78C73D518 1AE9073A42FE0E439544FE6945F6B33CF15A7A4A279020B5E0B3BE33FD189A7E
97ABE18993A700A607E37DC88E1434F84DDD1C2771693978C9D2FA4CE4F2AB7BBC7C3EB3E8545B37FBBE1C1F1CA03543 E161F007854BB33E0056FA09A2E2DEE66789B5C87C8D6D3DE2C8C1BD2B48983EB9D1C5697CA6E95996918F7C47B761B0
E86ABD0AAE5A4B4A9414C9CB6112CA49B3A8EC29723B14DCA85902F41B05ADDC 59AE4644DCB3D720C38B5115F230DA58E7BE0A697907F6174BB05AB7886ACDB1
C1FBE921035F408C59DA6AD5E76E3887AC9BC90146619B3CAE445BED556E96AC 634DF0BCC185C4C1F7E1B1594B4438D051ABAE092433078963063B51D961D08C
232C9F86915B927888352797B45F159268FE78956CF09B8D241CDC393D3B0225 1EBEBCB49E498B9BE977D53EC21B9A546155B627737BD0AA832D496035729346
3D9E2A3C701C9D4DD4D72038D4536CA6F515C547CAB0AD18BA71204BD2ABFB74 4DFA93E639197772D57E8ACE04512CEFC045B8CC965C175A25ED525B630CBB63
4D69A4506D2C97EF8EC68F90CF1AD1065A1EB909793EEB3AF71B0D75E55B9E76 C2D5235D1014A319B249EAE8A5EE350F18D5AB8A498EF222704BD4EB1435F388
5A7F4595DFA181C3E946EBEE4974DBD6DA85AF6FCAD0B3725FDD28667175A421D69A2122853E57927C38CCF368732476 F66D1937160E1392197F463A52E87FCE938A92070892113443C348D7553327A5715CF615CE2F2C96284F47759E043419
6A946FAEDE134155B5A88EC01AA535E7A778947D360218B560381A64CAF9ACE896079D04C14718D5AD5C0D4EE3005F52 841D29E7CBE040188E2283BFBA9F26EF2F65CCB085B56C3515E8C46C3F20BD75BAA963550869435FDAF509CEEE66A2C4
88AC0C723AAA875A1885C8392A616FA43B205119B0E8D299193979A1921FC8B3 7D87E24487D307635E7A17B989B8547EE11F3BF3468D055F0B44633B631BA42C
40588AADA5E1A8BE214B2CCF32D268B48C6B783AE0DD10D88BDF3FF88E921E09 B4916043973501B95A82B329196D6EBA69FBBC3AF8FD914583104E0E18CE82F6
A7BE05D05DEC9B9A3AE1575D411BF7B12366AD78B726F3E3E843E7BF199961A4 E4649F9C2A5465D2EA6F3E9724DD06CD6962FE2BAEB14F1453C14D1559232AE1
79F973A155A4367F0EAA078AA0857A2A2A82FC4C8A5AE9E567E7CBF62C2A5CE2 96E15D890DF7FD348441F5E429A875754C6BF0520A787F8E9D8C5415674783CC
C38296EEABDA1F95D0C401CC6DDC8656476DC19248588EEF1CB93773D94CDB02A40C902970C4FCB14FABEFFB4F8BC208 CB52005EDED47B57F795BC92FB0522EAB18D23EE028B8D10ED57828C250EB285BFEC6E4A4BE8DABCE0D57ECAA20D90C3
B0B7699B3C3573EE4D88D8CE65FAF3532B5A741D1F20892C0F38BAA2BCE98F2D 8E5A50C7D5C374445E88752301D20F0B3D6E4988B61D90FD63779B0EDEF9C60D
6E401D6BDB1B33A404DEB668F3FB353166475487BAADE4A348E3CFDEB3B1B54B 49D6CB276A0E5FF134A38062503F01351F44CD6455708B50B5F07D03FC477C33
0E44B87878617559783CC6A7C65BE9F99950FE8956ED4BB04894BC53085E3A09CA19915B1E8C143A68D1B7A97F5D1ECB CB45B56613DF208E79E4E10A6510F07DC1AA49210C7B94E8BBAECD2C35EC6ABC99FB10FD7C96DD6BB6A6685E9FAD93FB
AC19E55638429C65E6E567C0E96DA9648F8FB80215CF693D7FD5DD86FE7989AC7AC7BAE86BBD4FFF7161AFFB405FFA98 0743F3CC51200F763C242F1956B4D775C092ADF1A5C19ACAE96EB60C2990CF214F8FEA8FC6749286F6BDAB67657C479A
BCE70C69D90AD639A737813FC8FD26F40F803137BD36E47651C266A671428D6F E5608B28A058787D64A145F0362DEFD98CAE0B5A0F22C6DA7C6D278C7B5F95E3
F053CF5255AD2E1875A5C38635F7BF203B1DAE1433B162C30AE8695AC8A5589D D4C113D43E7FB6D2EFA9E87471AA76A61B26872607B4AF5B87F9D72113835CE6
B7EFC77FFA98B173E429B3566A27842C4DC5E91B0BC01F07A6A98332C4E1F42A 2DC502800BFD21B76126390CA64A08C5432A2254E822F214CDE1EA11430084C5
D7C7950FFB2C5E7D9BCDBC230BF5F1BFFC0FE6F1CF5C8C6013DD90E41AE403FE CA22C73010B0F1CB8009601BE2AF0B3674D83D5880E4A26C2A3FF0EA0A098CEA
50667B2E5909FD5F9D6385788A81DE5F72E56512EAD6BF5EACCA959CB6AF0DEF E53B2B102FDB000E9BB747F957156976E5A0C0E3898AA844C13AE8A9CEE7013B
6BDDE1EA185EA975343C161DF358E0AE71007DE13EE8CD26683C28B21470B910 EFB27324B5661419265804ABD130C13DC9DF9CD4D2AC2011CB4FD43D56304AD1
8128188D151CB4D465427768BF811B1AF5345801BF6F5C937A11F0485F90CA46 491D75A82ACE8CE216FBE4F0D2D0133BAC7EA8F4A5304337D5E8611AD9C72523
9FF6331E570479788C2D61916DB48DDE534F8C049056D4E3216ADCB37C9556A6 BBFA2B00827E0BCC8AC5CE12C972BB58DFA2EA59DFEFF5A538398FCF970F58A7
0636731CB79FC7459BAFA37E704D58765551631F3936892FD244CF989127540A 6BAF9C855926B683BEDC11883543B2C0E0866FF6B06C46CC09B3C4E1200E7716
ECB48EF5C599D4A5F1FD39A62A06EF910B1B4973BFBFDFEF61F00C81E87847BA B35A4D25FF4D5CFF93B9C4C07B78FCF7E2646138DAB7C090A938C8055CCCE3D8
AAC73DC804600A04BD962F7C5B9ACA99F3769EED9F2DD7AF8338E7220271090F 71CC3C0180771E6B304CE984F5A9962EB35D1965CB78EBAE6F4DDFA44E5E02A2
3EA4D2329D0BA54E80AF71966BD74CB13C21DF8010EE795BCCCE6A580EC05758 3DCF52C549FEFCCE2831DB74579AA2C157A4BEE70C43905664C9A6491A171F5D
F491DE599DA31EA9A51509B69846C6C1FB6AB5BBE3AA5915D51225F205A55EC2 F7E45AF200F7663DCCE54C14118D2CDFD1228ED0BFF7F70CFBCE15B6F9DF3D40
54347F82D73E4B66569DAAB52B03EB5A6440F9FDFD302454B84B4E41E0E7E55C C44E048AD5C003E68DCF0111317D109CF2B7DD79299692CDA7DA2A12EC9A295A
28BBAB93FEB24CE27C47B068C065A294758CECBC3531FA691D085D2B10D189616DB074AC6F8D75BBE176A9459347968C 2B3E6778A97B251A5FEB190991B8AE8EC48F5FC6E94C2ECB8DFADFDD9D8E21FEE5DCCEDD9A1EB8C5212DEAE36FBBDF92
61260BD3C4FCEF8208CC88682032E4FE295F8D000998302AD11D8D643A30EC4F 1DD4756E681528CBBDBA6C7BF8833DF556D41E5EA4E4DE52CAD3544C946CD8CA
97309829406F5CF8FA15565F8F6CF53DEA0E5C0B59DD657A2BB1F58FBCF3DF7F F903D388CF2016B40B492494F7475E71C50E9FDD63304558212DAF6FBC4E1BA4
EA622706F837A37D84D806F15E73D6B95658129F9E12170587200BFB8BDBAEEA 9E9F24951DB27917668CD6366795052306022F6F8BA11B08A970691C6857E6C5
67EAFE49F7872D6EBDB4127E5107D9EB147393038DBAC4D6C4916AD7668C463D C88461104FA0EAA68001B0C2D0483D1A53D6AE04F4CB291C76CEF3A1A5C5DC10
65D7D3225DEAE1BA33F1EAB6F14E817C9D47646123E02C9D4C1BEAF46DD9DF547FE9AD432E1CD648165AE10D7D240B88 8345B2B9F08B018FEAC2F74D76747FF30DBF426C9B390ACD42AD48104C12042E
223158904F64C174A87ED14F1CACB86DA9AD7D0ED32AEB2A7E955715498969FB 087269DC66C76E1D6449831A2C3B6F0006C0F8B1861062B95708C6B222C58A9C
9CA01D5797B93547F246CB06EDD96CABECE27E0BAB6D090681B63E83AD4F2167 4D31DE05DB12E552D43B1017C68AF3F52B6FE8063E4AD82CB568CDAF22950BCC26FF21EE968FB57650111B617A84DEF7
AD0BF3A0C1ECDF869BF3022AAA0065941F1D354CCE346B47740D2794FD042D47 769BAA780F84797431B6E9DD5180AF3848E03C942C67040B39CC6384E2A8F4C6
1844AAAAD6A6AFB2623DF1452DF940715E6EB92F54C49F408872EC4B2156DDB2
23EB39CD7F3921081199BA8B63D4C19F74365F8D8E71D486576DC900E5EFEEA3
45958B93A16A73CA2578ADCFB1EADAA983BB7015321B0592B67CDF573B084194

View File

@ -181,6 +181,12 @@ static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instanc
instance->generic.serial, manufacture_code->key); instance->generic.serial, manufacture_code->key);
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man); hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
break; break;
case KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_1:
//Magic Serial Type 1 learning
man = subghz_protocol_keeloq_common_magic_serial_type1_learning(
fix, manufacture_code->key);
hop = subghz_protocol_keeloq_common_encrypt(decrypt, man);
break;
case KEELOQ_LEARNING_UNKNOWN: case KEELOQ_LEARNING_UNKNOWN:
if(kl_type == 1) { if(kl_type == 1) {
hop = hop =
@ -610,6 +616,16 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
return 1; return 1;
} }
break; break;
case KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_1:
man = subghz_protocol_keeloq_common_magic_serial_type1_learning(
fix, manufacture_code->key);
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
*manufacture_name = string_get_cstr(manufacture_code->name);
mfname = *manufacture_name;
return 1;
}
break;
case KEELOQ_LEARNING_UNKNOWN: case KEELOQ_LEARNING_UNKNOWN:
// Simple Learning // Simple Learning
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key); decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
@ -619,6 +635,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
kl_type = 1; kl_type = 1;
return 1; return 1;
} }
// Check for mirrored man // Check for mirrored man
uint64_t man_rev = 0; uint64_t man_rev = 0;
uint64_t man_rev_byte = 0; uint64_t man_rev_byte = 0;
@ -626,6 +643,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
man_rev_byte = (uint8_t)(manufacture_code->key >> i); man_rev_byte = (uint8_t)(manufacture_code->key >> i);
man_rev = man_rev | man_rev_byte << (56 - i); man_rev = man_rev | man_rev_byte << (56 - i);
} }
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev); decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev);
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) { if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
*manufacture_name = string_get_cstr(manufacture_code->name); *manufacture_name = string_get_cstr(manufacture_code->name);
@ -633,6 +651,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
kl_type = 1; kl_type = 1;
return 1; return 1;
} }
//########################### //###########################
// Normal Learning // Normal Learning
// https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37 // https://phreakerclub.com/forum/showpost.php?p=43557&postcount=37
@ -696,6 +715,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
kl_type = 4; kl_type = 4;
return 1; return 1;
} }
break; break;
} }
} }
@ -748,6 +768,16 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
return 1; return 1;
} }
break; break;
case KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_1:
man = subghz_protocol_keeloq_common_magic_serial_type1_learning(
fix, manufacture_code->key);
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
*manufacture_name = string_get_cstr(manufacture_code->name);
mfname = *manufacture_name;
return 1;
}
break;
case KEELOQ_LEARNING_UNKNOWN: case KEELOQ_LEARNING_UNKNOWN:
// Simple Learning // Simple Learning
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key); decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
@ -836,6 +866,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
kl_type = 4; kl_type = 4;
return 1; return 1;
} }
break; break;
} }
} }
@ -925,7 +956,7 @@ bool subghz_protocol_decoder_keeloq_deserialize(void* context, FlipperFormat* fl
seed_data[sizeof(uint32_t) - i - 1] = (instance->generic.seed >> i * 8) & 0xFF; seed_data[sizeof(uint32_t) - i - 1] = (instance->generic.seed >> i * 8) & 0xFF;
} }
if(!flipper_format_read_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) { if(!flipper_format_read_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) {
FURI_LOG_E(TAG, "DECODER: Missing Seed"); FURI_LOG_D(TAG, "DECODER: Missing Seed");
} }
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
seed_data[3]; seed_data[3];

View File

@ -102,3 +102,14 @@ inline uint64_t
subghz_protocol_keeloq_common_encrypt(lsb, key); subghz_protocol_keeloq_common_encrypt(lsb, key);
return man; return man;
} }
/** Magic_serial_type1 Learning
* @param data - serial number (28bit)
* @param man - magic man (64bit)
* @return manufacture for this serial number (64bit)
*/
inline uint64_t
subghz_protocol_keeloq_common_magic_serial_type1_learning(uint32_t data, uint64_t man) {
return man | ((uint64_t)data << 40) |
((uint64_t)(((data & 0xff) + ((data >> 8) & 0xFF)) & 0xFF) << 32);
}

View File

@ -22,6 +22,7 @@
#define KEELOQ_LEARNING_SECURE 3u #define KEELOQ_LEARNING_SECURE 3u
#define KEELOQ_LEARNING_MAGIC_XOR_TYPE_1 4u #define KEELOQ_LEARNING_MAGIC_XOR_TYPE_1 4u
#define KEELOQ_LEARNING_FAAC 5u #define KEELOQ_LEARNING_FAAC 5u
#define KEELOQ_LEARNING_MAGIC_SERIAL_TYPE_1 6u
/** /**
* Simple Learning Encrypt * Simple Learning Encrypt
@ -71,3 +72,11 @@ uint64_t subghz_protocol_keeloq_common_magic_xor_type1_learning(uint32_t data, u
* @return man_learning for this fix number (64bit) * @return man_learning for this fix number (64bit)
*/ */
uint64_t subghz_protocol_keeloq_common_faac_learning(const uint32_t seed, const uint64_t key); uint64_t subghz_protocol_keeloq_common_faac_learning(const uint32_t seed, const uint64_t key);
/** 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);