8000 add encoding / parsing of real values by vetinari · Pull Request #17 · go-asn1-ber/asn1-ber · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add encoding / parsing of real values #17

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

Merged
merged 2 commits into from
Jun 11, 2020

Conversation

vetinari
Copy link
Contributor

This does not cover all test cases from the suite. TC8 returns an error instead of a warning, but I think that's ok.

@vetinari vetinari requested review from johnweldon and liggitt June 29, 2018 06:23
@liggitt
Copy link
Contributor
liggitt commented Jul 3, 2018

This does not cover all test cases from the suite. TC8 returns an error instead of a warning, but I think that's ok.

was the suite faulty, or was there a compelling reason not to support the type uniformly?

@vetinari
Copy link
Contributor Author
vetinari commented Jul 3, 2018

Wasn't clear what the errors from the suite were. Fixed now.

@vetinari
Copy link
Contributor Author
vetinari commented Jul 3, 2018

I guess I need to squash before merging ;-)

* TC8 returns an error instead of printing the suggested warning
* TC17 returns same error as TC15: no need to check all three conditions
  when we know one is already wrong...
@johnweldon
Copy link
Contributor

Try rebasing on master

@vetinari
Copy link
Contributor Author

merged w/ current master

@johnweldon johnweldon merged commit f64891d into go-asn1-ber:master Jun 11, 2020
@s00500
Copy link
Contributor
s00500 commented Sep 6, 2024

I am trying to use this library for ember. running on a 64bit os... and the results I get from the real parsing are strangely wrong. I have reimplemented the exact style used here... but I am not sure if it is different from what this library tries to achieve....

https://github.com/Lawo/ember-plus-sharp/blob/78e3cd816e699f3fe6b7a94db9668397398ec437/Lawo.EmberPlusSharp/Ember/EmberWriter.cs

Any Inputs ? I can get my code into a pr at some point, for now I am fine using the Bytes() function and continue with custom parsing....

@s00500
Copy link
Contributor
s00500 commented Sep 6, 2024

EG:
Bytes: 09 03 c0 04 05

Parse as -80.0

While I expect them to parse as -20....

@vetinari
Copy link
Contributor Author

Can you explain how you get to -20?

The contents of tests/tc10.ber (0x09, 0x07, 0x83, 0x04, 0xff, 0xff, 0xff, 0xfb, 0x05) parse correctly as 0.156250 with

func TestRealDecoding(t *testing.T) {
    dec, err := DecodePacketErr([]byte{0x09, 0x07, 0x83, 0x04, 0xff, 0xff, 0xff, 0xfb, 0x05})
    if err != nil {
        t.Errorf("Failed to decode: %s", err)
    }
    if dec.Value.(float64) != 0.156250 {
        t.Errorf("invalid value parsed in tc10: %f <=> 0.156250", dec.Value.(float64))
    }
}

so the algorythm to decode the binary encoding should be correct.

@vetinari
Copy link
Contributor Author

see also #46

@s00500
Copy link
Contributor
s00500 commented Sep 10, 2024

I am by no means an expert, but the code here is well structured and explained using references to the X.690 standard. It might make some use case (ember+) specific assumptions. But since this is the code that I work against I have now copied its behavior line by line and got a working result...

https://github.com/Lawo/ember-plus-sharp/blob/78e3cd816e699f3fe6b7a94db9668397398ec437/Lawo.EmberPlusSharp/Ember/EmberReader.cs#L452

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.

4 participants
0