fast_secure_compare 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fast_secure_compare.gemspec +2 -2
- data/lib/fast_secure_compare.rb +1 -0
- data/spec/fast_secure_compare_spec.rb +7 -0
- 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: e3fb2369f25ee854588c61eee84e3e8d83101935
|
4
|
+
data.tar.gz: 9ce4e51ea075a0356c94a5fbfa2ba73d782a747f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 014835e0a31b4c6c22e776c6641f77a82a41edef1be4048e20f9aeb201e5b2707d16ea52748ebd3affcd4152f66b7268325f295a8cc85567a5398902ecf53979
|
7
|
+
data.tar.gz: ee5a4427431ecb102938ef55bc6cf8588bae22e71f9e90fe32c5f73f17c5db0bd0334d4165c952ef1f0cef4c21302ab10d17f16edcee84297ac099027baf16c8
|
data/fast_secure_compare.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'fast_secure_compare'
|
3
|
-
s.version = '0.0.
|
4
|
-
s.date = '2014-08-
|
3
|
+
s.version = '0.0.3'
|
4
|
+
s.date = '2014-08-18'
|
5
5
|
s.summary = "A fast, simple way to do constant time string comparisons."
|
6
6
|
s.description = "A secure_comparison function implemented in C for blazing speed."
|
7
7
|
s.authors = ["Daniel Axtens"]
|
data/lib/fast_secure_compare.rb
CHANGED
@@ -8,6 +8,7 @@ module FastSecureCompare
|
|
8
8
|
attach_function :secure_compare_bytes, [:pointer, :uint, :pointer, :uint], :int
|
9
9
|
|
10
10
|
def self.compare(secret, input)
|
11
|
+
return false if secret == "" and input != ""
|
11
12
|
sBuf = FFI::MemoryPointer.new(:char, secret.size)
|
12
13
|
sBuf.put_bytes(0, secret)
|
13
14
|
iBuf = FFI::MemoryPointer.new(:char, input.size)
|
@@ -14,4 +14,11 @@ describe FastSecureCompare, "#compare" do
|
|
14
14
|
it "returns false on different strings of equal length" do
|
15
15
|
expect(FastSecureCompare.compare("aaa","bbb")).to eq(false)
|
16
16
|
end
|
17
|
+
it "returns true on two empty strings." do
|
18
|
+
expect(FastSecureCompare.compare("","")).to eq(true)
|
19
|
+
end
|
20
|
+
it "returns false on one empty string, one non-empty string." do
|
21
|
+
expect(FastSecureCompare.compare("a","")).to eq(false)
|
22
|
+
expect(FastSecureCompare.compare("","a")).to eq(false)
|
23
|
+
end
|
17
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_secure_compare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Axtens
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-compiler
|