Shorten pairing key to 8 chars

The previous key was 64 freakin characters long which made it more prone
to being ignored, and thus less secure.
This commit is contained in:
Albert Vaca Cintora
2024-05-17 10:41:01 +02:00
parent 27075e89be
commit 343270c793
3 changed files with 5 additions and 5 deletions

View File

@@ -182,8 +182,8 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
<string name="remote_device_fingerprint">SHA256 fingerprint of remote device certificate is:</string>
<string name="pair_requested">Pair requested</string>
<string name="pair_succeeded">Pair succeeded</string>
<string name="pairing_request_from">Pairing request from %1s</string>
<string name="pairing_verification_code" translatable="false">🔑%1s...</string>
<string name="pairing_verification_code" translatable="false">🔑 %1s</string>
<string name="pairing_request_from">Pairing request from "%1s"</string>
<plurals name="incoming_file_title">Receiving file from %1s>
<item quantity="one">Receiving %1$d file from %2$s</item>
<item quantity="other">Receiving %1$d files from %2$s</item>

View File

@@ -278,11 +278,11 @@ public class Device implements BaseLink.PacketReceiver {
final NotificationManager notificationManager = ContextCompat.getSystemService(getContext(), NotificationManager.class);
String verificationKeyShort = SslHelper.getVerificationKey(SslHelper.certificate, deviceInfo.certificate).substring(8);
String verificationKey = SslHelper.getVerificationKey(SslHelper.certificate, deviceInfo.certificate);
Notification noti = new NotificationCompat.Builder(getContext(), NotificationHelper.Channels.DEFAULT)
.setContentTitle(res.getString(R.string.pairing_request_from, getName()))
.setContentText(res.getString(R.string.pairing_verification_code, verificationKeyShort))
.setContentText(res.getString(R.string.pairing_verification_code, verificationKey))
.setTicker(res.getString(R.string.pair_requested))
.setSmallIcon(R.drawable.ic_notification)
.setContentIntent(pendingIntent)

View File

@@ -298,7 +298,7 @@ public class SslHelper {
for (byte value : hash) {
formatter.format("%02x", value);
}
return formatter.toString();
return formatter.toString().substring(0,8).toUpperCase(Locale.ROOT);
} catch(Exception e) {
e.printStackTrace();
return "error";