slosilo 0.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.
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Slosilo::Symmetric do
4
+ # TODO transform it to class methods only?
5
+ let(:plaintext) { "quick brown fox jumped over the lazy dog" }
6
+ let(:key) { "^\xBAIv\xDB1\x0Fi\x04\x11\xFD\x14\xA7\xCD\xDFf\x93\xFE\x93}\v\x01\x11\x98\x14\xE0;\xC1\xE2 v\xA5" }
7
+ let(:iv) { "\xA1\xFA#z\x16\x80R\xCC|\x0Fyc\xB7j\x17\xED" }
8
+ let(:ciphertext) { "\xA1\xFA#z\x16\x80R\xCC|\x0Fyc\xB7j\x17\xED\x15\xC9r\xC9\xEE\xB9\xBC5\xB7\ni\x0F\f\xC8X\x80 h\a\xF4\xA6\xE3\x15\x9D\xF1-\xE5\bs\xF6\x02Z\x0F\xCD|S\x1A\xAA\x9At\xEFT\x17\xA5lT\x8C\xF3" }
9
+ describe '#encrypt' do
10
+ it "encrypts with AES-256-CBC" do
11
+ subject.stub random_iv: iv
12
+ subject.encrypt(plaintext, key: key).should == ciphertext
13
+ end
14
+ end
15
+
16
+ describe '#decrypt' do
17
+ it "decrypts with AES-256-CBC" do
18
+ subject.decrypt(ciphertext, key: key).should == plaintext
19
+ end
20
+
21
+ context "when ciphertext happens to end in a zero" do
22
+ let(:ciphertext) { "\x7F\xD6\xEAb\xE56\a\xD3\xC5\xF2J\n\x8C\x8Fg\xB7-\\\x8A\fh\x18\xC8\x91\xB9 \x97\xC9\x12\xE6\xA6\xAE\xB1I\x1E\x80\xAB\xD8\xDC\xBD\xB6\xCD\x9A\xA3MH\xA8\xB0\xC7\xDA\x87\xA7c\xD75,\xD2A\xB8\x9E\xE3o\x04\x00" }
23
+ let(:key) { "4pSuk1rAQyuHA5uUYaj0X0BsiPCFb9Nc8J03XA6V5/Y" }
24
+ it "works correctly" do
25
+ subject.decrypt(ciphertext, key: key).should == "R6KNTQ4aUivojbaqhgAqj1I4PaF8h/5/YcENy4uNbfk="
26
+ end
27
+ end
28
+
29
+ context "when the iv ends in space" do
30
+ let(:ciphertext) { "\xC0\xDA#\xE9\xE1\xFD\xEDJ\xADs4P\xA9\xD6\x92 \xF7\xF8_M\xF6\x16\xC2i$\x8BT^\b\xA1\xB2L&\xE9\x80\x02[]6i\x9B\xD3\xC3\xED\xA9\xD1\x94\xE8\x15\xFD\xDA\xFEUj\xC5upH*\xBF\x82\x15le" }
31
+ let(:key) { "4pSuk1rAQyuHA5uUYaj0X0BsiPCFb9Nc8J03XA6V5/Y" }
32
+ it "works correctly" do
33
+ subject.decrypt(ciphertext, key: key).should == "zGptmL3vd4obi1vqSiWHt/Ias2k+6qDtuq9vdow8jNA="
34
+ end
35
+ end
36
+ end
37
+
38
+ describe '#random_iv' do
39
+ it "generates a random iv" do
40
+ OpenSSL::Cipher.any_instance.should_receive(:random_iv).and_return :iv
41
+ subject.random_iv.should == :iv
42
+ end
43
+ end
44
+
45
+ describe '#random_key' do
46
+ it "generates a random key" do
47
+ OpenSSL::Cipher.any_instance.should_receive(:random_key).and_return :key
48
+ subject.random_key.should == :key
49
+ end
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slosilo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rafał Rzepecki
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: ci_reporter
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: simplecov
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: sequel
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: sqlite3
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: This gem provides an easy way of storing and retrieving encryption keys
111
+ in the database.
112
+ email:
113
+ - divided.mind@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - LICENSE
121
+ - README.md
122
+ - Rakefile
123
+ - lib/slosilo.rb
124
+ - lib/slosilo/adapters/abstract_adapter.rb
125
+ - lib/slosilo/adapters/mock_adapter.rb
126
+ - lib/slosilo/adapters/sequel_adapter.rb
127
+ - lib/slosilo/adapters/sequel_adapter/migration.rb
128
+ - lib/slosilo/attr_encrypted.rb
129
+ - lib/slosilo/http_request.rb
130
+ - lib/slosilo/key.rb
131
+ - lib/slosilo/keystore.rb
132
+ - lib/slosilo/rack/middleware.rb
133
+ - lib/slosilo/random.rb
134
+ - lib/slosilo/symmetric.rb
135
+ - lib/slosilo/version.rb
136
+ - lib/tasks/slosilo.rake
137
+ - slosilo.gemspec
138
+ - spec/http_request_spec.rb
139
+ - spec/http_stack_spec.rb
140
+ - spec/key_spec.rb
141
+ - spec/keystore_spec.rb
142
+ - spec/rack_middleware_spec.rb
143
+ - spec/random_spec.rb
144
+ - spec/sequel_adapter_spec.rb
145
+ - spec/slosilo_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/symmetric_spec.rb
148
+ homepage: ''
149
+ licenses: []
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 1.9.3
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ segments:
167
+ - 0
168
+ hash: 40977695530656319
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 1.8.24
172
+ signing_key:
173
+ specification_version: 3
174
+ summary: Store SSL keys in a database
175
+ test_files:
176
+ - spec/http_request_spec.rb
177
+ - spec/http_stack_spec.rb
178
+ - spec/key_spec.rb
179
+ - spec/keystore_spec.rb
180
+ - spec/rack_middleware_spec.rb
181
+ - spec/random_spec.rb
182
+ - spec/sequel_adapter_spec.rb
183
+ - spec/slosilo_spec.rb
184
+ - spec/spec_helper.rb
185
+ - spec/symmetric_spec.rb