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

Missing support for BCDString in BER #145

Open
Jelmoh opened this issue Mar 15, 2022 · 1 comment
Open

Missing support for BCDString in BER #145

Jelmoh opened this issue Mar 15, 2022 · 1 comment

Comments

@Jelmoh
Copy link

Jelmoh commented Mar 15, 2022

Hi,

I am trying to decode a BER encoded file using a specification which also specifies several fields as being of BCDString type.
The specification provides the following comments for this type:

-- The BCDString data type (Binary Coded Decimal String) is used to represent
-- several digits from 0 through 9, a, b, c, d, e.
-- Two digits are encoded per octet. The four leftmost bits of the octet represent
-- the first digit while the four remaining bits represent the following digit.
-- A single f must be used as a filler when the total number of digits to be
-- encoded is odd.
-- No other filler is allowed.

And an example of one of the fields as it is in the specification:
Imsi ::= [APPLICATION 129] BCDString --(SIZE(3..8))

The provides SIZE value differs per field.

I am currently using the following code to decode these fields in my own script:

for char in field_value:
    for val in (char >> 4, char & 0xF):
        if val == 0xF:
            return
        yield str(val)

Let me know if this is enough information to go on, if not, which information do you need?

Cheers,
Jelmoh

@eerimoq
Copy link
Owner

eerimoq commented Mar 15, 2022

Hi!

I don't work on this project actively anymore. Feel free to implement support for it yourself and submit a PR and I can merge.

Thanks,
Erik

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

No branches or pull requests

2 participants