# Code coverage report for parseASN1/asn1.js

## Statements: 85.11% (40 / 47) Branches: 100% (0 / 0) Functions: 58.82% (10 / 17) Lines: 85.11% (40 / 47) Ignored: none

All files » parseASN1/ » asn1.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180

    1

    1
    1

    1

    1
    1

    1

    1
    1

    1
    1

    1
    1

    1

    1
    1

    1
    1

    1
    1
    1

    1

    1
    1

    1
    1

    1
    1
    1

    1

    1
    1

    1
    1

    1
    1
    1

    1

    1

    1

     // from https://github.com/indutny/self-signed/blob/gh-pages/lib/asn1.js
    // Fedor, you are amazing.

    var asn1 = require('asn1.js');

    var RSAPrivateKey = asn1.define('RSAPrivateKey', function() {
      this.seq().obj(
        this.key('version').int(),
        this.key('modulus').int(),
        this.key('publicExponent').int(),
        this.key('privateExponent').int(),
        this.key('prime1').int(),
        this.key('prime2').int(),
        this.key('exponent1').int(),
        this.key('exponent2').int(),
        this.key('coefficient').int()
      );
    });
    exports.RSAPrivateKey = RSAPrivateKey;

    var RSAPublicKey = asn1.define('RSAPublicKey', function() {
      this.seq().obj(
        this.key('modulus').int(),
        this.key('publicExponent').int()
      );
    });
    exports.RSAPublicKey = RSAPublicKey;

    var PublicKey = asn1.define('SubjectPublicKeyInfo', function() {
      this.seq().obj(
        this.key('algorithm').use(AlgorithmIdentifier),
        this.key('subjectPublicKey').bitstr()
      );
    });
    exports.PublicKey = PublicKey;
    var ECPublicKey =  asn1.define('ECPublicKey', function() {
      this.seq().obj(
        this.key('algorithm').seq().obj(
          this.key('id').objid(),
          this.key('curve').objid()
        ),
        this.key('subjectPrivateKey').bitstr()
      );
    });
    exports.ECPublicKey = ECPublicKey;
    var ECPrivateWrap =  asn1.define('ECPrivateWrap', function() {
      this.seq().obj(
        this.key('version').int(),
        this.key('algorithm').seq().obj(
          this.key('id').objid(),
          this.key('curve').objid()
        ),
        this.key('subjectPrivateKey').octstr()
      );
    });
    exports.ECPrivateWrap = ECPrivateWrap;

    var AlgorithmIdentifier = asn1.define('AlgorithmIdentifier', function() {
      this.seq().obj(
        this.key('algorithm').objid(),
        this.key('none').null_().optional(),
        this.key('curve').objid().optional(),
        this.key('params').seq().obj(
            this.key('p').int(),
            this.key('q').int(),
            this.key('g').int()
          ).optional()
      );
    });

    var PrivateKeyInfo = asn1.define('PrivateKeyInfo', function() {
      this.seq().obj(
        this.key('version').int(),
        this.key('algorithm').use(AlgorithmIdentifier),
        this.key('subjectPrivateKey').octstr()
      );
    });
    exports.PrivateKey = PrivateKeyInfo;
    var EncryptedPrivateKeyInfo = asn1.define('EncryptedPrivateKeyInfo', function() {
      this.seq().obj(
        this.key('algorithm').seq().obj(
          this.key('id').objid(),
          this.key('decrypt').seq().obj(
            this.key('kde').seq().obj(
              this.key('id').objid(),
              this.key('kdeparams').seq().obj(
                this.key('salt').octstr(),
                this.key('iters').int()
              )
            ),
            this.key('cipher').seq().obj(
              this.key('algo').objid(),
              this.key('iv').octstr()
            )
          )
        ),
        this.key('subjectPrivateKey').octstr()
      );
    });
    var dsaParams = asn1.define('dsaParams', function() {
      this.seq().obj(
        this.key('algorithm').objid(),
        this.key('parameters').seq().obj(
            this.key('p').int(),
            this.key('q').int(),
            this.key('g').int()
          )
      );
    });
    exports.EncryptedPrivateKey = EncryptedPrivateKeyInfo;
    var DSAPublicKey = asn1.define('DSAPublicKey', function() {
      this.seq().obj(
        this.key('algorithm').use(dsaParams),
        this.key('subjectPublicKey').bitstr()
      );
    });
    exports.DSAPublicKey = DSAPublicKey;
    var DSAPrivateWrap =  asn1.define('DSAPrivateWrap', function() {
      this.seq().obj(
        this.key('version').int(),
        this.key('algorithm').seq().obj(
          this.key('id').objid(),
          this.key('parameters').seq().obj(
            this.key('p').int(),
            this.key('q').int(),
            this.key('g').int()
          )
        ),
        this.key('subjectPrivateKey').octstr()
      );
    });
    exports.DSAPrivateWrap = DSAPrivateWrap;
    var DSAPrivateKey = asn1.define('DSAPrivateKey', function() {
      this.seq().obj(
        this.key('version').int(),
        this.key('p').int(),
        this.key('q').int(),
        this.key('g').int(),
        this.key('pub_key').int(),
        this.key('priv_key').int()
      );
    });
    exports.DSAPrivateKey = DSAPrivateKey;

    exports.DSAparam = asn1.define('DSAparam', function () {
      this.int();
    });
    var ECPrivateKey = asn1.define('ECPrivateKey', function() {
      this.seq().obj(
        this.key('version').int(),
        this.key('privateKey').octstr(),
        this.key('parameters').optional().explicit(0).use(ECParameters),
        this.key('publicKey').optional().explicit(1).bitstr()
      );
    });
    exports.ECPrivateKey = ECPrivateKey;
    var ECParameters = asn1.define('ECParameters', function() {
      this.choice({
        namedCurve: this.objid()
      });
    });

    var ECPrivateKey2 = asn1.define('ECPrivateKey2', function() {
      this.seq().obj(
        this.key('version').int(),
        this.key('privateKey').octstr(),
        this.key('publicKey').seq().obj(
          this.key('key').bitstr()
        )
      );
    });
    exports.ECPrivateKey2 = ECPrivateKey2;

    exports.signature = asn1.define('signature', function() {
      this.seq().obj(
        this.key('r').int(),
        this.key('s').int()
      );
    });