trocla 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15ad3b2b69741ce17e589140b7090df303bdaf47
4
- data.tar.gz: 591f3017a167c65b611efb10f8df06697b3988d4
3
+ metadata.gz: 6cc13bcea543e4ccd2ace87edf965b1ec6e2487b
4
+ data.tar.gz: c95767b887c4ab8b7b96d44bd540466d6abc822a
5
5
  SHA512:
6
- metadata.gz: f5020ec59b39e4e260955a9b8b3bd54bdd1c018c4fc3223f098130179a50d924fc1a4aad542895c92990170444d227a92d2f225b522be259973a3f2a570857c7
7
- data.tar.gz: 619b079e82c5e251ff61e0791245ea43adc139aa1d7e32f543acb6185faae8c5dc4fe30befb2a8c8997c9f979ca0ffa9e8369670117b10f3c0deaf24bcf6e230
6
+ metadata.gz: 9eb288ca58b60a7965bd366ac49425a0e5232ae26b358c914eeccaeedf61aa5f093b6885f4e96d859d173f5224c132bfc2079ae54e1949f80ffc5fa13294747a
7
+ data.tar.gz: 0a88f7c1e41ff3f77c0db5f2cf7bf0dffe9a6a155b5246150015b9db3871bb7a5f4a39a377eaa88e9426159e4fdd185935fbb7e03694f6dd9157be8037cb48f4
data/README.md CHANGED
@@ -177,6 +177,12 @@ ssl_options:
177
177
 
178
178
  ## Update & Changes
179
179
 
180
+ ### to 0.1.1
181
+
182
+ 1. fix storing data longer that public Keysize -11. Thanks [Timo Goebel](https://github.com/timogoebel)
183
+ 1. add a numeric only charset. Thanks [Jonas Genannt](https://github.com/hggh)
184
+ 1. fix reading key expire time. Thanks [asquelt](https://github.com/asquelt)
185
+
180
186
  ### to 0.1.0
181
187
 
182
188
  1. Supporting encryption of the backends. Many thanks to Thomas Gelf
data/lib/VERSION CHANGED
@@ -1,4 +1,4 @@
1
1
  major:0
2
2
  minor:1
3
- patch:0
3
+ patch:1
4
4
  build:
@@ -3,22 +3,27 @@ require 'base64'
3
3
 
4
4
  class Trocla::Encryptions::Ssl < Trocla::Encryptions::Base
5
5
  def encrypt(value)
6
- if option :use_base64
7
- Base64.encode64(public_key.public_encrypt(value))
8
- else
9
- public_key.public_encrypt(value)
6
+ ciphertext = ''
7
+ value.scan(/.{0,#{chunksize}}/m).each do |chunk|
8
+ ciphertext += Base64.encode64(public_key.public_encrypt(chunk)).gsub("\n",'')+"\n" if chunk
10
9
  end
10
+ ciphertext
11
11
  end
12
12
 
13
13
  def decrypt(value)
14
- if option :use_base64
15
- private_key.private_decrypt(Base64.decode64(value))
16
- else
17
- private_key.private_decrypt(value)
14
+ plaintext = ''
15
+ value.split(/\n/).each do |line|
16
+ plaintext += private_key.private_decrypt(Base64.decode64(line)) if line
18
17
  end
18
+ plaintext
19
19
  end
20
20
 
21
21
  private
22
+
23
+ def chunksize
24
+ public_key.n.num_bytes - 11
25
+ end
26
+
22
27
  def private_key
23
28
  pass = nil
24
29
  file = require_option(:private_key)
@@ -21,7 +21,7 @@ class Trocla::Formats::X509 < Trocla::Formats::Base
21
21
  sign_with = options['ca'] || nil
22
22
  keysize = options['keysize'] || 2048
23
23
  serial = options['serial'] || 1
24
- days = options['days'] || 365
24
+ days = options['days'].to_i || 365
25
25
  altnames = options['altnames'] || nil
26
26
  altnames.collect { |v| "DNS:#{v}" }.join(', ') if altnames
27
27
 
data/lib/trocla/util.rb CHANGED
@@ -20,6 +20,7 @@ class Trocla
20
20
  'alphanumeric' => alphanumeric,
21
21
  'shellsafe' => shellsafe,
22
22
  'windowssafe' => windowssafe,
23
+ 'numeric' => numeric,
23
24
  }
24
25
  end
25
26
 
@@ -35,6 +36,9 @@ class Trocla
35
36
  def alphanumeric
36
37
  @alphanumeric ||= ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
37
38
  end
39
+ def numeric
40
+ @numeric ||= ('0'..'9').to_a
41
+ end
38
42
  def special_chars
39
43
  @special_chars ||= "*()&![]{}-".split(//)
40
44
  end
@@ -9,7 +9,7 @@ describe "Trocla::Encryptions::Ssl" do
9
9
  after(:all) do
10
10
  remove_ssl_keys
11
11
  end
12
-
12
+
13
13
  before(:each) do
14
14
  expect_any_instance_of(Trocla).to receive(:read_config).and_return(ssl_test_config)
15
15
  @trocla = Trocla.new
@@ -24,6 +24,10 @@ describe "Trocla::Encryptions::Ssl" do
24
24
  @trocla.password('random1', 'plain').length.should eql(12)
25
25
  end
26
26
 
27
+ it "should be able to store long random passwords" do
28
+ @trocla.set_password('random1_long','plain',4096.times.collect{|s| 'x' }.join('')).length.should eql(4096)
29
+ end
30
+
27
31
  it "should be able to retrieve stored random passwords" do
28
32
  stored = @trocla.password('random1', 'plain')
29
33
  retrieved = @trocla.password('random1', 'plain')
@@ -49,5 +53,4 @@ describe "Trocla::Encryptions::Ssl" do
49
53
  yaml['one_key']['plain'].should_not eql(yaml['another_key']['plain'])
50
54
  end
51
55
  end
52
-
53
56
  end
@@ -7,11 +7,11 @@ describe "Trocla::Util" do
7
7
  it "should be random" do
8
8
  Trocla::Util.send(m).should_not eql(Trocla::Util.send(m))
9
9
  end
10
-
10
+
11
11
  it "should default to length #{length}" do
12
12
  Trocla::Util.send(m).length.should == length
13
13
  end
14
-
14
+
15
15
  it "should be possible to change length" do
16
16
  Trocla::Util.send(m,8).length.should == 8
17
17
  Trocla::Util.send(m,32).length.should == 32
@@ -20,6 +20,12 @@ describe "Trocla::Util" do
20
20
  end
21
21
  end
22
22
 
23
+ describe :numeric_generator do
24
+ it "should create random numeric password" do
25
+ Trocla::Util.send(:random_str, 12, 'numeric' ).should =~ /^[0-9]{12}$/
26
+ end
27
+ end
28
+
23
29
  describe :salt do
24
30
  it "should only contain characters and numbers" do
25
31
  Trocla::Util.salt =~ /^[a-z0-9]+$/i
data/trocla.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: trocla 0.1.0 ruby lib
5
+ # stub: trocla 0.1.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "trocla"
9
- s.version = "0.1.0"
9
+ s.version = "0.1.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["mh"]
14
- s.date = "2015-03-21"
14
+ s.date = "2015-04-19"
15
15
  s.description = "Trocla helps you to generate random passwords and to store them in various formats (plain, MD5, bcrypt) for later retrival."
16
16
  s.email = "mh+trocla@immerda.ch"
17
17
  s.executables = ["trocla"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trocla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-21 00:00:00.000000000 Z
11
+ date: 2015-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: moneta