summary refs log tree commit diff
path: root/crypto/src/openpgp/PgpSecretKey.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/openpgp/PgpSecretKey.cs')
-rw-r--r--crypto/src/openpgp/PgpSecretKey.cs16
1 files changed, 14 insertions, 2 deletions
diff --git a/crypto/src/openpgp/PgpSecretKey.cs b/crypto/src/openpgp/PgpSecretKey.cs

index 627b6788a..184621b5c 100644 --- a/crypto/src/openpgp/PgpSecretKey.cs +++ b/crypto/src/openpgp/PgpSecretKey.cs
@@ -67,9 +67,13 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp } else { - // 'reverse' because the native format for X25519 private keys is little-endian + // The native format for X25519 private keys is little-endian X25519PrivateKeyParameters xK = (X25519PrivateKeyParameters)privKey.Key; - secKey = new ECSecretBcpgKey(new BigInteger(1, Arrays.ReverseInPlace(xK.GetEncoded()))); +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + secKey = new ECSecretBcpgKey(new BigInteger(1, xK.DataSpan, bigEndian: false)); +#else + secKey = new ECSecretBcpgKey(new BigInteger(1, xK.GetEncoded(), bigEndian: false)); +#endif } break; } @@ -81,11 +85,19 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp { if (privKey.Key is Ed25519PrivateKeyParameters ed25519K) { +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + secKey = new EdSecretBcpgKey(new BigInteger(1, ed25519K.DataSpan)); +#else secKey = new EdSecretBcpgKey(new BigInteger(1, ed25519K.GetEncoded())); +#endif } else if (privKey.Key is Ed448PrivateKeyParameters ed448K) { +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + secKey = new EdSecretBcpgKey(new BigInteger(1, ed448K.DataSpan)); +#else secKey = new EdSecretBcpgKey(new BigInteger(1, ed448K.GetEncoded())); +#endif } else {