primitives.service.spec.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. describe('Primitives service...', function() {
  9. 'use strict';
  10. describe('should be able to ..', function() {
  11. it('return crypto random bytes generator', function() {
  12. cryptolib('primitives.service', function(box) {
  13. var cryptoRandomBytes = box.primitives.service.getCryptoRandomBytes();
  14. expect(cryptoRandomBytes).toBeDefined();
  15. cryptoRandomBytes.nextRandom(10);
  16. });
  17. });
  18. it('return crypto random integer generator', function() {
  19. cryptolib('primitives.service', function(box) {
  20. var cryptoRandomInteger =
  21. box.primitives.service.getCryptoRandomInteger();
  22. expect(cryptoRandomInteger).toBeDefined();
  23. cryptoRandomInteger.nextRandom(10);
  24. });
  25. });
  26. it('return the message digest of a data array in Base64 encoded format.',
  27. function() {
  28. cryptolib('primitives.service', 'commons.utils', function(box) {
  29. var converters = new box.commons.utils.Converters();
  30. var dataB64 = converters.base64Encode('Ox2fUJq1gAbX');
  31. var arrayDataBase64 = [dataB64];
  32. var digested = box.primitives.service.getHash(arrayDataBase64);
  33. expect(digested).toBeDefined();
  34. });
  35. });
  36. it('return a PBKDF secret key generator.', function() {
  37. cryptolib('primitives.service', function(box) {
  38. var generator = box.primitives.service.getPbkdfSecretKeyGenerator();
  39. expect(generator).toBeDefined();
  40. });
  41. });
  42. });
  43. });