Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80622 views
1
try {
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
9
var OCSPRequest = asn1.define('OCSPRequest', function() {
10
this.seq().obj(
11
this.key('tbsRequest').use(TBSRequest),
12
this.key('optionalSignature').optional().explicit(0).use(Signature)
13
);
14
});
15
exports.OCSPRequest = OCSPRequest;
16
17
var TBSRequest = asn1.define('TBSRequest', function() {
18
this.seq().obj(
19
this.key('version').def('v1').explicit(0).use(rfc3280.Version),
20
this.key('requestorName').optional().explicit(1).use(rfc3280.GeneralName),
21
this.key('requestList').seqof(Request),
22
this.key('requestExtensions').optional().explicit(2).use(rfc3280.Extensions)
23
);
24
});
25
exports.TBSRequest = TBSRequest;
26
27
var Signature = asn1.define('Signature', function() {
28
this.seq().obj(
29
this.key('signatureAlgorithm').use(rfc3280.AlgorithmIdentifier),
30
this.key('signature').bitstr(),
31
this.key('certs').optional().explicit(0).seqof(rfc3280.Certificate)
32
);
33
});
34
exports.Signature = Signature;
35
36
var Request = asn1.define('Request', function() {
37
this.seq().obj(
38
this.key('reqCert').use(CertID),
39
this.key('singleRequestExtensions').optional().explicit(0).use(
40
rfc3280.Extensions)
41
);
42
});
43
exports.Request = Request;
44
45
var OCSPResponse = asn1.define('OCSPResponse', function() {
46
this.seq().obj(
47
this.key('responseStatus').use(ResponseStatus),
48
this.key('responseBytes').optional().explicit(0).seq().obj(
49
this.key('responseType').objid({
50
'1 3 6 1 5 5 7 48 1 1': 'id-pkix-ocsp-basic'
51
}),
52
this.key('response').octstr()
53
)
54
);
55
});
56
exports.OCSPResponse = OCSPResponse;
57
58
var ResponseStatus = asn1.define('ResponseStatus', function() {
59
this.enum({
60
0: 'successful',
61
1: 'malformed_request',
62
2: 'internal_error',
63
3: 'try_later',
64
5: 'sig_required',
65
6: 'unauthorized'
66
});
67
});
68
exports.ResponseStatus = ResponseStatus;
69
70
var BasicOCSPResponse = asn1.define('BasicOCSPResponse', function() {
71
this.seq().obj(
72
this.key('tbsResponseData').use(ResponseData),
73
this.key('signatureAlgorithm').use(rfc3280.AlgorithmIdentifier),
74
this.key('signature').bitstr(),
75
this.key('certs').optional().explicit(0).seqof(rfc3280.Certificate)
76
);
77
});
78
exports.BasicOCSPResponse = BasicOCSPResponse;
79
80
var ResponseData = asn1.define('ResponseData', function() {
81
this.seq().obj(
82
this.key('version').def('v1').explicit(0).use(rfc3280.Version),
83
this.key('responderID').use(ResponderID),
84
this.key('producedAt').gentime(),
85
this.key('responses').seqof(SingleResponse),
86
this.key('responseExtensions').optional().explicit(0)
87
.use(rfc3280.Extensions)
88
);
89
});
90
exports.ResponseData = ResponseData;
91
92
var ResponderID = asn1.define('ResponderId', function() {
93
this.choice({
94
byName: this.explicit(1).use(rfc3280.Name),
95
byKey: this.explicit(2).use(KeyHash)
96
});
97
});
98
exports.ResponderID = ResponderID;
99
100
var KeyHash = asn1.define('KeyHash', function() {
101
this.octstr();
102
});
103
exports.KeyHash = KeyHash;
104
105
var SingleResponse = asn1.define('SingleResponse', function() {
106
this.seq().obj(
107
this.key('certId').use(CertID),
108
this.key('certStatus').use(CertStatus),
109
this.key('thisUpdate').gentime(),
110
this.key('nextUpdate').optional().explicit(0).gentime(),
111
this.key('singleExtensions').optional().explicit(1).use(rfc3280.Extensions)
112
);
113
});
114
exports.SingleResponse = SingleResponse;
115
116
var CertStatus = asn1.define('CertStatus', function() {
117
this.choice({
118
good: this.implicit(0).null_(),
119
revoked: this.implicit(1).use(RevokedInfo),
120
unknown: this.implicit(2).null_()
121
});
122
});
123
exports.CertStatus = CertStatus;
124
125
var RevokedInfo = asn1.define('RevokedInfo', function() {
126
this.seq().obj(
127
this.key('revocationTime').gentime(),
128
this.key('revocationReason').optional().explicit(0).use(rfc3280.CRLReason)
129
);
130
});
131
exports.RevokedInfo = RevokedInfo;
132
133
var CertID = asn1.define('CertID', function() {
134
this.seq().obj(
135
this.key('hashAlgorithm').use(rfc3280.AlgorithmIdentifier),
136
this.key('issuerNameHash').octstr(),
137
this.key('issuerKeyHash').octstr(),
138
this.key('serialNumber').use(rfc3280.CertificateSerialNumber)
139
);
140
});
141
exports.CertID = CertID;
142
143
var Nonce = asn1.define('Nonce', function() {
144
this.octstr();
145
});
146
exports.Nonce = Nonce;
147
148
exports['id-pkix-ocsp'] = [ 1, 3, 6, 1, 5, 5, 7, 48, 1 ];
149
exports['id-pkix-ocsp-nonce'] = [ 1, 3, 6, 1, 5, 5, 7, 48, 1, 2 ];
150
151