indutny / asn1.js

ASN.1 Decoder/Encoder/DSL
MIT License
184 stars 64 forks source link

RFC 3161 - PKIStatus #64

Closed toddwprice closed 8 years ago

toddwprice commented 8 years ago

I'm looking at implementing RFC 3161 (Time-Stamp Protocol) but need some guidance on defining this type:

PKIStatus ::= INTEGER {
   granted                (0),
   grantedWithMods        (1),
   rejection              (2),
   waiting                (3),
   revocationWarning      (4),
   revocationNotification (5) }

Is there a mechanism in asn1.js for defining an INTEGER type with identifiers as specified for this PKIStatus type?

toddwprice commented 8 years ago

I believe this is the correct method:

var PKIStatus = asn1.define('PKIStatus', function() {
  this.int({
    0: 'granted',
    1: 'grantedWithMods',
    2: 'rejection',
    3: 'waiting',
    4: 'revocationWarning',
    5: 'revocationNotification'
  });
});
indutny commented 8 years ago

Yep, it is! :)