cryptor 1.0.0 → 1.1.0

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: f5fd951f1826bc584bac34d75f61ed7a75af3875
4
- data.tar.gz: e89c7a58275dac153b47b2201fecee4194f0ad72
3
+ metadata.gz: 3e5e25d2bdd2ae21fb0c12e6874159107d3a0ca4
4
+ data.tar.gz: f088237f4bc084eddca999e037b4df858155ff78
5
5
  SHA512:
6
- metadata.gz: fde5ba8749bc1c6fa79ff27a5e8e3fcc733abfd8d164afbdd7cca3984371ce18f1a6e6d372f7c4080dd1e9945366d0d69f960fd835e8e87f1d03f34f6a85f69d
7
- data.tar.gz: 26c0c7f57afb309c8d993121e7d2d680f0edfd5b7c4485daed7024d7445186741637e85d7958334bfa97ddab2b5e70c7982049899f10ae8107bcd2e4e88459d8
6
+ metadata.gz: 87b64b2fe164d3b419f3248b1fbf2828ede7db5bc88f533ea51ad686694d25ce77d4216fe197d4ade5f017e3cdbae53d7f0473d3f6d8f8ab8b0c2e35b15d5a50
7
+ data.tar.gz: b335aaa66ad842c41b49e7a35b0c72466e9aee2ca9a43b638030f2cdf59660b4d626c29e16e7b49e2737a14781aaad73f5207f136999cbb76a98ec83de03419b
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ 1.1.0 (2014-06-18)
2
+ ------------------
3
+ * Add Cryptor::EncryptedAttribute module
4
+
1
5
  1.0.0 (2014-06-14)
2
6
  ------------------
3
7
  * Key rotation support
data/README.md CHANGED
@@ -9,8 +9,8 @@ Cryptor
9
9
  A safe Ruby encryption library, designed to support features like multiple
10
10
  active encryption keys and key rotation.
11
11
 
12
- Cryptor uses [authenticated encryption] *exclusively*, ensuring your data
13
- remains untamered with, even when it's in the hands of an attacker.
12
+ Cryptor utilizes [authenticated encryption], which ensures the confidentiality,
13
+ integrity, and authenticity of data while still providing a simple API.
14
14
 
15
15
  Cryptor supports two backends:
16
16
 
@@ -23,11 +23,15 @@ Cryptor uses the experimental [ORDO v0 message format][ordo] for serializing
23
23
  encrypted messages. Future versions may support additional message formats
24
24
  like OpenPGP or JWE.
25
25
 
26
+ Need help with Cryptor? Join the [RbNaCl Google Group][group].
27
+ We're also on IRC at #cryptosphere on irc.freenode.net
28
+
26
29
  [authenticated encryption]: https://en.wikipedia.org/wiki/Authenticated_encryption
27
30
  [RbNaCl::SimpleBox]: https://github.com/cryptosphere/rbnacl/wiki/SimpleBox
28
31
  [libsodium]: https://github.com/jedisct1/libsodium/
29
32
  [ActiveSupport::MessageEncryptor]: http://api.rubyonrails.org/classes/ActiveSupport/MessageEncryptor.html
30
33
  [ordo]: https://github.com/cryptosphere/ordo/wiki/Message-Format
34
+ [group]: http://groups.google.com/group/rbnacl
31
35
 
32
36
  ## Installation
33
37
 
@@ -1,6 +1,7 @@
1
1
  require 'cryptor/version'
2
2
 
3
3
  require 'cryptor/encoding'
4
+ require 'cryptor/encrypted_attribute'
4
5
  require 'cryptor/symmetric_encryption'
5
6
 
6
7
  # Multi-backend high-level encryption library
@@ -0,0 +1,18 @@
1
+ module Cryptor
2
+ # Support for the attr_encrypted encryptor API
3
+ module EncryptedAttribute
4
+ module_function
5
+
6
+ def symmetric_encrypt(options)
7
+ symmetric_cryptor(options).encrypt(options[:value])
8
+ end
9
+
10
+ def symmetric_decrypt(options)
11
+ symmetric_cryptor(options).decrypt(options[:value])
12
+ end
13
+
14
+ def symmetric_cryptor(options)
15
+ Cryptor::SymmetricEncryption.new(options[:key], keyring: options[:keyring])
16
+ end
17
+ end
18
+ end
@@ -1,4 +1,4 @@
1
1
  # An easy-to-use library for real-world Ruby cryptography
2
2
  module Cryptor
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ # "Default" cipher used in non-backend specific tests
4
+ require 'cryptor/symmetric_encryption/ciphers/xsalsa20poly1305'
5
+
6
+ RSpec.describe Cryptor::EncryptedAttribute do
7
+ let(:plaintext) { 'THE MAGIC WORDS ARE SQUEAMISH OSSIFRAGE' }
8
+ let(:secret_key) { Cryptor::SymmetricEncryption.random_key(:xsalsa20poly1305) }
9
+
10
+ context 'symmetric encryption' do
11
+ it 'encrypts and decrypts' do
12
+ ciphertext = described_class.symmetric_encrypt(key: secret_key, value: plaintext)
13
+ expect(described_class.symmetric_decrypt(key: secret_key, value: ciphertext)).to eq plaintext
14
+ end
15
+ end
16
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Cryptor::SymmetricEncryption::SecretKey do
3
+ RSpec.describe Cryptor::SymmetricEncryption::SecretKey do
4
4
  let(:algorithm) { :BassOmatic }
5
5
  let(:key_bytes) { 42 }
6
6
  let(:cipher) { Cryptor::SymmetricEncryption::Cipher.new(algorithm, key_bytes: key_bytes) }
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  # "Default" cipher used in non-backend specific tests
4
4
  require 'cryptor/symmetric_encryption/ciphers/xsalsa20poly1305'
5
5
 
6
- describe Cryptor::SymmetricEncryption do
6
+ RSpec.describe Cryptor::SymmetricEncryption do
7
7
  let(:plaintext) { 'THE MAGIC WORDS ARE SQUEAMISH OSSIFRAGE' }
8
8
 
9
9
  let(:garbage) do
@@ -4,3 +4,14 @@ Coveralls.wear!
4
4
 
5
5
  require 'bundler/setup'
6
6
  require 'cryptor'
7
+
8
+ RSpec.configure do |c|
9
+ # Setting this config option `false` removes rspec-core's monkey patching of the
10
+ # top level methods like `describe`, `shared_examples_for` and `shared_context`
11
+ # on `main` and `Module`. The methods are always available through the `RSpec`
12
+ # module like `RSpec.describe` regardless of this setting.
13
+ # For backwards compatibility this defaults to `true`.
14
+ #
15
+ # https://relishapp.com/rspec/rspec-core/v/3-0/docs/configuration/global-namespace-dsl
16
+ c.expose_dsl_globally = false
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-14 00:00:00.000000000 Z
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ordo
@@ -116,6 +116,7 @@ files:
116
116
  - cryptosaur.png
117
117
  - lib/cryptor.rb
118
118
  - lib/cryptor/encoding.rb
119
+ - lib/cryptor/encrypted_attribute.rb
119
120
  - lib/cryptor/symmetric_encryption.rb
120
121
  - lib/cryptor/symmetric_encryption/cipher.rb
121
122
  - lib/cryptor/symmetric_encryption/ciphers/message_encryptor.rb
@@ -123,9 +124,10 @@ files:
123
124
  - lib/cryptor/symmetric_encryption/keyring.rb
124
125
  - lib/cryptor/symmetric_encryption/secret_key.rb
125
126
  - lib/cryptor/version.rb
127
+ - spec/cryptor/encrypted_attribute_spec.rb
126
128
  - spec/cryptor/symmetric_encryption/secret_key_spec.rb
129
+ - spec/cryptor/symmetric_encryption_spec.rb
127
130
  - spec/spec_helper.rb
128
- - spec/symmetric_encryption_spec.rb
129
131
  - tasks/rspec.rake
130
132
  - tasks/rubocop.rake
131
133
  homepage: https://github.com/cryptosphere/cryptor
@@ -153,6 +155,7 @@ signing_key:
153
155
  specification_version: 4
154
156
  summary: An easy-to-use library for real-world Ruby cryptography
155
157
  test_files:
158
+ - spec/cryptor/encrypted_attribute_spec.rb
156
159
  - spec/cryptor/symmetric_encryption/secret_key_spec.rb
160
+ - spec/cryptor/symmetric_encryption_spec.rb
157
161
  - spec/spec_helper.rb
158
- - spec/symmetric_encryption_spec.rb