summaryrefslogtreecommitdiff
path: root/lib/net/ssh/buffer.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing commasBen Schmeckpeper2023-02-081-2/+2
|
* Don't use the deprecated set_XXX methods on RSA keys.Ben Schmeckpeper2023-02-081-21/+21
| | | | This code is taken from https://github.com/nov/json-jwt/pull/102/files
* Fix #854 regressionFlorian Wininger2022-04-291-5/+1
|
* fix rubocop issuesFlorian Wininger2022-04-291-15/+23
|
* buffer: create DSA keys by loading PEM data directlySimon Chopin2022-04-291-13/+18
| | | | | | | | | | | | | The OpenSSL 3.0 changes don't allow for us to modify the private key details directly, and there are no dedicated constructors as of Ruby 3.0, so we need to actually create a PEM certificate in-memory and load that instead. To add insult to injury, contrary to other types of keys such as RSA, we need to actually build the full PEM data and not just pack the numbers in a simple sequence, making the code even a bit more complicated. Co-authored-by: Lucas Kanashiro <lucas.kanashiro@canonical.com>
* buffer: create RSA keys by loading PEM data directlySimon Chopin2022-04-291-9/+9
| | | | | | | | | The OpenSSL 3.0 changes don't allow for us to modify the private key details directly, and there are no dedicated constructors as of Ruby 3.0, so we need to actually create a PEM certificate in-memory and load that instead. Co-authored-by: Lucas Kanashiro <lucas.kanashiro@canonical.com>
* Read ecdsa private key in openssh formatMartin Sander2022-04-121-0/+6
| | | | Fixes #657.
* Fix rubocop coding style.Florian Wininger2021-10-251-4/+4
| | | | Lot of spacing issues :)
* Support frozen_string_literalsmfazekas/frozen-literalMiklós Fazekas2021-08-071-4/+9
|
* Fix empty line for code clarityFlorian Wininger2021-07-011-1/+1
|
* Remove ruby_compat to comply with the new Ruby >= 2.3 requirementMaxime Alay-Eddine2019-11-131-1/+0
|
* Remove unnecessary defined?(OpenSSL::PKey::EC) and ↵Florian Wininger2019-08-231-9/+1
| | | | | | defined?(OpenSSL::Digest::SHA256) Signed-off-by: Florian Wininger <fw.centrale@gmail.com>
* Fixed private key read from new type ssh formatMiklos Fazekas2018-12-121-0/+40
|
* Whitespace fixeswhitespace-fixesMiklos Fazekas2018-03-211-2/+3
|
* Fix test test issueMiklos Fazekas2018-03-211-41/+41
|
* Updated rubocopMiklos Fazekas2018-03-211-341/+342
|
* Add support for SSH certificates for client authentication.David Bartley2017-01-101-3/+10
| | | | | | | | | This adds support for parsing and signing SSH certificates, and for using SSH certificates as identities when authenticating, via a "-cert.pub" file. This does not add support for authenticating host certificates. Supporting that requires understanding @cert-authority in known_hosts, and validating the hostname against the certificate principals.
* Rubocop update to 0.46.0Miklos Fazekas2016-12-151-1/+1
|
* Fix OpenSSL 2 deprecation warningsMiklos Fazekas2016-12-151-7/+20
|
* UTF-8: Optimize away dup when it's safe, added integrations testsMiklos Fazekas2016-07-231-0/+21
|
* Prevent encoding issues building UTF8 buffersIristyle2016-07-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Prior to this change, attempting to send UTF8 commands through SSH, or attempting to copy files with UTF8 filenames could fail. This was particularly easy to trigger by attempting to execute commands that were 128 bytes or longer. - monkey patch net-ssh gem to allow UTF-8 strings >= 128 bytes The buffer @content is often built as a UTF-8 string, until the point at which it appends data that cannot be encoded as a UTF-8 sequence. One case occurs when the call to write_string is made to append a string that exceeds 127 bytes in length. The SSH2 format says that strings must be length prefixed, and when the value [128] has pack("N*") called against it, the resultant 4 byte network order representation does not have a valid UTF-8 equivalent, resulting in an ASCII-8BIT / BINARY string. [127].pack('N*').encode('utf-8') => "\u0000\u0000\u0000\u007F" [128].pack('N*').encode('utf-8') Encoding::UndefinedConversionError: "\x80" from ASCII-8BIT to UTF-8 Ruby has a subtle behavior where appending a BINARY string to an existing UTF-8 string is allowed and the resultant string changes encoding to BINARY. However, once this has happened, the string can no longer have UTF-8 encoded strings appended as Ruby will raise an Encoding:CompatibilityError Appending BINARY to UTF-8 always creates BINARY: "foo".encode('utf-8') << [128].pack('N*') => "foo\x00\x00\x00\x80" Appending UTF-8 representable strings to existing strings: Ruby 2.1.7 keeps the string as its default UTF-8 "foo" << [127].pack('N*') => "foo\u0000\u0000\u0000\u007F" Ruby 1.9.3 keeps UTF-8 strings as UTF-8 "foo".encode('utf-8') << [127].pack('N*') => "foo\u0000\u0000\u0000\u007F" Ruby 1.9.3 defaults to US-ASCII which changes it to BINARY pry(main)> "foo" << [127].pack('N*') => "foo\x00\x00\x00\x7F" The simple solution is to call force_encoding on UTF-8 strings prior to appending them to @content, given it's always OK to append ASCII-8BIT / BINARY strings to existing strings, but appending UTF-8 to BINARY raises errors. "\x80".force_encoding('ASCII-8BIT') << "\u16A0" Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8 force_encoding in this case, will simply translate a valid UTF-8 string to its BINARY equivalent "\u16A0".force_encoding('BINARY') => "\xE1\x9A\xA0" Correct conversion per http://www.fileformat.info/info/unicode/char/16a0/index.htm
* Raise better errors if ED25519 support is not availableMiklos Fazekas2016-07-191-2/+4
|
* use bcrypt_pbkdf gem, add Gemfile, 4.0.0.alpha1Miklos Fazekas2016-03-191-0/+3
|
* Revert "Add support for ssh-ed25519 to lib/net/ssh/buffer.rb"Miklos Fazkeas2014-09-261-1/+1
| | | | This reverts commit 16398e414cdcf59939c31357c136a188fd10ecab.
* Add support for ssh-ed25519 to lib/net/ssh/buffer.rbChris Aumann2014-05-011-1/+1
|
* Handle ssh-rsa and ssh-dss certificate filesbobveznat-masterBob Van Zant2014-01-211-2/+2
| | | | | | | | | | | | | | | | | | This does not implement certificate based authentication (described here http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD) but instead makes it so that if the certificate is not needed for authentication net-ssh doesn't cause the entire application to die. The net-ssh test suite continues to pass. On my own machine I did tests with certificates loaded and verified that although authentication could not proceed to a host requiring a certificate it at least did not die. I also verified that I can continue to use normal rsa and dsa keys to ssh to hosts that do not require certificates even when the certificates are loaded into my ssh-agent instance. This is a potential solution to issue #124 and an alternative to the one presented in pull request #134.
* Removing warningsCarsten Dreesbach2012-12-231-1/+1
|
* Handle SSH messages that contain multibyte characters.Martin Emde2012-06-051-1/+1
| | | | | | | | | | | | | | Previously, UTF-8 encoded strings would result in the error: `final': data not multiple of block length (OpenSSL::Cipher::CipherError) This is because cipher padding length was based on character length instead of bytesize. When a UTF-8 character with a bytesize of e.g. 3 was encountered, Net::SSH would incorrectly add 2 more padding than was needed, breaking the block size multiple. Buffer also incorrectly identified the length of the string in write_string using character length instead of bytesize.
* implement many algorithmsRyosuke Yamazaki2012-03-261-2/+12
| | | | | | | | | | | | | | | | | | | | * Key Exchange * diffie-hellman-group14-sha1 * ecdh-sha2-nistp{256,384,521} * Host Key * ecdsa-sha2-nistp{256,384,521} * Authentication * ecdsa-sha2-nistp{256,384,521} * HMAC * hmac-ripemd160 * Cipher: * aes{128,192,256}-ctr * camellia{128,192,256}-ctr * blowfish-ctr * cast128-ctr * 3des-ctr * arcfour (has problems with weak keys, and should be used with caution) * camellia{128,192,256}-cbc
* tests all pass with ruby19Jamis Buck2008-09-061-1/+2
|
* start working to improve documentationJamis Buck2008-03-181-27/+92
|
* Starting to document everythingJamis Buck2007-08-171-0/+12
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@190 1d2a57f2-1ded-0310-ad52-83097a15a5de
* buffer testsJamis Buck2007-08-151-27/+15
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@183 1d2a57f2-1ded-0310-ad52-83097a15a5de
* tests for hostbased authmethodJamis Buck2007-08-141-1/+5
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@177 1d2a57f2-1ded-0310-ad52-83097a15a5de
* ssh-agent testsJamis Buck2007-08-141-0/+2
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@173 1d2a57f2-1ded-0310-ad52-83097a15a5de
* first pass at a test for diffie-hellman group1-sha1Jamis Buck2007-08-121-3/+4
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@158 1d2a57f2-1ded-0310-ad52-83097a15a5de
* Some more buffer enhancements (needed by the net-scp implementation) and ↵Jamis Buck2007-07-291-1/+25
| | | | | | make sure channel.close doesn't blow up if the channel has not been confirmed open yet git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@136 1d2a57f2-1ded-0310-ad52-83097a15a5de
* check the continuation status immediately after processing channels to avoid ↵Jamis Buck2007-07-281-0/+4
| | | | | | blocking on the select. fix the extended_data callback to use the correct parameters. git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@134 1d2a57f2-1ded-0310-ad52-83097a15a5de
* extended data callback. make sure remainder_as_buffer always returns a BufferJamis Buck2007-07-271-1/+1
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@132 1d2a57f2-1ded-0310-ad52-83097a15a5de
* infrastructure for supporting other async io, like forwarded connectionsJamis Buck2007-07-261-4/+2
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@121 1d2a57f2-1ded-0310-ad52-83097a15a5de
* buffer writes, rather than sending immediatelyJamis Buck2007-07-241-1/+1
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@119 1d2a57f2-1ded-0310-ad52-83097a15a5de
* keyboard-interactiveJamis Buck2007-07-241-0/+2
| | | | git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@118 1d2a57f2-1ded-0310-ad52-83097a15a5de
* Add v2 branchJamis Buck2007-07-241-0/+239
git-svn-id: http://svn.jamisbuck.org/net-ssh/branches/v2@117 1d2a57f2-1ded-0310-ad52-83097a15a5de