Skip to content

Commit

Permalink
fixed class shifting in single byte tags
Browse files Browse the repository at this point in the history
Signed-off-by: Theis <theismejnertsen@gmail.com>
  • Loading branch information
OmegaRelay committed Oct 10, 2024
1 parent 357d477 commit cc3d9e4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion encoding/tlv/ber.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewBERTag(number uint, class Class) Tag {
var tag uint

if number < 0x1F {
return Tag(number | (uint(class) >> 6))
return Tag(number | (uint(class) << 6))
}

tag = 0x1F | (uint(class) << 6)
Expand Down
1 change: 1 addition & 0 deletions encoding/tlv/ber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestTagBER(t *testing.T) {
class tlv.Class
constructed bool
}{
{tlv.NewBERTag(0x2, tlv.ClassContext), tlv.ClassContext, false},
{tlv.NewBERTag(0x20, tlv.ClassUniversal), tlv.ClassUniversal, false},
{tlv.NewBERTag(0x200, tlv.ClassContext), tlv.ClassContext, false},
{tlv.NewBERTag(0x20000, tlv.ClassPrivate), tlv.ClassPrivate, false},
Expand Down

0 comments on commit cc3d9e4

Please sign in to comment.