diff --git a/README.md b/README.md index 0cc04fb9b..eaf0b3e53 100644 --- a/README.md +++ b/README.md @@ -18,22 +18,70 @@ This project was inspired by **Sharp.SSH** library which was ported from java an * Remote, dynamic and local port forwarding * Shell/Terminal implementation * Specify key file pass phrase -* Use multiple key files to authenticate -* Supports 3des-cbc, aes128-cbc, aes192-cbc, aes256-cbc, aes128-ctr, aes192-ctr, aes256-ctr, blowfish-cbc, cast128-cbc, arcfour and twofish encryptions +* Use multiple key files to authenticate * Supports publickey, password and keyboard-interactive authentication methods -* Supports RSA and DSA private key -* Supports DES-EDE3-CBC, DES-EDE3-CFB, DES-CBC, AES-128-CBC, AES-192-CBC and AES-256-CBC algorithms for private key encryption * Supports two-factor or higher authentication * Supports SOCKS4, SOCKS5 and HTTP Proxy +## Encryption Method + +**SSH.NET** supports the following encryption methods: +* aes256-ctr +* 3des-cbc +* aes128-cbc +* aes192-cbc +* aes256-cbc +* blowfish-cbc +* twofish-cbc +* twofish192-cbc +* twofish128-cbc +* twofish256-cbc +* arcfour +* arcfour128 +* arcfour256 +* cast128-cbc +* aes128-ctr +* aes192-ctr + ## Key Exchange Method **SSH.NET** supports the following key exchange methods: +* curve25519-sha256 +* curve25519-sha256@libssh.org +* ecdh-sha2-nistp256 +* ecdh-sha2-nistp384 +* ecdh-sha2-nistp521 * diffie-hellman-group-exchange-sha256 * diffie-hellman-group-exchange-sha1 * diffie-hellman-group14-sha1 * diffie-hellman-group1-sha1 +## Public Key Authenntication + +**SSH.NET** supports the following private key formats: +* RSA in OpenSSL PEM and ssh.com format +* DSA in OpenSSL PEM and ssh.com format +* ECDSA 256/384/521 in OpenSSL PEM format +* ED25519 in OpenSSH key format + +Private keys can be encrypted using one of the following cipher methods: +* DES-EDE3-CBC +* DES-EDE3-CFB +* DES-CBC +* AES-128-CBC +* AES-192-CBC +* AES-256-CBC + +## Host Key Algorithms + +**SSH.NET** supports the following host key algorithms: +* ssh-ed25519 +* ecdsa-sha2-nistp256 +* ecdsa-sha2-nistp384 +* ecdsa-sha2-nistp521 +* ssh-rsa +* ssh-dss + ## Message Authentication Code **SSH.NET** supports the following MAC algorithms: diff --git a/THIRD-PARTY-NOTICES.TXT b/THIRD-PARTY-NOTICES.TXT new file mode 100644 index 000000000..1cacf79e2 --- /dev/null +++ b/THIRD-PARTY-NOTICES.TXT @@ -0,0 +1,73 @@ +SSH.NET uses third-party libraries or other resources that may be +distributed under licenses different than the SSH.NET software. + +License notice for BouncyCastle +------------------------------- + +http://bouncycastle.org/csharp + +Copyright (c) 2000 - 2018 The Legion of the Bouncy Castle Inc. (http://www.bouncycastle.org) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +License notice for Chaos.NaCl +------------------------------- + +https://github.com/CodesInChaos/Chaos.NaCl + +Public domain + +C# port + code by Christian Winnerlein (CodesInChaos) + +Poly1305 in c + written by Andrew M. (floodyberry) + original license: MIT or PUBLIC DOMAIN + https://github.com/floodyberry/poly1305-donna/blob/master/poly1305-donna-unrolled.c + +Curve25519 and Ed25519 in c + written by Dan Bernstein (djb) + public domain + from Ref10 in SUPERCOP http://bench.cr.yp.to/supercop.html + +(H)Salsa20 in c + written by Dan Bernstein (djb) + public domain + from SUPERCOP http://bench.cr.yp.to/supercop.html + +SHA512 + written by Christian Winnerlein (CodesInChaos) + public domain + directly from the specification + +License notice for BCrypt +------------------------- + +Copyright (c) 2006 Damien Miller +Copyright (c) 2010 Ryan D. Emerle + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/src/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj b/src/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj index a6878d187..ffd2bce5b 100644 --- a/src/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj +++ b/src/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj @@ -18,7 +18,7 @@ full false bin\Debug\ - TRACE;DEBUG;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII + TRACE;DEBUG;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII;FEATURE_ECDSA prompt 4 true @@ -29,7 +29,7 @@ none true bin\Release\ - TRACE;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII + TRACE;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_POLL;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII;FEATURE_ECDSA prompt 4 bin\Release\Renci.SshNet.xml @@ -602,12 +602,414 @@ Security\Algorithm.cs + + Security\Cryptography\BouncyCastle\asn1\sec\SECNamedCurves.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9Curve.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParameters.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParametersHolder.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECPoint.cs + + + Security\Cryptography\BouncyCastle\crypto\agreement\ECDHCBasicAgreement.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricCipherKeyPair.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricKeyParameter.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\GeneralDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\Sha256Digest.cs + + + Security\Cryptography\BouncyCastle\crypto\generators\ECKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IAsymmetricCipherKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\KeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECDomainParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPrivateKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPublicKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\CryptoApiRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\DigestRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\IRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\util\Pack.cs + + + Security\Cryptography\BouncyCastle\math\BigInteger.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\SimpleBigDecimal.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\Tnaf.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\ZTauElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECAlgorithms.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECCurve.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECFieldElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECLookupTable.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPoint.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPointMap.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\ECEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\GlvEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\LongArray.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\AbstractECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointCombMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\GlvMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\IPreCompCallback.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\PreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ValidityPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafL2RMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\field\FiniteFields.cs + + + Security\Cryptography\BouncyCastle\math\field\GenericPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\GF2Polynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\IFiniteField.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\PrimeField.cs + + + Security\Cryptography\BouncyCastle\math\raw\Mod.cs + + + Security\Cryptography\BouncyCastle\math\raw\Nat.cs + + + Security\Cryptography\BouncyCastle\security\DigestUtilities.cs + + + Security\Cryptography\BouncyCastle\security\SecureRandom.cs + + + Security\Cryptography\BouncyCastle\security\SecurityUtilityException.cs + + + Security\Cryptography\BouncyCastle\util\Arrays.cs + + + Security\Cryptography\BouncyCastle\util\BigIntegers.cs + + + Security\Cryptography\BouncyCastle\util\encoders\Hex.cs + + + Security\Cryptography\BouncyCastle\util\encoders\HexEncoder.cs + + + Security\Cryptography\BouncyCastle\util\Enums.cs + + + Security\Cryptography\BouncyCastle\util\IMemoable.cs + + + Security\Cryptography\BouncyCastle\util\Integers.cs + + + Security\Cryptography\BouncyCastle\util\MemoableResetException.cs + + + Security\Cryptography\BouncyCastle\util\Times.cs + Security\CertificateHostAlgorithm.cs + + Security\Cryptography\Chaos.NaCl\CryptoBytes.cs + + + Security\Cryptography\Chaos.NaCl\Ed25519.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array16.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array8.cs + + + Security\Cryptography\Chaos.NaCl\Internal\ByteIntegerConverter.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cmov.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cswap.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_invert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnegative.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnonzero.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul121666.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_neg.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_pow22523.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\FieldElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_double_scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_madd.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_msub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p3.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_cached.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_precomp_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_scalarmult_base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\GroupElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\keypair.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\open.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_clamp.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_mul_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_reduce.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sign.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sqrtm1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\InternalAssert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Poly1305Donna.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\Salsa20.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\SalsaCore.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Sha512Internal.cs + + + Security\Cryptography\Chaos.NaCl\MontgomeryCurve25519.cs + + + Security\Cryptography\Chaos.NaCl\Sha512.cs + Security\Cryptography\AsymmetricCipher.cs + + Security\Cryptography\Bcrypt.cs + Security\Cryptography\BlockCipher.cs @@ -677,6 +1079,12 @@ Security\Cryptography\DsaKey.cs + + Security\Cryptography\ED25519DigitalSignature.cs + + + Security\Cryptography\ED25519Key.cs + Security\Cryptography\HMACMD5.cs @@ -695,6 +1103,12 @@ Security\Cryptography\Key.cs + + Security\Cryptography\EcdsaDigitalSignature.cs + + + Security\Cryptography\EcdsaKey.cs + Security\Cryptography\RsaDigitalSignature.cs @@ -740,6 +1154,24 @@ Security\KeyExchangeDiffieHellmanGroupSha1.cs + + Security\KeyExchangeEC.cs + + + Security\KeyExchangeECCurve25519.cs + + + Security\KeyExchangeECDH.cs + + + Security\KeyExchangeECDH256.cs + + + Security\KeyExchangeECDH384.cs + + + Security\KeyExchangeECDH521.cs + Security\KeyHostAlgorithm.cs @@ -981,4 +1413,4 @@ --> - \ No newline at end of file + diff --git a/src/Renci.SshNet.NETCore/Renci.SshNet.NETCore.csproj b/src/Renci.SshNet.NETCore/Renci.SshNet.NETCore.csproj index ba1c5b855..b288064e6 100644 --- a/src/Renci.SshNet.NETCore/Renci.SshNet.NETCore.csproj +++ b/src/Renci.SshNet.NETCore/Renci.SshNet.NETCore.csproj @@ -27,11 +27,12 @@ + FEATURE_ENCODING_ASCII;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_DIRECTORYINFO_ENUMERATEFILES;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO;FEATURE_RNG_CREATE;FEATURE_SOCKET_TAP;FEATURE_SOCKET_EAP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_DNS_TAP;FEATURE_STREAM_TAP;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_TAP;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512 - FEATURE_ENCODING_ASCII;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_DIRECTORYINFO_ENUMERATEFILES;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_RNG_CREATE;FEATURE_SOCKET_TAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_EAP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_DNS_SYNC;FEATURE_DNS_APM;FEATURE_DNS_TAP;FEATURE_STREAM_APM;FEATURE_STREAM_TAP;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_TAP;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512 + FEATURE_ENCODING_ASCII;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_DIRECTORYINFO_ENUMERATEFILES;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_RNG_CREATE;FEATURE_SOCKET_TAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_EAP;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_DNS_SYNC;FEATURE_DNS_APM;FEATURE_DNS_TAP;FEATURE_STREAM_APM;FEATURE_STREAM_TAP;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_TAP;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_ECDSA - \ No newline at end of file + diff --git a/src/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj b/src/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj index 910eb7708..2523a02f3 100644 --- a/src/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj +++ b/src/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj @@ -602,12 +602,414 @@ Security\Algorithm.cs + + Security\Cryptography\BouncyCastle\asn1\sec\SECNamedCurves.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9Curve.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParameters.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParametersHolder.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECPoint.cs + + + Security\Cryptography\BouncyCastle\crypto\agreement\ECDHCBasicAgreement.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricCipherKeyPair.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricKeyParameter.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\GeneralDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\Sha256Digest.cs + + + Security\Cryptography\BouncyCastle\crypto\generators\ECKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IAsymmetricCipherKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\KeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECDomainParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPrivateKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPublicKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\CryptoApiRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\DigestRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\IRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\util\Pack.cs + + + Security\Cryptography\BouncyCastle\math\BigInteger.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\SimpleBigDecimal.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\Tnaf.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\ZTauElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECAlgorithms.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECCurve.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECFieldElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECLookupTable.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPoint.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPointMap.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\ECEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\GlvEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\LongArray.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\AbstractECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointCombMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\GlvMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\IPreCompCallback.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\PreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ValidityPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafL2RMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\field\FiniteFields.cs + + + Security\Cryptography\BouncyCastle\math\field\GenericPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\GF2Polynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\IFiniteField.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\PrimeField.cs + + + Security\Cryptography\BouncyCastle\math\raw\Mod.cs + + + Security\Cryptography\BouncyCastle\math\raw\Nat.cs + + + Security\Cryptography\BouncyCastle\security\DigestUtilities.cs + + + Security\Cryptography\BouncyCastle\security\SecureRandom.cs + + + Security\Cryptography\BouncyCastle\security\SecurityUtilityException.cs + + + Security\Cryptography\BouncyCastle\util\Arrays.cs + + + Security\Cryptography\BouncyCastle\util\BigIntegers.cs + + + Security\Cryptography\BouncyCastle\util\encoders\Hex.cs + + + Security\Cryptography\BouncyCastle\util\encoders\HexEncoder.cs + + + Security\Cryptography\BouncyCastle\util\Enums.cs + + + Security\Cryptography\BouncyCastle\util\IMemoable.cs + + + Security\Cryptography\BouncyCastle\util\Integers.cs + + + Security\Cryptography\BouncyCastle\util\MemoableResetException.cs + + + Security\Cryptography\BouncyCastle\util\Times.cs + Security\CertificateHostAlgorithm.cs + + Security\Cryptography\Chaos.NaCl\CryptoBytes.cs + + + Security\Cryptography\Chaos.NaCl\Ed25519.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array16.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array8.cs + + + Security\Cryptography\Chaos.NaCl\Internal\ByteIntegerConverter.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cmov.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cswap.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_invert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnegative.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnonzero.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul121666.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_neg.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_pow22523.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\FieldElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_double_scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_madd.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_msub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p3.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_cached.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_precomp_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_scalarmult_base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\GroupElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\keypair.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\open.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_clamp.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_mul_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_reduce.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sign.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sqrtm1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\InternalAssert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Poly1305Donna.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\Salsa20.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\SalsaCore.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Sha512Internal.cs + + + Security\Cryptography\Chaos.NaCl\MontgomeryCurve25519.cs + + + Security\Cryptography\Chaos.NaCl\Sha512.cs + Security\Cryptography\AsymmetricCipher.cs + + Security\Cryptography\Bcrypt.cs + Security\Cryptography\BlockCipher.cs @@ -677,6 +1079,12 @@ Security\Cryptography\DsaKey.cs + + Security\Cryptography\ED25519DigitalSignature.cs + + + Security\Cryptography\ED25519Key.cs + Security\Cryptography\HMACMD5.cs @@ -740,6 +1148,24 @@ Security\KeyExchangeDiffieHellmanGroupSha1.cs + + Security\KeyExchangeEC.cs + + + Security\KeyExchangeECCurve25519.cs + + + Security\KeyExchangeECDH.cs + + + Security\KeyExchangeECDH256.cs + + + Security\KeyExchangeECDH384.cs + + + Security\KeyExchangeECDH521.cs + Security\KeyHostAlgorithm.cs @@ -980,4 +1406,4 @@ --> - \ No newline at end of file + diff --git a/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj b/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj index a42cf8ec1..abeeb691f 100644 --- a/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj +++ b/src/Renci.SshNet.Tests.NET35/Renci.SshNet.Tests.NET35.csproj @@ -351,6 +351,12 @@ Classes\Common\ExtensionsTest_Take_OffsetAndCount.cs + + Classes\Common\ExtensionsTest_ToBigInteger2.cs + + + Classes\Common\ExtensionsTest_Pad.cs + Classes\Common\ExtensionsTest_TrimLeadingZeros.cs @@ -1737,6 +1743,32 @@ Data\Key.SSH2.RSA.txt + + + Data\Key.ECDSA.txt + + + Data\Key.ECDSA384.txt + + + Data\Key.ECDSA521.txt + + + Data\Key.ECDSA.Encrypted.txt + + + Data\Key.ECDSA384.Encrypted.txt + + + Data\Key.ECDSA521.Encrypted.txt + + + Data\Key.OPENSSH.ED25519.Encrypted.txt + + + Data\Key.OPENSSH.ED25519.txt + + @@ -1750,4 +1782,4 @@ --> - \ No newline at end of file + diff --git a/src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Pad.cs b/src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Pad.cs new file mode 100644 index 000000000..f39c45ded --- /dev/null +++ b/src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Pad.cs @@ -0,0 +1,32 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Renci.SshNet.Common; + +namespace Renci.SshNet.Tests.Classes.Common +{ + [TestClass] + [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] + public class ExtensionsTest_Pad + { + [TestMethod] + public void ShouldReturnNotPadded() + { + byte[] value = {0x0a, 0x0d}; + byte[] padded = value.Pad(2); + Assert.AreEqual(value, padded); + Assert.AreEqual(value.Length, padded.Length); + } + + [TestMethod] + public void ShouldReturnPadded() + { + byte[] value = { 0x0a, 0x0d }; + byte[] padded = value.Pad(3); + Assert.AreEqual(value.Length + 1, padded.Length); + Assert.AreEqual(0x00, padded[0]); + Assert.AreEqual(0x0a, padded[1]); + Assert.AreEqual(0x0d, padded[2]); + } + } +} diff --git a/src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_ToBigInteger2.cs b/src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_ToBigInteger2.cs new file mode 100644 index 000000000..1299f17ad --- /dev/null +++ b/src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_ToBigInteger2.cs @@ -0,0 +1,40 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Renci.SshNet.Common; + +namespace Renci.SshNet.Tests.Classes.Common +{ + [TestClass] + [SuppressMessage("ReSharper", "InvokeAsExtensionMethod")] + public class ExtensionsTest_ToBigInteger2 + { + [TestMethod] + public void ShouldNotAppendZero() + { + byte[] value = { 0x0a, 0x0d }; + + var actual = value.ToBigInteger2().ToByteArray().Reverse(); + + Assert.IsNotNull(actual); + Assert.AreEqual(2, actual.Length); + Assert.AreEqual(0x0a, actual[0]); + Assert.AreEqual(0x0d, actual[1]); + } + + [TestMethod] + public void ShouldAppendZero() + { + byte[] value = { 0xff, 0x0a, 0x0d }; + + var actual = value.ToBigInteger2().ToByteArray().Reverse(); + + Assert.IsNotNull(actual); + Assert.AreEqual(4, actual.Length); + Assert.AreEqual(0x00, actual[0]); + Assert.AreEqual(0xff, actual[1]); + Assert.AreEqual(0x0a, actual[2]); + Assert.AreEqual(0x0d, actual[3]); + } + } +} diff --git a/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs b/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs index 21bd97853..99434d71a 100644 --- a/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs +++ b/src/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs @@ -319,6 +319,72 @@ public void Test_PrivateKey_RSA_DES_EDE3_CFB() } } + [TestMethod] + [Owner("darinkes")] + [TestCategory("PrivateKey")] + public void Test_PrivateKey_ECDSA() + { + using (var stream = GetData("Key.ECDSA.txt")) + { + new PrivateKeyFile(stream); + } + } + + [TestMethod] + [Owner("darinkes")] + [TestCategory("PrivateKey")] + public void Test_PrivateKey_ECDSA384() + { + using (var stream = GetData("Key.ECDSA384.txt")) + { + new PrivateKeyFile(stream); + } + } + + [TestMethod] + [Owner("darinkes")] + [TestCategory("PrivateKey")] + public void Test_PrivateKey_ECDSA521() + { + using (var stream = GetData("Key.ECDSA521.txt")) + { + new PrivateKeyFile(stream); + } + } + + [TestMethod] + [Owner("darinkes")] + [TestCategory("PrivateKey")] + public void Test_PrivateKey_ECDSA_Encrypted() + { + using (var stream = GetData("Key.ECDSA.Encrypted.txt")) + { + new PrivateKeyFile(stream, "12345"); + } + } + + [TestMethod] + [Owner("darinkes")] + [TestCategory("PrivateKey")] + public void Test_PrivateKey_ECDSA384_Encrypted() + { + using (var stream = GetData("Key.ECDSA384.Encrypted.txt")) + { + new PrivateKeyFile(stream, "12345"); + } + } + + [TestMethod] + [Owner("darinkes")] + [TestCategory("PrivateKey")] + public void Test_PrivateKey_ECDSA521_Encrypted() + { + using (var stream = GetData("Key.ECDSA521.Encrypted.txt")) + { + new PrivateKeyFile(stream, "12345"); + } + } + /// ///A test for Dispose /// @@ -479,6 +545,34 @@ public void ConstructorWithFileNameAndPassPhraseShouldBeAbleToReadFileThatIsShar } } + /// + /// A test for opening an openssh v1 keyfile where there is no passphrase. + /// + [TestMethod()] + [Owner("bhalbright")] + [TestCategory("PrivateKey")] + public void TestOpenSshV1KeyFileNoPassphrase() + { + using (var stream = GetData("Key.OPENSSH.ED25519.txt")) + { + new PrivateKeyFile(stream); + } + } + + /// + /// A test for opening an openssh v1 keyfile where there is a passphrase. + /// + [TestMethod()] + [Owner("bhalbright")] + [TestCategory("PrivateKey")] + public void TestOpenSshV1KeyFileWithPassphrase() + { + using (var stream = GetData("Key.OPENSSH.ED25519.Encrypted.txt")) + { + new PrivateKeyFile(stream, "password"); + } + } + private void SaveStreamToFile(Stream stream, string fileName) { var buffer = new byte[4000]; @@ -501,4 +595,4 @@ private string GetTempFileName() return tempFile; } } -} \ No newline at end of file +} diff --git a/src/Renci.SshNet.Tests/Data/Key.ECDSA.Encrypted.txt b/src/Renci.SshNet.Tests/Data/Key.ECDSA.Encrypted.txt new file mode 100644 index 000000000..f0af5ba7d --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.ECDSA.Encrypted.txt @@ -0,0 +1,8 @@ +-----BEGIN EC PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,54D46F498C989115AAE14FEA21E3AF11 + +IQdFnndcbzz10d7YQIgEE1TzuzJrm7uYJr4Hvdfz/FshVxMRqxqaqtEgo2vAHHik +BOcPkm+84ERlTNPslcJqLSkKzCdxb7Rz5hfwHuN3Y6Lf01qGakDlzAUEjEyDor+4 +zQtAne+f+gRUJnBvLLoVhH4xdeQFC55GECNUFQpEmos= +-----END EC PRIVATE KEY----- \ No newline at end of file diff --git a/src/Renci.SshNet.Tests/Data/Key.ECDSA.txt b/src/Renci.SshNet.Tests/Data/Key.ECDSA.txt new file mode 100644 index 000000000..13ac9fb49 --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.ECDSA.txt @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIEdqaFKgJBIibVjyUh1v7Y35LwIQJrocdTaYFLwl7iB0oAoGCCqGSM49 +AwEHoUQDQgAEQD5MO/n9yqSDTszwzVpApLx5SQFecE5ZfDkgxqVdHQecm1BAPozZ +4eKGNhKn72hT79mLlp9HXX+oNEcuVT83Hw== +-----END EC PRIVATE KEY----- \ No newline at end of file diff --git a/src/Renci.SshNet.Tests/Data/Key.ECDSA384.Encrypted.txt b/src/Renci.SshNet.Tests/Data/Key.ECDSA384.Encrypted.txt new file mode 100644 index 000000000..00072ce24 --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.ECDSA384.Encrypted.txt @@ -0,0 +1,9 @@ +-----BEGIN EC PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,1D64653C5E18C2AACB0B17E3FE43C219 + +lCtRmcvKSeIACwqTtsf/ei1brtCZ386rsk/j7bSXdkZBpvzcmzbeo6w6CYm206Km +hV9TMl2dIO/I1/ov5/2VIR3ZkaElyDOJD/+Be0e3aus4EZj1H1YM/Dv+4QJId+is +Cw4ycWjfudYPPejGdiyjzt5qjaIJwrrEvGtMg7sWVAqDpjcAjS9KuaCu5nOgdItL +s7oHuz+DTGdJQNfUHAlUnz1JaMRWzpP0MwtxdcaRY+w= +-----END EC PRIVATE KEY----- \ No newline at end of file diff --git a/src/Renci.SshNet.Tests/Data/Key.ECDSA384.txt b/src/Renci.SshNet.Tests/Data/Key.ECDSA384.txt new file mode 100644 index 000000000..f2d658ea4 --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.ECDSA384.txt @@ -0,0 +1,6 @@ +-----BEGIN EC PRIVATE KEY----- +MIGkAgEBBDCQawHdHLR7NvKa2vPV0sVkbzOE8c0enp95iEysGcGV66RXE1EH//nh +gu5UzeTR4KigBwYFK4EEACKhZANiAAQUk4rVvoOPI1hQzWpNx09Uo6qG+srGcbvB +q15eFK0GnK/T0UBKxdbZ2+//KAYI6SeDHM9t3ORF1aX5EpjTEBI4d7ZY/lV9jX6M +nJ4XuGteJselM2iMmy+p9ZYw83BYB1Y= +-----END EC PRIVATE KEY----- \ No newline at end of file diff --git a/src/Renci.SshNet.Tests/Data/Key.ECDSA521.Encrypted.txt b/src/Renci.SshNet.Tests/Data/Key.ECDSA521.Encrypted.txt new file mode 100644 index 000000000..381b30be8 --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.ECDSA521.Encrypted.txt @@ -0,0 +1,10 @@ +-----BEGIN EC PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: AES-128-CBC,F995028237EBD79C928530CC6C3E957F + +wT+iajbte4MnpCipVy/7W9t2I8OgwbMjNBw9PB5xmXR1NQX+yWa81DXMTgjHi8++ +6tp+Vlftkr7mY1yvZCVo1Sy4VgcvZeMhtpVKtvYdMCmHJC6gaDOTYX3yee8DJ4FL +fG+IQz0wFyZZ26NFrHiwbufW9z6pXhGNCQZK0KLbFxI9iKwVA0llc7uzTEcmBBpn +0/Snp0CVvX+i6AP9Xj0bBdrFCsvcoT+ZHzS8YWJUfu3m6cpAJksCAy0PXR3ifvus +edTfDpkMxd4/b+DtPB6SMekIAjnQyzbyaTwJCujm8iU= +-----END EC PRIVATE KEY----- \ No newline at end of file diff --git a/src/Renci.SshNet.Tests/Data/Key.ECDSA521.txt b/src/Renci.SshNet.Tests/Data/Key.ECDSA521.txt new file mode 100644 index 000000000..31abe917a --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.ECDSA521.txt @@ -0,0 +1,7 @@ +-----BEGIN EC PRIVATE KEY----- +MIHcAgEBBEIBn2DAme7AU8sCA+/sd6s3c2FNW26IiPvulGd3FC8k5q+fjBZ5LUWR +iJMGrsf2rJLO8hXMGJYoF9tjZEGaabQ8KVagBwYFK4EEACOhgYkDgYYABABrpVjs +ANqcvqMUo1wo0I1uVCXQ6xrauy4iU86FiOwFmkYRrle4w3oYdRJwniC3TwGMuBuM +PMIoCTXr0UtUzn1vkQESNR/J/jAxVseLlVe+KDfZHKvsvk2+O4XaSa1qMfLwN3sp +wlj08+ylKjlO6V3g0hbz4ZaSVwuiRS7Xsv8W2MV6rg== +-----END EC PRIVATE KEY----- \ No newline at end of file diff --git a/src/Renci.SshNet.Tests/Data/Key.OPENSSH.ED25519.Encrypted.txt b/src/Renci.SshNet.Tests/Data/Key.OPENSSH.ED25519.Encrypted.txt new file mode 100644 index 000000000..50b4d9689 --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.OPENSSH.ED25519.Encrypted.txt @@ -0,0 +1,9 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jYmMAAAAGYmNyeXB0AAAAGAAAABBg +HWh+J0IG6OfYxD74SoT9AAAAEAAAAAEAAAAzAAAAC3NzaC1lZDI1NTE5AAAAIGFd +yflleGqSPOhgSYZf7ZQFlG0zEL9VDGC69UbtaaByAAAAoDLm8u8wFwlqjzZRfVxj +wzGTYFJFtfkHRqfFBE4xKgknHNRbCT1OQb7rgE7nZbUXIlb1NCTZLbXti9AYNZpz +ycvPD4Dc6lB03b8pNHoFVSkrCwxrWB5bKtIM4OZNcDK1lZDBEWE2aZXf9puRHbu3 +ccrK/F5GjRi2pUa8qnfqThN1mNPZwFTx4oSKeRaUMdeHBrNwDtaxq32A6Q4KHoYO +KPM= +-----END OPENSSH PRIVATE KEY----- diff --git a/src/Renci.SshNet.Tests/Data/Key.OPENSSH.ED25519.txt b/src/Renci.SshNet.Tests/Data/Key.OPENSSH.ED25519.txt new file mode 100644 index 000000000..84811f653 --- /dev/null +++ b/src/Renci.SshNet.Tests/Data/Key.OPENSSH.ED25519.txt @@ -0,0 +1,8 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz +c2gtZWQyNTUxOQAAACANCWZw0K8UGXDQC32WBuyzwFtTGBBr1VuZ43uzpTBjIgAA +AKBATgCiQE4AogAAAAtzc2gtZWQyNTUxOQAAACANCWZw0K8UGXDQC32WBuyzwFtT +GBBr1VuZ43uzpTBjIgAAAEAAzBF1MPUxrs+ycpJh28zzo/F3m6WcKO+orsSbR5Lw +KQ0JZnDQrxQZcNALfZYG7LPAW1MYEGvVW5nje7OlMGMiAAAAFGVkMjU1MTkta2V5 +LTIwMTgxMTI3AQIDBAUGBwgJ +-----END OPENSSH PRIVATE KEY----- diff --git a/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj b/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj index d968dd27b..5b9ccafc6 100644 --- a/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj +++ b/src/Renci.SshNet.Tests/Renci.SshNet.Tests.csproj @@ -169,6 +169,8 @@ + + @@ -709,6 +711,18 @@ Renci.SshNet + + + + + + + + + + + + - \ No newline at end of file + diff --git a/src/Renci.SshNet.UAP10/Renci.SshNet.UAP10.csproj b/src/Renci.SshNet.UAP10/Renci.SshNet.UAP10.csproj index 87316c9d9..d1b874f42 100644 --- a/src/Renci.SshNet.UAP10/Renci.SshNet.UAP10.csproj +++ b/src/Renci.SshNet.UAP10/Renci.SshNet.UAP10.csproj @@ -666,12 +666,414 @@ Security\Algorithm.cs + + Security\Cryptography\BouncyCastle\asn1\sec\SECNamedCurves.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9Curve.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParameters.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParametersHolder.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECPoint.cs + + + Security\Cryptography\BouncyCastle\crypto\agreement\ECDHCBasicAgreement.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricCipherKeyPair.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricKeyParameter.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\GeneralDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\Sha256Digest.cs + + + Security\Cryptography\BouncyCastle\crypto\generators\ECKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IAsymmetricCipherKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\KeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECDomainParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPrivateKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPublicKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\CryptoApiRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\DigestRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\IRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\util\Pack.cs + + + Security\Cryptography\BouncyCastle\math\BigInteger.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\SimpleBigDecimal.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\Tnaf.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\ZTauElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECAlgorithms.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECCurve.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECFieldElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECLookupTable.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPoint.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPointMap.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\ECEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\GlvEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\LongArray.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\AbstractECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointCombMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\GlvMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\IPreCompCallback.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\PreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ValidityPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafL2RMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\field\FiniteFields.cs + + + Security\Cryptography\BouncyCastle\math\field\GenericPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\GF2Polynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\IFiniteField.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\PrimeField.cs + + + Security\Cryptography\BouncyCastle\math\raw\Mod.cs + + + Security\Cryptography\BouncyCastle\math\raw\Nat.cs + + + Security\Cryptography\BouncyCastle\security\DigestUtilities.cs + + + Security\Cryptography\BouncyCastle\security\SecureRandom.cs + + + Security\Cryptography\BouncyCastle\security\SecurityUtilityException.cs + + + Security\Cryptography\BouncyCastle\util\Arrays.cs + + + Security\Cryptography\BouncyCastle\util\BigIntegers.cs + + + Security\Cryptography\BouncyCastle\util\encoders\Hex.cs + + + Security\Cryptography\BouncyCastle\util\encoders\HexEncoder.cs + + + Security\Cryptography\BouncyCastle\util\Enums.cs + + + Security\Cryptography\BouncyCastle\util\IMemoable.cs + + + Security\Cryptography\BouncyCastle\util\Integers.cs + + + Security\Cryptography\BouncyCastle\util\MemoableResetException.cs + + + Security\Cryptography\BouncyCastle\util\Times.cs + Security\CertificateHostAlgorithm.cs + + Security\Cryptography\Chaos.NaCl\CryptoBytes.cs + + + Security\Cryptography\Chaos.NaCl\Ed25519.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array16.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array8.cs + + + Security\Cryptography\Chaos.NaCl\Internal\ByteIntegerConverter.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cmov.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cswap.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_invert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnegative.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnonzero.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul121666.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_neg.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_pow22523.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\FieldElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_double_scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_madd.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_msub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p3.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_cached.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_precomp_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_scalarmult_base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\GroupElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\keypair.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\open.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_clamp.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_mul_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_reduce.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sign.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sqrtm1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\InternalAssert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Poly1305Donna.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\Salsa20.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\SalsaCore.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Sha512Internal.cs + + + Security\Cryptography\Chaos.NaCl\MontgomeryCurve25519.cs + + + Security\Cryptography\Chaos.NaCl\Sha512.cs + Security\Cryptography\AsymmetricCipher.cs + + Security\Cryptography\Bcrypt.cs + Security\Cryptography\BlockCipher.cs @@ -741,6 +1143,12 @@ Security\Cryptography\DsaKey.cs + + Security\Cryptography\ED25519DigitalSignature.cs + + + Security\Cryptography\ED25519Key.cs + Security\Cryptography\HMACMD5.cs @@ -759,6 +1167,12 @@ Security\Cryptography\Key.cs + + Security\Cryptography\EcdsaDigitalSignature.cs + + + Security\Cryptography\EcdsaKey.cs + Security\Cryptography\RsaDigitalSignature.cs @@ -804,6 +1218,24 @@ Security\KeyExchangeDiffieHellmanGroupSha1.cs + + Security\KeyExchangeEC.cs + + + Security\KeyExchangeECCurve25519.cs + + + Security\KeyExchangeECDH.cs + + + Security\KeyExchangeECDH256.cs + + + Security\KeyExchangeECDH384.cs + + + Security\KeyExchangeECDH521.cs + Security\KeyHostAlgorithm.cs @@ -1034,4 +1466,4 @@ --> - \ No newline at end of file + diff --git a/src/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj b/src/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj index f1bd9c407..7a915c18b 100644 --- a/src/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj +++ b/src/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj @@ -631,12 +631,414 @@ Security\Algorithm.cs + + Security\Cryptography\BouncyCastle\asn1\sec\SECNamedCurves.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9Curve.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParameters.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECParametersHolder.cs + + + Security\Cryptography\BouncyCastle\asn1\x9\X9ECPoint.cs + + + Security\Cryptography\BouncyCastle\crypto\agreement\ECDHCBasicAgreement.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricCipherKeyPair.cs + + + Security\Cryptography\BouncyCastle\crypto\AsymmetricKeyParameter.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\GeneralDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\digests\Sha256Digest.cs + + + Security\Cryptography\BouncyCastle\crypto\generators\ECKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IAsymmetricCipherKeyPairGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\IDigest.cs + + + Security\Cryptography\BouncyCastle\crypto\KeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECDomainParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyGenerationParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPrivateKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\parameters\ECPublicKeyParameters.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\CryptoApiRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\DigestRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\prng\IRandomGenerator.cs + + + Security\Cryptography\BouncyCastle\crypto\util\Pack.cs + + + Security\Cryptography\BouncyCastle\math\BigInteger.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\SimpleBigDecimal.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\Tnaf.cs + + + Security\Cryptography\BouncyCastle\math\ec\abc\ZTauElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECAlgorithms.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECCurve.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECFieldElement.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECLookupTable.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPoint.cs + + + Security\Cryptography\BouncyCastle\math\ec\ECPointMap.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\ECEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\endo\GlvEndomorphism.cs + + + Security\Cryptography\BouncyCastle\math\ec\LongArray.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\AbstractECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ECMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointCombMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\FixedPointUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\GlvMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\IPreCompCallback.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\PreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\ValidityPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafL2RMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WNafUtilities.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafMultiplier.cs + + + Security\Cryptography\BouncyCastle\math\ec\multiplier\WTauNafPreCompInfo.cs + + + Security\Cryptography\BouncyCastle\math\field\FiniteFields.cs + + + Security\Cryptography\BouncyCastle\math\field\GenericPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\GF2Polynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\IFiniteField.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomial.cs + + + Security\Cryptography\BouncyCastle\math\field\IPolynomialExtensionField.cs + + + Security\Cryptography\BouncyCastle\math\field\PrimeField.cs + + + Security\Cryptography\BouncyCastle\math\raw\Mod.cs + + + Security\Cryptography\BouncyCastle\math\raw\Nat.cs + + + Security\Cryptography\BouncyCastle\security\DigestUtilities.cs + + + Security\Cryptography\BouncyCastle\security\SecureRandom.cs + + + Security\Cryptography\BouncyCastle\security\SecurityUtilityException.cs + + + Security\Cryptography\BouncyCastle\util\Arrays.cs + + + Security\Cryptography\BouncyCastle\util\BigIntegers.cs + + + Security\Cryptography\BouncyCastle\util\encoders\Hex.cs + + + Security\Cryptography\BouncyCastle\util\encoders\HexEncoder.cs + + + Security\Cryptography\BouncyCastle\util\Enums.cs + + + Security\Cryptography\BouncyCastle\util\IMemoable.cs + + + Security\Cryptography\BouncyCastle\util\Integers.cs + + + Security\Cryptography\BouncyCastle\util\MemoableResetException.cs + + + Security\Cryptography\BouncyCastle\util\Times.cs + Security\CertificateHostAlgorithm.cs + + Security\Cryptography\Chaos.NaCl\CryptoBytes.cs + + + Security\Cryptography\Chaos.NaCl\Ed25519.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array16.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Array8.cs + + + Security\Cryptography\Chaos.NaCl\Internal\ByteIntegerConverter.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\base2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\d2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cmov.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_cswap.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_invert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnegative.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_isnonzero.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_mul121666.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_neg.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_pow22523.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sq2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\fe_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\FieldElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_double_scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_frombytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_madd.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_msub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p1p1_to_p3.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p2_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_dbl.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_cached.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_p3_to_p2.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_precomp_0.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_scalarmult_base.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_sub.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\ge_tobytes.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\GroupElement.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\keypair.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\open.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\scalarmult.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_clamp.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_mul_add.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sc_reduce.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sign.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Ed25519Ref10\sqrtm1.cs + + + Security\Cryptography\Chaos.NaCl\Internal\InternalAssert.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Poly1305Donna.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\Salsa20.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Salsa\SalsaCore.cs + + + Security\Cryptography\Chaos.NaCl\Internal\Sha512Internal.cs + + + Security\Cryptography\Chaos.NaCl\MontgomeryCurve25519.cs + + + Security\Cryptography\Chaos.NaCl\Sha512.cs + Security\Cryptography\AsymmetricCipher.cs + + Security\Cryptography\Bcrypt.cs + Security\Cryptography\BlockCipher.cs @@ -703,6 +1105,12 @@ Security\Cryptography\DsaKey.cs + + Security\Cryptography\ED25519DigitalSignature.cs + + + Security\Cryptography\ED25519Key.cs + Security\Cryptography\HMACMD5.cs @@ -721,6 +1129,12 @@ Security\Cryptography\Key.cs + + Security\Cryptography\EcdsaDigitalSignature.cs + + + Security\Cryptography\EcdsaKey.cs + Security\Cryptography\RsaDigitalSignature.cs @@ -766,6 +1180,24 @@ Security\KeyExchangeDiffieHellmanGroupSha1.cs + + Security\KeyExchangeEC.cs + + + Security\KeyExchangeECCurve25519.cs + + + Security\KeyExchangeECDH.cs + + + Security\KeyExchangeECDH256.cs + + + Security\KeyExchangeECDH384.cs + + + Security\KeyExchangeECDH521.cs + Security\KeyHostAlgorithm.cs @@ -1007,4 +1439,4 @@ --> - \ No newline at end of file + diff --git a/src/Renci.SshNet/Common/DerData.cs b/src/Renci.SshNet/Common/DerData.cs index c84c0b176..35178798a 100644 --- a/src/Renci.SshNet/Common/DerData.cs +++ b/src/Renci.SshNet/Common/DerData.cs @@ -12,7 +12,7 @@ public class DerData private const byte Boolean = 0x01; private const byte Integer = 0x02; - //private const byte BITSTRING = 0x03; + private const byte BITSTRING = 0x03; private const byte Octetstring = 0x04; private const byte Null = 0x05; private const byte Objectidentifier = 0x06; @@ -70,12 +70,20 @@ public DerData() /// Initializes a new instance of the class. /// /// DER encoded data. - public DerData(byte[] data) + /// its a construct + public DerData(byte[] data, bool construct = false) { _data = new List(data); - ReadByte(); // skip dataType - var length = ReadLength(); - _lastIndex = _readerIndex + length; + if (construct) + { + _lastIndex = _readerIndex + data.Length; + } + else + { + ReadByte(); // skip dataType + var length = ReadLength(); + _lastIndex = _readerIndex + length; + } } /// @@ -101,7 +109,7 @@ public BigInteger ReadBigInteger() { var type = ReadByte(); if (type != Integer) - throw new InvalidOperationException("Invalid data type, INTEGER(02) is expected."); + throw new InvalidOperationException(string.Format("Invalid data type, INTEGER(02) is expected, but was {0}", type.ToString("X2"))); var length = ReadLength(); @@ -118,7 +126,7 @@ public int ReadInteger() { var type = ReadByte(); if (type != Integer) - throw new InvalidOperationException("Invalid data type, INTEGER(02) is expected."); + throw new InvalidOperationException(string.Format("Invalid data type, INTEGER(02) is expected, but was {0}", type.ToString("X2"))); var length = ReadLength(); @@ -140,6 +148,51 @@ public int ReadInteger() return result; } + /// + /// Reads next octetstring data type from internal buffer. + /// + /// data read. + public byte[] ReadOctetString() + { + var type = ReadByte(); + if (type != Octetstring) + throw new InvalidOperationException(string.Format("Invalid data type, OCTETSTRING(04) is expected, but was {0}", type.ToString("X2"))); + + var length = ReadLength(); + var data = ReadBytes(length); + return data; + } + + /// + /// Reads next bitstring data type from internal buffer. + /// + /// data read. + public byte[] ReadBitString() + { + var type = ReadByte(); + if (type != BITSTRING) + throw new InvalidOperationException(string.Format("Invalid data type, BITSTRING(03) is expected, but was {0}", type.ToString("X2"))); + + var length = ReadLength(); + var data = ReadBytes(length); + return data; + } + + /// + /// Reads next object data type from internal buffer. + /// + /// data read. + public byte[] ReadObject() + { + var type = ReadByte(); + if (type != Objectidentifier) + throw new InvalidOperationException(string.Format("Invalid data type, OBJECT(06) is expected, but was {0}", type.ToString("X2"))); + + var length = ReadLength(); + var data = ReadBytes(length); + return data; + } + /// /// Writes BOOLEAN data into internal buffer. /// @@ -189,6 +242,18 @@ public void Write(byte[] data) WriteBytes(data); } + /// + /// Writes BITSTRING data into internal buffer. + /// + /// The data. + public void WriteBitstring(byte[] data) + { + _data.Add(BITSTRING); + var length = GetLength(data.Length); + WriteBytes(length); + WriteBytes(data); + } + /// /// Writes OBJECTIDENTIFIER data into internal buffer. /// @@ -229,6 +294,18 @@ public void Write(ObjectIdentifier identifier) WriteBytes(bytes); } + /// + /// Writes OBJECTIDENTIFIER data into internal buffer. + /// + /// The bytes. + public void WriteObjectIdentifier(byte[] bytes) + { + _data.Add(Objectidentifier); + var length = GetLength(bytes.Length); + WriteBytes(length); + WriteBytes(bytes); + } + /// /// Writes NULL data into internal buffer. /// @@ -268,10 +345,13 @@ private static IEnumerable GetLength(int length) return data; } - return new[] {(byte) length}; + return new[] { (byte)length }; } - - private int ReadLength() + /// + /// Gets Data Length + /// + /// length + public int ReadLength() { int length = ReadByte(); @@ -306,12 +386,19 @@ private int ReadLength() return length; } - private void WriteBytes(IEnumerable data) + /// + /// Write Byte data into internal buffer. + /// + public void WriteBytes(IEnumerable data) { _data.AddRange(data); } - private byte ReadByte() + /// + /// Reads Byte data into internal buffer. + /// + /// data read + public byte ReadByte() { if (_readerIndex > _data.Count) throw new InvalidOperationException("Read out of boundaries."); @@ -319,7 +406,12 @@ private byte ReadByte() return _data[_readerIndex++]; } - private byte[] ReadBytes(int length) + /// + /// Reads lengths Bytes data into internal buffer. + /// + /// data read + /// amount of data to read. + public byte[] ReadBytes(int length) { if (_readerIndex + length > _data.Count) throw new InvalidOperationException("Read out of boundaries."); @@ -330,4 +422,4 @@ private byte[] ReadBytes(int length) return result; } } -} +} \ No newline at end of file diff --git a/src/Renci.SshNet/Common/Extensions.cs b/src/Renci.SshNet/Common/Extensions.cs index 9d163bc96..b2c2e7d75 100644 --- a/src/Renci.SshNet/Common/Extensions.cs +++ b/src/Renci.SshNet/Common/Extensions.cs @@ -72,6 +72,20 @@ internal static BigInteger ToBigInteger(this byte[] data) return new BigInteger(reversed.Reverse()); } + /// + /// Initializes a new instance of the structure using the SSH BigNum2 Format + /// + public static BigInteger ToBigInteger2(this byte[] data) + { + if ((data[0] & (1 << 7)) != 0) + { + var buf = new byte[data.Length + 1]; + Buffer.BlockCopy(data, 0, buf, 1, data.Length); + data = buf; + } + return data.ToBigInteger(); + } + /// /// Reverses the sequence of the elements in the entire one-dimensional . /// @@ -247,6 +261,20 @@ public static byte[] TrimLeadingZeros(this byte[] value) return value; } + /// + /// Pads with leading zeros if needd + /// + /// The data. + /// The length to pad to. + public static byte[] Pad(this byte[] data, int length) + { + if (length <= data.Length) + return data; + var newData = new byte[length]; + Buffer.BlockCopy(data, 0, newData, newData.Length - data.Length, data.Length); + return newData; + } + public static byte[] Concat(this byte[] first, byte[] second) { if (first == null || first.Length == 0) diff --git a/src/Renci.SshNet/ConnectionInfo.cs b/src/Renci.SshNet/ConnectionInfo.cs index f9b872d3c..d76882c25 100644 --- a/src/Renci.SshNet/ConnectionInfo.cs +++ b/src/Renci.SshNet/ConnectionInfo.cs @@ -322,14 +322,15 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy KeyExchangeAlgorithms = new Dictionary { + {"curve25519-sha256", typeof(KeyExchangeECCurve25519)}, + {"curve25519-sha256@libssh.org", typeof(KeyExchangeECCurve25519)}, + {"ecdh-sha2-nistp256", typeof(KeyExchangeECDH256)}, + {"ecdh-sha2-nistp384", typeof(KeyExchangeECDH384)}, + {"ecdh-sha2-nistp521", typeof(KeyExchangeECDH521)}, {"diffie-hellman-group-exchange-sha256", typeof (KeyExchangeDiffieHellmanGroupExchangeSha256)}, {"diffie-hellman-group-exchange-sha1", typeof (KeyExchangeDiffieHellmanGroupExchangeSha1)}, {"diffie-hellman-group14-sha1", typeof (KeyExchangeDiffieHellmanGroup14Sha1)}, {"diffie-hellman-group1-sha1", typeof (KeyExchangeDiffieHellmanGroup1Sha1)}, - //{"ecdh-sha2-nistp256", typeof(KeyExchangeEllipticCurveDiffieHellman)}, - //{"ecdh-sha2-nistp256", typeof(...)}, - //{"ecdh-sha2-nistp384", typeof(...)}, - //{"ecdh-sha2-nistp521", typeof(...)}, //"gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD //"gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==" - WinSSHD }; @@ -377,9 +378,14 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy HostKeyAlgorithms = new Dictionary> { + {"ssh-ed25519", data => new KeyHostAlgorithm("ssh-ed25519", new ED25519Key(), data)}, +#if FEATURE_ECDSA + {"ecdsa-sha2-nistp256", data => new KeyHostAlgorithm("ecdsa-sha2-nistp256", new EcdsaKey(), data)}, + {"ecdsa-sha2-nistp384", data => new KeyHostAlgorithm("ecdsa-sha2-nistp384", new EcdsaKey(), data)}, + {"ecdsa-sha2-nistp521", data => new KeyHostAlgorithm("ecdsa-sha2-nistp521", new EcdsaKey(), data)}, +#endif {"ssh-rsa", data => new KeyHostAlgorithm("ssh-rsa", new RsaKey(), data)}, {"ssh-dss", data => new KeyHostAlgorithm("ssh-dss", new DsaKey(), data)}, - //{"ecdsa-sha2-nistp256 "} //{"x509v3-sign-rsa", () => { ... }, //{"x509v3-sign-dss", () => { ... }, //{"spki-sign-rsa", () => { ... }, diff --git a/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs b/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs index 2620d982a..ddcf03f19 100644 --- a/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs +++ b/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhInitMessage.cs @@ -1,6 +1,4 @@ -#if false - -using System; +using System; using Renci.SshNet.Common; namespace Renci.SshNet.Messages.Transport @@ -8,7 +6,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Represents SSH_MSG_KEXECDH_INIT message. /// - [Message("SSH_MSG_KEXECDH_INIT", 30)] + [Message("SSH_MSG_KEX_ECDH_INIT", 30)] internal class KeyExchangeEcdhInitMessage : Message, IKeyExchangedAllowed { /// @@ -33,6 +31,14 @@ protected override int BufferCapacity } } + /// + /// Initializes a new instance of the class. + /// + public KeyExchangeEcdhInitMessage(byte[] q) + { + QC = q; + } + /// /// Initializes a new instance of the class. /// @@ -63,7 +69,10 @@ protected override void SaveData() { WriteBinaryString(QC); } - } -} -#endif // false \ No newline at end of file + internal override void Process(Session session) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs b/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs index 42c363150..a194caf1e 100644 --- a/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs +++ b/src/Renci.SshNet/Messages/Transport/KeyExchangeEcdhReplyMessage.cs @@ -1,11 +1,9 @@ -#if false - -namespace Renci.SshNet.Messages.Transport +namespace Renci.SshNet.Messages.Transport { /// /// Represents SSH_MSG_KEXECDH_REPLY message. /// - [Message("SSH_MSG_KEXECDH_REPLY", 31)] + [Message("SSH_MSG_KEX_ECDH_REPLY", 31)] public class KeyExchangeEcdhReplyMessage : Message { /// @@ -65,7 +63,10 @@ protected override void SaveData() WriteBinaryString(QS); WriteBinaryString(Signature); } - } -} -#endif // false \ No newline at end of file + internal override void Process(Session session) + { + session.OnKeyExchangeEcdhReplyMessageReceived(this); + } + } +} \ No newline at end of file diff --git a/src/Renci.SshNet/PrivateKeyFile.cs b/src/Renci.SshNet/PrivateKeyFile.cs index f44672347..31fac7db4 100644 --- a/src/Renci.SshNet/PrivateKeyFile.cs +++ b/src/Renci.SshNet/PrivateKeyFile.cs @@ -11,6 +11,7 @@ using Renci.SshNet.Security.Cryptography.Ciphers.Modes; using Renci.SshNet.Security.Cryptography.Ciphers.Paddings; using System.Diagnostics.CodeAnalysis; +using Renci.SshNet.Security.Cryptography; namespace Renci.SshNet { @@ -22,7 +23,21 @@ namespace Renci.SshNet /// /// /// - /// Supports RSA and DSA private key in both OpenSSH and ssh.com format. + /// The following private keys are supported: + /// + /// + /// RSA in OpenSSL PEM and ssh.com format + /// + /// + /// DSA in OpenSSL PEM and ssh.com format + /// + /// + /// ECDSA 256/384/521 in OpenSSL PEM format + /// + /// + /// ED25519 in OpenSSH key format + /// + /// /// /// /// The following encryption algorithms are supported: @@ -197,6 +212,16 @@ private void Open(Stream privateKey, string passPhrase) _key = new DsaKey(decryptedData); HostKey = new KeyHostAlgorithm("ssh-dss", _key); break; +#if FEATURE_ECDSA + case "EC": + _key = new EcdsaKey(decryptedData); + HostKey = new KeyHostAlgorithm(_key.ToString(), _key); + break; +#endif + case "OPENSSH": + _key = ParseOpenSshV1Key(decryptedData, passPhrase); + HostKey = new KeyHostAlgorithm(_key.ToString(), _key); + break; case "SSH2 ENCRYPTED": var reader = new SshDataReader(decryptedData); var magicNumber = reader.ReadUInt32(); @@ -341,6 +366,144 @@ private static byte[] DecryptKey(CipherInfo cipherInfo, byte[] cipherData, strin return cipher.Decrypt(cipherData); } + /// + /// Parses an OpenSSH V1 key file (i.e. ED25519 key) according to the the key spec: + /// https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key. + /// + /// the key file data (i.e. base64 encoded data between the header/footer) + /// passphrase or null if there isn't one + /// + private ED25519Key ParseOpenSshV1Key(byte [] keyFileData, string passPhrase) + { + var keyReader = new SshDataReader(keyFileData); + + //check magic header + var authMagic = Encoding.UTF8.GetBytes("openssh-key-v1\0"); + var keyHeaderBytes = keyReader.ReadBytes(authMagic.Length); + if (!authMagic.IsEqualTo(keyHeaderBytes)) + { + throw new SshException("This openssh key does not contain the 'openssh-key-v1' format magic header"); + } + + //cipher will be "aes256-cbc" if using a passphrase, "none" otherwise + var cipherName = keyReader.ReadString(Encoding.UTF8); + //key derivation function (kdf): bcrypt or nothing + var kdfName = keyReader.ReadString(Encoding.UTF8); + //kdf options length: 24 if passphrase, 0 if no passphrase + var kdfOptionsLen = (int)keyReader.ReadUInt32(); + byte[] salt = null; + int rounds = 0; + if (kdfOptionsLen > 0) + { + var saltLength = (int)keyReader.ReadUInt32(); + salt = keyReader.ReadBytes(saltLength); + rounds = (int)keyReader.ReadUInt32(); + } + + //number of public keys, only supporting 1 for now + var numberOfPublicKeys = (int)keyReader.ReadUInt32(); + if (numberOfPublicKeys != 1) + { + throw new SshException("At this time only one public key in the openssh key is supported."); + } + + //length of first public key section + keyReader.ReadUInt32(); + var keyType = keyReader.ReadString(Encoding.UTF8); + if(keyType != "ssh-ed25519") + { + throw new SshException("openssh key type: " + keyType + " is not supported"); + } + + //read public key + var publicKeyLength = (int)keyReader.ReadUInt32(); //32 + var publicKey = keyReader.ReadBytes(publicKeyLength); + + //possibly encrypted private key + var privateKeyLength = (int)keyReader.ReadUInt32(); + var privateKeyBytes = keyReader.ReadBytes(privateKeyLength); + + //decrypt private key if necessary + if (cipherName == "aes256-cbc") + { + if (string.IsNullOrEmpty(passPhrase)) + { + throw new SshPassPhraseNullOrEmptyException("Private key is encrypted but passphrase is empty."); + } + if (string.IsNullOrEmpty(kdfName) || kdfName != "bcrypt") + { + throw new SshException("kdf " + kdfName + " is not supported for openssh key file"); + } + + //inspired by the SSHj library (https://github.com/hierynomus/sshj) + //apply the kdf to derive a key and iv from the passphrase + var passPhraseBytes = Encoding.UTF8.GetBytes(passPhrase); + byte[] keyiv = new byte[48]; + new BCrypt().Pbkdf(passPhraseBytes, salt, rounds, keyiv); + byte[] key = new byte[32]; + Array.Copy(keyiv, 0, key, 0, 32); + byte[] iv = new byte[16]; + Array.Copy(keyiv, 32, iv, 0, 16); + + //now that we have the key/iv, use a cipher to decrypt the bytes + var cipher = new AesCipher(key, new CbcCipherMode(iv), new PKCS7Padding()); + privateKeyBytes = cipher.Decrypt(privateKeyBytes); + } + else if (cipherName != "none") + { + throw new SshException("cipher name " + cipherName + " for openssh key file is not supported"); + } + + //validate private key length + privateKeyLength = privateKeyBytes.Length; + if (privateKeyLength % 8 != 0) + { + throw new SshException("The private key section must be a multiple of the block size (8)"); + } + + //now parse the data we called the private key, it actually contains the public key again + //so we need to parse through it to get the private key bytes, plus there's some + //validation we need to do. + var privateKeyReader = new SshDataReader(privateKeyBytes); + + //check ints should match, they wouldn't match for example if the wrong passphrase was supplied + int checkInt1 = (int)privateKeyReader.ReadUInt32(); + int checkInt2 = (int)privateKeyReader.ReadUInt32(); + if (checkInt1 != checkInt2) + { + throw new SshException("The checkints differed, the openssh key was not correctly decoded."); + } + + //key type, we already know it is ssh-ed25519 + privateKeyReader.ReadString(Encoding.UTF8); + + //public key length/bytes (again) + var publicKeyLength2 = (int)privateKeyReader.ReadUInt32(); + privateKeyReader.ReadBytes(publicKeyLength2); + + //length of private and public key (64) + privateKeyReader.ReadUInt32(); + var unencryptedPrivateKey = privateKeyReader.ReadBytes(32); + //public key (again) + privateKeyReader.ReadBytes(32); + + //comment, we don't need this but we could log it, not sure if necessary + var comment = privateKeyReader.ReadString(Encoding.UTF8); + + //The list of privatekey/comment pairs is padded with the bytes 1, 2, 3, ... + //until the total length is a multiple of the cipher block size. + var padding = privateKeyReader.ReadBytes(); + for (int i = 0; i < padding.Length; i++) + { + if ((int)padding[i] != i + 1) + { + throw new SshException("Padding of openssh key format contained wrong byte at position: " + i); + } + } + + return new ED25519Key(publicKey.Reverse(), unencryptedPrivateKey); + } + #region IDisposable Members private bool _isDisposed; @@ -409,6 +572,11 @@ public SshDataReader(byte[] data) return base.ReadBytes(length); } + public new byte[] ReadBytes() + { + return base.ReadBytes(); + } + /// /// Reads next mpint data type from internal buffer where length specified in bits. /// diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj index 0598d18ce..d44d10bb2 100644 --- a/src/Renci.SshNet/Renci.SshNet.csproj +++ b/src/Renci.SshNet/Renci.SshNet.csproj @@ -18,7 +18,7 @@ full false bin\Debug\ - TRACE;DEBUG;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII + TRACE;DEBUG;FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII;FEATURE_ECDSA prompt 4 bin\Debug\Renci.SshNet.xml @@ -29,7 +29,7 @@ none true bin\Release\ - FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII + FEATURE_REGEX_COMPILE;FEATURE_BINARY_SERIALIZATION;FEATURE_RNG_CREATE;FEATURE_SOCKET_SYNC;FEATURE_SOCKET_EAP;FEATURE_SOCKET_APM;FEATURE_SOCKET_SETSOCKETOPTION;FEATURE_SOCKET_SELECT;FEATURE_SOCKET_POLL;FEATURE_SOCKET_DISPOSE;FEATURE_STREAM_APM;FEATURE_DNS_SYNC;FEATURE_THREAD_COUNTDOWNEVENT;FEATURE_THREAD_THREADPOOL;FEATURE_THREAD_SLEEP;FEATURE_WAITHANDLE_DISPOSE;FEATURE_HASH_MD5;FEATURE_HASH_SHA1_CREATE;FEATURE_HASH_SHA256_CREATE;FEATURE_HASH_SHA384_CREATE;FEATURE_HASH_SHA512_CREATE;FEATURE_HASH_RIPEMD160_CREATE;FEATURE_HMAC_MD5;FEATURE_HMAC_SHA1;FEATURE_HMAC_SHA256;FEATURE_HMAC_SHA384;FEATURE_HMAC_SHA512;FEATURE_HMAC_RIPEMD160;FEATURE_MEMORYSTREAM_GETBUFFER;FEATURE_DIAGNOSTICS_TRACESOURCE;FEATURE_ENCODING_ASCII;FEATURE_ECDSA prompt 4 bin\Release\Renci.SshNet.xml @@ -168,6 +168,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -176,6 +314,12 @@ + + + + + + @@ -468,6 +612,8 @@ + +