kellerkindt / asn1rs

Generates Rust Code and optionally compatible Protobuf schema files from ASN.1 definitions.
http://asn1.rs
Apache License 2.0
55 stars 20 forks source link

OBJECT IDENTIFIER not supported #74

Open lynxis opened 2 years ago

lynxis commented 2 years ago

Hi,

[I'm quite new to asn1 (I only used it, but not written anything in it). Are there any good references or books to get into the asn1 topic?]

I've started to try asn1c against 3G/UMTS asn1 files (https://github.com/osmocom/osmo-iuh/tree/master/asn1) It fails when parsing https://github.com/osmocom/osmo-iuh/blob/master/asn1/hnbap/HNBAP-CommonDataTypes.asn with the following error.

I'm using asn1rs v0.2.2-25-gb6d5f77f6095 with rustc 1.56.1.

PrivateIE-ID    ::= CHOICE {
        local           INTEGER (0..65535),
        global          OBJECT IDENTIFIER
}
lynxis@rust:~/asn1rs$ ./target/debug/asn1rs /tmp/dest  /home/lynxis/asn-tests/osmo-iuh/hnbap/HNBAP-CommonDataTypes.asn 
Failed to load file /home/lynxis/asn-tests/osmo-iuh/hnbap/HNBAP-CommonDataTypes.asn: Model(At line 36, column 17 an unexpected token was encountered: "IDENTIFIER"
   0: <asn1rs_model::model::err::Error as core::convert::From<asn1rs_model::model::err::ErrorKind>>::from
             at asn1rs-model/src/model/err.rs:36:24
   1: <T as core::convert::Into<U>>::into
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/convert/mod.rs:540:9
   2: asn1rs_model::model::err::Error::unexpected_token
             at asn1rs-model/src/model/err.rs:93:9
   3: <asn1rs_model::model::choice::Choice<asn1rs_model::model::lor::Unresolved> as core::convert::TryFrom<&mut core::iter::adapters::peekable::Peekable<T>>>::try_from
             at asn1rs-model/src/model/choice.rs:93:13
   4: asn1rs_model::model::Model<asn1rs_model::model::asn::Asn<asn1rs_model::model::lor::Unresolved>>::read_definition
             at asn1rs-model/src/model/mod.rs:240:30
   5: asn1rs_model::model::Model<asn1rs_model::model::asn::Asn<asn1rs_model::model::lor::Unresolved>>::try_from
             at asn1rs-model/src/model/mod.rs:116:40
   6: asn1rs::converter::Converter::load_file
             at src/converter.rs:66:21
   7: asn1rs::main
             at src/main.rs:34:25
   8: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
   9: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/sys_common/backtrace.rs:125:18
  10: std::rt::lang_start::{{closure}}
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/rt.rs:63:18
  11: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:259:13
      std::panicking::try::do_call
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:403:40
      std::panicking::try
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:367:19
      std::panic::catch_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panic.rs:129:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/rt.rs:45:48
      std::panicking::try::do_call
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:403:40
      std::panicking::try
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:367:19
      std::panic::catch_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panic.rs:129:14
      std::rt::lang_start_internal
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/rt.rs:45:20
  12: std::rt::lang_start
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/rt.rs:62:5
  13: main
  14: __libc_start_main
  15: _start

)
lynxis commented 2 years ago

This is also required for X.509 https://github.com/kellerkindt/asn1rs/issues/6#issuecomment-708369996

Should I create an overview ticket for osmo-iuh / (parts of 3G/UMTS) instead opening issues for every missing feature?

kellerkindt commented 2 years ago

Hi there. You are right, OBJECT IDENTIFIER is not yet supported. An overview ticket would be nice to have :)

septs commented 10 months ago

I hope to support, OBJECT IDENTIFIER

niltooth commented 9 months ago

Happy to help implement this if I can. So far what I have found is the following.

  1. asn1rs-model/src/model/oid.go needs to be implemented?
  2. object identifier needs to be added to read_role_given_string in asn1rs-model/src/model/mod.go