UNPKG

3.21 kBJavaScriptView Raw
1try {
2 var asn1 = require('asn1.js');
3 var rfc3280 = require('asn1.js-rfc3280');
4} catch (e) {
5 var asn1 = require('../..');
6 var rfc3280 = require('../3280');
7}
8
9var OCSPResponse = asn1.define('OCSPResponse', function() {
10 this.seq().obj(
11 this.key('responseStatus').use(ResponseStatus),
12 this.key('responseBytes').optional().explicit(0).seq().obj(
13 this.key('responseType').objid({
14 '1 3 6 1 5 5 7 48 1 1': 'id-pkix-ocsp-basic'
15 }),
16 this.key('response').octstr()
17 )
18 );
19});
20exports.OCSPResponse = OCSPResponse;
21
22var ResponseStatus = asn1.define('ResponseStatus', function() {
23 this.enum({
24 0: 'successful',
25 1: 'malformed_request',
26 2: 'internal_error',
27 3: 'try_later',
28 5: 'sig_required',
29 6: 'unauthorized'
30 });
31});
32exports.ResponseStatus = ResponseStatus;
33
34var BasicOCSPResponse = asn1.define('BasicOCSPResponse', function() {
35 this.seq().obj(
36 this.key('tbsResponseData').use(ResponseData),
37 this.key('signatureAlgorithm').use(rfc3280.AlgorithmIdentifier),
38 this.key('signature').bitstr(),
39 this.key('certs').optional().explicit(0).seqof(rfc3280.Certificate)
40 );
41});
42exports.BasicOCSPResponse = BasicOCSPResponse;
43
44var ResponseData = asn1.define('ResponseData', function() {
45 this.seq().obj(
46 this.key('version').def('v1').explicit(0).use(rfc3280.Version),
47 this.key('responderID').use(ResponderID),
48 this.key('producedAt').gentime(),
49 this.key('responses').seqof(SingleResponse),
50 this.key('responseExtensions').optional().explicit(0)
51 .use(rfc3280.Extensions)
52 );
53});
54exports.ResponseData = ResponseData;
55
56var ResponderID = asn1.define('ResponderId', function() {
57 this.choice({
58 byName: this.explicit(1).use(rfc3280.Name),
59 byKey: this.explicit(2).use(KeyHash)
60 });
61});
62exports.ResponderID = ResponderID;
63
64var KeyHash = asn1.define('KeyHash', function() {
65 this.octstr();
66});
67exports.KeyHash = KeyHash;
68
69var SingleResponse = asn1.define('SingleResponse', function() {
70 this.seq().obj(
71 this.key('certId').use(CertID),
72 this.key('certStatus').use(CertStatus),
73 this.key('thisUpdate').gentime(),
74 this.key('nextUpdate').optional().explicit(0).gentime(),
75 this.key('singleExtensions').optional().explicit(1).use(Extensions)
76 );
77});
78exports.SingleResponse = SingleResponse;
79
80var CertStatus = asn1.define('CertStatus', function() {
81 this.choice({
82 good: this.implicit(0).null_(),
83 revoked: this.implicit(1).use(RevokedInfo),
84 unknown: this.implicit(2).null_()
85 });
86});
87exports.CertStatus = CertStatus;
88
89var RevokedInfo = asn1.define('RevokedInfo', function() {
90 this.seq().obj(
91 this.key('revocationTime').gentime(),
92 this.key('revocationReason').optional().explicit(0).use(rfc3280.CRLReason)
93 );
94});
95exports.RevokedInfo = RevokedInfo;
96
97var CertID = asn1.define('CertID', function() {
98 this.seq().obj(
99 this.key('hashAlgorithm').use(rfc3280.AlgorithmIdentifier),
100 this.key('issuerNameHash').octstr(),
101 this.key('issuerKeyHash').octstr(),
102 this.key('serialNumber').use(rfc3280.CertificateSerialNumber)
103 );
104});
105exports.CertID = CertID;
106
107var Extensions = asn1.define('Extensions', function() {
108 this.any();
109});
110exports.Extensions = Extensions;