summary refs log tree commit diff
path: root/crypto/src/security
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-11-06 11:14:41 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-11-06 11:14:41 +0700
commit07fd9c25ff3aae8f3f4209b6e1815fa65a1b5685 (patch)
tree49f90b9dbfe42458ffe8a5e3eb597a2adf806541 /crypto/src/security
parentTLS: Improve ASN.1 parsing (diff)
downloadBouncyCastle.NET-ed25519-07fd9c25ff3aae8f3f4209b6e1815fa65a1b5685.tar.xz
Refactoring
Diffstat (limited to 'crypto/src/security')
-rw-r--r--crypto/src/security/DotNetUtilities.cs14
1 files changed, 2 insertions, 12 deletions
diff --git a/crypto/src/security/DotNetUtilities.cs b/crypto/src/security/DotNetUtilities.cs
index df9d327de..f0064fb3d 100644
--- a/crypto/src/security/DotNetUtilities.cs
+++ b/crypto/src/security/DotNetUtilities.cs
@@ -9,6 +9,7 @@ using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Math;
+using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.X509;
 
 namespace Org.BouncyCastle.Security
@@ -223,20 +224,9 @@ namespace Org.BouncyCastle.Security
             return rp;
         }
 
-        // TODO Move functionality to more general class
         private static byte[] ConvertRSAParametersField(BigInteger n, int size)
         {
-            byte[] bs = n.ToByteArrayUnsigned();
-
-            if (bs.Length == size)
-                return bs;
-
-            if (bs.Length > size)
-                throw new ArgumentException("Specified size too small", "size");
-
-            byte[] padded = new byte[size];
-            Array.Copy(bs, 0, padded, size - bs.Length, bs.Length);
-            return padded;
+            return BigIntegers.AsUnsignedByteArray(size, n);
         }
 
         private static RSA CreateRSAProvider(RSAParameters rp)