diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-05 15:44:48 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-05 15:44:48 +0700 |
commit | 7699428eb4416a52ae9a529c133839b2fd989903 (patch) | |
tree | 64bf393583c98549253b5edd6c67695d70c8f091 /crypto/src/openpgp | |
parent | BigInteger in-place conversions (diff) | |
download | BouncyCastle.NET-ed25519-7699428eb4416a52ae9a529c133839b2fd989903.tar.xz |
Various span usages
Diffstat (limited to 'crypto/src/openpgp')
-rw-r--r-- | crypto/src/openpgp/PgpPublicKey.cs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crypto/src/openpgp/PgpPublicKey.cs b/crypto/src/openpgp/PgpPublicKey.cs index 09c8b9743..6d5f35018 100644 --- a/crypto/src/openpgp/PgpPublicKey.cs +++ b/crypto/src/openpgp/PgpPublicKey.cs @@ -507,7 +507,17 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp { ECPublicBcpgKey ecK = (ECPublicBcpgKey)publicPk.Key; X9ECParameters x9 = ECKeyPairGenerator.FindECCurveByOid(ecK.CurveOid); - ECPoint q = x9.Curve.DecodePoint(BigIntegers.AsUnsignedByteArray(ecK.EncodedPoint)); + BigInteger encodedPoint = ecK.EncodedPoint; + +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + int encodingLength = BigIntegers.GetUnsignedByteLength(encodedPoint); + Span<byte> encoding = stackalloc byte[encodingLength]; + BigIntegers.AsUnsignedByteArray(encodedPoint, encoding); + ECPoint q = x9.Curve.DecodePoint(encoding); +#else + ECPoint q = x9.Curve.DecodePoint(BigIntegers.AsUnsignedByteArray(encodedPoint)); +#endif + return new ECPublicKeyParameters(algorithm, q, ecK.CurveOid); } |