diff --git a/crypto/src/math/ec/rfc7748/X25519.cs b/crypto/src/math/ec/rfc7748/X25519.cs
index d63cc5a3e..6b6acdecd 100644
--- a/crypto/src/math/ec/rfc7748/X25519.cs
+++ b/crypto/src/math/ec/rfc7748/X25519.cs
@@ -2,6 +2,8 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
+using Org.BouncyCastle.Utilities;
+
namespace Org.BouncyCastle.Math.EC.Rfc7748
{
public abstract class X25519
@@ -21,6 +23,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc7748
private static int[] precompBase = null;
+ public static bool CalculateAgreement(byte[] k, int kOff, byte[] u, int uOff, byte[] r, int rOff)
+ {
+ ScalarMult(k, kOff, u, uOff, r, rOff);
+ return !Arrays.AreAllZeroes(r, rOff, PointSize);
+ }
+
private static uint Decode32(byte[] bs, int off)
{
uint n = bs[off];
diff --git a/crypto/src/math/ec/rfc7748/X448.cs b/crypto/src/math/ec/rfc7748/X448.cs
index aac603b08..b93cb24c5 100644
--- a/crypto/src/math/ec/rfc7748/X448.cs
+++ b/crypto/src/math/ec/rfc7748/X448.cs
@@ -2,6 +2,8 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
+using Org.BouncyCastle.Utilities;
+
namespace Org.BouncyCastle.Math.EC.Rfc7748
{
public abstract class X448
@@ -24,6 +26,12 @@ namespace Org.BouncyCastle.Math.EC.Rfc7748
private static uint[] precompBase = null;
+ public static bool CalculateAgreement(byte[] k, int kOff, byte[] u, int uOff, byte[] r, int rOff)
+ {
+ ScalarMult(k, kOff, u, uOff, r, rOff);
+ return !Arrays.AreAllZeroes(r, rOff, PointSize);
+ }
+
private static uint Decode32(byte[] bs, int off)
{
uint n = bs[off];
|