diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-20 15:32:18 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-20 15:32:18 +0700 |
commit | caa2a7dfcc4038b83d7ff19d90c491912827f448 (patch) | |
tree | 9ee395339edd6b0a8a51f14a1a25813ccb980080 /crypto/src/security | |
parent | Refactoring in BigInteger (diff) | |
download | BouncyCastle.NET-ed25519-caa2a7dfcc4038b83d7ff19d90c491912827f448.tar.xz |
BigInteger construction from little-endian
Diffstat (limited to 'crypto/src/security')
-rw-r--r-- | crypto/src/security/PrivateKeyFactory.cs | 15 | ||||
-rw-r--r-- | crypto/src/security/PublicKeyFactory.cs | 4 |
2 files changed, 9 insertions, 10 deletions
diff --git a/crypto/src/security/PrivateKeyFactory.cs b/crypto/src/security/PrivateKeyFactory.cs index 38e571cd6..d6fa87943 100644 --- a/crypto/src/security/PrivateKeyFactory.cs +++ b/crypto/src/security/PrivateKeyFactory.cs @@ -151,7 +151,7 @@ namespace Org.BouncyCastle.Security Asn1OctetString privEnc = keyInfo.PrivateKeyData; if (privEnc.GetOctets().Length == 32 || privEnc.GetOctets().Length == 64) { - d = new BigInteger(1, Arrays.Reverse(privEnc.GetOctets())); + d = new BigInteger(1, privEnc.GetOctets(), bigEndian: false); } else { @@ -162,8 +162,8 @@ namespace Org.BouncyCastle.Security } else { - byte[] dVal = Arrays.Reverse(Asn1OctetString.GetInstance(privKey).GetOctets()); - d = new BigInteger(1, dVal); + byte[] dVal = Asn1OctetString.GetInstance(privKey).GetOctets(); + d = new BigInteger(1, dVal, bigEndian: false); } } } @@ -233,7 +233,7 @@ namespace Org.BouncyCastle.Security } else { - x = new BigInteger(1, Arrays.Reverse(Asn1OctetString.GetInstance(privKey).GetOctets())); + x = new BigInteger(1, Asn1OctetString.GetInstance(privKey).GetOctets(), bigEndian: false); } return new Gost3410PrivateKeyParameters(x, gostParams.PublicKeyParamSet); @@ -280,8 +280,7 @@ namespace Org.BouncyCastle.Security Asn1OctetString privEnc = keyInfo.PrivateKeyData; if (privEnc.GetOctets().Length == 32 || privEnc.GetOctets().Length == 64) { - byte[] dVal = Arrays.Reverse(privEnc.GetOctets()); - d = new BigInteger(1, dVal); + d = new BigInteger(1, privEnc.GetOctets(), bigEndian: false); } else { @@ -292,8 +291,8 @@ namespace Org.BouncyCastle.Security } else { - byte[] dVal = Arrays.Reverse(Asn1OctetString.GetInstance(privKey).GetOctets()); - d = new BigInteger(1, dVal); + byte[] dVal = Asn1OctetString.GetInstance(privKey).GetOctets(); + d = new BigInteger(1, dVal, bigEndian: false); } } } diff --git a/crypto/src/security/PublicKeyFactory.cs b/crypto/src/security/PublicKeyFactory.cs index 03cabbb13..d3ecef5c7 100644 --- a/crypto/src/security/PublicKeyFactory.cs +++ b/crypto/src/security/PublicKeyFactory.cs @@ -203,9 +203,9 @@ namespace Org.BouncyCastle.Security throw new ArgumentException("error recovering GOST3410_94 public key", e); } - byte[] keyBytes = Arrays.Reverse(key.GetOctets()); // was little endian + byte[] keyBytes = key.GetOctets(); - BigInteger y = new BigInteger(1, keyBytes); + BigInteger y = new BigInteger(1, keyBytes, bigEndian: false); return new Gost3410PublicKeyParameters(y, algParams.PublicKeyParamSet); } |