-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Printing of Authorization bits from BSI TR 03110-4 #7
Conversation
Cleaned up the bits_test and added asserts Also added utility to convert arbitrary files to hexstring
and added --print-bits flag
cvc/tools/cvc_print.py
Outdated
def main(args): | ||
print("ARGS",args) |
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.
Should be removed
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 yeah, missed that one 😃
@@ -31,12 +31,58 @@ | |||
logger = logging.getLogger(__name__) | |||
cert_dir = b'' | |||
|
|||
# Authorization bits according to | |||
# BSI-TR-03110-4 Chapter 2.2.3.2 Table 4 | |||
AuthorizationBits = { |
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.
It is not necessary to have a dict, a reverse list is sufficient.
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.
I like the explicit functionality to check set bits with human readable strings like self.assertTrue(bits[AuthorizationBits["Age Verification"]])
How would you structure the code with a reverse list ?
cvc/certificates.py
Outdated
@@ -38,6 +38,20 @@ def decode(self, data): | |||
self.__a = ASN1().decode(self.__data) | |||
return self | |||
|
|||
def decode_authorization_bits(self): |
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.
Once CHAT bytes are exposed via chat(), I am not sure the purpose of exposing them as bits. If it for just printing them, it should be placed in the printing script and not in the API.
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.
I'm with you on that and moved the function over to cvc_print.py
and adapted the tests Removed unused debug prints
I've been using pycvc more often and thought it would be nice to see which rights/bits are actually set in an certificate for an AuthenticationTerminal.
The BSI TR 03110-4 specifies these bits in Table 4 in the TR 03110-4
https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/TechGuidelines/TR03110/BSI_TR-03110_Part-4_V2-2.pdf?__blob=publicationFile&v=1
I've added a method
decode_authorization_bits
onto the CVC class to decode the bits and order them properly https://github.com/xoryouyou/pycvc/blob/main/cvc/certificates.py#L36The actual bits are declared in a dict at https://github.com/xoryouyou/pycvc/blob/main/cvc/tools/cvc_print.py#L36
which allows the lookup and human readable usage of while checking the bits of a certificate.
I've also added a
--print-bits
argument to the argparse at https://github.com/xoryouyou/pycvc/blob/main/cvc/tools/cvc_print.py#L85which then triggers an if further down in https://github.com/xoryouyou/pycvc/blob/main/cvc/tools/cvc_print.py#L134
and prints the detailed bits in formation for the given certificate.
E.g.
Finally I added two dummy certificates which I created with
cvc-create
and put as a hex string into the test code.These certificates have known bits set and are thus suitable to be used in an
assertTrue
test.As a helper function to create a hexlified cvcert I've added https://github.com/xoryouyou/pycvc/blob/main/tests/cvcert_to_hexstring.py
I have no clue if I've put things where they belong in your project but placed them by gut feeling.
Also I tried to comment everything as detailed as possible which IMHO helps when dealing with the certificates and BSI TRs :)
Would like to get your feedback on this and possibly merge the functionality if you like it.