Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Nice Flor-s decryption (see PR #2238) #2344

Closed
uski opened this issue Jan 24, 2023 · 10 comments
Closed

Implement Nice Flor-s decryption (see PR #2238) #2344

uski opened this issue Jan 24, 2023 · 10 comments
Labels
device support Request for a new/improved device decoder feedback request for more information; may be closed id 30d if not received

Comments

@uski
Copy link

uski commented Jan 24, 2023

Hi!

Feature request time!

The protocol to encrypt and decrypt Nice Flor-s encryption has been published here: https://github.com/DarkFlippers/unleashed-firmware/blob/dev/lib/subghz/protocols/nice_flor_s.c

It can be implemented in rtl_433. Currently rtl_433 does support Flor-s, but it does not decrypt the remote ID, which means that every time the remote is pressed, the ID seems random. This greatly reduces the usefulness of the decoder. Decoding the remote ID would allow using Nice Flor-s remotes completely.

The only issue is that for some reason, they have decided to obfuscate the encryption key. It is stored as an encrypted asset, decrypted through the secure enclave of the Flipper Zero. It should be possible to decrypt it by building an alternative firmware to Flipper Zero and simply doing a printf() of the decrypted bitstream, or by doing a bit more exploration of the Flipper Zero to discover the encryption key. No idea what they were thinking when doing this.

@zuckschwerdt
Copy link
Collaborator

Possible dup of #2238

It's very unlikely that we add AES support or unrolled tables to support complex decryption.
We can however add e.g. a Python example to read the raw data from rtl_433 and decrypt.

@uski
Copy link
Author

uski commented Jan 24, 2023

The AES is just used to obfuscate the master key within the Flipper Zero. AES is not used for the actual Flor-S algorithm.

Once the master key is deobfuscated it can be stored in plain text in rtl_433 and no encryption is required besides basic stuff like xor.

@uski
Copy link
Author

uski commented Jan 24, 2023

If you look at the encrypted master key, it is very short: https://github.com/DarkFlippers/unleashed-firmware/blob/dev/assets/resources/subghz/assets/nice_flor_s

The IV is obfuscated through some short assembly code visible in the firmware of Flipper Zero

I think the course of action is to find anyone with a Flipper Zero and just printf() the decrypted key. If I had a Flipper Zero I'd have done it already, but I don't unfortunately

Then it is just a matter of porting the decryption function

@zuckschwerdt
Copy link
Collaborator

There is a working decryption in that PR I take it? Not sure why the 16-bit lookup is needed if the decryption is an xor stream though.

@merbanan
Copy link
Owner

I have 2 Flipper Zeros. Post some instructions and I'll eventually get to it.

@jurek4321
Copy link

@merbanan
To read this decryption tables from flipper zero you will need to modify source to display decrypted keys.
You can see here https://github.com/DarkFlippers/unleashed-firmware/blob/dev/lib/subghz/subghz_keystore.c
In this file there is function called subghz_keystore_raw_get_data, in this function after line furi_hal_crypto_store_unload_key(SUBGHZ_KEYSTORE_FILE_ENCRYPTION_KEY_SLOT);
You will need to add :
for(int i = 0; i < len/4; i++) { FURI_LOG_E(TAG, "Decrypted bytes: %02X %02X %02X %02X\n", data[i*4], data[1+i*4], data[2+i*4], data[3+i*4]); }

Then you will need to compile modified firmware and flash it to flipper, after that you will be able to see decrypted keys in serial console when you connect device via usb and connect to it using putty or something.

You can also see decrypted keeloq keys in similar way,
In function subghz_keystore_process_line(SubGhzKeystore* instance, char* line) before uint64_t key = 0; you can add
FURI_LOG_E(TAG, "Decrypted key: %s\r\n", line);.
Then you will see decrypted keeloq keys in serial console.

I'm interested in DTM Neo key if anyone has it.

@merbanan
Copy link
Owner

merbanan commented May 5, 2023

@jurek4321
Copy link

Maybe it is, that is interesting why they encrypted it if it is in comments in code.
You can try to modify firmware and compare if encrypted key is the same as this in comments.

@gdt gdt added device support Request for a new/improved device decoder discuss Way forward is unclear; discussion is needed labels Sep 27, 2023
@gdt gdt changed the title Implement Nice Flor-s decryption Implement Nice Flor-s decryption (see PR #2238) Sep 27, 2023
@gdt
Copy link
Collaborator

gdt commented Oct 15, 2023

Where are we on this? Is there information here that isn't in #2238 (e.g as comments)? It would be nice to make progress to just have a PR, even if we are still going to argue about doctrine of including AES in rtl_433.

@gdt gdt added feedback request for more information; may be closed id 30d if not received and removed discuss Way forward is unclear; discussion is needed labels Oct 15, 2023
@gdt
Copy link
Collaborator

gdt commented Jun 4, 2024

Closing this in favor of the PR, after no response to asking if there is info in the issue but not the PR, in 7.5 months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
device support Request for a new/improved device decoder feedback request for more information; may be closed id 30d if not received
Projects
None yet
Development

No branches or pull requests

5 participants