summary refs log tree commit diff
path: root/crypto/src/math/ec/rfc8032
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-10-06 12:19:49 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-10-06 12:19:49 +0700
commit2d28fafa7fe1becdada43f939b5121946468052c (patch)
treeab0b57beefd9976b7d3091fbefc0fab4635f3d04 /crypto/src/math/ec/rfc8032
parentRefactor RSACoreEngine.ConvertOutput (diff)
downloadBouncyCastle.NET-ed25519-2d28fafa7fe1becdada43f939b5121946468052c.tar.xz
Refactor stackalloc usage
Diffstat (limited to 'crypto/src/math/ec/rfc8032')
-rw-r--r--crypto/src/math/ec/rfc8032/Ed25519.cs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/src/math/ec/rfc8032/Ed25519.cs b/crypto/src/math/ec/rfc8032/Ed25519.cs
index d6bf461cf..f3b63f3b3 100644
--- a/crypto/src/math/ec/rfc8032/Ed25519.cs
+++ b/crypto/src/math/ec/rfc8032/Ed25519.cs
@@ -433,7 +433,10 @@ namespace Org.BouncyCastle.Math.EC.Rfc8032
         public static void GeneratePublicKey(ReadOnlySpan<byte> sk, Span<byte> pk)
         {
             IDigest d = CreateDigest();
-            Span<byte> h = stackalloc byte[d.GetDigestSize()];
+            int digestSize = d.GetDigestSize();
+            Span<byte> h = digestSize <= 128
+                ? stackalloc byte[digestSize]
+                : new byte[digestSize];
 
             d.BlockUpdate(sk[..SecretKeySize]);
             d.DoFinal(h);