diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-20 17:43:39 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-11-20 17:43:39 +0700 |
commit | b791c4a030f0e06f5abab52a68a4225a33878207 (patch) | |
tree | 2e4617dde901f5edd8fd84e64a5a706b9f4e93bf /crypto/src/math/ec/rfc8032/Ed448.cs | |
parent | Intrinsics for shuffles (diff) | |
download | BouncyCastle.NET-ed25519-b791c4a030f0e06f5abab52a68a4225a33878207.tar.xz |
Refactoring in Math.EC.Rfc8032
Diffstat (limited to '')
-rw-r--r-- | crypto/src/math/ec/rfc8032/Ed448.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crypto/src/math/ec/rfc8032/Ed448.cs b/crypto/src/math/ec/rfc8032/Ed448.cs index 7baa221a5..75629c293 100644 --- a/crypto/src/math/ec/rfc8032/Ed448.cs +++ b/crypto/src/math/ec/rfc8032/Ed448.cs @@ -298,6 +298,16 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 private static void Dom4(IXof d, byte phflag, byte[] ctx) { int n = Dom4Prefix.Length; + +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + Span<byte> t = stackalloc byte[n + 2 + ctx.Length]; + Dom4Prefix.CopyTo(t); + t[n] = phflag; + t[n + 1] = (byte)ctx.Length; + ctx.CopyTo(t.Slice(n + 2)); + + d.BlockUpdate(t); +#else byte[] t = new byte[n + 2 + ctx.Length]; Dom4Prefix.CopyTo(t, 0); t[n] = phflag; @@ -305,6 +315,7 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032 ctx.CopyTo(t, n + 2); d.BlockUpdate(t, 0, t.Length); +#endif } private static int EncodePoint(ref PointProjective p, byte[] r, int rOff) |