sshkeyproof 0.1 → 0.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/CHANGELOG CHANGED
@@ -1,2 +1,3 @@
1
+ v0.2. fixed filename incorrect, fixed double hex encode bug
1
2
  v0.1. first version
2
3
 
data/Manifest CHANGED
@@ -2,5 +2,5 @@ CHANGELOG
2
2
  Manifest
3
3
  README.md
4
4
  Rakefile
5
- lib/sshkeyauth.rb
5
+ lib/sshkeyproof.rb
6
6
  test/test_all.rb
data/README.md CHANGED
@@ -1,17 +1,17 @@
1
1
 
2
- h3. gem install 'sshkeyproof'
2
+ ### gem install 'sshkeyproof'
3
3
 
4
4
  If you have a user's public key, you can verify they are who they say they are (ie. they hold the correspending private key):
5
5
 
6
6
 
7
- h3. Client
7
+ ### Client
8
8
 
9
9
  The client takes their private key (defaults to ~/.ssh/id_rsa) and encrypts a random string as proof of work.
10
10
 
11
11
  request = Sshkeyproof::Client.new key_file: "./id_rsa"
12
12
 
13
13
 
14
- h3. Server
14
+ ### Server
15
15
 
16
16
  The server takes the request string and verifies it
17
17
 
@@ -13,14 +13,17 @@ module Sshkeyproof
13
13
  end
14
14
 
15
15
  def random
16
- @random ||= OpenSSL::Random.random_bytes(10).unpack('H*').first
16
+ @random ||= OpenSSL::Random.random_bytes(10)
17
17
  end
18
18
 
19
19
  def request
20
- ciphertext = @privkey.private_encrypt(random).unpack('H*').first
21
- "#{SSHKey.sha1_fingerprint(@pubkey.to_s)}|#{random.unpack('H*').first}|#{ciphertext}"
20
+ ciphertext = to_hex @privkey.private_encrypt(random)
21
+ [SSHKey.sha1_fingerprint(@pubkey.to_s),to_hex(random),ciphertext].join('|')
22
+ end
23
+
24
+ def to_hex(str)
25
+ str.unpack('H*').first
22
26
  end
23
-
24
27
  end
25
28
 
26
29
  class Server
@@ -31,7 +34,11 @@ module Sshkeyproof
31
34
 
32
35
  def correct?(key)
33
36
  openssl_key = String===key ? OpenSSL::PKey::RSA.new(key) : key
34
- @fingerprint && @random && @ciphertext && openssl_key.public_key.public_decrypt([@ciphertext].pack('H*')) == [@random].pack('H*') rescue nil
37
+ @fingerprint && @random && @ciphertext && openssl_key.public_key.public_decrypt(from_hex(@ciphertext)) == from_hex(@random) rescue nil
38
+ end
39
+
40
+ def from_hex(str)
41
+ [str].pack('H*')
35
42
  end
36
43
  end
37
44
 
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "sshkeyproof"
5
- s.version = "0.1"
5
+ s.version = "0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Andrew Snow"]
9
9
  s.date = "2013-01-24"
10
10
  s.description = "Ruby gem to prove client has the other half of a keypair"
11
11
  s.email = "andrew@modulus.org"
12
- s.extra_rdoc_files = ["CHANGELOG", "README.md", "lib/sshkeyauth.rb"]
13
- s.files = ["CHANGELOG", "Manifest", "README.md", "Rakefile", "lib/sshkeyauth.rb", "test/test_all.rb", "sshkeyproof.gemspec"]
12
+ s.extra_rdoc_files = ["CHANGELOG", "README.md", "lib/sshkeyproof.rb"]
13
+ s.files = ["CHANGELOG", "Manifest", "README.md", "Rakefile", "lib/sshkeyproof.rb", "test/test_all.rb", "sshkeyproof.gemspec"]
14
14
  s.homepage = "https://github.com/andys/sshkeyproof"
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sshkeyproof", "--main", "README.md"]
16
16
  s.require_paths = ["lib"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sshkeyproof
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: '0.1'
5
+ version: '0.2'
6
6
  platform: ruby
7
7
  authors:
8
8
  - Andrew Snow
@@ -34,13 +34,13 @@ extensions: []
34
34
  extra_rdoc_files:
35
35
  - CHANGELOG
36
36
  - README.md
37
- - lib/sshkeyauth.rb
37
+ - lib/sshkeyproof.rb
38
38
  files:
39
39
  - CHANGELOG
40
40
  - Manifest
41
41
  - README.md
42
42
  - Rakefile
43
- - lib/sshkeyauth.rb
43
+ - lib/sshkeyproof.rb
44
44
  - test/test_all.rb
45
45
  - sshkeyproof.gemspec
46
46
  homepage: https://github.com/andys/sshkeyproof