strongbox 0.4.8 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -1
- data/lib/strongbox.rb +19 -3
- data/test/strongbox_multiply_test.rb +52 -0
- metadata +50 -54
data/Rakefile
CHANGED
data/lib/strongbox.rb
CHANGED
@@ -5,7 +5,7 @@ require 'strongbox/lock'
|
|
5
5
|
|
6
6
|
module Strongbox
|
7
7
|
|
8
|
-
VERSION = "0.
|
8
|
+
VERSION = "0.5.0"
|
9
9
|
|
10
10
|
RSA_PKCS1_PADDING = OpenSSL::PKey::RSA::PKCS1_PADDING
|
11
11
|
RSA_SSLV23_PADDING = OpenSSL::PKey::RSA::SSLV23_PADDING
|
@@ -45,9 +45,25 @@ module Strongbox
|
|
45
45
|
# database column of the same name as the attibute. If symmetric encryption is
|
46
46
|
# used (the default) additional column are need to store the generated password
|
47
47
|
# and IV.
|
48
|
-
|
48
|
+
#
|
49
|
+
# Last argument should be the options hash
|
50
|
+
# Argument 0..-2 contains columns to be encrypted
|
51
|
+
def encrypt_with_public_key(*args)
|
49
52
|
include InstanceMethods
|
50
|
-
|
53
|
+
|
54
|
+
options = args.delete_at(-1) || {}
|
55
|
+
|
56
|
+
unless options.is_a?(Hash)
|
57
|
+
args.push(options)
|
58
|
+
options = {}
|
59
|
+
end
|
60
|
+
|
61
|
+
if args.one?
|
62
|
+
name = args.first
|
63
|
+
else
|
64
|
+
return args.each { |name| encrypt_with_public_key(name, options) }
|
65
|
+
end
|
66
|
+
|
51
67
|
if respond_to?(:class_attribute)
|
52
68
|
self.lock_options = {} if lock_options.nil?
|
53
69
|
else
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'test/test_helper'
|
3
|
+
|
4
|
+
class StrongboxMultiPlyTest < Test::Unit::TestCase
|
5
|
+
context 'A Class with two secured fields' do
|
6
|
+
setup do
|
7
|
+
@password = 'boost facile'
|
8
|
+
key_pair = File.join(FIXTURES_DIR,'keypair.pem')
|
9
|
+
Dummy.class_eval do
|
10
|
+
encrypt_with_public_key :secret, :segreto, :key_pair => key_pair
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'that is valid' do
|
15
|
+
setup do
|
16
|
+
@dummy = Dummy.new
|
17
|
+
@dummy.secret = 'I have a secret...'
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'return "*encrypted*" when the record is locked' do
|
21
|
+
assert_equal '*encrypted*', @dummy.secret.decrypt
|
22
|
+
end
|
23
|
+
|
24
|
+
should 'return the secrets when unlocked' do
|
25
|
+
assert_equal 'I have a secret...', @dummy.secret.decrypt(@password)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'Using strings for keys' do
|
32
|
+
setup do
|
33
|
+
@password = 'boost facile'
|
34
|
+
key_pair = File.read(File.join(FIXTURES_DIR,'keypair.pem'))
|
35
|
+
public_key = OpenSSL::PKey::RSA.new(key_pair,"")
|
36
|
+
private_key = OpenSSL::PKey::RSA.new(key_pair,@password)
|
37
|
+
Dummy.class_eval do
|
38
|
+
encrypt_with_public_key :secret, :public_key => public_key, :private_key => private_key
|
39
|
+
end
|
40
|
+
@dummy = Dummy.new
|
41
|
+
@dummy.secret = 'Shhhh'
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'return "*encrypted*" when locked' do
|
45
|
+
assert_equal '*encrypted*', @dummy.secret.decrypt
|
46
|
+
end
|
47
|
+
|
48
|
+
should 'return secret when unlocked' do
|
49
|
+
assert_equal 'Shhhh', @dummy.secret.decrypt(@password)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,60 +1,58 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: strongbox
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.4.8
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Spike Ilacqua
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: activerecord
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70333660206440 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: thoughtbot-shoulda
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *70333660206440
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thoughtbot-shoulda
|
27
|
+
requirement: &70333660206020 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
36
33
|
type: :development
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: sqlite3
|
40
34
|
prerelease: false
|
41
|
-
|
35
|
+
version_requirements: *70333660206020
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sqlite3
|
38
|
+
requirement: &70333660205600 !ruby/object:Gem::Requirement
|
42
39
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
47
44
|
type: :development
|
48
|
-
|
49
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70333660205600
|
47
|
+
description: ! " Strongbox provides Public Key Encryption for ActiveRecord. By
|
48
|
+
using a\n public key sensitive information can be encrypted and stored automatically.\n
|
49
|
+
\ Once stored a password is required to access the information. dependencies\n
|
50
|
+
\ are specified in standard Ruby syntax.\n"
|
50
51
|
email: spike@stuff-things.net
|
51
52
|
executables: []
|
52
|
-
|
53
53
|
extensions: []
|
54
|
-
|
55
54
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
55
|
+
files:
|
58
56
|
- .gitignore
|
59
57
|
- Gemfile
|
60
58
|
- LICENSE
|
@@ -69,42 +67,40 @@ files:
|
|
69
67
|
- test/fixtures/encrypted
|
70
68
|
- test/fixtures/keypair.pem
|
71
69
|
- test/missing_attributes_test.rb
|
70
|
+
- test/strongbox_multiply_test.rb
|
72
71
|
- test/strongbox_test.rb
|
73
72
|
- test/test_helper.rb
|
74
73
|
- test/validations_test.rb
|
75
|
-
has_rdoc: true
|
76
74
|
homepage: http://stuff-things.net/strongbox
|
77
75
|
licenses: []
|
78
|
-
|
79
76
|
post_install_message:
|
80
77
|
rdoc_options: []
|
81
|
-
|
82
|
-
require_paths:
|
78
|
+
require_paths:
|
83
79
|
- lib
|
84
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
81
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
87
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version:
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
96
92
|
requirements: []
|
97
|
-
|
98
93
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.
|
94
|
+
rubygems_version: 1.8.10
|
100
95
|
signing_key:
|
101
96
|
specification_version: 3
|
102
97
|
summary: Secures ActiveRecord fields with public key encryption.
|
103
|
-
test_files:
|
98
|
+
test_files:
|
104
99
|
- test/database.yml
|
105
100
|
- test/fixtures/encrypted
|
106
101
|
- test/fixtures/keypair.pem
|
107
102
|
- test/missing_attributes_test.rb
|
103
|
+
- test/strongbox_multiply_test.rb
|
108
104
|
- test/strongbox_test.rb
|
109
105
|
- test/test_helper.rb
|
110
106
|
- test/validations_test.rb
|