Skip to content

Commit 6541fe3

Browse files
committed
chore: wip
1 parent b94fcc9 commit 6541fe3

4 files changed

Lines changed: 119 additions & 53 deletions

File tree

src/asn1-validator.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44

55
import { asn1 } from './asn1'
66

7-
export const privateKeyValidator = {
7+
export interface Asn1Validator {
8+
name: string
9+
tagClass: asn1.Class
10+
type: asn1.Type
11+
constructed: boolean
12+
value: Asn1Validator[]
13+
}
14+
15+
export const privateKeyValidator: Asn1Validator = {
816
// PrivateKeyInfo
917
name: 'PrivateKeyInfo',
1018
tagClass: asn1.Class.UNIVERSAL,
@@ -40,7 +48,7 @@ export const privateKeyValidator = {
4048
}],
4149
}
4250

43-
exports.publicKeyValidator = {
51+
export const publicKeyValidator: Asn1Validator = {
4452
name: 'SubjectPublicKeyInfo',
4553
tagClass: asn1.Class.UNIVERSAL,
4654
type: asn1.Type.SEQUENCE,
@@ -66,5 +74,12 @@ exports.publicKeyValidator = {
6674
constructed: false,
6775
composed: true,
6876
captureBitStringValue: 'ed25519PublicKey',
69-
}, // FIXME: this is capture group for rsaPublicKey, use it in this API or // discard? /* { // subjectPublicKey name: 'SubjectPublicKeyInfo.subjectPublicKey', tagClass: asn1.Class.UNIVERSAL, type: asn1.Type.BITSTRING, constructed: false, value: [{ // RSAPublicKey name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey', tagClass: asn1.Class.UNIVERSAL, type: asn1.Type.SEQUENCE, constructed: true, optional: true, captureAsn1: 'rsaPublicKey' }] } */ ],
77+
}, // FIXME: this is capture group for rsaPublicKey, use it in this API or // discard? /* { // subjectPublicKey name: 'SubjectPublicKeyInfo.subjectPublicKey', tagClass: asn1.Class.UNIVERSAL, type: asn1.Type.BITSTRING, constructed: false, value: [{ // RSAPublicKey name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey', tagClass: asn1.Class.UNIVERSAL, type: asn1.Type.SEQUENCE, constructed: true, optional: true, captureAsn1: 'rsaPublicKey' }] } */
78+
]}
79+
80+
const asn1Validator: Asn1Validator = {
81+
privateKeyValidator,
82+
publicKeyValidator,
7083
}
84+
85+
export default asn1Validator

0 commit comments

Comments
 (0)