-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve folding signature algorithm #29
Conversation
Example output:
|
The likely issue is addition of non-empty Line 261 in e4c8736
and for formatSignature(s.sigParams) here:Line 276 in e4c8736
It is important to make sure both values are equal (with the exception of |
In your case, it shows:
Uh, missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem with b=
handling that causes generation of broken signatures. Additionally, I would appreciate if you add more test cases to ensure it generates valid signatures in edge cases related to folding.
dkim/header.go
Outdated
} | ||
} | ||
sort.Strings(keys) | ||
if found { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never set to anything other than false.
dkim/header.go
Outdated
} | ||
|
||
if bvalue != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty string is a valid value. The DKIM-Signature contents are signed with b=
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh thanks, I've got it now! It seems it works :D
Codecov Report
@@ Coverage Diff @@
## master #29 +/- ##
==========================================
+ Coverage 66.30% 66.62% +0.31%
==========================================
Files 7 7
Lines 837 845 +8
==========================================
+ Hits 555 563 +8
Misses 213 213
Partials 69 69
Continue to review full report at Codecov.
|
Yea! I'll add some additional test cases! To be honest, I did not added more test before because they are covered by |
Now, if we have some part of the header longher than 75cahrs, the new algorithm will break the line length limit. This should not be an issues since this limit is only a recommendation! What do you think? #18 (comment) Anyway this should fix #18 |
I agree that 75 chars limitation can be ignored. Following rationale in RFC, it is not really relevant today as a rare person looks at message header. |
@foxcpp thanks! I've also added a more test that checks only if the headers names in the "h" values are properly folded in the generated signature! |
FWIW, That's the h= value my mail server used for a typical plaintext message:
Interesting is that old folding algorithm broke it in the middle of a field name yet |
@emersion, what do you think about this PR? |
I also notice this! I've tried with different mail provider receivers and in some case (like hotmail/outlook) the dkim fails while other (like gmail) it passes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the meat of the patch looks good :)
Hi @emersion, thanks for the feedback! I was wondering: if we do not want to limit the line lenght to 75 chars, we could make the folding algorithm simpler by just putting the "b" value at the end of the header without folding it! What do you think about this? |
Would the |
Not super sure about Regarding |
@emersion what do you think about b folding? |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, let's merge this as-is since it already fixes a bug. I've opened #31 for future work.
Thanks!
Following #27, I've rewritten the folding algorithm in order to better fold headers and avoid introducing new lines inside headers.
However, it seems it breaks the skim sign.
In my understanding, this should have been call after the signature was generated, but it seems that the new algorithm changes the generates signature itself.
Any help?