|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- var assert = require("assert");
- var pbkdf2 = require("../src/pbkdf2");
-
- describe("pbkdf2", function() {
- it("secret, salt, 2 iterations, 32 keylen, sha256 hash", function() {
- return pbkdf2("secret", "salt", 2, 32, "sha256").then(function(key) {
- assert.equal(
- "f92f45f9df4c2aeabae1ed3c16f7b64660c1f8e377fa9b4699b23c2c3a29f569",
- key
- );
- });
- });
- it("use pbkdf2 with 8192 iterations and sha256", function() {
- return pbkdf2(
- "password",
- "test@example.org",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "d8af5f918db6b65b1db3d3984e5a400e39e1dbb19462220e4431de283809f472",
- key
- );
- });
- });
- it("customize number of iterations", function() {
- return pbkdf2(
- "password",
- "test@example.org",
- 4096,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "0a91208545e3aa4935d3a22984ca097a7669259a04d261ac16361bdc1a2e960f",
- key
- );
- });
- });
- it("customize key length", function() {
- return pbkdf2(
- "password",
- "test@example.org",
- 8192,
- 16,
- "sha256"
- ).then(function(key) {
- assert.equal("d8af5f918db6b65b1db3d3984e5a400e", key);
- });
- });
- it("customize iterations and key length", function() {
- return pbkdf2(
- "password",
- "test@example.org",
- 4096,
- 16,
- "sha256"
- ).then(function(key) {
- assert.equal("0a91208545e3aa4935d3a22984ca097a", key);
- });
- });
- it("utf8 parameter", function() {
- return pbkdf2(
- "♥ LessPass ♥",
- "test@example.org",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "997fe81d3d0db236e039c75efdb487f17a902fdf94f9dacaa9884329c85d9651",
- key
- );
- });
- });
- it("auto generated test 0", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 1", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 2", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 3", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 4", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 5", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 6", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 7", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 8", function() {
- return pbkdf2(
- "password",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
- key
- );
- });
- });
- it("auto generated test 9", function() {
- return pbkdf2("password", "lesspass", 8192, 32, "sha256").then(function(
- key
- ) {
- assert.equal(
- "7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116",
- key
- );
- });
- });
- it("auto generated test 10", function() {
- return pbkdf2(
- "password2",
- "contact@lesspass.com",
- 8192,
- 32,
- "sha256"
- ).then(function(key) {
- assert.equal(
- "ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4",
- key
- );
- });
- });
- });
|