You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

141 line
4.3 KiB

  1. const assert = require("assert");
  2. const pbkdf2 = require("../src/pbkdf2");
  3. describe("pbkdf2", () => {
  4. it("secret, salt, 2 iterations, 32 keylen, sha256 hash", () =>
  5. pbkdf2("secret", "salt", 2, 32, "sha256").then((key) => {
  6. assert.equal(
  7. "f92f45f9df4c2aeabae1ed3c16f7b64660c1f8e377fa9b4699b23c2c3a29f569",
  8. key
  9. );
  10. }));
  11. it("use pbkdf2 with 8192 iterations and sha256", () =>
  12. pbkdf2("password", "test@example.org", 8192, 32, "sha256").then((key) => {
  13. assert.equal(
  14. "d8af5f918db6b65b1db3d3984e5a400e39e1dbb19462220e4431de283809f472",
  15. key
  16. );
  17. }));
  18. it("customize number of iterations", () =>
  19. pbkdf2("password", "test@example.org", 4096, 32, "sha256").then((key) => {
  20. assert.equal(
  21. "0a91208545e3aa4935d3a22984ca097a7669259a04d261ac16361bdc1a2e960f",
  22. key
  23. );
  24. }));
  25. it("customize key length", () =>
  26. pbkdf2("password", "test@example.org", 8192, 16, "sha256").then((key) => {
  27. assert.equal("d8af5f918db6b65b1db3d3984e5a400e", key);
  28. }));
  29. it("customize iterations and key length", () =>
  30. pbkdf2("password", "test@example.org", 4096, 16, "sha256").then((key) => {
  31. assert.equal("0a91208545e3aa4935d3a22984ca097a", key);
  32. }));
  33. it("utf8 parameter", () =>
  34. pbkdf2("♥ LessPass ♥", "test@example.org", 8192, 32, "sha256").then(
  35. (key) => {
  36. assert.equal(
  37. "997fe81d3d0db236e039c75efdb487f17a902fdf94f9dacaa9884329c85d9651",
  38. key
  39. );
  40. }
  41. ));
  42. it("auto generated test 0", () =>
  43. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  44. (key) => {
  45. assert.equal(
  46. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  47. key
  48. );
  49. }
  50. ));
  51. it("auto generated test 1", () =>
  52. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  53. (key) => {
  54. assert.equal(
  55. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  56. key
  57. );
  58. }
  59. ));
  60. it("auto generated test 2", () =>
  61. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  62. (key) => {
  63. assert.equal(
  64. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  65. key
  66. );
  67. }
  68. ));
  69. it("auto generated test 3", () =>
  70. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  71. (key) => {
  72. assert.equal(
  73. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  74. key
  75. );
  76. }
  77. ));
  78. it("auto generated test 4", () =>
  79. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  80. (key) => {
  81. assert.equal(
  82. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  83. key
  84. );
  85. }
  86. ));
  87. it("auto generated test 5", () =>
  88. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  89. (key) => {
  90. assert.equal(
  91. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  92. key
  93. );
  94. }
  95. ));
  96. it("auto generated test 6", () =>
  97. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  98. (key) => {
  99. assert.equal(
  100. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  101. key
  102. );
  103. }
  104. ));
  105. it("auto generated test 7", () =>
  106. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  107. (key) => {
  108. assert.equal(
  109. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  110. key
  111. );
  112. }
  113. ));
  114. it("auto generated test 8", () =>
  115. pbkdf2("password", "contact@lesspass.com", 8192, 32, "sha256").then(
  116. (key) => {
  117. assert.equal(
  118. "63d850713d0b2f7f2c4396fe93f4ac0c6bc7485f9e7473c4b8c4a33ec12199c0",
  119. key
  120. );
  121. }
  122. ));
  123. it("auto generated test 9", () =>
  124. pbkdf2("password", "lesspass", 8192, 32, "sha256").then((key) => {
  125. assert.equal(
  126. "7d05ee25597dcc3ac16d082aa910e7707f75be620ed8db5bef7245e2a8579116",
  127. key
  128. );
  129. }));
  130. it("auto generated test 10", () =>
  131. pbkdf2("password2", "contact@lesspass.com", 8192, 32, "sha256").then(
  132. (key) => {
  133. assert.equal(
  134. "ce853092fc54fe88c281e38df97bd5826d64e6bee315dc94939cbba8930df0e4",
  135. key
  136. );
  137. }
  138. ));
  139. });