asn1c | The ASN.1 Compiler - ASN | Cryptography library
kandi X-RAY | asn1c Summary
kandi X-RAY | asn1c Summary
The ASN.1 Compiler
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of asn1c
asn1c Key Features
asn1c Examples and Code Snippets
Community Discussions
Trending Discussions on asn1c
QUESTION
I have some messages data structures represantations in ASN1. These messages have to sent using the canonical octect encoding rule (COER). I currently user asn1c for python,but, there is no support for coer. How could I create the instances and later do the encoding in python?
...ANSWER
Answered 2020-Sep-05 at 19:51I'm afraid you might be in trouble. COER looks like it was standardised relatively recently (bearing in mind that ASN.1 is well over 30 years old), and I don't think that a lot of the tools have caught up yet.
The tools from OSS Nokalva seem to support COER, but they don't do a Python binding, and their tools are quite pricey (but very good).
For Python the "goto" has been the pyasn1 library, which doesn't seem to do COER (or even PER, which is a real pity).
Objective Systems, which are also very good, now do a Python ASN.1 compiler(which trumps pyasn1's code first approach), but that doesn't yet do COER.
The easiest thing might be whince, fork out for the OSS Nokalva tools, and use Iron Python to interop with their C# library and tools. That might seem an expensive way of doing it, but if your project is on a fixed timescale, that might be the lowest risk way of accomplishing what you want. You'd likely not be having to write any code to "do" COER, and instead you can concentrate on the application itself and avoid writing your own COER implementation that'd be a pain to maintain, and will eventually get surpassed by other ASN.1 tools anyway.
QUESTION
I'm trying to parse RSA (private) keys using asn1c. I based the asn1 module on https://tools.ietf.org/html/rfc3447 and it looks as following (i tried to only use the private and public key part):
...ANSWER
Answered 2019-Nov-08 at 20:36You need to compile with -fwide-types
flag.
-fwide-types Use the wide integer types (INTEGER_t, REAL_t) instead of ma-chine’s native data types (long, double).
The problem is that most of the INTEGER
fields of RSAPrivateKey
contain really big numbers that not fit in long
type that is being used by default.
Without -fwide-types
QUESTION
I am using the c code generated by asn1c from the TCAP protocol specification (i.e., the corresponding ASN1 files). I can successfully encode TCAP packets by the generated code. However, trying to "decode" related byte streams fails.
A sample code is as follows.
...ANSWER
Answered 2019-Aug-19 at 15:20I am using the c code generated by asn1c from the TCAP protocol specification
Which asn1c are you using (git commit id) and where do you get it from as there are quite a log of forks out there?
While the message type ("Begin", in this case), is correctly detected, but other paramters are not parsed.
How do you know that Begin is correctly detected?
Using other encoding rules, i.e., aper_decode() and uper_decode(), also fails.
There is no point in trying other encodings as they are not binary compatible.
I would be thankful if anyone can describe how to use the auto-generated c code for decoding (parsing) a byte string of TCAP messages.
You are using it correctly and probably there is a bug somewhere in the BER decoder.
You could try compiling with -DASN_EMIT_DEBUG=1
in CFLAGS
(or -DEMIT_ASN_DEBUG=1
depending on the asn1c
version you are using) to get some more debug messages.
QUESTION
I am using the c code generated by asn1c from the MAP protocol specification (i.e., the corresponding ASN1 files). Please consider the following sample code:
...ANSWER
Answered 2019-Aug-19 at 15:09The invokeId and opCode parameters are truely detected, and the parser gives us a buffer named as invokeParameters which is of type ANY.
The question is how to decode (parse) invokeParameters?
You need to call ber_decode
with the appropriate type (depending on the operation code) and the content of the ANY buffer. From ANY.h
QUESTION
I'm using the asn1c lib for many projects, but I never found how to use the free member of a SEQUENCE_OF
. I always set it to nullptr
because of that, and when I use Valgrind, I see (of course) that my lists members are not freed when using ASN_STRUCT_FREE
on the element containing the list.
So my question is how can I use that free member?
Here is a simple example of how I use my lists with asn1c.
...ANSWER
Answered 2019-May-07 at 18:03QUESTION
I use asn1c to parse the LDAP messages.
For this purpose, after compiling the ASN.1 Definition defined in rfc4511, I use the ber_decode and xer_fprint functions for decoding and printing content in my program.
For example, the two outputs indicated below are related to two different LDAP messages:
...ANSWER
Answered 2018-Dec-15 at 17:48You cannot change LDAP asn1 specification to solve your problem.
For example: when you decode a BindRequest
, to decode name
(of type LDAPDN
) ber_decode expects the tag of OCTET STRING
. If you change the spec as you suggest, you will expect the tag of UTF8String
and receive the tag of OCTET STRING
(hence the error)
Unfortunately, with generic tools, there is no way to display a human readable text while the specification is using OCTET STRING
QUESTION
I have installed the osmocom asn1c compiler, the aper-prefix
branch, to obtain an implementation of the TCAP protocol.
I have used the respective script to compile the ".asn" files.
The C files are generated successfully, but when compiling the obtained C code, an error is raised, which is related to this line of code:
ANSWER
Answered 2018-Dec-05 at 15:56You have several options:
Use a newer version of asn1c from this PR (still not merged)
Copy the EXTERNAL.h from the osmocom repository
Rename
EXTERNAL
toEXTERNALt
in all asn files and add the following in the asn files that has EXTERNALt.
QUESTION
I am trying to generate C code for the GSM-TCAP asn1 files obtained from libosmo-asn1-TCAP. I have installed the osmocom libasnc1 compiler (tried both master and aper-prefix branches) and run this code:
...ANSWER
Answered 2018-Dec-05 at 04:06You don't need to compile all asn files in asn sub-directory. There is a rebuild script that you could use.
QUESTION
asn.1 = abstract syntax annotation one. I know it can define some types of data and by using asn1c compiler, we can convert Rectangle.asn to some of .c and .h files. Then we can encode or decode from or to different form of data(ber, per, xer, etc.) by using these .c and .h files. But how? I have a file named Rectangle.asn:
...ANSWER
Answered 2018-Jan-26 at 15:29You need to read more about ASN.1.
The problem that it solves is that things on different computers are not all the same. If you want to send data from an embedded x86 DOS system (16 bit little endian int) to a SPARC (32 bit big endian int) then you can't just use int
on both sides.
There are two main parts to ASN.1:
- the language description i.e., the ASN.1 grammar
- the encoding rules that apply the grammar to convert host data to and from encoded data
There are some examples on the asn1c web site.
QUESTION
I'm trying to use the OpenSSL ASN.1 API to implement my own custom types. I expect to extend these types in the future, and the ASN.1 standard itself supports this via the concept of extensible types (see here for an overview of what I want). However, I can't figure out if the OpenSSL ASN.1 API supports this concept and if so how to implement it. I've got the following structures defined using the macros supplied by OpenSSL:
...ANSWER
Answered 2017-Nov-01 at 12:11Luke,
You're probably going to have better luck with an actual ASN.1 compiler—there are several commercially available, but Lev Walkin's free ASN.1 Compiler might fit the bill for your needs.
I'm not very familiar with OpenSSL, but a quick browse through the asn1t.h source (among others) doesn't suggest that there's builtin support for declaring an extensible sequence. You're probably more motivated than I to look, but I confess I wouldn't be surprised to find they didn't include it. Extensibility can be a hard problem to solve, especially if you're relying on preprocessor macros for code generation.
In any case, relying on the OpenSSL code could cause problems in the future anyway: when the APIs or code change, you'll be forced to manually update all of your code to match. A code generator would (probably) do a better job of maintaining API (and ABI) compatibility while allowing somewhat more flexible code generation and language choices.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install asn1c
(also check out doc/asn1c-quick.pdf).
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page