Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

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