Skip to content

Commit

Permalink
Merge pull request #32 from pocke/supress-warnings
Browse files Browse the repository at this point in the history
Supress warnings
  • Loading branch information
bensie committed Aug 6, 2017
2 parents 187c159 + cbc561d commit ba6d3bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/sshkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def generate(options = {})
default_bits = type == "rsa" ? 2048 : 1024

bits = options[:bits] || default_bits
cipher = OpenSSL::Cipher::Cipher.new("AES-128-CBC") if options[:passphrase]
cipher = OpenSSL::Cipher.new("AES-128-CBC") if options[:passphrase]

case type.downcase
when "rsa" then new(OpenSSL::PKey::RSA.generate(bits).to_pem(cipher, options[:passphrase]), options)
Expand Down Expand Up @@ -121,7 +121,7 @@ def sha256_fingerprint(key)
def ssh_public_key_to_ssh2_public_key(ssh_public_key, headers = nil)
raise PublicKeyError, "invalid ssh public key" unless SSHKey.valid_ssh_public_key?(ssh_public_key)

source_format, source_key = parse_ssh_public_key(ssh_public_key)
_source_format, source_key = parse_ssh_public_key(ssh_public_key)

# Add a 'Comment' Header Field unless others are explicitly passed in
if source_comment = ssh_public_key.split(source_key)[1]
Expand Down Expand Up @@ -231,7 +231,7 @@ def private_key
# If no passphrase is set, returns the unencrypted private key
def encrypted_private_key
return private_key unless passphrase
key_object.to_pem(OpenSSL::Cipher::Cipher.new("AES-128-CBC"), passphrase)
key_object.to_pem(OpenSSL::Cipher.new("AES-128-CBC"), passphrase)
end

# Fetch the RSA/DSA public key
Expand Down
5 changes: 1 addition & 4 deletions test/sshkey_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,6 @@ def test_ssh2_public_key_output
expected1 = SSH2_PUBLIC_KEY1
expected2 = SSH2_PUBLIC_KEY2
expected3 = SSH2_PUBLIC_KEY3
public_key1 = "ssh-rsa #{SSH_PUBLIC_KEY1} me@example.com"
public_key2 = "ssh-rsa #{SSH_PUBLIC_KEY2}"
public_key3 = "ssh-rsa #{SSH_PUBLIC_KEY3} 1024-bit DSA with provided comment"

assert_equal expected1, @key1.ssh2_public_key
assert_equal expected2, @key2.ssh2_public_key({})
Expand Down Expand Up @@ -385,7 +382,7 @@ def test_ssh2_public_key_bits
assert_equal(SSH2_PUBLIC_KEY2, SSHKey.ssh_public_key_to_ssh2_public_key(public_key2))
assert_equal(SSH2_PUBLIC_KEY2, SSHKey.ssh_public_key_to_ssh2_public_key(public_key2, {}))
assert_equal(SSH2_PUBLIC_KEY3, SSHKey.ssh_public_key_to_ssh2_public_key(public_key3, {'Comment' => '1024-bit DSA with provided comment', 'x-private-use-header' => 'some value that is long enough to go to wrap around to a new line.'}))
end
end

def test_exponent
assert_equal 35, @key1.key_object.e.to_i
Expand Down

0 comments on commit ba6d3bb

Please sign in to comment.