slosilo 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slosilo/key.rb +3 -2
- data/lib/slosilo/version.rb +1 -1
- data/spec/key_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6918af427a277c2bb00cfee84403f527b2f9add6
|
4
|
+
data.tar.gz: 55e3365667529c34e2999f5313211779ee38e032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ccab3fc113dda1efe8a603a80f48309d4f776ade1f0ab45198ef6bc8d53736c54dc0e78e6cd0fbbbf0bcf15e4baf5da89884b8543303f5f7d10e3c1821ec141
|
7
|
+
data.tar.gz: b313e1b365592f9ec2c60c5992bcd92305856894006e2440661494b90df9faae6a630ce3458b681a3a20f22df569c194472cbe89a8d3643f97638baedff739b8
|
data/lib/slosilo/key.rb
CHANGED
@@ -81,7 +81,7 @@ module Slosilo
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def sign_string value
|
84
|
-
salt =
|
84
|
+
salt = shake_salt
|
85
85
|
key.private_encrypt(hash_function.digest(salt + value)) + salt
|
86
86
|
end
|
87
87
|
|
@@ -100,6 +100,7 @@ module Slosilo
|
|
100
100
|
end
|
101
101
|
|
102
102
|
private
|
103
|
+
|
103
104
|
# Note that this is currently somewhat shallow stringification --
|
104
105
|
# to implement originating tokens we may need to make it deeper.
|
105
106
|
def stringify value
|
@@ -113,7 +114,7 @@ module Slosilo
|
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
116
|
-
def
|
117
|
+
def shake_salt
|
117
118
|
Slosilo::Random::salt
|
118
119
|
end
|
119
120
|
|
data/lib/slosilo/version.rb
CHANGED
data/spec/key_spec.rb
CHANGED
@@ -110,7 +110,7 @@ describe Slosilo::Key do
|
|
110
110
|
context "when given a string" do
|
111
111
|
let(:expected_signature) { "d[\xA4\x00\x02\xC5\x17\xF5P\x1AD\x91\xF9\xC1\x00P\x0EG\x14,IN\xDE\x17\xE1\xA2a\xCC\xABR\x99'\xB0A\xF5~\x93M/\x95-B\xB1\xB6\x92!\x1E\xEA\x9C\v\xC2O\xA8\x91\x1C\xF9\x11\x92a\xBFxm-\x93\x9C\xBBoM\x92%\xA9\xD06$\xC1\xBC.`\xF8\x03J\x16\xE1\xB0c\xDD\xBF\xB0\xAA\xD7\xD4\xF4\xFC\e*\xAB\x13A%-\xD3\t\xA5R\x18\x01let6\xC8\xE9\"\x7F6O\xC7p\x82\xAB\x04J(IY\xAA]b\xA4'\xD6\x873`\xAB\x13\x95g\x9C\x17\xCAB\xF8\xB9\x85B:^\xC5XY^\x03\xEA\xB6V\x17b2\xCA\xF5\xD6\xD4\xD2\xE3u\x11\xECQ\x0Fb\x14\xE2\x04\xE1<a\xC5\x01eW-\x15\x01X\x81K\x1A\xE5A\vVj\xBF\xFC\xFE#\xD5\x93y\x16\xDC\xB4\x8C\xF0\x02Y\xA8\x87i\x01qC\xA7#\xE8\f\xA5\xF0c\xDEJ\xB0\xDB BJ\x87\xA4\xB0\x92\x80\x03\x95\xEE\xE9\xB8K\xC0\xE3JbE-\xD4\xCBP\\\x13S\"\eZ\xE1\x93\xFDa pinch of salt".force_encoding("ASCII-8BIT") }
|
112
112
|
it "signs it" do
|
113
|
-
key.stub
|
113
|
+
key.stub shake_salt: 'a pinch of salt'
|
114
114
|
key.sign("this sentence is not this sentence").should == expected_signature
|
115
115
|
end
|
116
116
|
end
|
@@ -125,7 +125,7 @@ describe Slosilo::Key do
|
|
125
125
|
let(:expected_signature) { Base64::urlsafe_encode64 "\xB0\xCE{\x9FP\xEDV\x9C\xE7b\x8B[\xFAil\x87^\x96\x17Z\x97\x1D\xC2?B\x96\x9C\x8Ep-\xDF_\x8F\xC21\xD9^\xBC\n\x16\x04\x8DJ\xF6\xAF-\xEC\xAD\x03\xF9\xEE:\xDF\xB5\x8F\xF9\xF6\x81m\xAB\x9C\xAB1\x1E\x837\x8C\xFB\xA8P\xA8<\xEA\x1Dx\xCEd\xED\x84f\xA7\xB5t`\x96\xCC\x0F\xA9t\x8B\x9Fo\xBF\x92K\xFA\xFD\xC5?\x8F\xC68t\xBC\x9F\xDE\n$\xCA\xD2\x8F\x96\x0EtX2\x8Cl\x1E\x8Aa\r\x8D\xCAi\x86\x1A\xBD\x1D\xF7\xBC\x8561j\x91YlO\xFA(\x98\x10iq\xCC\xAF\x9BV\xC6\v\xBC\x10Xm\xCD\xFE\xAD=\xAA\x95,\xB4\xF7\xE8W\xB8\x83;\x81\x88\xE6\x01\xBA\xA5F\x91\x17\f\xCE\x80\x8E\v\x83\x9D<\x0E\x83\xF6\x8D\x03\xC0\xE8A\xD7\x90i\x1D\x030VA\x906D\x10\xA0\xDE\x12\xEF\x06M\xD8\x8B\xA9W\xC8\x9DTc\x8AJ\xA4\xC0\xD3!\xFA\x14\x89\xD1p\xB4J7\xA5\x04\xC2l\xDC8<\x04Y\xD8\xA4\xFB[\x89\xB1\xEC\xDA\xB8\xD7\xEA\x03Ja pinch of salt".force_encoding("ASCII-8BIT") }
|
126
126
|
let(:expected_token) { token_to_sign.merge "signature" => expected_signature, "key" => key_fingerprint }
|
127
127
|
before do
|
128
|
-
key.stub
|
128
|
+
key.stub shake_salt: salt
|
129
129
|
Time.stub new: time
|
130
130
|
end
|
131
131
|
subject { key.signed_token data }
|