Closed trailfog closed 2 years ago
@fheidenreich Would you like to open a PR for your fixes?
@DivineDominion Yes, just opened a PR for this fix (for reference: https://github.com/glebd/cocoafob/pull/55)
Thank you
this bug is also present in the objc version
@sweetppro Could you switch to the .framework building version based on Swift instead of "inlining" the .m/.h files into your project? That might be the best option if you don't want to replicate @fheidenreich's fix in ObjC
id prefer not to as it would add unnecessary size to my app
While playing around, I noticed that adding extra characters to the end of the registration key still produces a valid return in the swift5 implementation. This is down to how the Security framework by apple handles additional characters during a Base32 decode: They simply get ignored and no error is thrown!
Example: The swift implementation will accept both of these registration keys:
GAWQE-F9AQP-XJCCL-PAFAX-NU5XX-EUG6W-KLT3H-VTEB9-A9KHJ-8DZ5R-DL74G-TU4BN-7ATPY-3N4XB-V4V27-Q
GAWQE-F9AQP-XJCCL-PAFAX-NU5XX-EUG6W-KLT3H-VTEB9-A9KHJ-8DZ5R-DL74G-TU4BN-7ATPY-3N4XB-V4V27-Qasdf
asdfGAWQE-F9AQP-XJCCL-PAFAX-NU5XX-EUG6W-KLT3H-VTEB9-A9KHJ-8DZ5R-DL74G-TU4BN-7ATPY-3N4XB-V4V27-Q
You can reproduce this by adding the following test to the swift5 project in Xcode:
The expected result would be that this is an invalid key, thus asserting the result with a
false
value. However, this test will fail, because the verification function will return atrue
!I also tried this in the Python implementation and that "successfully" failed during the Base32 decode -> All okay.
As I don't know the security framework to well, I added the following code to the
LicenceVerifier.swift
:and a bit further down add this function:
I don't think this is the nicest solution, but it works. Does anyone else know this might be fixed with a cleaner method? Seems like a workaround for something that I have missed!