gibberish 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
Binary file
data/CHANGELOG.mdown CHANGED
@@ -1,3 +1,7 @@
1
+ ### v1.2.1
2
+ * Added support for an optional salt - PR mdp/gibberish#9
3
+ * Adding gem signing
4
+
1
5
  ### v1.2.0
2
6
  * Added digest support for SHA224/384 and HMAC SHA224/384/512. [Pull request #5](https://github.com/mdp/gibberish/pull/5)
3
7
 
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012 Mark Percival <m@mdp.im>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDHjCCAgagAwIBAgIBADANBgkqhkiG9w0BAQUFADA1MQowCAYDVQQDDAFtMRMw
3
+ EQYKCZImiZPyLGQBGRYDbWRwMRIwEAYKCZImiZPyLGQBGRYCaW0wHhcNMTMwMjEx
4
+ MTYwNjAxWhcNMTQwMjExMTYwNjAxWjA1MQowCAYDVQQDDAFtMRMwEQYKCZImiZPy
5
+ LGQBGRYDbWRwMRIwEAYKCZImiZPyLGQBGRYCaW0wggEiMA0GCSqGSIb3DQEBAQUA
6
+ A4IBDwAwggEKAoIBAQCsyb70vRSb3hfN5Go04jz84/XRf68uJD9NeNyE0y+lylOY
7
+ jWEMaLu9TE2kYKOAvyZ/9+ioK19P+se1jCTIM+PZ11bz4Wmgk23XqmuSjA6v1dEA
8
+ rlmsudYmlW36VviSIdTN3rvwoSiB+XXiUujF97nhvjxBpxnc1hJkxRz4KYwjjUPd
9
+ NiGxK2GULOVwEEk5BScIG+FFJd/NKHF8tkxiiZNyjZDIwTvqMhYpnr/VRX+EsCkr
10
+ A9j1a1GRyAHSUtxWuqjpWaXff2CEg5JavLZk1P74Zxx0c+rpsvY+bD0w9bMyNdgu
11
+ jxxRo0Ompt3sCfpPwdp1hTBHJycrsdfH9rscQ7SPAgMBAAGjOTA3MAkGA1UdEwQC
12
+ MAAwHQYDVR0OBBYEFLqZ2ITNwA6y/W8sBBWIUECnr5KjMAsGA1UdDwQEAwIEsDAN
13
+ BgkqhkiG9w0BAQUFAAOCAQEAWRYRvVRJadDNC5zUEakTzrxb45Ket7dkTn8ejvHK
14
+ nYtr9rjtreDjUrXSrQ9rThIMvcmMixyflSF93n5cqWYPFkU0V0p7s8K6b0vmRk6d
15
+ iALE8XKqQKqzQSxk4r9FZeM/hk1FC2WBwjuNEy5tcpLF4KERVJzYq54mIyWDUV5c
16
+ VJKW8u5/Wu2D4LNNIkwkhh2ULYOA6UBVwMrjp0ZHpV7jrt8SIyl1c7ONhnY0Pxey
17
+ mxtia3OcUaHjfnuLeQqK7YpQCM2f/8sur+kpDjXH0DYTjmlOvZ07JI0Isd7zobrL
18
+ 2NEhdVRiMlG7L/ncFwqpHzWFY0r37QIQ9UwO5+t6lC9Cfg==
19
+ -----END CERTIFICATE-----
data/gibberish.gemspec CHANGED
@@ -14,6 +14,10 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "gibberish"
16
16
 
17
+ # Gem Signing
18
+ s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
19
+ s.cert_chain = ["gem-public_cert.pem"]
20
+
17
21
  s.files = `git ls-files`.split("\n")
18
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
data/lib/gibberish/aes.rb CHANGED
@@ -38,7 +38,7 @@ module Gibberish
38
38
  end
39
39
 
40
40
  def encrypt(data, opts={})
41
- salt = generate_salt
41
+ salt = generate_salt(opts[:salt])
42
42
  setup_cipher(:encrypt, salt)
43
43
  e = cipher.update(data) + cipher.final
44
44
  e = "Salted__#{salt}#{e}" #OpenSSL compatible
@@ -59,7 +59,10 @@ module Gibberish
59
59
 
60
60
  private
61
61
 
62
- def generate_salt
62
+ def generate_salt(supplied_salt)
63
+ if supplied_salt
64
+ return supplied_salt.to_s[0,8].ljust(8,'.')
65
+ end
63
66
  s = ''
64
67
  8.times {s << rand(255).chr}
65
68
  s
@@ -1,3 +1,3 @@
1
1
  module Gibberish
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
data/spec/aes_spec.rb CHANGED
@@ -13,10 +13,53 @@ describe "the aes cipher" do
13
13
  from_openssl.must_equal(secret_text)
14
14
  end
15
15
 
16
+ it "when salt is not specified, encrypted text from repeated calls should not be the same" do
17
+ secret_text = "Made with Gibberish"
18
+ encrypted1 = @cipher.e(secret_text)
19
+ encrypted2 = @cipher.e(secret_text)
20
+ encrypted1.wont_equal(encrypted2)
21
+ end
22
+
23
+ it "when salt is specified, encrypted text from repeated calls (with same salt) be the same" do
24
+ secret_text = "Made with Gibberish"
25
+ salt = 'NaClNaCl'
26
+ encrypted1 = @cipher.e(secret_text, {:salt => salt})
27
+ encrypted2 = @cipher.e(secret_text, {:salt => salt})
28
+ encrypted1.must_equal(encrypted2)
29
+ end
30
+
31
+ it "when supplied salt is too long, text should still encrypt/decrypt correctly" do
32
+ secret_text = "Made with Gibberish"
33
+ salt = 'NaClNaClNaClNaClNaClNaClNaClNaClNaClNaCl'
34
+ encrypted1 = @cipher.e(secret_text, {:salt => salt})
35
+ @cipher.d(encrypted1).must_equal(secret_text)
36
+ end
37
+
38
+ it "when supplied salt is too short, text should still encrypt/decrypt correctly" do
39
+ secret_text = "Made with Gibberish"
40
+ salt = 'NaCl'
41
+ encrypted1 = @cipher.e(secret_text, {:salt => salt})
42
+ @cipher.d(encrypted1).must_equal(secret_text)
43
+ end
44
+
45
+ it "when number is supplied for salt, text should still encrypt/decrypt correctly" do
46
+ secret_text = "Made with Gibberish"
47
+ salt = 42
48
+ encrypted1 = @cipher.e(secret_text, {:salt => salt})
49
+ @cipher.d(encrypted1).must_equal(secret_text)
50
+ end
51
+
52
+ it "when idiotic value is supplied for salt, text should still encrypt/decrypt correctly" do
53
+ secret_text = "Made with Gibberish"
54
+ salt = {:whoknew => "I'm an idiot"}
55
+ encrypted1 = @cipher.e(secret_text, {:salt => salt})
56
+ @cipher.d(encrypted1).must_equal(secret_text)
57
+ end
58
+
16
59
  it "should decrypt base64 encoded data from the OpenSSL CLI" do
17
60
  secret_text = "Made with Gibberish"
18
61
  from_openssl = `echo #{secret_text} | openssl enc -aes-256-cbc -a -k password`
19
- decrypted_text = @cipher.d(from_openssl).chomp
62
+ decrypted_text = @cipher.d(from_openssl).chomp
20
63
  decrypted_text.must_equal(secret_text)
21
64
  end
22
65
 
metadata CHANGED
@@ -1,34 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gibberish
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.1
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 0
10
- version: 1.2.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Mark Percival
14
9
  autorequire:
15
10
  bindir: bin
16
- cert_chain: []
11
+ cert_chain:
12
+ - ! '-----BEGIN CERTIFICATE-----
17
13
 
18
- date: 2011-12-09 00:00:00 -08:00
19
- default_executable:
20
- dependencies: []
14
+ MIIDHjCCAgagAwIBAgIBADANBgkqhkiG9w0BAQUFADA1MQowCAYDVQQDDAFtMRMw
15
+
16
+ EQYKCZImiZPyLGQBGRYDbWRwMRIwEAYKCZImiZPyLGQBGRYCaW0wHhcNMTMwMjEx
17
+
18
+ MTYwNjAxWhcNMTQwMjExMTYwNjAxWjA1MQowCAYDVQQDDAFtMRMwEQYKCZImiZPy
19
+
20
+ LGQBGRYDbWRwMRIwEAYKCZImiZPyLGQBGRYCaW0wggEiMA0GCSqGSIb3DQEBAQUA
21
+
22
+ A4IBDwAwggEKAoIBAQCsyb70vRSb3hfN5Go04jz84/XRf68uJD9NeNyE0y+lylOY
23
+
24
+ jWEMaLu9TE2kYKOAvyZ/9+ioK19P+se1jCTIM+PZ11bz4Wmgk23XqmuSjA6v1dEA
25
+
26
+ rlmsudYmlW36VviSIdTN3rvwoSiB+XXiUujF97nhvjxBpxnc1hJkxRz4KYwjjUPd
27
+
28
+ NiGxK2GULOVwEEk5BScIG+FFJd/NKHF8tkxiiZNyjZDIwTvqMhYpnr/VRX+EsCkr
29
+
30
+ A9j1a1GRyAHSUtxWuqjpWaXff2CEg5JavLZk1P74Zxx0c+rpsvY+bD0w9bMyNdgu
31
+
32
+ jxxRo0Ompt3sCfpPwdp1hTBHJycrsdfH9rscQ7SPAgMBAAGjOTA3MAkGA1UdEwQC
33
+
34
+ MAAwHQYDVR0OBBYEFLqZ2ITNwA6y/W8sBBWIUECnr5KjMAsGA1UdDwQEAwIEsDAN
35
+
36
+ BgkqhkiG9w0BAQUFAAOCAQEAWRYRvVRJadDNC5zUEakTzrxb45Ket7dkTn8ejvHK
37
+
38
+ nYtr9rjtreDjUrXSrQ9rThIMvcmMixyflSF93n5cqWYPFkU0V0p7s8K6b0vmRk6d
39
+
40
+ iALE8XKqQKqzQSxk4r9FZeM/hk1FC2WBwjuNEy5tcpLF4KERVJzYq54mIyWDUV5c
41
+
42
+ VJKW8u5/Wu2D4LNNIkwkhh2ULYOA6UBVwMrjp0ZHpV7jrt8SIyl1c7ONhnY0Pxey
43
+
44
+ mxtia3OcUaHjfnuLeQqK7YpQCM2f/8sur+kpDjXH0DYTjmlOvZ07JI0Isd7zobrL
45
+
46
+ 2NEhdVRiMlG7L/ncFwqpHzWFY0r37QIQ9UwO5+t6lC9Cfg==
21
47
 
48
+ -----END CERTIFICATE-----
49
+
50
+ '
51
+ date: 2013-02-11 00:00:00.000000000 Z
52
+ dependencies: []
22
53
  description: Supports OpenSSL compatible AES, HMAC, and RSA encryption
23
- email:
54
+ email:
24
55
  - mark@markpercival.us
25
56
  executables: []
26
-
27
57
  extensions: []
28
-
29
58
  extra_rdoc_files: []
30
-
31
- files:
59
+ files:
32
60
  - .gitignore
33
61
  - .gitmodules
34
62
  - .yardoc/checksums
@@ -37,8 +65,10 @@ files:
37
65
  - .yardopts
38
66
  - CHANGELOG.mdown
39
67
  - Gemfile
68
+ - LICENSE
40
69
  - README.markdown
41
70
  - Rakefile
71
+ - gem-public_cert.pem
42
72
  - gibberish.gemspec
43
73
  - lib/gibberish.rb
44
74
  - lib/gibberish/aes.rb
@@ -55,47 +85,28 @@ files:
55
85
  - spec/openssl/public.pem
56
86
  - spec/rsa_spec.rb
57
87
  - spec/spec_helper.rb
58
- has_rdoc: true
59
88
  homepage: http://github.com/mdp/gibberish
60
89
  licenses: []
61
-
62
90
  post_install_message:
63
91
  rdoc_options: []
64
-
65
- require_paths:
92
+ require_paths:
66
93
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
94
+ required_ruby_version: !ruby/object:Gem::Requirement
68
95
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
101
  none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- hash: 3
82
- segments:
83
- - 0
84
- version: "0"
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
85
106
  requirements: []
86
-
87
107
  rubyforge_project: gibberish
88
- rubygems_version: 1.6.2
108
+ rubygems_version: 1.8.23
89
109
  signing_key:
90
110
  specification_version: 3
91
111
  summary: An opinionated ruby encryption library
92
- test_files:
93
- - spec/aes_spec.rb
94
- - spec/digest_spec.rb
95
- - spec/hmac_spec.rb
96
- - spec/openssl/plaintext.crypted
97
- - spec/openssl/plaintext.txt
98
- - spec/openssl/private.pem
99
- - spec/openssl/public.pem
100
- - spec/rsa_spec.rb
101
- - spec/spec_helper.rb
112
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ �����k֋缺����4:����[��@��9���[��9g�{�;�g���e�J/T�P��6P��OBt��X�ɧk ���� }���䐂$�֬l��9e�f��%V<�a���e� �=!�`t����4�W����K�R�����|J�`�1M����!�D��#��%3�ʏZ���_�R�8�e��>b`>/�kfa��4L��Y��Ws��64��:�ʉ��
2
+ I�#y+$�DUzSF��C�C����7 ��O