opendroneid / opendroneid-core-c

Open Drone ID Core C Library
Apache License 2.0
178 stars 64 forks source link

Auth message 'length' checks #48

Closed cedric-papon closed 2 years ago

cedric-papon commented 2 years ago

When compiling with "-Wextra" flag and ODID_AUTH_MAX_PAGES = 16, the compiler warns that we are comparing an uint8_t against MAX_AUTH_LENGTH, in this case with the value 362.

The latest F3411 draft states:

"After the Length limit is reached, additional data may be sent in full 23 byte pages."

My understanding would be that

friissoren commented 2 years ago

Thanks for checking this. I agree that the whole topic of the length of authentication data is somewhat confusing.

Did you see the additional text that was added to Chapter 5.4.5.15 of the latest v1.1 draft? It was added fairly recently as an attempt to further clarify how exactly to interpret the somewhat ambiguous comment added to the Length field in Table 8. You are now quoting an earlier version of the draft v1.1 (I guess the one that was sent for ballot). Please get the latest from Gabriel's OneDrive. It will be sent for a second ballot at some point (hopefully soon).

I have tried to also give an explanation of this here.

The reason the code is checking a uint8 against a value larger than 255 is that the code also allows lowering ODID_AUTH_MAX_PAGES. Since the value of MAX_AUTH_LENGTH depends on ODID_AUTH_MAX_PAGES, there are situations where this check becomes relevant. I saw the warning in the IDE I am using when I wrote the code but since it didn't show up when I compiled, I didn't think of suppressing it. I agree it needs to be fixed. I will add some comments to the PR.

friissoren commented 2 years ago

I will take the liberty of closing this issue since the compile warnings were now fixed. If you don't agree with the interpretation of the Length field, please just re-open.

cedric-papon commented 2 years ago

Works for me :+1: Thanks