Closed xshadowlegendx closed 1 year ago
@xshadowlegendx Thanks for your report and the details! I've been going over your data to test and verify things. Here's where I'm at.
I believe your OpenSSLError(ErrorStack[])
is being caused by OpenSSL saying the signature is invalid.
In the bug/13-invalid-signatures
branch, I have created a dart script in ./scripts/test_signature.dart
that takes the attestation base64 as the first argument, and the clientDataJson base64 as the second argument. This script parses everything out and attempts to verify the signature.
What I found is that my library says that each of your example signatures is valid. But OpenSSL says the ones throwing errors are not valid.
I'm going to have to do some more testing where I can dump the private key to try to figure out what is going wrong with how I'm generating the signature.
Thanks for your patience while I keep digging in.
hello @killermonk, thanks you, if you need any help from my side please let me know
I've been testing on this @xshadowlegendx and I'm not entirely sure what the issue is. Currently, it appears that there is something wrong with the underlying crypto_keys
library that is being used. I have opened an issue in that library, and will see if I can work with them to figure anything out on this.
OK, so I was attempting to debug the crypto_keys
library and got deep deep into the depths of the data. This is something with how I'm serializing the signature and handling numbers with a MSB of 1.
In the valid signature below the MSB of r/s are both 0 from 0x22 and 0x32.
00000000 30 44 02 20 *22* b7 e0 26 0f 37 4f 01 00 5e a5 ca |0D. "..&.7O..^..|
00000010 09 98 37 13 e5 b1 3d 70 24 27 b8 eb 63 53 bd f8 |..7...=p$'..cS..|
00000020 59 d9 8f 94 02 20 *32* 66 8a bc 6a 3b 2e dc 40 dd |Y.... 2f..j;..@.|
00000030 52 ce 70 fb 44 93 0a bd 27 3e 23 a6 04 cf c8 d0 |R.p.D...'>#.....|
00000040 7f 81 00 01 36 42 |....6B|
In this invalid signature the MSB on both r/s is 1 from 0xe2 and 0xe8.
00000000 30 44 02 20 *e2* da 45 a4 d2 e0 db 5a 00 92 4f 61 |0D. ..E....Z..Oa|
00000010 cb 86 51 ee 40 b0 30 ae 11 ee 5f 5a f0 85 5a af |..Q.@.0..._Z..Z.|
00000020 db d1 84 4d 02 20 *e8* 38 0d 28 11 4b 58 a8 f4 5f |...M. .8.(.KX.._|
00000030 a3 b5 d5 86 f9 0e 8e 2a 0d 6d b0 41 e6 04 81 8d |.......*.m.A....|
00000040 ab 3d 19 95 06 56 |.=...V|
In this OpenSSL signature using the same keys, the MSB of r is 0 from 0x26, but the MSB of s would be 1 from 0x9a so OpenSSL put a 0x00 in front of it to ensure the number is not treated as negative.
00000000 30 45 02 20 *26* dc 4e 4a 54 93 c3 7d 38 1b df 0a |0E. &.NJT..}8...|
00000010 9c 61 08 e1 42 cb 94 eb 8f 73 73 a2 0d 4f b2 70 |.a..B....ss..O.p|
00000020 ef 03 f4 02 02 21 *00 9a* 2f 4f fd 59 2e 63 ac 71 |.....!../O.Y.c.q|
00000030 58 3f 0a 17 1d f9 99 4f fb 5c 77 fa 3f a0 39 ec |X?.....O.\w.?.9.|
00000040 25 fd 09 74 ef 5f 84 |%..t._.|
I was naively assuming the 32 byte integers were treated as unsigned values instead of signed.
I'm working on getting a new version published to address this issue.
🤦 turns out I even caught this earlier on. If you look at https://github.com/flutter-institute/webauthn/blob/master/test/util/webauthn_cryptography_test.dart#L39 you can see that I had a bad signature and the line above has the valid OpenSSL signature.
And I didn't dig in deep enough to figure out why there was a disparity.
@xshadowlegendx I've just published version 0.2.2 that should address this issue. Please let me know if you continue running into errors.
hello, so I am implementing passkey server using
webauthn_rs
library from rust and currently integrating with flutterwebauthn
library, so far I am able to initialize and finish the registration except sometime it fails with the error stated in the title, sometime it success at first try, sometime have to try multiple time to get successful registration.versions
dart: 3.0.5
flutter: 3.10.5
webauthn: ^0.2.0
sample attestations with success response
sample attestations with the failure response
flutter demo code