sshkey 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -4,14 +4,14 @@ Generate private/public SSH keys using Ruby without the `ssh-keygen` system comm
4
4
 
5
5
  gem install sshkey
6
6
 
7
- Currently requires Ruby 1.9.
8
-
7
+ Tested on Ruby 1.8.7 and 1.9.2 (MRI).
8
+
9
9
  == Usage
10
10
 
11
11
  Generate an SSH Keypair with foo@bar.com as the comment - providing a comment is optional
12
12
 
13
13
  k = SSHKey.generate(:comment => "foo@bar.com")
14
-
14
+
15
15
  Return an SSHKey object from an existing RSA Private Key (provided as a string)
16
16
 
17
17
  k = SSHKey.new(File.read("~/.ssh/id_rsa"), :comment => "foo@bar.com")
@@ -22,19 +22,19 @@ Both of these will return an SSHKey object with the following methods:
22
22
  # See http://www.ruby-doc.org/stdlib/libdoc/openssl/rdoc/classes/OpenSSL/PKey/RSA.html
23
23
  k.key_object
24
24
  # => -----BEGIN RSA PRIVATE KEY-----\nMIIEowI...
25
-
25
+
26
26
  # Returns the RSA Private Key as a string
27
27
  k.rsa_private_key
28
28
  # => "-----BEGIN RSA PRIVATE KEY-----\nMIIEowI..."
29
-
29
+
30
30
  # Returns the RSA Public Key as a string
31
31
  k.rsa_public_key
32
32
  # => "-----BEGIN RSA PUBLIC KEY-----\nMIIBCg..."
33
-
33
+
34
34
  # Returns the SSH Public Key as a string
35
35
  k.ssh_public_key
36
36
  # => "ssh-rsa AAAAB3NzaC1yc2EA...."
37
-
37
+
38
38
  # Returns the comment as a string
39
39
  k.comment
40
40
  # => "foo@bar.com"
data/lib/sshkey.rb CHANGED
@@ -11,12 +11,17 @@ class SSHKey
11
11
  attr_reader :key_object, :comment, :rsa_private_key, :rsa_public_key, :ssh_public_key, :fingerprint
12
12
 
13
13
  def initialize(private_key, options = {})
14
- @key_object = OpenSSL::PKey::RSA.new(private_key)
15
- @comment = options[:comment] || ""
16
- @rsa_private_key = @key_object.to_pem
17
- @rsa_public_key = @key_object.public_key.to_pem
18
- @ssh_public_key = ["ssh-rsa", Base64.strict_encode64(ssh_public_key_conversion), @comment].join(" ").strip
19
- @fingerprint = Digest::MD5.hexdigest(ssh_public_key_conversion).gsub(/(.{2})(?=.)/, '\1:\2')
14
+ @key_object = OpenSSL::PKey::RSA.new(private_key)
15
+ @comment = options[:comment] || ""
16
+ @rsa_private_key = @key_object.to_pem
17
+ @rsa_public_key = @key_object.public_key.to_pem
18
+ raw_ssh_public_key = ssh_public_key_conversion
19
+ @ssh_public_key = [
20
+ "ssh-rsa",
21
+ Base64.encode64(raw_ssh_public_key).gsub("\n", ""),
22
+ @comment,
23
+ ].join(" ").strip
24
+ @fingerprint = Digest::MD5.hexdigest(raw_ssh_public_key).gsub(/(.{2})(?=.)/, '\1:\2')
20
25
  end
21
26
 
22
27
  private
@@ -1,3 +1,3 @@
1
1
  class SSHKey
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
data/test/sshkey_test.rb CHANGED
@@ -82,19 +82,19 @@ EOF
82
82
  end
83
83
 
84
84
  def test_ssh_public_key_decoded1
85
- assert_equal Base64.strict_decode64(SSH_PUBLIC_KEY1), @key1.send(:ssh_public_key_conversion)
85
+ assert_equal Base64.decode64(SSH_PUBLIC_KEY1), @key1.send(:ssh_public_key_conversion)
86
86
  end
87
87
 
88
88
  def test_ssh_public_key_decoded2
89
- assert_equal Base64.strict_decode64(SSH_PUBLIC_KEY2), @key2.send(:ssh_public_key_conversion)
89
+ assert_equal Base64.decode64(SSH_PUBLIC_KEY2), @key2.send(:ssh_public_key_conversion)
90
90
  end
91
91
 
92
92
  def test_ssh_public_key_encoded1
93
- assert_equal SSH_PUBLIC_KEY1, Base64.strict_encode64(@key1.send(:ssh_public_key_conversion))
93
+ assert_equal SSH_PUBLIC_KEY1, Base64.encode64(@key1.send(:ssh_public_key_conversion)).gsub("\n", "")
94
94
  end
95
95
 
96
96
  def test_ssh_public_key_encoded2
97
- assert_equal SSH_PUBLIC_KEY2, Base64.strict_encode64(@key2.send(:ssh_public_key_conversion))
97
+ assert_equal SSH_PUBLIC_KEY2, Base64.encode64(@key2.send(:ssh_public_key_conversion)).gsub("\n", "")
98
98
  end
99
99
 
100
100
  def test_ssh_public_key_output
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkey
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease:
5
- version: 1.1.1
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 2
10
+ version: 1.1.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - James Miller
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-03-12 23:00:00 -08:00
18
+ date: 2011-04-19 00:00:00 -07:00
14
19
  default_executable:
15
20
  dependencies: []
16
21
 
@@ -47,17 +52,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
52
  requirements:
48
53
  - - ">="
49
54
  - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
50
58
  version: "0"
51
59
  required_rubygems_version: !ruby/object:Gem::Requirement
52
60
  none: false
53
61
  requirements:
54
62
  - - ">="
55
63
  - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
56
67
  version: "0"
57
68
  requirements: []
58
69
 
59
70
  rubyforge_project: sshkey
60
- rubygems_version: 1.6.2
71
+ rubygems_version: 1.5.2
61
72
  signing_key:
62
73
  specification_version: 3
63
74
  summary: SSH private/public key generator in Ruby