You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
The raw signatures need to have a fixed length, so that the recipient can know where the value of R ends and the value of S begins. In the ASN.1 format this length can vary, since the length of the numbers is explicitly encoded.
Basically this means the integers inside the ASN.1 structure can sometimes be shorter than the fixed length they need to have in the raw signature format. On the rare occasions when this happens the signature validation will fail.
I think you should be able to reproduce this issue by generating and verifying something like 10k signatures using the raw format. Some of the verifications should fail because of this issue.
I was only working and testing with the ASN1.swift file and not with your full project, so I am not submitting a PR right now, but this is the fix that worked for me in that context:
I replaced your calls to
private func dropLeadingBytes() -> Data {
if self.count == 33 {
return self.dropFirst()
}
return self
}
I think I found a bug in your ASN.1 parsing logic while I was working on an open issue in the JOSESwift project.
The raw signatures need to have a fixed length, so that the recipient can know where the value of R ends and the value of S begins. In the ASN.1 format this length can vary, since the length of the numbers is explicitly encoded.
Basically this means the integers inside the ASN.1 structure can sometimes be shorter than the fixed length they need to have in the raw signature format. On the rare occasions when this happens the signature validation will fail.
I think you should be able to reproduce this issue by generating and verifying something like 10k signatures using the raw format. Some of the verifications should fail because of this issue.
I was only working and testing with the ASN1.swift file and not with your full project, so I am not submitting a PR right now, but this is the fix that worked for me in that context:
I replaced your calls to
with calls to
which also pads R and S if they are too short.
The text was updated successfully, but these errors were encountered: