# Code coverage report for parseASN1/EVP_BytesToKey.js

## Statements: 100% (29 / 29) Branches: 90% (9 / 10) Functions: 100% (1 / 1) Lines: 100% (29 / 29) Ignored: none

All files » parseASN1/ » EVP_BytesToKey.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
    1
    3
    3
    3
    3
    3
    3
    3
    3
    5
    5
    2

    5
    5
    5
    5
    5
    5
    77
    3

    74
    2

    72
    72

    5
    3

    3
    48

    3

    module.exports = function evp(crypto, password, salt, keyLen) {
      keyLen = keyLen/8;
      var ki = 0;
      var ii = 0;
      var key = new Buffer(keyLen);
      var addmd = 0;
      var md, md_buf;
      var i;
      while (true) {
        md = crypto.createHash('md5');
        if(addmd++ > 0) {
           md.update(md_buf);
        }
        md.update(password);
        md.update(salt);
        md_buf = md.digest();
        i = 0;
        Eif(keyLen > 0) {
          while(true) {
            if(keyLen === 0) {
              break;
            }
            if(i === md_buf.length) {
              break;
            }
            key[ki++] = md_buf[i++];
            keyLen--;
           }
        }
       if(keyLen === 0) {
          break;
        }
      }
      for(i=0;i<md_buf.length;i++) {
        md_buf[i] = 0;
      }
      return key;
    };