ASN1.js icon indicating copy to clipboard operation
ASN1.js copied to clipboard

Add support for ASN.1 REAL type

Open rmhrisk opened this issue 11 years ago • 5 comments

The REAL type is not used all that commonly but the library does not currently support it, it should. REALs are a machine representation of a real number.

rmhrisk avatar May 02 '14 02:05 rmhrisk

Anybody made some improvement in a fork?

JanFellner avatar Oct 21 '22 08:10 JanFellner

@JanFellner In you do need ASN.1 REAL type you can you predecessor of the ASN1.js - father of ASN1.js. It is on C++, btw. Since I left PeculiarVetures team do not think anybody will append REAL in ASN1.js.

YuryStrozhevsky avatar Oct 21 '22 09:10 YuryStrozhevsky

I did fork the library and i am trying to see if i get AsnReal implemented based on the way AsnInteger is coded. On the c++ side we are using the snacc compiler which we extended so that it is able to create not only strucutres but also a ROSE like RPC interface to call functions. This compiler was extended serveral times and is also able to created JSON typescript stubs and structures. Due to the overhead of JSON i wanted to give BER on the browser a chance but i need Real values as some values are encoded that way on the server side. I need to get debugging working on monday so that i can encode and decode AsnReal values and step through the code. The structure of the library looks promising to me. Should be duable :)

JanFellner avatar Oct 21 '22 14:10 JanFellner

@YuryStrozhevsky i am progressing concerning the real encoding. I read the X690 documentation as well as your "ASN.1 by simple words" which is pretty understandable (thanks for this document 😉)

I am trying to connect asn1js to messages created and parsed by the snacc compiler. As you seem to be pretty long in the asn1 topic you may also have humbled over it. https://github.com/petesh/snacc/blob/master/c%2B%2B-lib/src/asn-real.C

The X690 states to use two complements values for the exponent, https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.690-202102-I!!PDF-E&type=items 8.5.7.4

I see that asn1js is providing methods to encode to and decode from two complement values. The interesting thing is: Your document is not loosing a word about this (neither for the integer values nor for the real values)

I am kind of struggeling here as:

  • the snacc compiler is not doing any two complements adoption (or i did not see it) (https://github.com/petesh/snacc/blob/master/c%2B%2B-lib/src/asn-real.C)
  • your documention is not loosing words about it
  • but on the other hand the asn1js implementation is calling the decode method for it (https://github.com/PeculiarVentures/ASN1.js/blob/master/src/internals/LocalIntegerValueBlock.ts#L143)

Maybe i am missing the puzzle piece that completes my picture.

(For completeness the FeatureBranch i am working on to get it "real": https://github.com/JanFellner/ASN1.js/blob/feature/CC-2490-add-support-for-asn1Real/src/internals/LocalRealValueBlock.ts)

JanFellner avatar Oct 27 '22 13:10 JanFellner

For those looking for the missing real encoding decoding take a look at

https://github.com/PeculiarVentures/ASN1.js/pull/79

respectively

https://github.com/ESTOS/ASN1.js

JanFellner avatar Oct 31 '22 15:10 JanFellner