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.

entropy.tests.js 2.7 KiB

8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
8 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var assert = chai.assert;
  2. describe('LessPass v2', function () {
  3. describe('entropy', function () {
  4. it('calc entropy pbkdf2 with default params (100000 iterations, 32 bytes length, sha256 digest)', function () {
  5. this.timeout(10000);
  6. var site = 'example.org';
  7. var login = 'contact@example.org';
  8. var masterPassword = 'password';
  9. var passwordProfile = {
  10. iterations: 100000,
  11. keylen: 32,
  12. digest: 'sha256',
  13. counter: 1
  14. };
  15. return LessPass._calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) {
  16. assert.equal('dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e', entropy);
  17. });
  18. });
  19. it('calc entropy with different options (8192 iterations, 16 bytes length, sha512 digest)', function () {
  20. var site = 'example.org';
  21. var login = 'contact@example.org';
  22. var masterPassword = 'password';
  23. var passwordProfile = {
  24. iterations: 8192,
  25. keylen: 16,
  26. digest: 'sha512',
  27. counter: 1
  28. };
  29. return LessPass._calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) {
  30. assert.equal('fff211c16a4e776b3574c6a5c91fd252', entropy);
  31. });
  32. });
  33. it('calc entropy different if counter different 1', function () {
  34. var site = 'example.org';
  35. var login = 'contact@example.org';
  36. var masterPassword = 'password';
  37. var passwordProfile1 = {iterations: 1, keylen: 16, digest: 'sha256', counter: 1};
  38. return LessPass._calcEntropy(site, login, masterPassword, passwordProfile1).then(function (entropy) {
  39. assert.equal('d3ec1e988dd0b3640c7491cd2c2a88b5', entropy)
  40. });
  41. });
  42. it('calc entropy different if counter different 2', function () {
  43. var site = 'example.org';
  44. var login = 'contact@example.org';
  45. var masterPassword = 'password';
  46. var passwordProfile2 = {iterations: 1, keylen: 16, digest: 'sha256', counter: 2};
  47. return LessPass._calcEntropy(site, login, masterPassword, passwordProfile2).then(function (entropy) {
  48. assert.equal('ddfb1136260f930c21f6d72f6eddbd40', entropy)
  49. });
  50. });
  51. it('consume entropy', function () {
  52. var password = LessPass._consumeEntropy('', bigInt(4 * 4 + 2), "abcd", 2);
  53. assert.equal('ca', password.value);
  54. assert.equal(1, password.entropy)
  55. });
  56. });
  57. });