Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

46 wiersze
2.2 KiB

  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. return LessPass._calcEntropy(site, login, masterPassword).then(function (entropy) {
  10. assert.equal('dc33d431bce2b01182c613382483ccdb0e2f66482cbba5e9d07dab34acc7eb1e', entropy);
  11. });
  12. });
  13. it('calc entropy with different options (8192 iterations, 16 bytes length, sha512 digest)', function () {
  14. var site = 'example.org';
  15. var login = 'contact@example.org';
  16. var masterPassword = 'password';
  17. var passwordProfile = {
  18. iterations: 8192,
  19. keylen: 16,
  20. digest: 'sha512',
  21. counter: 1
  22. };
  23. return LessPass._calcEntropy(site, login, masterPassword, passwordProfile).then(function (entropy) {
  24. assert.equal('fff211c16a4e776b3574c6a5c91fd252', entropy);
  25. })
  26. });
  27. it('calc entropy different if counter different', function () {
  28. var site = 'example.org';
  29. var login = 'contact@example.org';
  30. var masterPassword = 'password';
  31. var passwordProfile1 = {iterations: 1, keylen: 16, digest: 'sha256', counter: 1};
  32. var passwordProfile2 = {iterations: 1, keylen: 16, digest: 'sha256', counter: 2};
  33. var p1 = LessPass._calcEntropy(site, login, masterPassword, passwordProfile1);
  34. var p2 = LessPass._calcEntropy(site, login, masterPassword, passwordProfile2);
  35. return Promise.all([p1, p2]).then(function (entropies) {
  36. assert.notEqual(entropies[0], entropies[1])
  37. });
  38. });
  39. it('consume entropy', function () {
  40. var password = LessPass._consumeEntropy('', bigInt(4 * 4 + 2), "abcd", 2);
  41. assert.equal('ca', password.value);
  42. assert.equal(1, password.entropy)
  43. });
  44. });
  45. });