Skip to content
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

Add method to get a BER encoded tag's number #39

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

OmegaRelay
Copy link
Contributor

Hello, this commit adds a method to get the tag number from a BER encoded tag, and modifies the tag test to include the new method.

Let me know what you think :)

@OmegaRelay OmegaRelay requested a review from stv0g as a code owner October 11, 2024 20:45
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 80.95238% with 4 lines in your changes missing coverage. Please review.

Project coverage is 35.04%. Comparing base (bd70605) to head (b612c60).
Report is 45 commits behind head on main.

Files with missing lines Patch % Lines
encoding/tlv/ber.go 80.95% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
- Coverage   36.70%   35.04%   -1.67%     
==========================================
  Files          25       27       +2     
  Lines        1531     1672     +141     
==========================================
+ Hits          562      586      +24     
- Misses        896     1026     +130     
+ Partials       73       60      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@stv0g stv0g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition 👍 I like it. What do you think about naming it just Number()? The tags number alone isn't BER specific, or is it?

It happens just that we use the BER encoding to for our internal representation for a Tag in a uint. We could also have used a struct, but decided for a unit as it's easier to declare a large set if tags as it happens in a lot of SmartCard applications.

@OmegaRelay
Copy link
Contributor Author

OmegaRelay commented Oct 13, 2024

Great addition 👍 I like it. What do you think about naming it just Number()? The tags number alone isn't BER specific, or is it?

It happens just that we use the BER encoding to for our internal representation for a Tag in a uint. We could also have used a struct, but decided for a unit as it's easier to declare a large set if tags as it happens in a lot of SmartCard applications.

Thanks for reviewing.
I see the reason behind using the uint instead of a struct but the intention behind this method is to be able to get the tag number specifically for BER encoded tags where the tag also contains the class and constructed bits. This method does not work for simple or compact tlv tags and therefore I named it BERNumber to specify usage.

Alternatively, we could seperate tag types where only the BERTag type implements the Number(), Class() and IsContstructed() methods?

@stv0g stv0g enabled auto-merge (rebase) October 14, 2024 02:08
@stv0g
Copy link
Member

stv0g commented Oct 14, 2024

I see. Thanks for your contribution :)

@stv0g stv0g changed the title method to get a BER encoded tag's number Add method to get a BER encoded tag's number Oct 14, 2024
@stv0g stv0g merged commit ad9d621 into cunicu:main Oct 14, 2024
6 of 7 checks passed
@OmegaRelay OmegaRelay deleted the tag_number branch October 14, 2024 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants