Skip to content

Commit

Permalink
Only split the signed message in to 2 parts with the message verifier.
Browse files Browse the repository at this point in the history
…Fixes #1595 (#1596)
  • Loading branch information
jwoertink authored Oct 29, 2021
1 parent 74c049f commit b30040a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions spec/lucky/support/message_verifier_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "../../spec_helper"

describe Lucky::MessageVerifier do
it "is valid" do
verifier = Lucky::MessageVerifier.new("supersecretsquirrel", :sha256)
signed_message = verifier.generate("abc123")
verifier.verified(signed_message).should eq("abc123")
end
end
4 changes: 2 additions & 2 deletions src/lucky/support/message_verifier.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Lucky
end

def verified(signed_message : String) : String?
data, digest = signed_message.split("--")
data, digest = signed_message.split("--", 2)
if valid_message?(data, digest)
String.new(decode(data))
end
Expand All @@ -25,7 +25,7 @@ module Lucky
end

def verify_raw(signed_message : String) : Bytes
data, digest = signed_message.split("--")
data, digest = signed_message.split("--", 2)
if valid_message?(data, digest)
decode(data)
else
Expand Down

0 comments on commit b30040a

Please # to comment.