简体   繁体   中英

How to convert Java Object to ASN.1 stream?

I wonder if there is a simple way to convert a java object to a ASN.1 byte stream. Thanks in advance.

I use http://bnotes.sourceforge.net/ and it is working quite good for me. It's very simple and easy to use, just read the development guide and you will understand very fast.

Perhaps you first need to get the concept of what ASN.1 is, since you say you are new to it.

With ASN.1 you specify the types that may be used to form a message. When this is combined with a defined set of encoding rules, you then have a full specification of the bytes that constitute a message.

Databinding tools (such as one my company, Objective Systems, sells) can take an ASN.1 specification and then generate Java classes that model the types defined in the ASN.1, and which include methods to encode/decode the modeled data, according to a defined set of encoding rules (BER, PER), to bytes.

It doesn't really make sense to speak of taking an arbitrary Java object and turning it into an ASN.1 byte stream because you lack two key pieces: the ASN.1 that specifies what will be in the message and the selection of encoding rules. In theory, I suppose someone could come up with a standard according to which arbitrary Java objects would be serialized to ASN.1, but I'm not aware of such, and that would be rather different from what the databinding tools do.

I hope I've made sense.

I see java library from at least the below

  1. http://www.chaosinmotion.com/asn1.m
  2. bouncycastle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM