ece 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: 44649fdca6ff58ef3b0831277607fa979a2c206c
4
- data.tar.gz: 8197c1f1d10916433b2ef9a42fce6fa4b47c12df
3
+ metadata.gz: 1792d0df2dfaebbd292e5bded75b3443bf77b759
4
+ data.tar.gz: 86503dc1ef68ca2086807fc1bd76ad286c5241e4
5
5
  SHA512:
6
- metadata.gz: f6e325e8147ed9d6f60fef039ce81fb632b01499b9e662b8cb5d20612714d0fbef19ec89eee9563580ce01bb7d6a7ff9278d0f8ace6162a63f2818faf656b202
7
- data.tar.gz: 4cde40d586d950843e4e853a7c3f8d5c8137bdad88e5faa751380a59aba5e74d7e2cc1a5cdda5de83ef9e2ca6c9d1c14fac6cc8db19420112d76e8aedb0900cc
6
+ metadata.gz: fd05ae640d123bbd41ee6655b22f214e9211576dd4215e946cd0f2ba7970240979b5903b361adc0b3ead077f50fb93beb8d391178e7aea1b105c8fca53eb6af7
7
+ data.tar.gz: 8708544d9a4711ab34b49adb4937d49084a2033c646665217a096061de824959209325aa0fdc1489d72cc68692e47d23119931ca970e4cee9cff91f6bba8e014
data/README.md CHANGED
@@ -22,16 +22,20 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- ```
25
+ Encrypting:
26
+
27
+ ```ruby
26
28
  require 'ece'
27
29
 
28
30
  key = Random.new.bytes(16)
29
31
  salt = Random.new.bytes(16)
30
32
  data = "Your very private data"
31
33
 
32
- Ece.encrypt(data, key: key, salt: salt)
33
-
34
- Ece.decrypt(data, key: key, salt: salt)
34
+ encrypted_data = Ece.encrypt(data, key: key, salt: salt)
35
+ ```
36
+ Decrypting:
37
+ ```ruby
38
+ Ece.decrypt(encrypted_data, key: key, salt: salt)
35
39
  ```
36
40
  Data can be bytestring as well.
37
41
  ## Contributing
@@ -2,7 +2,6 @@ require 'openssl'
2
2
  require 'hkdf'
3
3
  require 'base64'
4
4
 
5
- #fore testing purposes only
6
5
  #TODO: variable padding
7
6
 
8
7
  class Ece
@@ -48,7 +47,7 @@ class Ece
48
47
 
49
48
  def self.encrypt(data, params)
50
49
  key = extract_key(params)
51
- rs = 4095 #look TODO
50
+ rs = 4095 #should be variable, but for now it's constant
52
51
  result = ""
53
52
  counter = 0
54
53
  (0..data.length).step(rs) do |i|
@@ -65,9 +64,9 @@ class Ece
65
64
  gcm.decrypt
66
65
  gcm.key = params[:key]
67
66
  gcm.iv = generate_nonce(params[:nonce], counter)
68
- gcm.auth_tag = buffer[-16..-1]
69
- decrypted = gcm.update(buffer[0..-17]) + gcm.final
70
- #padding = decrypted[0]
67
+ gcm.auth_tag = buffer[-TAG_LENGTH..-1]
68
+ decrypted = gcm.update(buffer[0..-TAG_LENGTH-1]) + gcm.final
69
+ #padding = decrypted[0] -- this would be used once variable record-size is implemented
71
70
  #padding_length = decrypted[0].unpack("C")
72
71
  #raise Err unless padding = "\x00"*padding_length
73
72
  decrypted[1..-1]
@@ -1,3 +1,3 @@
1
1
  class Ece
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ece
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
  - Alexander Shevtsov