Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Potential fix for #5 wrong fingerprints
Browse files Browse the repository at this point in the history
  • Loading branch information
COM8 committed Feb 10, 2019
1 parent dbffe25 commit 11e86bd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
4 changes: 3 additions & 1 deletion UWPX_UI/Controls/Settings/AccountOmemoInfoControl.xaml
Expand Up @@ -14,7 +14,9 @@
<omemo:OmemoDeviceIdStringValueConverter x:Key="OmemoDeviceIdStringValueConverter"/>
</UserControl.Resources>

<ScrollViewer HorizontalScrollMode="Disabled">
<ScrollViewer Margin="0,0,-10,0"
Padding="0,0,10,0"
HorizontalScrollMode="Disabled">
<StackPanel>
<TextBlock>
<Run FontWeight="Bold"
Expand Down
Expand Up @@ -14,6 +14,12 @@ public string Fingerprint
get { return _Fingerprint; }
set { SetProperty(ref _Fingerprint, value); }
}
private string _QrCodeFingerprint;
public string QrCodeFingerprint
{
get { return _QrCodeFingerprint; }
set { SetProperty(ref _QrCodeFingerprint, value); }
}

#endregion
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\
Expand All @@ -36,14 +42,17 @@ public void UpdateView(AccountDataTemplate account)
if (!(key is null))
{
Fingerprint = CryptoUtils.genOmemoFingerprint(key);
return;
QrCodeFingerprint = CryptoUtils.genOmemoQrCodeFingerprint(key, account.Account);
}
else
{
Fingerprint = "Failed to load fingerprint!";
QrCodeFingerprint = null;
}
return;
}
Fingerprint = "";
QrCodeFingerprint = null;
}

#endregion
Expand Down
18 changes: 18 additions & 0 deletions XMPP_API/Classes/Crypto/CryptoUtils.cs
Expand Up @@ -12,6 +12,7 @@
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
using XMPP_API.Classes.Network;

namespace XMPP_API.Classes.Crypto
{
Expand Down Expand Up @@ -153,6 +154,23 @@ public static string genOmemoFingerprint(IdentityKey key)
return Regex.Replace(fingerprint, ".{8}", "$0 ");
}

/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="account"></param>
/// <returns></returns>
public static string genOmemoQrCodeFingerprint(IdentityKey key, XMPPAccount account)
{
StringBuilder sb = new StringBuilder("xmpp:");
sb.Append(account.getIdAndDomain());
sb.Append("?omemo-sid-");
sb.Append(account.omemoDeviceId);
sb.Append('=');
sb.Append(byteArrayToHexString(key.serialize()));
return sb.ToString();
}

public static void nextBytesSecureRandom(out byte[] b, in uint length)
{
IBuffer buf = CryptographicBuffer.GenerateRandom(length);
Expand Down

0 comments on commit 11e86bd

Please sign in to comment.