1 | /**
|
---|
2 | * Copyright (c) 2019 Digital Bazaar, Inc.
|
---|
3 | */
|
---|
4 |
|
---|
5 | var forge = require('./forge');
|
---|
6 | require('./asn1');
|
---|
7 | var asn1 = forge.asn1;
|
---|
8 |
|
---|
9 | exports.privateKeyValidator = {
|
---|
10 | // PrivateKeyInfo
|
---|
11 | name: 'PrivateKeyInfo',
|
---|
12 | tagClass: asn1.Class.UNIVERSAL,
|
---|
13 | type: asn1.Type.SEQUENCE,
|
---|
14 | constructed: true,
|
---|
15 | value: [{
|
---|
16 | // Version (INTEGER)
|
---|
17 | name: 'PrivateKeyInfo.version',
|
---|
18 | tagClass: asn1.Class.UNIVERSAL,
|
---|
19 | type: asn1.Type.INTEGER,
|
---|
20 | constructed: false,
|
---|
21 | capture: 'privateKeyVersion'
|
---|
22 | }, {
|
---|
23 | // privateKeyAlgorithm
|
---|
24 | name: 'PrivateKeyInfo.privateKeyAlgorithm',
|
---|
25 | tagClass: asn1.Class.UNIVERSAL,
|
---|
26 | type: asn1.Type.SEQUENCE,
|
---|
27 | constructed: true,
|
---|
28 | value: [{
|
---|
29 | name: 'AlgorithmIdentifier.algorithm',
|
---|
30 | tagClass: asn1.Class.UNIVERSAL,
|
---|
31 | type: asn1.Type.OID,
|
---|
32 | constructed: false,
|
---|
33 | capture: 'privateKeyOid'
|
---|
34 | }]
|
---|
35 | }, {
|
---|
36 | // PrivateKey
|
---|
37 | name: 'PrivateKeyInfo',
|
---|
38 | tagClass: asn1.Class.UNIVERSAL,
|
---|
39 | type: asn1.Type.OCTETSTRING,
|
---|
40 | constructed: false,
|
---|
41 | capture: 'privateKey'
|
---|
42 | }]
|
---|
43 | };
|
---|
44 |
|
---|
45 | exports.publicKeyValidator = {
|
---|
46 | name: 'SubjectPublicKeyInfo',
|
---|
47 | tagClass: asn1.Class.UNIVERSAL,
|
---|
48 | type: asn1.Type.SEQUENCE,
|
---|
49 | constructed: true,
|
---|
50 | captureAsn1: 'subjectPublicKeyInfo',
|
---|
51 | value: [{
|
---|
52 | name: 'SubjectPublicKeyInfo.AlgorithmIdentifier',
|
---|
53 | tagClass: asn1.Class.UNIVERSAL,
|
---|
54 | type: asn1.Type.SEQUENCE,
|
---|
55 | constructed: true,
|
---|
56 | value: [{
|
---|
57 | name: 'AlgorithmIdentifier.algorithm',
|
---|
58 | tagClass: asn1.Class.UNIVERSAL,
|
---|
59 | type: asn1.Type.OID,
|
---|
60 | constructed: false,
|
---|
61 | capture: 'publicKeyOid'
|
---|
62 | }]
|
---|
63 | },
|
---|
64 | // capture group for ed25519PublicKey
|
---|
65 | {
|
---|
66 | tagClass: asn1.Class.UNIVERSAL,
|
---|
67 | type: asn1.Type.BITSTRING,
|
---|
68 | constructed: false,
|
---|
69 | composed: true,
|
---|
70 | captureBitStringValue: 'ed25519PublicKey'
|
---|
71 | }
|
---|
72 | // FIXME: this is capture group for rsaPublicKey, use it in this API or
|
---|
73 | // discard?
|
---|
74 | /* {
|
---|
75 | // subjectPublicKey
|
---|
76 | name: 'SubjectPublicKeyInfo.subjectPublicKey',
|
---|
77 | tagClass: asn1.Class.UNIVERSAL,
|
---|
78 | type: asn1.Type.BITSTRING,
|
---|
79 | constructed: false,
|
---|
80 | value: [{
|
---|
81 | // RSAPublicKey
|
---|
82 | name: 'SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey',
|
---|
83 | tagClass: asn1.Class.UNIVERSAL,
|
---|
84 | type: asn1.Type.SEQUENCE,
|
---|
85 | constructed: true,
|
---|
86 | optional: true,
|
---|
87 | captureAsn1: 'rsaPublicKey'
|
---|
88 | }]
|
---|
89 | } */
|
---|
90 | ]
|
---|
91 | };
|
---|