ece 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ece/ece.rb +13 -4
  3. data/lib/ece/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c93241d913169ee1b99d4981b7984c677c4f43ed
4
- data.tar.gz: d7b99ebadb19980c081b870c0dde6e83f7cc7259
3
+ metadata.gz: 2e947d1704ffb9c3b8df64b1e1086b0cb6ccc582
4
+ data.tar.gz: a3106fb907ef7f8be5e16b9bbbd48230e8065dfd
5
5
  SHA512:
6
- metadata.gz: cd8783c304738147ac82eb572de3f773cd5097303c4e03ff06cbc701b2368b7160722bc42fb1cb3f5ba0147ac07dabf9f4a01408230dfc14568ab9ea166b2034
7
- data.tar.gz: d538fb755d02ac2965e2c8134694453b559d38bef5f4cd8961b2f78cc25a69bb5c5a93dfad01cd812d959de87fd0fde93871f8da3f846c73ec57b263a726ae42
6
+ metadata.gz: e715f1010c9d164946d1764c413fbf220387bbf579a32cfac29590a797ace9a8455b5d8d7ca820ae54c45399f7431cb4eb0c5060356be0c2603e49db8b7d7dba
7
+ data.tar.gz: 3b1e07649a250825e1cb0b078006519fc19023306784566c4b889fe368906b86446167271f797885d9ec7e268798fbf5e7e41f2bf4bd106d1544def73d247dac
@@ -62,9 +62,14 @@ class ECE
62
62
  raise "The rs parameter must be greater than 1." if rs <= 1
63
63
  rs -=1 #this ensures encrypted data cannot be truncated
64
64
  result = ""
65
+ pad_bytes = 1
66
+ if params[:auth] # old spec used 1 byte for padding, latest one always uses 2 bytes
67
+ pad_bytes = 2
68
+ end
69
+
65
70
  counter = 0
66
- (0..data.length).step(rs) do |i|
67
- block = encrypt_record(key, counter, data[i..i+rs-1], padsize)
71
+ (0..data.length).step(rs-pad_bytes+1) do |i|
72
+ block = encrypt_record(key, counter, data[i..i+rs-pad_bytes], padsize)
68
73
  result += block
69
74
  counter +=1
70
75
  end
@@ -75,7 +80,7 @@ class ECE
75
80
  key = extract_key(params)
76
81
  rs = params[:rs] ? params [:rs] : 4096
77
82
  raise "The rs parameter must be greater than 1." if rs <= 1
78
- rs += 16
83
+ rs += TAG_LENGTH
79
84
  raise "Message is truncated" if data.length % rs == 0
80
85
  result = ""
81
86
  counter = 0
@@ -92,7 +97,11 @@ class ECE
92
97
  gcm.decrypt
93
98
  gcm.key = params[:key]
94
99
  gcm.iv = generate_nonce(params[:nonce], counter)
95
- raise "Block is too small" if buffer.length <= TAG_LENGTH+1
100
+ pad_bytes = 1
101
+ if params[:auth] # old spec used 1 byte for padding, latest one always uses 2 bytes
102
+ pad_bytes = 2
103
+ end
104
+ raise "Block is too small" if buffer.length <= TAG_LENGTH+pad_bytes
96
105
  gcm.auth_tag = buffer[-TAG_LENGTH..-1]
97
106
  decrypted = gcm.update(buffer[0..-TAG_LENGTH-1]) + gcm.final
98
107
 
@@ -1,3 +1,3 @@
1
1
  class ECE
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ece
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shevtsov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-14 00:00:00.000000000 Z
11
+ date: 2016-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler