Bug 445955 - paring keys dont match
Summary: paring keys dont match
Status: RESOLVED FIXED
Alias: None
Product: kdeconnect
Classification: Applications
Component: android-application (other bugs)
Version First Reported In: 1.10
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-23 02:50 UTC by John Andrew McInnes
Modified: 2022-05-30 21:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Andrew McInnes 2021-11-23 02:50:44 UTC
SUMMARY
When paring android phone with PC, the PC plasmoid app shows a key that has 2 extra digits: 32. The key on the phone does not have this. The keys do not match.


STEPS TO REPRODUCE
1. Pair phone with PC
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma:  kdeconnect-kde-21.08.3-1.1.x86_64
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Android: v1.18
Comment 1 Bug Janitor Service 2022-05-25 00:06:12 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kdeconnect-android/-/merge_requests/286
Comment 2 Nicolas Fella 2022-05-30 21:28:07 UTC
Git commit 8f49ff57ab43961bea65cddd35b250f7f5301567 by Nicolas Fella, on behalf of Ravi Mistry.
Committed on 30/05/2022 at 21:28.
Pushed by nicolasfella into branch 'master'.

Fix byte array conversions

## Summary

Currently, KDE Connect for Android doesn't show the last 2 characters of the verification key when pairing a device. This MR solves this issue.

This bug is caused by incomplete conversions from byte arrays to strings in `SslHelper.java`:

```java
for (int i = 0; i < hash.length - 1; i++) {
    formatter.format("%02x", hash[i]);
}
```
The ```i < hash.length -1``` converts the bytes in the array up to (inclusive) the penultimate one. Removing the ```- 1``` allows for the last byte to be converted (this is the missing 2 characters).

## Test Plan

### Before:
Selecting a desktop from the available devices, then clicking the `Request Pairing` button causes a 62 character key to be displayed. It is 2 characters short of the actual key, which can be seen on the desktop KDE Connect app.

### After:
Selecting the `Request Pairing` button now shows the whole verification key, as intended.

M  +2    -2    src/org/kde/kdeconnect/Helpers/SecurityHelpers/SslHelper.java

https://invent.kde.org/network/kdeconnect-android/commit/8f49ff57ab43961bea65cddd35b250f7f5301567