diff --git a/Component_Tests/Classes/Crypto/Omemo/Test_KeyHelper.cs b/Component_Tests/Classes/Crypto/Omemo/Test_KeyHelper.cs index 3c55217d..da4b842c 100644 --- a/Component_Tests/Classes/Crypto/Omemo/Test_KeyHelper.cs +++ b/Component_Tests/Classes/Crypto/Omemo/Test_KeyHelper.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; -using NSec.Cryptography; using Omemo.Classes; using Omemo.Classes.Keys; +using Org.BouncyCastle.Math.EC.Rfc8032; using Shared.Classes; namespace Component_Tests.Classes.Crypto.Omemo @@ -56,7 +56,9 @@ public void Test_SignPreKey() for (uint id = 1; id < 250; id++) { byte[] data = Encoding.ASCII.GetBytes("Message for Ed25519 signing"); - byte[] signature = SignatureAlgorithm.Ed25519.Sign(Key.Import(SignatureAlgorithm.Ed25519, identityKeyPair.privKey.key, KeyBlobFormat.RawPrivateKey), data); + + byte[] signature = new byte[Ed25519.SignatureSize]; + Ed25519.Sign(identityKeyPair.privKey.key, 0, data, 0, data.Length, signature, 0); byte[] sigRef = SharedUtils.HexStringToByteArray("6dd355667fae4eb43c6e0ab92e870edb2de0a88cae12dbd8591507f584fe4912babff497f1b8edf9567d2483d54ddc6459bea7855281b7a246a609e3001a4e08"); string sigRefBase64 = Convert.ToBase64String(sigRef); string sigBase64 = Convert.ToBase64String(signature); diff --git a/Omemo/Classes/KeyHelper.cs b/Omemo/Classes/KeyHelper.cs index dea6988f..bbdcecc1 100644 --- a/Omemo/Classes/KeyHelper.cs +++ b/Omemo/Classes/KeyHelper.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using NSec.Cryptography; using Omemo.Classes.Keys; +using Org.BouncyCastle.Math.EC.Rfc8032; using X25519; namespace Omemo.Classes @@ -9,8 +9,8 @@ public static class KeyHelper { //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ #region --Attributes-- - public static int PUB_KEY_SIZE = SignatureAlgorithm.Ed25519.PublicKeySize; - public static int PRIV_KEY_SIZE = SignatureAlgorithm.Ed25519.PrivateKeySize; + public static int PUB_KEY_SIZE = Ed25519.PublicKeySize; + public static int PRIV_KEY_SIZE = Ed25519.SecretKeySize; #endregion //--------------------------------------------------------Constructor:----------------------------------------------------------------\\ @@ -95,8 +95,9 @@ public static SignedPreKeyModel GenerateSignedPreKey(uint id, ECPrivKeyModel ide public static byte[] SignPreKey(PreKeyModel preKey, ECPrivKeyModel identiyKey) { byte[] pubKey = preKey.pubKey.ToByteArrayWithPrefix(); - Key key = Key.Import(SignatureAlgorithm.Ed25519, identiyKey.key, KeyBlobFormat.RawPrivateKey); - return SignatureAlgorithm.Ed25519.Sign(key, pubKey); + byte[] signature = new byte[Ed25519.SignatureSize]; + Ed25519.Sign(identiyKey.key, 0, pubKey, 0, pubKey.Length, signature, 0); + return signature; } /// @@ -108,7 +109,7 @@ public static byte[] SignPreKey(PreKeyModel preKey, ECPrivKeyModel identiyKey) /// True in case the signature is valid. public static bool VerifySignature(ECPubKeyModel identityKey, ECPubKeyModel preKey, byte[] signature) { - return SignatureAlgorithm.Ed25519.Verify(PublicKey.Import(SignatureAlgorithm.Ed25519, identityKey.key, KeyBlobFormat.RawPublicKey), preKey.ToByteArrayWithPrefix(), signature); + return Ed25519.Verify(signature, 0, identityKey.key, 0, preKey.key, 0, preKey.key.Length); } /// diff --git a/Omemo/Omemo.csproj b/Omemo/Omemo.csproj index 88689cb5..55b09111 100644 --- a/Omemo/Omemo.csproj +++ b/Omemo/Omemo.csproj @@ -160,9 +160,6 @@ 6.2.13 - - 20.2.0 - 1.9.0 @@ -177,11 +174,6 @@ Shared - - - Visual C++ 2015-2019 UWP Desktop Runtime for native apps - - 14.0