pax_global_header 0000666 0000000 0000000 00000000064 15025343214 0014511 g ustar 00root root 0000000 0000000 52 comment=3e40827b183f7f5a14946bdb7d57de3d1d8dd581
pbkdf2-3.1.3/ 0000775 0000000 0000000 00000000000 15025343214 0012665 5 ustar 00root root 0000000 0000000 pbkdf2-3.1.3/.eslintrc 0000664 0000000 0000000 00000001516 15025343214 0014514 0 ustar 00root root 0000000 0000000 {
"root": true,
"extends": "@ljharb",
"globals": {
"Uint8Array": "readonly",
"Uint16Array": "readonly",
"Uint32Array": "readonly",
"Int8Array": "readonly",
"Int16Array": "readonly",
"Int32Array": "readonly",
"Float32Array": "readonly",
"Float64Array": "readonly",
"BigInt64Array": "readonly",
"BigUint64Array": "readonly",
},
"rules": {
"func-style": "warn",
"max-params": "warn",
"multiline-comment-style": "off",
"no-param-reassign": "warn",
"sort-keys": "warn",
},
"ignorePatterns": [
"test/bundle.js",
],
"overrides": [
{
"files": "bench/*",
"extends": "@ljharb/eslint-config/node/4",
"rules": {
"func-style": "warn",
"max-params": "warn",
"no-param-reassign": "warn",
"no-var": "off",
"prefer-arrow-callback": "off",
"prefer-template": "off",
},
},
],
}
pbkdf2-3.1.3/.github/ 0000775 0000000 0000000 00000000000 15025343214 0014225 5 ustar 00root root 0000000 0000000 pbkdf2-3.1.3/.github/FUNDING.yml 0000664 0000000 0000000 00000001101 15025343214 0016033 0 ustar 00root root 0000000 0000000 # These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/pbkdf2
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
pbkdf2-3.1.3/.github/workflows/ 0000775 0000000 0000000 00000000000 15025343214 0016262 5 ustar 00root root 0000000 0000000 pbkdf2-3.1.3/.github/workflows/node-aught.yml 0000664 0000000 0000000 00000000504 15025343214 0021037 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js < 10'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 0.12 < 10'
type: minors
command: npm run tests-only
node:
name: 'node < 10'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
pbkdf2-3.1.3/.github/workflows/node-pretest.yml 0000664 0000000 0000000 00000000206 15025343214 0021414 0 ustar 00root root 0000000 0000000 name: 'Tests: pretest/posttest'
on: [pull_request, push]
jobs:
tests:
uses: ljharb/actions/.github/workflows/pretest.yml@main
pbkdf2-3.1.3/.github/workflows/node-tens.yml 0000664 0000000 0000000 00000000547 15025343214 0020707 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js 10 - 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 10 < 20'
type: minors
command: npm run tests-only
node:
name: 'node 10 - 20'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
pbkdf2-3.1.3/.github/workflows/node-twenties.yml 0000664 0000000 0000000 00000000536 15025343214 0021576 0 ustar 00root root 0000000 0000000 name: 'Tests: node.js >= 20'
on: [pull_request, push]
permissions:
contents: read
jobs:
tests:
uses: ljharb/actions/.github/workflows/node.yml@main
with:
range: '>= 20'
type: minors
command: npm run tests-only
node:
name: 'node >= 20'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true
pbkdf2-3.1.3/.github/workflows/rebase.yml 0000664 0000000 0000000 00000000257 15025343214 0020252 0 ustar 00root root 0000000 0000000 name: Automatic Rebase
on: [pull_request_target]
jobs:
_:
uses: ljharb/actions/.github/workflows/rebase.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
pbkdf2-3.1.3/.github/workflows/require-allow-edits.yml 0000664 0000000 0000000 00000000303 15025343214 0022677 0 ustar 00root root 0000000 0000000 name: Require “Allow Edits”
on: [pull_request_target]
jobs:
_:
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- uses: ljharb/require-allow-edits@main
pbkdf2-3.1.3/.gitignore 0000664 0000000 0000000 00000001243 15025343214 0014655 0 ustar 00root root 0000000 0000000 # Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules
# build artifact
test/bundle.js
.nyc_output
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
.npmignore
pbkdf2-3.1.3/.npmrc 0000664 0000000 0000000 00000000067 15025343214 0014010 0 ustar 00root root 0000000 0000000 package-lock=false
allow-same-version=true
message=v%s
pbkdf2-3.1.3/.nycrc 0000664 0000000 0000000 00000000226 15025343214 0014004 0 ustar 00root root 0000000 0000000 {
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"exclude": [
"bench",
"coverage",
"test"
]
}
pbkdf2-3.1.3/CHANGELOG.md 0000664 0000000 0000000 00000056601 15025343214 0014506 0 ustar 00root root 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.1.3](https://github.com/browserify/pbkdf2/compare/v3.1.2...v3.1.3) - 2025-06-20
### Commits
- Only apps should have lockfiles [`8b06730`](https://github.com/browserify/pbkdf2/commit/8b067308eedcc3b7da3e06202d437ff532de75bd)
- [lint] fix whitespace [`9a76e2f`](https://github.com/browserify/pbkdf2/commit/9a76e2f37ef4541aeff92d97b7335b7fa6e989a8)
- [lint] fix parens/curlies/semis/etc [`6fd84bf`](https://github.com/browserify/pbkdf2/commit/6fd84bf64a423d207d9e665f3e9fd88b148c4480)
- [meta] add `auto-changelog` [`796c38d`](https://github.com/browserify/pbkdf2/commit/796c38d428ed9546e7ddfbb38322faa99921d716)
- [Tests] fix tests in node 17 [`3661fb0`](https://github.com/browserify/pbkdf2/commit/3661fb0156177bfe380c7bcc133917e7ee501bc7)
- Revert "[Tests] fix tests in node < 3" [`7431b57`](https://github.com/browserify/pbkdf2/commit/7431b5766805cbf880c1b3d0f38d484357844ff7)
- [Tests] fix tests in node < 3 [`eb9f97a`](https://github.com/browserify/pbkdf2/commit/eb9f97a66ed83836bebc4ff563a1588248708501)
- [Fix] ensure unknown algorithms throw + known ones match node [`26d4fd3`](https://github.com/browserify/pbkdf2/commit/26d4fd391e00ed806840ea1ef7341937985f4ba8)
- [Tests] add GHA, always run nyc [`513906a`](https://github.com/browserify/pbkdf2/commit/513906a735e80a0e125e1a3363c5dbe90bb34bb7)
- [lint] fix a few more rules [`ab04da8`](https://github.com/browserify/pbkdf2/commit/ab04da834a0342cb3779486314fa67ebc1e3f035)
- [lint] switch to eslint [`89694cf`](https://github.com/browserify/pbkdf2/commit/89694cf7e4062a8c924fbe74ad2b2d3cf78f1715)
- [Tests] add coverage [`d0d534b`](https://github.com/browserify/pbkdf2/commit/d0d534bfdc4db6d6ea9f719606ad18a78db6c124)
- [Refactor] use `to-buffer` [`e3102a8`](https://github.com/browserify/pbkdf2/commit/e3102a8cd4830a3ac85cd0dd011cc002fdde33bb)
- [readme] improve badges [`fca0c9d`](https://github.com/browserify/pbkdf2/commit/fca0c9d4c5b053d911315a3607367d1db9f9f605)
- [Tests] remove unused travis file [`a2c7d93`](https://github.com/browserify/pbkdf2/commit/a2c7d93bbcad73c49dad0c18fef6b8a4af8c3310)
- [meta] switch from `files` to `npmignore` [`7f31fbc`](https://github.com/browserify/pbkdf2/commit/7f31fbca528fa5af3b7d3910daf09a7e5ed8adb4)
- [Tests] use .nycrc [`8d628e8`](https://github.com/browserify/pbkdf2/commit/8d628e8d5559b4acd4d4a714afb04a2990f901b7)
- [Refactor] minor tweaks [`fc61005`](https://github.com/browserify/pbkdf2/commit/fc61005c8cbd480e24ee103ac39a45f0d90ac636)
- [Deps] update `create-hmac`, `safe-buffer`, `sha.js` [`ae2a7d0`](https://github.com/browserify/pbkdf2/commit/ae2a7d051c9133c25d5212ba4f46747c0ed4c190)
- [Fix] pin `create-hash`, `ripemd160` due to breaking changes [`e079968`](https://github.com/browserify/pbkdf2/commit/e07996890af79296f1913431fb3b252e25df2f0e)
- [Tests] fix tests in node 3 [`45fbcf3`](https://github.com/browserify/pbkdf2/commit/45fbcf30431f9585ae3b61f2207c0a16c1953915)
- [meta] skip publishing benchmarks [`19ea57b`](https://github.com/browserify/pbkdf2/commit/19ea57bf11d055ddcd97d2556cd3097663b050b9)
- [Dev Deps] add missing peer dep [`645e252`](https://github.com/browserify/pbkdf2/commit/645e252375087e97beb95e518038b99eb5724c5b)
## [v3.1.2](https://github.com/browserify/pbkdf2/compare/v3.1.1...v3.1.2) - 2021-04-09
### Commits
- handle nextTick [`36457b9`](https://github.com/browserify/pbkdf2/commit/36457b9fecfd1e128c8e9884a57e277649679832)
- Check for process before accessing [`449e510`](https://github.com/browserify/pbkdf2/commit/449e510f861f56ed673613d8102f6b1a3e680ced)
- handle different returns [`fb82137`](https://github.com/browserify/pbkdf2/commit/fb82137ecefb56b5e93b70686e0dc0b4bb591b7c)
## [v3.1.1](https://github.com/browserify/pbkdf2/compare/v3.1.0...v3.1.1) - 2020-06-04
### Commits
- style nit [`6d994f2`](https://github.com/browserify/pbkdf2/commit/6d994f2e71934c26f96791bde440e86d9d93ff2b)
- remove arrow [`70ea270`](https://github.com/browserify/pbkdf2/commit/70ea2709b761b8fbb0551f4411feb52efb9c8690)
## [v3.1.0](https://github.com/browserify/pbkdf2/compare/v3.0.17...v3.1.0) - 2020-06-03
### Merged
- check if process.version is available [`#85`](https://github.com/browserify/pbkdf2/pull/85)
### Commits
- fix style [`1674cbd`](https://github.com/browserify/pbkdf2/commit/1674cbdb359ae166e6c99733e0af40e92ebb3cd4)
- add support for all ArrayBuffers [`b888820`](https://github.com/browserify/pbkdf2/commit/b88882005853ad5d8ecbc00a56e101c336b5ea04)
- Build type check into toBuffer [`0b77ea9`](https://github.com/browserify/pbkdf2/commit/0b77ea96191a374fa6774ebaa4fe89be86c3d1af)
- fix fixtures [`6af65e7`](https://github.com/browserify/pbkdf2/commit/6af65e797f5c0738fd9f4e9dfa9b00ae0885f5d7)
- Add tests for Uint8Array [`bca4182`](https://github.com/browserify/pbkdf2/commit/bca4182a30ce5d73ed527fa254c6d3a62e07e8f8)
- fix encodings [`b1c669b`](https://github.com/browserify/pbkdf2/commit/b1c669b6dfa9a0f82cecdec7bd4a14a042d9a070)
- minor fixes for Uint8Array support [`f61abc7`](https://github.com/browserify/pbkdf2/commit/f61abc7596d40540d5d759bc583044082c52badc)
- fix tests [`ab62504`](https://github.com/browserify/pbkdf2/commit/ab6250458dac29f4f9d7144e903e18726bed8535)
- Add Uint8Array support [`3fbb793`](https://github.com/browserify/pbkdf2/commit/3fbb7935e2aa810a5ed861ef32c44092fb3fafbb)
- adjust node versions [`a572cbc`](https://github.com/browserify/pbkdf2/commit/a572cbc655a1cc626ae72ccf8bb29f25418d394e)
- update travis [`4a4deed`](https://github.com/browserify/pbkdf2/commit/4a4deed4d115d55a698cf1292abef4f38cdbe922)
- fix standard typo (that was not caught locally for some reason) [`47c59ad`](https://github.com/browserify/pbkdf2/commit/47c59ad879f5fcce529a69ed902ca9b664813020)
## [v3.0.17](https://github.com/browserify/pbkdf2/compare/v3.0.16...v3.0.17) - 2018-09-25
### Commits
- Add ripemd160 test [`9da9d9c`](https://github.com/browserify/pbkdf2/commit/9da9d9c4f426237e72b8f189ae14e3e473c84c69)
- Do not inline rmd160Func [`b498c9b`](https://github.com/browserify/pbkdf2/commit/b498c9b779c40823fc504764c9a333fd44c79f31)
- Fix RIPEMD160 support [`68729a6`](https://github.com/browserify/pbkdf2/commit/68729a6b54e1438e1960931fd6aa3bb343fcc173)
## [v3.0.16](https://github.com/browserify/pbkdf2/compare/v3.0.15...v3.0.16) - 2018-04-20
### Merged
- default to SHA1 for native [`#76`](https://github.com/browserify/pbkdf2/pull/76)
### Commits
- fix standard indentation [`740d93e`](https://github.com/browserify/pbkdf2/commit/740d93e2f5798bc66d32d3a648ec2d96f7254c12)
- tests: fix JS/sync tests not being run [`1416637`](https://github.com/browserify/pbkdf2/commit/1416637d82848494bd427a38643a58795213191f)
- increase sync.js internal coverage [`4e07660`](https://github.com/browserify/pbkdf2/commit/4e076601b82e518cac6179ea62cc4f3c4553e43b)
- travis: add 8 and 9 [`d82c51b`](https://github.com/browserify/pbkdf2/commit/d82c51bb04897f099512b3add9f892a36a71cedc)
## [v3.0.15](https://github.com/browserify/pbkdf2/compare/v3.0.14...v3.0.15) - 2018-04-01
### Merged
- Throw if password / salt is not a buffer or string [`#77`](https://github.com/browserify/pbkdf2/pull/77)
- Update README.md for async recommendation [`#75`](https://github.com/browserify/pbkdf2/pull/75)
### Commits
- throw if password / salt is not a buffer or string [`2410eb0`](https://github.com/browserify/pbkdf2/commit/2410eb0ee1f41da47d1ba2e53411b489d88838ce)
- typos [`9dae437`](https://github.com/browserify/pbkdf2/commit/9dae437df90f5940eb332a5c6f86f78309f79f06)
- Update README.md [`ad85843`](https://github.com/browserify/pbkdf2/commit/ad8584337742d4cf83d9244a73abce2a7af90ff2)
## [v3.0.14](https://github.com/browserify/pbkdf2/compare/v3.0.13...v3.0.14) - 2017-09-08
### Merged
- use the local implementations if crypto.bpkdf2Sync [`#72`](https://github.com/browserify/pbkdf2/pull/72)
### Commits
- use the local implementations if *either* crypto.bpkdf2Sync doesn't exist OR it doesn't contain the marker string [`9132b7a`](https://github.com/browserify/pbkdf2/commit/9132b7a81540a5743ece086bea87ada10028e05f)
## [v3.0.13](https://github.com/browserify/pbkdf2/compare/v3.0.12...v3.0.13) - 2017-08-02
### Merged
- fail better when node version loaded in browser [`#71`](https://github.com/browserify/pbkdf2/pull/71)
- remove unnecessary r, T values [`#68`](https://github.com/browserify/pbkdf2/pull/68)
### Commits
- tests: add dkLen < and > [`c3d2998`](https://github.com/browserify/pbkdf2/commit/c3d29981a600cd30fa57849ce12bf95d45bb4b8f)
- align definitions with assignment, formatting [`5c50528`](https://github.com/browserify/pbkdf2/commit/5c5052859b7ea4dba9484ce4ad0c1edfb507790b)
- lib/sync*: avoid inner-loop T copy [`74b80d3`](https://github.com/browserify/pbkdf2/commit/74b80d32640d1c90a4a6a90d99784dadc9d2d880)
- sync: align definitions with assignment [`c818cf1`](https://github.com/browserify/pbkdf2/commit/c818cf1bf6b7c23278ebd8196ebddc6b54c92c8c)
- remove unused r variable [`9e0d168`](https://github.com/browserify/pbkdf2/commit/9e0d1684abca98e08a1334b0ead141ebf6c91806)
- travis: drop 0.12 [`0985c3e`](https://github.com/browserify/pbkdf2/commit/0985c3e03cb4392a5f931c4a62869257f3feaeba)
- sync-browser: consistent exports [`90ac748`](https://github.com/browserify/pbkdf2/commit/90ac7488016ad97023d3b42795dc1da00b310490)
- just remove microtime [`0fa9638`](https://github.com/browserify/pbkdf2/commit/0fa9638dad5384d7afb8943c1e22d2e4a16957d4)
- standard --fix [`8281fc6`](https://github.com/browserify/pbkdf2/commit/8281fc64b281bacab50f4b735aa768474eaaadcd)
## [v3.0.12](https://github.com/browserify/pbkdf2/compare/v3.0.11...v3.0.12) - 2017-05-11
### Merged
- fix #60 - use browser.js in the browser, instead of index.js; include lib folder in the published package [`#62`](https://github.com/browserify/pbkdf2/pull/62)
### Fixed
- fix #60 - use browser.js in the browser, instead of index.js; include lib folder in the published package (#62) [`#60`](https://github.com/browserify/pbkdf2/issues/60)
### Commits
- switch to optional dep #63, 65 [`7d246e9`](https://github.com/browserify/pbkdf2/commit/7d246e91bbdaedbb55fa0c323306cbcc58d9ec73)
## [v3.0.11](https://github.com/browserify/pbkdf2/compare/v3.0.10...v3.0.11) - 2017-05-11
### Commits
- update files [`3313867`](https://github.com/browserify/pbkdf2/commit/3313867fd5dd5fcce716b4c195556f5c329cbdd5)
## [v3.0.10](https://github.com/browserify/pbkdf2/compare/v3.0.9...v3.0.10) - 2017-05-11
### Merged
- node for the node, js for the browser [`#59`](https://github.com/browserify/pbkdf2/pull/59)
- real optimizations [`#57`](https://github.com/browserify/pbkdf2/pull/57)
- benchmark [`#56`](https://github.com/browserify/pbkdf2/pull/56)
- do our own hmacing [`#54`](https://github.com/browserify/pbkdf2/pull/54)
### Commits
- use native crypto when available [`cdaf5c0`](https://github.com/browserify/pbkdf2/commit/cdaf5c0da8502c47a40d2b2caaafb497836e3b42)
- actually add bench [`fa2e0a1`](https://github.com/browserify/pbkdf2/commit/fa2e0a106adf8f2b2529bb9912f16d07f061cb17)
- passing tests [`216a6a7`](https://github.com/browserify/pbkdf2/commit/216a6a7d137ba5a363d1be9c3a7a42d47398429e)
- hmac ourselves [`9699045`](https://github.com/browserify/pbkdf2/commit/9699045c37a07f8319cfb8d44e2ff4252d7a7078)
- use hashes directly [`89e0e80`](https://github.com/browserify/pbkdf2/commit/89e0e80dbce67e16b8946deb38dc755aeea78222)
- correctly test both [`fb56873`](https://github.com/browserify/pbkdf2/commit/fb56873fa885059a8c17410eba0b544e5932cd28)
- avoid Buffer.concat [`96518aa`](https://github.com/browserify/pbkdf2/commit/96518aac66af803a0040e3bd1ca48b2828f38881)
- formatting [`dd3467c`](https://github.com/browserify/pbkdf2/commit/dd3467c75abd0136fc93f2acdbf1df94af10924f)
- some fixes [`15b2cbf`](https://github.com/browserify/pbkdf2/commit/15b2cbfd9c3575593fc147dbd170e23c293a6f12)
- cleanup [`fec6652`](https://github.com/browserify/pbkdf2/commit/fec66520e38de3b2fccaf924dd61807bf500ad36)
- formating [`dc2e15a`](https://github.com/browserify/pbkdf2/commit/dc2e15aa0f25b091a94fd575eb0edbd41c2300b0)
- fix coverage [`ae3f2a5`](https://github.com/browserify/pbkdf2/commit/ae3f2a5d0b475d0f4fb5a38b7ce6c9206a4a0c9b)
- move stuff around [`52c3960`](https://github.com/browserify/pbkdf2/commit/52c3960b217a9933e8ef8a833b9a60141ddbd70a)
- 100% [`ef38b2b`](https://github.com/browserify/pbkdf2/commit/ef38b2b9bb02bb4167689ab8955a0b323c03d644)
- trailing space [`03832fb`](https://github.com/browserify/pbkdf2/commit/03832fbdd47fb354329bdbb51c463ed60033e2ea)
- reduce coverage [`2f720b4`](https://github.com/browserify/pbkdf2/commit/2f720b4b4d3441f743d1637a479cda596c39b4a9)
- switch to optional dep [`8423738`](https://github.com/browserify/pbkdf2/commit/8423738759f67929760c828cadd88c5867d4e5f2)
- fix style [`5b33204`](https://github.com/browserify/pbkdf2/commit/5b33204d0172b06d7d93238ef72a1240b3e3f3c6)
## [v3.0.9](https://github.com/browserify/pbkdf2/compare/v3.0.8...v3.0.9) - 2016-10-05
### Merged
- protect 0.10 users by throwing [`#47`](https://github.com/browserify/pbkdf2/pull/47)
### Commits
- warn 0.10 users by throwing [`5e63f63`](https://github.com/browserify/pbkdf2/commit/5e63f63c149182f617b209d0419c408691b918d7)
## [v3.0.8](https://github.com/browserify/pbkdf2/compare/v3.0.7...v3.0.8) - 2016-09-22
### Fixed
- package: add engines [`#46`](https://github.com/browserify/pbkdf2/issues/46)
### Commits
- package: 1 too many indentations [`bffd057`](https://github.com/browserify/pbkdf2/commit/bffd0578fd2eb892a36cfd830fadc535deae9a49)
- package: 90% branch coverage is fine for now [`c3d57f9`](https://github.com/browserify/pbkdf2/commit/c3d57f96666f556034b8b59839b28b7fa7c342e9)
## [v3.0.7](https://github.com/browserify/pbkdf2/compare/v3.0.6...v3.0.7) - 2016-09-16
### Merged
- browser: avoid process.version split before process.browser [`#44`](https://github.com/browserify/pbkdf2/pull/44)
## [v3.0.6](https://github.com/browserify/pbkdf2/compare/v3.0.5...v3.0.6) - 2016-09-14
### Merged
- tests: fix UTF-8 encoding [`#42`](https://github.com/browserify/pbkdf2/pull/42)
- Add browserify dependency, rename index.html to bundle.html [`#41`](https://github.com/browserify/pbkdf2/pull/41)
- package: add browser.js [`#39`](https://github.com/browserify/pbkdf2/pull/39)
### Commits
- add browserify and remove mocha from test/index.html [`f28965d`](https://github.com/browserify/pbkdf2/commit/f28965d0a494e9f6f95f616bb3f608d3a15bff9c)
- rename index.html to bundle.html [`7d850d2`](https://github.com/browserify/pbkdf2/commit/7d850d247a93122a5e1b60fabddf64f7958cfeeb)
## [v3.0.5](https://github.com/browserify/pbkdf2/compare/3.0.4...v3.0.5) - 2016-09-12
### Merged
- use tape instead of mocha [`#35`](https://github.com/browserify/pbkdf2/pull/35)
- tests: remove binary assumption, fixes #34 [`#36`](https://github.com/browserify/pbkdf2/pull/36)
- README: add documentation, close #31 [`#33`](https://github.com/browserify/pbkdf2/pull/33)
- fix coverage [`#32`](https://github.com/browserify/pbkdf2/pull/32)
- [trivial] update README.md [`#28`](https://github.com/browserify/pbkdf2/pull/28)
- [trivial] rename async-shim.js to node-shim-async.js [`#29`](https://github.com/browserify/pbkdf2/pull/29)
- update travis & standard [`#24`](https://github.com/browserify/pbkdf2/pull/24)
- browser: delay async computation, fixes #13 [`#14`](https://github.com/browserify/pbkdf2/pull/14)
### Fixed
- Merge pull request #36 from crypto-browserify/testfix [`#34`](https://github.com/browserify/pbkdf2/issues/34)
- tests: remove binary assumption, fixes #34 [`#34`](https://github.com/browserify/pbkdf2/issues/34)
- Merge pull request #33 from crypto-browserify/dcousens-patch-1 [`#31`](https://github.com/browserify/pbkdf2/issues/31)
- README: add documentation, close #31 [`#31`](https://github.com/browserify/pbkdf2/issues/31)
- README: fix pbkdf2 spelling, resolves #20 [`#20`](https://github.com/browserify/pbkdf2/issues/20)
- Merge pull request #14 from crypto-browserify/dcousens-patch-1 [`#13`](https://github.com/browserify/pbkdf2/issues/13)
- browser: delay async computation, fixes #13 [`#13`](https://github.com/browserify/pbkdf2/issues/13)
### Commits
- add node-shim.js [`5eaa6ba`](https://github.com/browserify/pbkdf2/commit/5eaa6baa87564ab46775d1b8d547dd0f4ca8515b)
- browser: default the encoding [`94e7979`](https://github.com/browserify/pbkdf2/commit/94e79791fcab6c91cc5cb773857e2d51783edada)
- update tests [`931b7d5`](https://github.com/browserify/pbkdf2/commit/931b7d527a7a46e7518506680a1d431e6eb24dd3)
- package: update standard [`dd02315`](https://github.com/browserify/pbkdf2/commit/dd02315c41b8339d14c656c7e70ba433c893b36f)
- move checkParameters to separate file [`93ffd51`](https://github.com/browserify/pbkdf2/commit/93ffd519878f22d881a36eadcde4ad3e710caecc)
- tests: merge to avoid double up of code [`59f6577`](https://github.com/browserify/pbkdf2/commit/59f6577f8783d6e71a99988397c3a1e0811ed6d5)
- travis: update config [`7ab61b4`](https://github.com/browserify/pbkdf2/commit/7ab61b401c7c3d40bcb16d98bab97143c89d97e1)
- update README.md [`8bf4958`](https://github.com/browserify/pbkdf2/commit/8bf4958da1da9a8a5d13cbe91aff0fe9e632371c)
- pull out type checking [`e6b815f`](https://github.com/browserify/pbkdf2/commit/e6b815fa4c0b2edf222c663c7b5d761dddf23d57)
- browser: s/testParams/checkParameters/ [`7730a55`](https://github.com/browserify/pbkdf2/commit/7730a552e89e09da0d8a42b56f8a376c851b2c11)
- package: add files field to package.json [`3ee45ed`](https://github.com/browserify/pbkdf2/commit/3ee45ed1bd6b751d7918075b2a76d166eb61ae8a)
- rename async-shim.js to node-shim-async.js [`2268e11`](https://github.com/browserify/pbkdf2/commit/2268e11ad301ebf377a1f859e05214bdf3622919)
- browser: return null for error [`c470de1`](https://github.com/browserify/pbkdf2/commit/c470de18779fcb0f998d8c542bad5787dfb5f5f1)
- .travis: test node 6 [`9f949d4`](https://github.com/browserify/pbkdf2/commit/9f949d46d9392be9e937e2916df7863ac17f2815)
## [3.0.4](https://github.com/browserify/pbkdf2/compare/v3.0.3...3.0.4) - 2015-03-27
### Merged
- Fix shim encoding and more reliably close child process [`#12`](https://github.com/browserify/pbkdf2/pull/12)
### Commits
- async errors and exiting [`2bcfba8`](https://github.com/browserify/pbkdf2/commit/2bcfba85216694c10663540b34a4e3b400c205ed)
- tests: add failing utf8 test [`ea1ddaf`](https://github.com/browserify/pbkdf2/commit/ea1ddaf28d06a288a955ae41b717011c1596fb0b)
- fix 2 types of errors [`0cbba29`](https://github.com/browserify/pbkdf2/commit/0cbba29b0a81a7acf2619fd49ab5b9f40c47bfa8)
- fix standard formatting issues [`93b06d3`](https://github.com/browserify/pbkdf2/commit/93b06d3762fdb850d5532e0f63b8051515db666f)
- fix shim encoding [`a57d9c6`](https://github.com/browserify/pbkdf2/commit/a57d9c6b37fba515eb6a83cf8239bcd67356a203)
- index/browser: rename MAX_INT to MAX_ALLOC [`9f6fb05`](https://github.com/browserify/pbkdf2/commit/9f6fb05b7284bc0fc72cde6e37524deffdc2d3a8)
- package: use standard 3.0.0 [`941b46b`](https://github.com/browserify/pbkdf2/commit/941b46ba580918ec44bc0072b6ae0ecfa9fde277)
## [v3.0.3](https://github.com/browserify/pbkdf2/compare/3.0.2...v3.0.3) - 2015-02-15
### Commits
- repo name [`a6516d9`](https://github.com/browserify/pbkdf2/commit/a6516d9fa34bb250c2ef6e0d75ef7e47b7c1b1a4)
- change name [`471fb83`](https://github.com/browserify/pbkdf2/commit/471fb83c50fb1019b099fe9926fc28d3d25900e1)
## [3.0.2](https://github.com/browserify/pbkdf2/compare/3.0.1...3.0.2) - 2015-02-15
### Merged
- fix bug in encoding [`#10`](https://github.com/browserify/pbkdf2/pull/10)
### Commits
- tests: add non-printable fixture handling and example fixture [`040707d`](https://github.com/browserify/pbkdf2/commit/040707da888f4eb7737dd671a3e0c71875b94b2b)
- add 0.12 and iojs to travis [`45165c4`](https://github.com/browserify/pbkdf2/commit/45165c45bf2c1938431eed592eef5c087a43aa20)
## [3.0.1](https://github.com/browserify/pbkdf2/compare/2.0.1...3.0.1) - 2015-01-29
### Commits
- modularize [`68c6c36`](https://github.com/browserify/pbkdf2/commit/68c6c36e4a0af2862274d0a8effc82d0650a546d)
- all: standard cmpliance [`2f5ff3b`](https://github.com/browserify/pbkdf2/commit/2f5ff3ba739f84b2e51335c5f3cfacbf856bc587)
- add shim [`386d4af`](https://github.com/browserify/pbkdf2/commit/386d4afd32b1ea3384cc175d3993ada757836e01)
- add browser tests [`b88ad8d`](https://github.com/browserify/pbkdf2/commit/b88ad8d14ee02fefddb99f3b89c89ca51e90122f)
- package: add coveralls and re-order [`5834697`](https://github.com/browserify/pbkdf2/commit/58346973b7d2e45b9bb313e159b43e05ab5024ae)
- package: add standard test suite [`e504eed`](https://github.com/browserify/pbkdf2/commit/e504eed0a6e38846a752f9f49aa1b38ceb8dbd67)
- package: update repository URL [`b217d1a`](https://github.com/browserify/pbkdf2/commit/b217d1ab6c153e9899cbd96b29653f7da308d444)
- tests: remove unnecessary semicolon/vars [`24f8ab3`](https://github.com/browserify/pbkdf2/commit/24f8ab3b5d1928f5b87f50aa357475cd5855b03d)
- package: add coveralls [`c5b6d51`](https://github.com/browserify/pbkdf2/commit/c5b6d510bdbd5792b98e4d27daf94849c70b9d57)
- index: remove unnecessary __pbkdf2Export [`e51121f`](https://github.com/browserify/pbkdf2/commit/e51121f46887e545fedd817ac8624e0d68c9ace5)
- index: fix digest algorithm typo [`558b3dd`](https://github.com/browserify/pbkdf2/commit/558b3dd06bb17b782ee0c1994c5aed19624d4c3b)
- README: update repository URL [`f1fc7b4`](https://github.com/browserify/pbkdf2/commit/f1fc7b448f93e21a23bfe40f39670129f2ff31d6)
- package: latest devDependencies [`9624836`](https://github.com/browserify/pbkdf2/commit/9624836014c4976f8907273a4a77020b51a4fe8c)
- package: use latest create-hmac [`ffd5b94`](https://github.com/browserify/pbkdf2/commit/ffd5b943434dc78a36858f0bd61399aba6176617)
- package: update description [`7fbec99`](https://github.com/browserify/pbkdf2/commit/7fbec99bfc993d01161aae4c4b00c3718a8737f4)
## [2.0.1](https://github.com/browserify/pbkdf2/compare/2.0.0...2.0.1) - 2014-09-25
### Merged
- move istanbul to dev dependencies [`#1`](https://github.com/browserify/pbkdf2/pull/1)
## [2.0.0](https://github.com/browserify/pbkdf2/compare/1.0.1...2.0.0) - 2014-09-24
### Commits
- pbkdf2: add async impl. and invalid tests [`16d209e`](https://github.com/browserify/pbkdf2/commit/16d209ecd2e997ca775f32b47b8c2318a55ecdd8)
- README: update to latest API [`c2f01cf`](https://github.com/browserify/pbkdf2/commit/c2f01cf719063975dd943d8f6c280896f1c0958d)
- index: re-order var declarations [`8ad010d`](https://github.com/browserify/pbkdf2/commit/8ad010d6ad5869b06ec9a8c0d80650c9b517da7f)
## 1.0.1 - 2014-09-17
### Commits
- index: adds implementation [`1792996`](https://github.com/browserify/pbkdf2/commit/1792996f8f967ff5297990c498338b6790fc8a8b)
- fixtures: adds test fixtures [`33e999e`](https://github.com/browserify/pbkdf2/commit/33e999e8630ce967adc28f64462bdc98b5ab5a47)
- Initial commit [`f17b827`](https://github.com/browserify/pbkdf2/commit/f17b827efadd65634ab2f98de538b05ec526d959)
- package: adds package.json [`2782f71`](https://github.com/browserify/pbkdf2/commit/2782f7152d283c709e4700bf473f15069adcd5c5)
- README: add badges + usage instructions [`51ac17d`](https://github.com/browserify/pbkdf2/commit/51ac17db44d4b7e0b1bfc5995123dc5b2d031bc6)
- index: adhere to node.js spec [`98ec635`](https://github.com/browserify/pbkdf2/commit/98ec635aa4d0d4909048483de4080a19b86b45f4)
- travis: adds yml [`965f37f`](https://github.com/browserify/pbkdf2/commit/965f37fb409f1daffd01fad353bd923ed0aa2b2d)
- README: add credits [`aa9ac2f`](https://github.com/browserify/pbkdf2/commit/aa9ac2f38e74a834500ec1fdaa7fe14ca976b26d)
- README: no need for there [`0f6c37f`](https://github.com/browserify/pbkdf2/commit/0f6c37f10924fc3ceb8b2bf4074508e559454feb)
pbkdf2-3.1.3/LICENSE 0000664 0000000 0000000 00000002071 15025343214 0013672 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2014 Daniel Cousens
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
pbkdf2-3.1.3/README.md 0000664 0000000 0000000 00000004322 15025343214 0014145 0 ustar 00root root 0000000 0000000 # pbkdf2 [![Version Badge][2]][1]
This library provides the functionality of PBKDF2 with the ability to use any supported hashing algorithm returned from `crypto.getHashes()`
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![npm badge][11]][1]
## Usage
```js
var pbkdf2 = require('pbkdf2')
var derivedKey = pbkdf2.pbkdf2Sync('password', 'salt', 1, 32, 'sha512')
...
```
For more information on the API, please see the relevant [Node documentation](https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback).
For high performance, use the `async` variant (`pbkdf2.pbkdf2`), not `pbkdf2.pbkdf2Sync`; this variant has the oppurtunity to use `window.crypto.subtle` when browserified.
## Credits
This module is a derivative of [cryptocoinjs/pbkdf2-sha256](https://github.com/cryptocoinjs/pbkdf2-sha256/), so thanks to [JP Richardson](https://github.com/jprichardson/) for laying the ground work.
Thank you to [FangDun Cai](https://github.com/fundon) for donating the package name on npm, if you're looking for his previous module it is located at [fundon/pbkdf2](https://github.com/fundon/pbkdf2).
[1]: https://npmjs.org/package/pbkdf2
[2]: https://versionbadg.es/browserify/pbkdf2.svg
[5]: https://david-dm.org/browserify/pbkdf2.svg
[6]: https://david-dm.org/browserify/pbkdf2
[7]: https://david-dm.org/browserify/pbkdf2/dev-status.svg
[8]: https://david-dm.org/browserify/pbkdf2#info=devDependencies
[11]: https://nodei.co/npm/pbkdf2.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/pbkdf2.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/pbkdf2.svg
[downloads-url]: https://npm-stat.com/charts.html?package=pbkdf2
[codecov-image]: https://codecov.io/gh/browserify/pbkdf2/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/browserify/pbkdf2/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/browserify/pbkdf2
[actions-url]: https://github.com/browserify/pbkdf2/actions
pbkdf2-3.1.3/bench/ 0000775 0000000 0000000 00000000000 15025343214 0013744 5 ustar 00root root 0000000 0000000 pbkdf2-3.1.3/bench/index.js 0000664 0000000 0000000 00000002025 15025343214 0015410 0 ustar 00root root 0000000 0000000 'use strict';
var Benchmark = require('benchmark');
var current = require('../lib/sync');
var old = require('./old');
function run(password, salt, iterations, keylen, digest) {
var suite = new Benchmark.Suite();
console.log(`password: ${password}`);
console.log(`salt: ${salt}`);
console.log(`iterations: ${iterations}`);
console.log(`keylen: ${keylen}`);
console.log(`digest: ${digest}`);
// add tests
suite
.add('current', function () {
current(password, salt, iterations, keylen, digest);
})
.add('old', function () {
old(password, salt, iterations, keylen, digest);
})
// add listeners
.on('cycle', function (event) {
console.log(String(event.target));
})
.on('complete', function () {
// eslint-disable-next-line no-invalid-this
console.log('Fastest is ' + this.filter('fastest').map('name'));
console.log('');
})
.run();
}
run('hello', 'world', 100, 32, 'md5');
run('hello', 'world', 100, 32, 'sha256');
run('hello', 'world', 10000, 70, 'md5');
run('hello', 'world', 10000, 70, 'sha256');
pbkdf2-3.1.3/bench/old.js 0000664 0000000 0000000 00000002376 15025343214 0015070 0 ustar 00root root 0000000 0000000 'use strict';
var createHmac = require('create-hmac');
var checkParameters = require('../lib/precondition');
var defaultEncoding = require('../lib/default-encoding');
var Buffer = require('safe-buffer').Buffer;
module.exports = function pbkdf2(password, salt, iterations, keylen, digest) {
if (!Buffer.isBuffer(password)) {
password = Buffer.from(password, defaultEncoding);
}
if (!Buffer.isBuffer(salt)) {
salt = Buffer.from(salt, defaultEncoding);
}
checkParameters(iterations, keylen);
digest = digest || 'sha1';
var hLen;
var l = 1;
var DK = Buffer.allocUnsafe(keylen);
var block1 = Buffer.allocUnsafe(salt.length + 4);
salt.copy(block1, 0, 0, salt.length);
var r;
var T;
for (var i = 1; i <= l; i++) {
block1.writeUInt32BE(i, salt.length);
var U = createHmac(digest, password).update(block1).digest();
if (!hLen) {
hLen = U.length;
T = Buffer.allocUnsafe(hLen);
l = Math.ceil(keylen / hLen);
r = keylen - ((l - 1) * hLen);
}
U.copy(T, 0, 0, hLen);
for (var j = 1; j < iterations; j++) {
U = createHmac(digest, password).update(U).digest();
for (var k = 0; k < hLen; k++) {
T[k] ^= U[k];
}
}
var destPos = (i - 1) * hLen;
var len = i === l ? r : hLen;
T.copy(DK, destPos, 0, len);
}
return DK;
};
pbkdf2-3.1.3/browser.js 0000664 0000000 0000000 00000000144 15025343214 0014705 0 ustar 00root root 0000000 0000000 'use strict';
exports.pbkdf2 = require('./lib/async');
exports.pbkdf2Sync = require('./lib/sync');
pbkdf2-3.1.3/index.js 0000664 0000000 0000000 00000002516 15025343214 0014336 0 ustar 00root root 0000000 0000000 'use strict';
var nativeImpl = require('crypto');
var checkParameters = require('./lib/precondition');
var defaultEncoding = require('./lib/default-encoding');
var toBuffer = require('./lib/to-buffer');
function nativePBKDF2(password, salt, iterations, keylen, digest, callback) {
checkParameters(iterations, keylen);
password = toBuffer(password, defaultEncoding, 'Password');
salt = toBuffer(salt, defaultEncoding, 'Salt');
if (typeof digest === 'function') {
callback = digest;
digest = 'sha1';
}
if (typeof callback !== 'function') {
throw new Error('No callback provided to pbkdf2');
}
return nativeImpl.pbkdf2(password, salt, iterations, keylen, digest, callback);
}
function nativePBKDF2Sync(password, salt, iterations, keylen, digest) {
checkParameters(iterations, keylen);
password = toBuffer(password, defaultEncoding, 'Password');
salt = toBuffer(salt, defaultEncoding, 'Salt');
digest = digest || 'sha1';
return nativeImpl.pbkdf2Sync(password, salt, iterations, keylen, digest);
}
/* istanbul ignore next */
if (!nativeImpl.pbkdf2Sync || nativeImpl.pbkdf2Sync.toString().indexOf('keylen, digest') === -1) {
/* eslint global-require: 0 */
exports.pbkdf2Sync = require('./lib/sync');
exports.pbkdf2 = require('./lib/async');
// native
} else {
exports.pbkdf2Sync = nativePBKDF2Sync;
exports.pbkdf2 = nativePBKDF2;
}
pbkdf2-3.1.3/lib/ 0000775 0000000 0000000 00000000000 15025343214 0013433 5 ustar 00root root 0000000 0000000 pbkdf2-3.1.3/lib/async.js 0000664 0000000 0000000 00000005572 15025343214 0015117 0 ustar 00root root 0000000 0000000 'use strict';
var Buffer = require('safe-buffer').Buffer;
var checkParameters = require('./precondition');
var defaultEncoding = require('./default-encoding');
var sync = require('./sync');
var toBuffer = require('./to-buffer');
var ZERO_BUF;
var subtle = global.crypto && global.crypto.subtle;
var toBrowser = {
sha: 'SHA-1',
'sha-1': 'SHA-1',
sha1: 'SHA-1',
sha256: 'SHA-256',
'sha-256': 'SHA-256',
sha384: 'SHA-384',
'sha-384': 'SHA-384',
'sha-512': 'SHA-512',
sha512: 'SHA-512'
};
var checks = [];
var nextTick;
function getNextTick() {
if (nextTick) {
return nextTick;
}
if (global.process && global.process.nextTick) {
nextTick = global.process.nextTick;
} else if (global.queueMicrotask) {
nextTick = global.queueMicrotask;
} else if (global.setImmediate) {
nextTick = global.setImmediate;
} else {
nextTick = global.setTimeout;
}
return nextTick;
}
function browserPbkdf2(password, salt, iterations, length, algo) {
return subtle.importKey('raw', password, { name: 'PBKDF2' }, false, ['deriveBits']).then(function (key) {
return subtle.deriveBits({
name: 'PBKDF2',
salt: salt,
iterations: iterations,
hash: {
name: algo
}
}, key, length << 3);
}).then(function (res) {
return Buffer.from(res);
});
}
function checkNative(algo) {
if (global.process && !global.process.browser) {
return Promise.resolve(false);
}
if (!subtle || !subtle.importKey || !subtle.deriveBits) {
return Promise.resolve(false);
}
if (checks[algo] !== undefined) {
return checks[algo];
}
ZERO_BUF = ZERO_BUF || Buffer.alloc(8);
var prom = browserPbkdf2(ZERO_BUF, ZERO_BUF, 10, 128, algo)
.then(
function () { return true; },
function () { return false; }
);
checks[algo] = prom;
return prom;
}
function resolvePromise(promise, callback) {
promise.then(function (out) {
getNextTick()(function () {
callback(null, out);
});
}, function (e) {
getNextTick()(function () {
callback(e);
});
});
}
module.exports = function (password, salt, iterations, keylen, digest, callback) {
if (typeof digest === 'function') {
callback = digest;
digest = undefined;
}
digest = digest || 'sha1';
var algo = toBrowser[digest.toLowerCase()];
if (!algo || typeof global.Promise !== 'function') {
getNextTick()(function () {
var out;
try {
out = sync(password, salt, iterations, keylen, digest);
} catch (e) {
callback(e);
return;
}
callback(null, out);
});
return;
}
checkParameters(iterations, keylen);
password = toBuffer(password, defaultEncoding, 'Password');
salt = toBuffer(salt, defaultEncoding, 'Salt');
if (typeof callback !== 'function') {
throw new Error('No callback provided to pbkdf2');
}
resolvePromise(checkNative(algo).then(function (resp) {
if (resp) {
return browserPbkdf2(password, salt, iterations, keylen, algo);
}
return sync(password, salt, iterations, keylen, digest);
}), callback);
};
pbkdf2-3.1.3/lib/default-encoding.js 0000664 0000000 0000000 00000000623 15025343214 0017202 0 ustar 00root root 0000000 0000000 'use strict';
var defaultEncoding;
/* istanbul ignore next */
if (global.process && global.process.browser) {
defaultEncoding = 'utf-8';
} else if (global.process && global.process.version) {
var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10);
defaultEncoding = pVersionMajor >= 6 ? 'utf-8' : 'binary';
} else {
defaultEncoding = 'utf-8';
}
module.exports = defaultEncoding;
pbkdf2-3.1.3/lib/precondition.js 0000664 0000000 0000000 00000001000 15025343214 0016455 0 ustar 00root root 0000000 0000000 'use strict';
var MAX_ALLOC = Math.pow(2, 30) - 1; // default in iojs
module.exports = function (iterations, keylen) {
if (typeof iterations !== 'number') {
throw new TypeError('Iterations not a number');
}
if (iterations < 0) {
throw new TypeError('Bad iterations');
}
if (typeof keylen !== 'number') {
throw new TypeError('Key length not a number');
}
if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
throw new TypeError('Bad key length');
}
};
pbkdf2-3.1.3/lib/sync-browser.js 0000664 0000000 0000000 00000005607 15025343214 0016436 0 ustar 00root root 0000000 0000000 'use strict';
var md5 = require('create-hash/md5');
var RIPEMD160 = require('ripemd160');
var sha = require('sha.js');
var Buffer = require('safe-buffer').Buffer;
var checkParameters = require('./precondition');
var defaultEncoding = require('./default-encoding');
var toBuffer = require('./to-buffer');
var ZEROS = Buffer.alloc(128);
var sizes = {
__proto__: null,
md5: 16,
sha1: 20,
sha224: 28,
sha256: 32,
sha384: 48,
sha512: 64,
'sha512-256': 32,
ripemd160: 20,
rmd160: 20
};
var mapping = {
__proto__: null,
'sha-1': 'sha1',
'sha-224': 'sha224',
'sha-256': 'sha256',
'sha-384': 'sha384',
'sha-512': 'sha512',
'ripemd-160': 'ripemd160'
};
function rmd160Func(data) {
return new RIPEMD160().update(data).digest();
}
function getDigest(alg) {
function shaFunc(data) {
return sha(alg).update(data).digest();
}
if (alg === 'rmd160' || alg === 'ripemd160') {
return rmd160Func;
}
if (alg === 'md5') {
return md5;
}
return shaFunc;
}
function Hmac(alg, key, saltLen) {
var hash = getDigest(alg);
var blocksize = alg === 'sha512' || alg === 'sha384' ? 128 : 64;
if (key.length > blocksize) {
key = hash(key);
} else if (key.length < blocksize) {
key = Buffer.concat([key, ZEROS], blocksize);
}
var ipad = Buffer.allocUnsafe(blocksize + sizes[alg]);
var opad = Buffer.allocUnsafe(blocksize + sizes[alg]);
for (var i = 0; i < blocksize; i++) {
ipad[i] = key[i] ^ 0x36;
opad[i] = key[i] ^ 0x5C;
}
var ipad1 = Buffer.allocUnsafe(blocksize + saltLen + 4);
ipad.copy(ipad1, 0, 0, blocksize);
this.ipad1 = ipad1;
this.ipad2 = ipad;
this.opad = opad;
this.alg = alg;
this.blocksize = blocksize;
this.hash = hash;
this.size = sizes[alg];
}
Hmac.prototype.run = function (data, ipad) {
data.copy(ipad, this.blocksize);
var h = this.hash(ipad);
h.copy(this.opad, this.blocksize);
return this.hash(this.opad);
};
function pbkdf2(password, salt, iterations, keylen, digest) {
checkParameters(iterations, keylen);
password = toBuffer(password, defaultEncoding, 'Password');
salt = toBuffer(salt, defaultEncoding, 'Salt');
var lowerDigest = (digest || 'sha1').toLowerCase();
var mappedDigest = mapping[lowerDigest] || lowerDigest;
var size = sizes[mappedDigest];
if (typeof size !== 'number' || !size) {
throw new TypeError('Digest algorithm not supported: ' + digest);
}
var hmac = new Hmac(mappedDigest, password, salt.length);
var DK = Buffer.allocUnsafe(keylen);
var block1 = Buffer.allocUnsafe(salt.length + 4);
salt.copy(block1, 0, 0, salt.length);
var destPos = 0;
var hLen = size;
var l = Math.ceil(keylen / hLen);
for (var i = 1; i <= l; i++) {
block1.writeUInt32BE(i, salt.length);
var T = hmac.run(block1, hmac.ipad1);
var U = T;
for (var j = 1; j < iterations; j++) {
U = hmac.run(U, hmac.ipad2);
for (var k = 0; k < hLen; k++) {
T[k] ^= U[k];
}
}
T.copy(DK, destPos);
destPos += hLen;
}
return DK;
}
module.exports = pbkdf2;
pbkdf2-3.1.3/lib/sync.js 0000664 0000000 0000000 00000003161 15025343214 0014746 0 ustar 00root root 0000000 0000000 'use strict';
var sizes = {
__proto__: null,
md5: 16,
sha1: 20,
sha224: 28,
sha256: 32,
sha384: 48,
sha512: 64,
'sha512-256': 32,
rmd160: 20,
ripemd160: 20
};
var mapping = {
__proto__: null,
'sha-1': 'sha1',
'sha-224': 'sha224',
'sha-256': 'sha256',
'sha-384': 'sha384',
'sha-512': 'sha512',
'ripemd-160': 'ripemd160'
};
var createHmac = require('create-hmac');
var Buffer = require('safe-buffer').Buffer;
var checkParameters = require('./precondition');
var defaultEncoding = require('./default-encoding');
var toBuffer = require('./to-buffer');
function pbkdf2(password, salt, iterations, keylen, digest) {
checkParameters(iterations, keylen);
password = toBuffer(password, defaultEncoding, 'Password');
salt = toBuffer(salt, defaultEncoding, 'Salt');
var lowerDigest = (digest || 'sha1').toLowerCase();
var mappedDigest = mapping[lowerDigest] || lowerDigest;
var size = sizes[mappedDigest];
if (typeof size !== 'number' || !size) {
throw new TypeError('Digest algorithm not supported: ' + digest);
}
var DK = Buffer.allocUnsafe(keylen);
var block1 = Buffer.allocUnsafe(salt.length + 4);
salt.copy(block1, 0, 0, salt.length);
var destPos = 0;
var hLen = size;
var l = Math.ceil(keylen / hLen);
for (var i = 1; i <= l; i++) {
block1.writeUInt32BE(i, salt.length);
var T = createHmac(mappedDigest, password).update(block1).digest();
var U = T;
for (var j = 1; j < iterations; j++) {
U = createHmac(mappedDigest, password).update(U).digest();
for (var k = 0; k < hLen; k++) {
T[k] ^= U[k];
}
}
T.copy(DK, destPos);
destPos += hLen;
}
return DK;
}
module.exports = pbkdf2;
pbkdf2-3.1.3/lib/to-buffer.js 0000664 0000000 0000000 00000001143 15025343214 0015661 0 ustar 00root root 0000000 0000000 'use strict';
var Buffer = require('safe-buffer').Buffer;
var toBuffer = require('to-buffer');
var useUint8Array = typeof Uint8Array !== 'undefined';
var useArrayBuffer = useUint8Array && typeof ArrayBuffer !== 'undefined';
var isView = useArrayBuffer && ArrayBuffer.isView;
module.exports = function (thing, encoding, name) {
if (
typeof thing === 'string'
|| Buffer.isBuffer(thing)
|| (useUint8Array && thing instanceof Uint8Array)
|| (isView && isView(thing))
) {
return toBuffer(thing, encoding);
}
throw new TypeError(name + ' must be a string, a Buffer, a Uint8Array, or a DataView');
};
pbkdf2-3.1.3/package.json 0000664 0000000 0000000 00000004007 15025343214 0015154 0 ustar 00root root 0000000 0000000 {
"name": "pbkdf2",
"version": "3.1.3",
"description": "This library provides the functionality of PBKDF2 with the ability to use any supported hashing algorithm returned from crypto.getHashes()",
"keywords": [
"pbkdf2",
"kdf",
"salt",
"hash"
],
"homepage": "https://github.com/crypto-browserify/pbkdf2",
"bugs": {
"url": "https://github.com/crypto-browserify/pbkdf2/issues"
},
"license": "MIT",
"author": "Daniel Cousens",
"browser": {
"./index.js": "./browser.js",
"./lib/sync.js": "./lib/sync-browser.js"
},
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/crypto-browserify/pbkdf2.git"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"lint": "eslint --ext=js,mjs .",
"pretest": "npm run lint",
"tests-only": "nyc tape test/index.js",
"test": "npm run tests-only && npm run bundle-test",
"posttest": "npx npm@\">= 10.2\" audit --production",
"bundle-test": "browserify test/index.js > test/bundle.js",
"bench": "node bench/",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"devDependencies": {
"@ljharb/eslint-config": "^21.1.1",
"auto-changelog": "^2.5.0",
"benchmark": "^2.1.4",
"browserify": "^17.0.1",
"encoding": "^0.1.13",
"eslint": "=8.8.0",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"object.assign": "^4.1.7",
"semver": "^6.3.1",
"tape": "^5.9.0"
},
"dependencies": {
"create-hash": "~1.1.3",
"create-hmac": "^1.1.7",
"ripemd160": "=2.0.1",
"safe-buffer": "^5.2.1",
"sha.js": "^2.4.11",
"to-buffer": "^1.2.0"
},
"engines": {
"node": ">=0.12"
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows",
"bench",
"test"
]
}
}
pbkdf2-3.1.3/test/ 0000775 0000000 0000000 00000000000 15025343214 0013644 5 ustar 00root root 0000000 0000000 pbkdf2-3.1.3/test/bundle.html 0000664 0000000 0000000 00000000071 15025343214 0016001 0 ustar 00root root 0000000 0000000
pbkdf2-3.1.3/test/fixtures.json 0000664 0000000 0000000 00000031166 15025343214 0016417 0 ustar 00root root 0000000 0000000 {
"valid": [
{
"key": "password",
"salt": "salt",
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "0c60c80f961f0e71f3a9b524af6012062fe037a6e0f0eb94fe8fc46bdc637164",
"sha256": "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b",
"sha512": "867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252",
"sha224": "3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e63155d4e490557fd85989497",
"sha384": "c0e14f06e49e32d73f9f52ddf1d0c5c7191609233631dadd76a567db42b78676",
"ripemd160": "b725258b125e0bacb0e2307e34feb16a4d0d6aed6cb4b0eee458fc1829020428"
}
},
{
"key": "password",
"salt": "salt",
"iterations": 2,
"dkLen": 32,
"results": {
"sha1": "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957cae93136266537a8d7bf4b76",
"sha256": "ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43",
"sha512": "e1d9c16aa681708a45f5c7c4e215ceb66e011a2e9f0040713f18aefdb866d53c",
"sha224": "93200ffa96c5776d38fa10abdf8f5bfc0054b9718513df472d2331d2d1e66a3f",
"sha384": "54f775c6d790f21930459162fc535dbf04a939185127016a04176a0730c6f1f4",
"ripemd160": "768dcc27b7bfdef794a1ff9d935090fcf598555e66913180b9ce363c615e9ed9"
}
},
{
"key": "password",
"salt": "salt",
"iterations": 1,
"dkLen": 64,
"results": {
"sha1": "0c60c80f961f0e71f3a9b524af6012062fe037a6e0f0eb94fe8fc46bdc637164ac2e7a8e3f9d2e83ace57e0d50e5e1071367c179bc86c767fc3f78ddb561363f",
"sha256": "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b4dbf3a2f3dad3377264bb7b8e8330d4efc7451418617dabef683735361cdc18c",
"sha512": "867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252c02d470a285a0501bad999bfe943c08f050235d7d68b1da55e63f73b60a57fce",
"sha224": "3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e63155d4e490557fd859894978ab846d52a1083ac610c36c2c5ea8ce4a024dd691064d5453bd17b15ea1ac194",
"sha384": "c0e14f06e49e32d73f9f52ddf1d0c5c7191609233631dadd76a567db42b78676b38fc800cc53ddb642f5c74442e62be44d727702213e3bb9223c53b767fbfb5d",
"ripemd160": "b725258b125e0bacb0e2307e34feb16a4d0d6aed6cb4b0eee458fc18290204289e55d962783bf52237d264cbbab25f18d89d8c798f90f558ea7b45bdf3d08334"
}
},
{
"key": "password",
"salt": "salt",
"iterations": 2,
"dkLen": 64,
"results": {
"sha1": "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957cae93136266537a8d7bf4b76c51094cc1ae010b19923ddc4395cd064acb023ffd1edd5ef4be8ffe61426c28e",
"sha256": "ae4d0c95af6b46d32d0adff928f06dd02a303f8ef3c251dfd6e2d85a95474c43830651afcb5c862f0b249bd031f7a67520d136470f5ec271ece91c07773253d9",
"sha512": "e1d9c16aa681708a45f5c7c4e215ceb66e011a2e9f0040713f18aefdb866d53cf76cab2868a39b9f7840edce4fef5a82be67335c77a6068e04112754f27ccf4e",
"sha224": "93200ffa96c5776d38fa10abdf8f5bfc0054b9718513df472d2331d2d1e66a3f97b510224f700ce72581ffb10a1c99ec99a8cc1b951851a71f30d9265fccf912",
"sha384": "54f775c6d790f21930459162fc535dbf04a939185127016a04176a0730c6f1f4fb48832ad1261baadd2cedd50814b1c806ad1bbf43ebdc9d047904bf7ceafe1e",
"ripemd160": "768dcc27b7bfdef794a1ff9d935090fcf598555e66913180b9ce363c615e9ed953b95fd07169be535e38afbea29c030e06d14f40745b1513b7ccdf0e76229e50"
}
},
{
"key": "password",
"salt": "salt",
"iterations": 4096,
"dkLen": 32,
"results": {
"sha1": "4b007901b765489abead49d926f721d065a429c12e463f6c4cd79401085b03db",
"sha256": "c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a",
"sha512": "d197b1b33db0143e018b12f3d1d1479e6cdebdcc97c5c0f87f6902e072f457b5",
"sha224": "218c453bf90635bd0a21a75d172703ff6108ef603f65bb821aedade1d6961683",
"sha384": "559726be38db125bc85ed7895f6e3cf574c7a01c080c3447db1e8a76764deb3c",
"ripemd160": "99a40d3fe4ee95869791d9faa24864562782762171480b620ca8bed3dafbbcac"
}
},
{
"key": "passwordPASSWORDpassword",
"salt": "saltSALTsaltSALTsaltSALTsaltSALTsalt",
"iterations": 4096,
"dkLen": 40,
"results": {
"sha1": "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038b6b89a48612c5a25284e6605e12329",
"sha256": "348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c4e2a1fb8dd53e1c635518c7dac47e9",
"sha512": "8c0511f4c6e597c6ac6315d8f0362e225f3c501495ba23b868c005174dc4ee71115b59f9e60cd953",
"sha224": "056c4ba438ded91fc14e0594e6f52b87e1f3690c0dc0fbc05784ed9a754ca780e6c017e80c8de278",
"sha384": "819143ad66df9a552559b9e131c52ae6c5c1b0eed18f4d283b8c5c9eaeb92b392c147cc2d2869d58",
"ripemd160": "503b9a069633b261b2d3e4f21c5d0cafeb3f5008aec25ed21418d12630b6ce036ec82a0430ef1974"
}
},
{
"key": "pass\u00000word",
"salt": "sa\u00000lt",
"iterations": 4096,
"dkLen": 16,
"results": {
"sha1": "345cbad979dfccb90cac5257bea6ea46",
"sha256": "1df6274d3c0bd2fc7f54fb46f149dda4",
"sha512": "336d14366099e8aac2c46c94a8f178d2",
"sha224": "0aca9ca9634db6ef4927931f633c6453",
"sha384": "b6ab6f8f6532fd9c5c30a79e1f93dcc6",
"ripemd160": "914d58209e6483e491571a60e433124a"
}
},
{
"keyHex": "63ffeeddccbbaa",
"salt": "salt",
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "f6635023b135a57fb8caa89ef8ad93a29d9debb1b011e6e88bffbb212de7c01c",
"sha256": "dadd4a2638c1cf90a220777bc85d81859459513eb83063e3fce7d081490f259a",
"sha512": "f69de451247225a7b30cc47632899572bb980f500d7c606ac9b1c04f928a3488",
"sha224": "9cdee023b5d5e06ccd6c5467463e34fe461a7ed43977f8237f97b0bc7ebfd280",
"sha384": "25c72b6f0e052c883a9273a54cfd41fab86759fa3b33eb7920b923abaad62f99",
"ripemd160": "08609cb567308b81164fe1307c38bb9b87b072a756ce8d74760c4d216ee4e9fb"
}
},
{
"description": "Unicode salt, no truncation due to hex",
"key": "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",
"saltHex": "6d6e656d6f6e6963e383a1e383bce38388e383abe382abe38299e3838fe38299e382a6e38299e382a1e381afe3829ae381afe38299e3818fe38299e3829de38299e381a1e381a1e38299e58d81e4babae58d81e889b2",
"iterations": 2048,
"dkLen": 64,
"results": {
"sha1": "7e042a2f41ba17e2235fbc794e22a150816b0f54a1dfe113919fccb7a056066a109385e538f183c92bad896ae8b7d8e0f4cd66df359c77c8c7785cd1001c9a2c",
"sha256": "0b57118f2b6b079d9371c94da3a8315c3ada87a1e819b40c4c4e90b36ff2d3c8fd7555538b5119ac4d3da7844aa4259d92f9dd2188e78ac33c4b08d8e6b5964b",
"sha512": "ba553eedefe76e67e2602dc20184c564010859faada929a090dd2c57aacb204ceefd15404ab50ef3e8dbeae5195aeae64b0def4d2eead1cdc728a33ced520ffd",
"sha224": "d76474c525616ce2a527d23df8d6f6fcc4251cc3535cae4e955810a51ead1ec6acbe9c9619187ca5a3c4fd636de5b5fe58d031714731290bbc081dbf0fcb8fc1",
"sha384": "15010450f456769467e834db7fa93dd9d353e8bb733b63b0621090f96599ac3316908eb64ac9366094f0787cd4bfb2fea25be41dc271a19309710db6144f9b34",
"ripemd160": "255321c22a32f41ed925032043e01afe9cacf05470c6506621782c9d768df03c74cb3fe14a4296feba4c2825e736486fb3871e948f9c413ca006cc20b7ff6d37"
}
},
{
"key": "password",
"salt": "salt",
"iterations": 1,
"dkLen": 10,
"results": {
"sha1": "0c60c80f961f0e71f3a9",
"sha256": "120fb6cffcf8b32c43e7",
"sha512": "867f70cf1ade02cff375",
"sha224": "3c198cbdb9464b785796",
"sha384": "c0e14f06e49e32d73f9f",
"ripemd160": "b725258b125e0bacb0e2"
}
},
{
"key": "password",
"salt": "salt",
"iterations": 1,
"dkLen": 100,
"results": {
"sha1": "0c60c80f961f0e71f3a9b524af6012062fe037a6e0f0eb94fe8fc46bdc637164ac2e7a8e3f9d2e83ace57e0d50e5e1071367c179bc86c767fc3f78ddb561363fc692ba406d1301e42bcccc3c520d06751d78b80c3db926b16ffa3395bd697c647f280b51",
"sha256": "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b4dbf3a2f3dad3377264bb7b8e8330d4efc7451418617dabef683735361cdc18c22cd7fe60fa40e91c65849e1f60c0d8b62a7b2dbd0d3dfd75fb8498a5c2131ab02b66de5",
"sha512": "867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252c02d470a285a0501bad999bfe943c08f050235d7d68b1da55e63f73b60a57fce7b532e206c2967d4c7d2ffa460539fc4d4e5eec70125d74c6c7cf86d25284f297907fcea",
"sha224": "3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e63155d4e490557fd859894978ab846d52a1083ac610c36c2c5ea8ce4a024dd691064d5453bd17b15ea1ac1944bbfd62e61b997e7b22660f588e297186572480015f33bc2bfd2b423827bcdcdb4845914",
"sha384": "c0e14f06e49e32d73f9f52ddf1d0c5c7191609233631dadd76a567db42b78676b38fc800cc53ddb642f5c74442e62be44d727702213e3bb9223c53b767fbfb5db9d270d54c45d9cb6003d2967280b22671e2dbc6375f6ebf219c36f0d127be35e19d65a8",
"ripemd160": "b725258b125e0bacb0e2307e34feb16a4d0d6aed6cb4b0eee458fc18290204289e55d962783bf52237d264cbbab25f18d89d8c798f90f558ea7b45bdf3d083340c18b9d23ba842183c5364d18bc0ffde5a8a408dd7ef02dde561a08d21c6d2325a69869b"
}
},
{
"keyUint8Array": [112, 97, 115, 115, 119, 111, 114, 100],
"salt": "salt",
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "0c60c80f961f0e71f3a9b524af6012062fe037a6e0f0eb94fe8fc46bdc637164",
"sha256": "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b",
"sha512": "867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252",
"sha224": "3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e63155d4e490557fd85989497",
"sha384": "c0e14f06e49e32d73f9f52ddf1d0c5c7191609233631dadd76a567db42b78676",
"ripemd160": "b725258b125e0bacb0e2307e34feb16a4d0d6aed6cb4b0eee458fc1829020428"
}
},
{
"key": "password",
"saltUint8Array": [115, 97, 108, 116],
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "0c60c80f961f0e71f3a9b524af6012062fe037a6e0f0eb94fe8fc46bdc637164",
"sha256": "120fb6cffcf8b32c43e7225256c4f837a86548c92ccc35480805987cb70be17b",
"sha512": "867f70cf1ade02cff3752599a3a53dc4af34c7a669815ae5d513554e1c8cf252",
"sha224": "3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e63155d4e490557fd85989497",
"sha384": "c0e14f06e49e32d73f9f52ddf1d0c5c7191609233631dadd76a567db42b78676",
"ripemd160": "b725258b125e0bacb0e2307e34feb16a4d0d6aed6cb4b0eee458fc1829020428"
}
},
{
"keyInt32Array": [112, 97, 115, 115, 119, 111, 114, 100],
"salt": "salt",
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "f260ccd0bbc8fe6773119b834feec48636b716caad4180a4d0af4f9aa67c646e",
"sha256": "9b4608f5eeab348f0b9d85a918b140706b24f275acf6829382dfee491015f9eb",
"sha512": "c44b8f26550fe6ca0a55bce54b4a75e9530398f32ec28b59d0fded996e95e3d5",
"sha224": "03d0c2b530ec6339e6418cb0f906e50591619be40aa8817aa9c7305d1773231c",
"sha384": "2e69d62ae8c21ebc2de45a885b488f65fb88dfa58aaa9c57dd1fcb9d1edce96a",
"ripemd160": "fc69276ba3f145492065feb0259b9edf68179f2023c95094e71ac7d01748018a"
}
},
{
"key": "password",
"saltInt32Array": [115, 97, 108, 116],
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "b297f1ea23008f10ba9d645961e4661109e804b10af26bea22c44244492d6252",
"sha256": "f678f0772894c079f21377d9ee1e76dd77b62dfc1f0575e6aa9eb030af7a356a",
"sha512": "7f8133f6937ae1d7e4a43c19aabd2de8308d5b833341281716a501334cdb2470",
"sha224": "ab66d29d3dacc731e44f091a7baa051926219cf493e8b9e3934cedfb215adc8b",
"sha384": "cf139d648cf63e9b85a3b9b8f23f4445b84d22201bc2544bc273a17d5dcb7b28",
"ripemd160": "26142e48fae1ad1c53be54823aadda2aa7d42f5524463fb1eff0efafa08edb9d"
}
},
{
"keyFloat64Array": [112, 97, 115, 115, 119, 111, 114, 100],
"salt": "salt",
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "c2b17a7e98cc48690a92cd9f753a2c700229045905167571aa281aafe8230bba",
"sha256": "55d62579a083a6c14b886710f81b54f567d214d343af776e5e90c467ea81b821",
"sha512": "ded01ce343e2683d962fc74b7b5ceef525228f49393ce9353254f44e3dc7e9aa",
"sha224": "5f10a348d320c7555b972b8d7d45a363a91e1a82dea063c3ac495cfad74a8d89",
"sha384": "4b7f97dbadfd652e0579499d0e23607ec476ed4bea9d6f1740d0b110e2d08792",
"ripemd160": "f92080d972a649d98d91a53922863fc7b8076c54869e9885f9a804868ef752e0"
}
},
{
"key": "password",
"saltFloat64Array": [115, 97, 108, 116],
"iterations": 1,
"dkLen": 32,
"results": {
"sha1": "f158b9edd28c16ad3b41e0e8197ec132a98c2ddea73b959f55ec9792e0b29d6f",
"sha256": "a6154d17480547a10212f75883509842f88f2ca5d6c1a2419646e47342051852",
"sha512": "b10c2ea742de7dd0525988761ee1733564c91380eeaa1b199f4fafcbf7144b0c",
"sha224": "29b315ac30c7d5e1640ca0f9e27b68a794fb9f950b8dd117129824f103ffb9db",
"sha384": "624b4ed6ad389b976fb7503e54a35109f249c29ac6eb8b56850152be21b3cb0e",
"ripemd160": "8999b9280207bc9c76cf25327aa352da26a683fac7a2adff17a39dcc4f4c3b5b"
}
}
],
"invalid": [
{
"key": "password",
"salt": "salt",
"iterations": "NaN",
"dkLen": 16,
"exception": "Iterations not a number"
},
{
"key": "password",
"salt": "salt",
"iterations": -1,
"dkLen": 16,
"exception": "Bad iterations"
},
{
"key": "password",
"salt": "salt",
"iterations": 1,
"dkLen": "NaN",
"exception": "Key length not a number"
},
{
"key": "password",
"salt": "salt",
"iterations": 1,
"dkLen": -1,
"exception": "Bad key length"
}
]
}
pbkdf2-3.1.3/test/index.js 0000664 0000000 0000000 00000025635 15025343214 0015324 0 ustar 00root root 0000000 0000000 'use strict';
// SHA-1 vectors generated by Node.js
// SHA-256/SHA-512 test vectors from:
// https://stackoverflow.com/questions/5130513/pbkdf2-hmac-sha2-test-vectors
// https://stackoverflow.com/questions/15593184/pbkdf2-hmac-sha-512-test-vectors
var tape = require('tape');
var satisfies = require('semver').satisfies;
var Buffer = require('safe-buffer').Buffer;
var node = require('crypto');
var fixtures = require('./fixtures');
var js = require('../browser');
var browserImpl = require('../lib/sync-browser');
var errMsg = function (name) { return new RegExp(name + ' must be a string, a Buffer, a Uint8Array, or a DataView'); };
var pVersionMajor = parseInt(process.version.split('.')[0].slice(1), 10);
/* istanbul ignore next */
if (pVersionMajor !== 4 || process.browser) {
fixtures.invalid.push({
key: 'password',
salt: 'salt',
iterations: 1,
dkLen: -1,
exception: 'Bad key length'
}, {
key: 'password',
salt: 'salt',
iterations: 1,
dkLen: 4073741824,
exception: 'Bad key length'
});
}
/* istanbul ignore next */
if (pVersionMajor >= 5 || process.browser) {
fixtures.invalid.push({
key: 'password',
salt: 'salt',
iterations: 1,
dkLen: NaN,
exception: 'Bad key length'
}, {
key: 'password',
salt: 'salt',
iterations: 1,
dkLen: Infinity,
exception: 'Bad key length'
});
}
/* istanbul ignore next */
if (pVersionMajor >= 6 || process.browser) {
fixtures.valid.push({
description: 'Unicode salt, no truncation',
key: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
salt: 'mnemonicメートルガバヴァぱばぐゞちぢ十人十色',
iterations: 2048,
dkLen: 64,
results: {
sha1: '7e042a2f41ba17e2235fbc794e22a150816b0f54a1dfe113919fccb7a056066a109385e538f183c92bad896ae8b7d8e0f4cd66df359c77c8c7785cd1001c9a2c',
sha256: '0b57118f2b6b079d9371c94da3a8315c3ada87a1e819b40c4c4e90b36ff2d3c8fd7555538b5119ac4d3da7844aa4259d92f9dd2188e78ac33c4b08d8e6b5964b',
sha512: 'ba553eedefe76e67e2602dc20184c564010859faada929a090dd2c57aacb204ceefd15404ab50ef3e8dbeae5195aeae64b0def4d2eead1cdc728a33ced520ffd',
sha224: 'd76474c525616ce2a527d23df8d6f6fcc4251cc3535cae4e955810a51ead1ec6acbe9c9619187ca5a3c4fd636de5b5fe58d031714731290bbc081dbf0fcb8fc1',
sha384: '15010450f456769467e834db7fa93dd9d353e8bb733b63b0621090f96599ac3316908eb64ac9366094f0787cd4bfb2fea25be41dc271a19309710db6144f9b34',
ripemd160: '255321c22a32f41ed925032043e01afe9cacf05470c6506621782c9d768df03c74cb3fe14a4296feba4c2825e736486fb3871e948f9c413ca006cc20b7ff6d37'
}
});
// 'binary' behaviour, Node 6 defaulted to 'utf-8'
} else {
fixtures.valid.push({
description: 'Unicode salt, suffers from truncation',
key: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
salt: 'mnemonicメートルガバヴァぱばぐゞちぢ十人十色',
iterations: 2048,
dkLen: 64,
results: {
sha1: 'd85d14adcb7bdb5d976160e504f520a98cf71aca4cd5fceadf37759743bd6e1d2ff78bdd4403552aef7658094384b341ede80fffd334182be076f9d988a0a40f',
sha256: 'b86b5b900c29ed2724359afd793e10ffc1eb0e7d6f624fc9c85b8ac1785d9a2f0575af52a2338e611f2e6cffdee544adfff6f3d4f43be2ba0e2bd7e917b38a14',
sha512: '3a863fa00f2e97a83fa9b18805e0047a6282cbae0ff48438b33a14475771c52d05137daa12e364cb34d84547ac07568b801c5c7f8dd4baaeee18a67a5c6a3377',
sha224: '95727793842437774ad9ae27b8154a6f37f208b75a03d3a4d4a2443422bb6bc85efcfa92aa4376926ea89a8f5a63118eecdb58c8ca28ab31007da79437e0a1ef',
sha384: '1a7e02e8ba0e357269a55642024b85738b95238d6cdc49bc440204995aefeff499e22cba76d4c7e96b7d4a9596a70e744f53fa94f3547e7dc506fcaf16ceb4a2',
ripemd160: 'bac7849db13e90604620945695288ffee20369107c3a6632d6b1d6b926175ac914319b5a742e6b1a37b82841b6f010ad47ebdb5cd608026eb48513bf68cb54f5'
}
});
}
function runTests(name, compat) {
tape(name + ' defaults to sha1 and handles buffers', function (t) {
t.plan(3);
var resultSync = compat.pbkdf2Sync('password', 'salt', 1, 32);
t.equal(resultSync.toString('hex'), '0c60c80f961f0e71f3a9b524af6012062fe037a6e0f0eb94fe8fc46bdc637164');
compat.pbkdf2(Buffer.from('password'), Buffer.from('salt'), 1, 32, function (err, result) {
t.error(err);
t.equal(result.toString('hex'), '0c60c80f961f0e71f3a9b524af6012062fe037a6e0f0eb94fe8fc46bdc637164');
});
});
tape(name + ' should throw if no callback is provided', function (t) {
t.plan(1);
t['throws'](function () {
compat.pbkdf2('password', 'salt', 1, 32, 'sha1');
}, /No callback provided to pbkdf2/);
});
tape(name + ' should throw if the password is not a string or an ArrayBuffer', function (t) {
t.plan(2);
t['throws'](
function () { compat.pbkdf2(['a'], 'salt', 1, 32, 'sha1', function () {}); },
errMsg('Password')
);
t['throws'](
function () { compat.pbkdf2Sync(['a'], 'salt', 1, 32, 'sha1'); },
errMsg('Password')
);
});
tape(name + ' should throw if the salt is not a string or an ArrayBuffer', function (t) {
t.plan(2);
t['throws'](
function () { compat.pbkdf2('pass', ['salt'], 1, 32, 'sha1'); },
errMsg('Salt')
);
t['throws'](
function () { compat.pbkdf2Sync('pass', ['salt'], 1, 32, 'sha1'); },
errMsg('Salt')
);
});
var algos = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160'];
algos.forEach(function (algorithm) {
var isUnsupported = satisfies(process.version, '^17') && algorithm === 'ripemd160';
tape(
name + ' + ' + algorithm,
{ skip: isUnsupported && 'this node version does not support ' + algorithm },
function (t) {
fixtures.valid.forEach(function (f) {
var key, keyType, salt, saltType;
if (f.keyUint8Array) {
key = new Uint8Array(f.keyUint8Array);
keyType = 'Uint8Array';
} else if (f.keyInt32Array) {
key = new Int32Array(f.keyInt32Array);
keyType = 'Int32Array';
} else if (f.keyFloat64Array) {
key = new Float64Array(f.keyFloat64Array);
keyType = 'Float64Array';
} else if (f.keyHex) {
key = Buffer.from(f.keyHex, 'hex');
keyType = 'hex';
} else {
key = f.key;
keyType = 'string';
}
if (f.saltUint8Array) {
salt = new Uint8Array(f.saltUint8Array);
saltType = 'Uint8Array';
} else if (f.saltInt32Array) {
salt = new Int32Array(f.saltInt32Array);
saltType = 'Int32Array';
} else if (f.saltFloat64Array) {
salt = new Float64Array(f.saltFloat64Array);
saltType = 'Float64Array';
} else if (f.saltHex) {
salt = Buffer.from(f.saltHex, 'hex');
saltType = 'hex';
} else {
salt = f.salt;
saltType = 'string';
}
var expected = f.results[algorithm];
var description = algorithm + ' encodes "' + key + '" (' + keyType + ') with salt "' + salt + '" (' + saltType + ') with ' + algorithm + ' to ' + expected;
t.test(name + ' async w/ ' + description, function (st) {
st.plan(3);
compat.pbkdf2(key, salt, f.iterations, f.dkLen, algorithm, function (err, result) {
st.error(err);
var hash = result.toString('hex');
st.doesNotMatch(hash, /^0+$/, 'is not the all-zeroes result');
st.equal(hash, expected);
});
});
t.test(name + 'sync w/ ' + description, function (st) {
st.plan(2);
var result = compat.pbkdf2Sync(key, salt, f.iterations, f.dkLen, algorithm);
var hash = result.toString('hex');
st.doesNotMatch(hash, /^0+$/, 'is not the all-zeroes result');
st.equal(hash, expected);
});
});
fixtures.invalid.forEach(function (f) {
var description = algorithm + ' should throw ' + f.exception;
t.test(name + ' async w/ ' + description, function (st) {
st.plan(1);
/* istanbul ignore next */
function noop() {}
st['throws'](function () {
compat.pbkdf2(f.key, f.salt, f.iterations, f.dkLen, f.algo, noop);
}, new RegExp(f.exception));
});
t.test(name + ' sync w/' + description, function (st) {
st.plan(1);
st['throws'](function () {
compat.pbkdf2Sync(f.key, f.salt, f.iterations, f.dkLen, f.algo);
}, new RegExp(f.exception));
});
});
t.end();
}
);
});
}
tape('does not return all zeroes for any algorithm', function (t) {
var algos2 = [
// 'sha3-512',
// 'sha3-256',
// 'SHA3-384',
// 'blake2b512',
'Sha256',
'ShA256',
'Sha512',
'sha512-256',
'SHA512',
'SHA1',
's-h-a-1',
'sha-1',
'RMD160',
'RIPEMD-160',
'ripemd-160'
];
algos2.forEach(function (algo) {
var throwCount = 0;
var impls = { __proto__: null, node: node.pbkdf2Sync, lib: js.pbkdf2Sync, browser: browserImpl };
var results = { __proto__: null };
var throws = { __proto__: null };
for (var implName in impls) { // eslint-disable-line no-restricted-syntax
var pbkdf2Sync = impls[implName];
try {
var key = pbkdf2Sync('secret', 'salt', 1e4, 64, algo).toString('hex');
results[implName] = key;
t.doesNotMatch(key, /^0+$/, implName + ' does not return all zeros for ' + algo);
} catch (e) {
throwCount += 1;
throws[implName] = true;
t.ok(e, implName + ' throws for ' + algo);
t.comment(e);
}
}
if (throwCount === 0) {
t.equal(throwCount, 0, 'all implementations return a value for ' + algo);
t.deepEqual(throws, { __proto__: null }, 'no implementations throw for ' + algo);
t.equal(
results.node,
results.lib,
'node and js pbkdf2Sync should return the same value for ' + algo
);
t.equal(
results.node,
results.browser,
'node and browser pbkdf2Sync should return the same value for ' + algo
);
} else {
var expected = {
__proto__: null,
node: true,
lib: true,
browser: true
};
if (
(algo.toLowerCase() === 'ripemd-160' || algo.toLowerCase() === 'rmd160')
&& satisfies(process.version, '< 18') // node < 18 doesn't support ripemd160
) {
if (!throws.browser) {
delete expected.browser;
}
if (!throws.lib) {
delete expected.lib;
}
}
if (
algo.toLowerCase() === 'sha-1'
&& satisfies(process.version, '< 17') // node < 17 doesn't support "sha-1"
&& !throws.lib
&& !throws.browser
) {
delete expected.lib;
delete expected.browser;
}
if (
(algo.toLowerCase() === 'sha256' || algo.toLowerCase() === 'sha512')
&& satisfies(process.version, '< 10') // node < 10 doesn't support "sha256" or "sha512"
&& !throws.lib
&& !throws.browser
) {
delete expected.lib;
delete expected.browser;
}
t.deepEqual(
throws,
expected,
'all implementations throw for ' + algo,
{ todo: throwCount === 1 && algo === 'sha512-256' && 'sha.js does not yet support sha512-256' }
);
}
});
t.end();
});
runTests('JavaScript pbkdf2', js);
var assign = require('object.assign');
/* istanbul ignore next */
if (!process.browser) {
/* eslint global-require: 0 */
var browser = assign({}, js);
browser.pbkdf2Sync = browserImpl;
runTests('browser pbkdf2', {
pbkdf2: browser.pbkdf2,
pbkdf2Sync: require('../lib/sync-browser')
});
runTests('node pbkdf2', require('../'));
}
pbkdf2-3.1.3/test/to-buffer.js 0000664 0000000 0000000 00000001107 15025343214 0016072 0 ustar 00root root 0000000 0000000 'use strict';
var test = require('tape');
var SafeBuffer = require('safe-buffer').Buffer;
var toBuffer = require('../lib/to-buffer');
test('toBuffer', function (t) {
var nodeBuffer = new Buffer([1, 2, 3]);
var safeBuffer = new SafeBuffer([4, 5, 6]);
t.equal(toBuffer(nodeBuffer, 'utf-8', 'bob'), nodeBuffer, 'should return the Buffer when given a Buffer');
t.equal(toBuffer(safeBuffer, 'utf-8', 'bob'), safeBuffer, 'should return the Buffer when given a Buffer');
t.deepEqual(toBuffer('abc', 'utf-8', 'bob'), new Buffer('abc'), 'converts string to Buffer');
t.end();
});