ece 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ece/ece.rb +13 -4
- data/lib/ece/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e947d1704ffb9c3b8df64b1e1086b0cb6ccc582
|
4
|
+
data.tar.gz: a3106fb907ef7f8be5e16b9bbbd48230e8065dfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e715f1010c9d164946d1764c413fbf220387bbf579a32cfac29590a797ace9a8455b5d8d7ca820ae54c45399f7431cb4eb0c5060356be0c2603e49db8b7d7dba
|
7
|
+
data.tar.gz: 3b1e07649a250825e1cb0b078006519fc19023306784566c4b889fe368906b86446167271f797885d9ec7e268798fbf5e7e41f2bf4bd106d1544def73d247dac
|
data/lib/ece/ece.rb
CHANGED
@@ -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-
|
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 +=
|
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
|
-
|
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
|
|
data/lib/ece/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|