code: function passphraseToKey(type, passphrase, salt)
    {
    debug('passphraseToKey', type, passphrase, salt);
    var nkey = keyBytes[type];
  
    if (!nkey)
      {
      var allowed = Object.keys(keyBytes);
      throw new TypeError('Unsupported type. Allowed: ' + allowed);
      }
  
    var niv = salt.length;
    var saltLen = 8;
    if (salt.length !== saltLen)
      salt = salt.slice(0, saltLen);
    var mds = 16;
    var addmd = false;
    var md_buf;
    var key = new Buffer(nkey);
    var keyidx = 0;
  
    while (true)
      {
      debug('loop nkey=%d mds=%d', nkey, mds);
      var c = crypto.createHash('md5');
  
      if (addmd)
        c.update(md_buf);
      else
        addmd = true;
  
      if (!Buffer.isBuffer(passphrase))
        c.update(passphrase, 'ascii');
      else
        c.update(passphrase);
  
      c.update(salt);
      md_buf = c.digest('buffer');
  
      var i = 0;
      while (nkey && i < mds)
        {
        key[keyidx++] = md_buf[i];
        nkey--;
        i++;
        }
  
      var steps = Math.min(niv, mds - i);
      niv -= steps;
      i += steps;
  
      if ((nkey == 0) && (niv == 0)) break;
      }
  
    return key
    }
docs: port of EVP_BytesToKey, as used when decrypting PEM keys