views:

261

answers:

2

Is there a free package for reading, manipulating and writing ASN.1 in Java?

It must be:

  1. Free
  2. Lightweight
  3. Self-contained (without external dependencies on, e.g. Apache commons)
  4. Java 5 (not Java 6), and Java 4 is preferred.
+1  A: 

The free BouncyCastle library provides low-level ASN.1 parsing. You don't need to install BC as a provider to use the ASN.1 capabilities. It has different versions for 1.4 and up. It has no external dependencies. As the default bundle contains all of the BC provider classes, you may want to repackage it if you want something more compact.

erickson
It's a viable option, but it doesn't really seem to meet the light-weight requirement (I consider light-weight to be under 50K).
Software Monkey
Yes, I wrote my own decoder class. It's about 200 lines of code, maybe. I've been using it for over 10 years, and I'd like to refactor it to provide a different interface, but it has definitely met the need.
erickson
@Erickson: Any chance you want to share it? (Although it is a low priority for me now that I have resolved my immediate problems with a PKCS#12 keystore, so no rush).
Software Monkey
Looking more closely at BC, it's a looonnnggg way from light-weight (nearly 400 classes - and separating out the non-core classes from core would be a lot of work).
Software Monkey
The code I wrote already is not mine to share. But I am thinking about writing my own decoder that would be event-oriented, like a SAX parser. If I do that I would be willing to share.
erickson
+3  A: 

The following project looks promising:

http://www.chaosinmotion.com/asn1.m

It is provided under a liberal BSD-style licence.

It is small, 41 classes compiling to 55KiB.

It compiled clean with no dependencies to Java 3.

Software Monkey