scytl-keystore-validation.spec.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. /* jshint node:true */
  9. 'use strict';
  10. var keyStore = require('../lib/index');
  11. var cryptoPolicy = require('scytl-cryptopolicy');
  12. describe('The key store module that should be able to ...', function() {
  13. var PASSWORD = '01234567890abcdefghijk';
  14. var PRIVATE_KEY_ALIAS = 'user1';
  15. var SECRET_KEY_ALIAS = 'symmetricalias1';
  16. var ELGAMAL_PRIVATE_KEY_ALIAS = 'elgamalprivatekeyalias1';
  17. var SCYTL_KEY_STORE = {
  18. 'salt': 'AWnL9mtD1UoAQ58l+8GH9aHPlrDMgeMF8m+0wHyCPAI=',
  19. 'secrets': {
  20. 'symmetricalias1':
  21. '7mgsaxqwL1oBASLQ40bcP5btCcLF1kgo+382PsIeqkyw3JeQIYsEIdRuUxdmP/9lUqQj+2sxxlCk6XU=',
  22. 'symmetricalias2':
  23. 'hF+vhbcCy0odpXrpPAohUKrnX3LP1sLv9t7QCaBgdStg8rvx55opMrV+l3+ywOwx6u3jKfhTbmL4tnM='
  24. },
  25. 'store':
  26. 'MIIo1QIBAzCCKI8GCSqGSIb3DQEHAaCCKIAEgih8M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lbWSec69SujR8HRPFQx0fBVsjdcL/g1MeX8Y9FzPRwQuTZiAmc320HBJO5bgixmkZgWrfESqQQx96mXZR///Cic423+D8LViSqUO4pfX1XSttCLnJtFKGvWpaOmfEK6OsVFOeP24Cf3vXtbtNqev/84zTDs2+DB+FEJq1mFZCV5O4iob76nF214rzZlpc5G66q1ZQ6hWPu14h2VdSe9opp6rVxk4dRg1JdceNZ9PmvjaiX5RtS0THKZdzNgWbj57bX1TPxFwprHREGMQWgX0ioK/ZI+K6ZfmLtuv/9Vh0FEYuWps2ACSaTE+bR4JmonEJPg15ANjOzug5AtyVIGum1fMKp0jupyK1K8qvXZ7uk6vLpHvEcwIhPqC9luipgJjbVTHGE0cPNc+EFfdnM2QcbcSPiZosZlFxB0M6XqnL1KGPkUBuDZQuvAfC057g4OjU8Xu+5OuruXgcMnMQCYhCj00C2EvlbUc/C/+iWLRwQWuMJMwVqxNwf8gvBCLaiTQOPlUIIFn7JtFnqxb4wR/eV0nMbcKEbsmCVDICnwCNp0uhMivje0ECg8rYzUJnPIRj9OpYwUCO2/t/npKwCA78oW5Au5N1wlgh3zOOigUHQuLOp4XCJckJev/yKCehbyWFGysupEXw9X3r2NiumDm6Q5u8deARy9N6oHZpkNkr1z3uQhgn0A/q7jjuE/v2q98nhJPCxShkfJjW0O72O+bwgPmCL6+75Q0NNu71/7F+Ex4tfxZy+IJEkU1NdNBztdxPC4whxxAx2FHlzwNj6BS/8rZVcmSOzfiqIdTpxrvDHy7KDtw5EIipTY5uZIZ0wPTAhMAkGBSsOAwIaBQAEFN8/+hqTNNrLi6iVazDqnxResURRBBRe3Z0mBQG7oRJl7k0p9XHUJLJI5QICBAA='
  27. };
  28. var SCYTL_KEY_STORE_WITH_ELGAMAL_KEYS = {
  29. 'salt': '7Q951QtBynbVfljodmtQmg351nq/kmxcHfCwdrTUdng=',
  30. 'egPrivKeys': {
  31. 'elgamalprivatekeyalias1':
  32. 'HA5aI6+JCB1/AIeb70bcMetz+1AuY9zTh4G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5kS0/G2EDZ3ZG5AQEwQmczf4kNVWwk62XhTRcKcqdRRX/7h6OOMDc1nP5/GmcderDbaRFV28eFrzi4Mjjcjzpz889ttmHXPN7D8AvbTtHqRm4ujAFAvYbhU5hguY7x7BP+OOB01jvOM/F1U7Zzgg12FQoaMvcacJECaMR1Alz22htPaK0VIxCmxZd+q/T1xAJYPNwver4QbKJX6Pg==',
  33. 'elgamalprivatekeyalias2':
  34. 'vezAhuUI9Rqb9SNp9QXGpdiiKjJCGjK3MWmQbSC+NV+4HYEKKuCP6N9RuKAprssqmGYDWUc3ecYD6JsRlW2PNnbAv0oK/aGGogh3gqrVDLqBqSet1hmnN3NImAmXscpioAAnfPd1RR4V2lv8+Lc3aUPKTvNwl1P3jATM3TViGzb0hxMhsCuUwFOX'
  35. },
  36. 'store':
  37. 'MFUCAQMwEQYJKoZIhvcNAQcBoAQEAjAAMD0wITAJBgUrDgMCGgUABBR+zoG7NsLvE8zqUFX7HXeP/yK07gQUQaC4BDlbcjaPJxp4KTcJh9wSzMMCAgQA'
  38. };
  39. var keyStoreService_;
  40. var scytlKeyStore_;
  41. var scytlKeyStoreWithElGamalKeys_;
  42. var nonObject_;
  43. var emptyObject_;
  44. var nonString_;
  45. var nonJsonString_;
  46. var wrongPassword_;
  47. var wrongAlias_;
  48. var wrongSubjectCn_;
  49. var keyStoreWithNoSalt_ = clone(SCYTL_KEY_STORE);
  50. delete keyStoreWithNoSalt_.salt;
  51. var keyStoreWithUndefinedSalt_ = clone(SCYTL_KEY_STORE);
  52. keyStoreWithUndefinedSalt_.salt = undefined;
  53. var keyStoreWithNoStore_ = clone(SCYTL_KEY_STORE);
  54. delete keyStoreWithNoStore_.store;
  55. var keyStoreWithUndefinedStore_ = clone(SCYTL_KEY_STORE);
  56. keyStoreWithUndefinedStore_.store = undefined;
  57. beforeAll(function() {
  58. var policy = cryptoPolicy.newInstance();
  59. policy.symmetric.secretKey.encryption.lengthBytes = 32;
  60. policy.primitives.keyDerivation.pbkdf.keyLengthBytes = 16;
  61. policy.primitives.keyDerivation.pbkdf.minSaltLengthBytes = 20;
  62. policy.primitives.keyDerivation.pbkdf.hashAlgorithm = 'SHA256';
  63. policy.primitives.keyDerivation.pbkdf.numIterations = 1;
  64. keyStoreService_ = keyStore.newService({policy: policy});
  65. scytlKeyStore_ =
  66. keyStoreService_.newScytlKeyStore(SCYTL_KEY_STORE, PASSWORD);
  67. policy = cryptoPolicy.newInstance();
  68. policy.symmetric.secretKey.encryption.lengthBytes = 32;
  69. policy.primitives.keyDerivation.pbkdf.keyLengthBytes = 16;
  70. policy.primitives.keyDerivation.pbkdf.minSaltLengthBytes = 32;
  71. policy.primitives.keyDerivation.pbkdf.hashAlgorithm = 'SHA256';
  72. policy.primitives.keyDerivation.pbkdf.numIterations = 32000;
  73. var keyStoreService = keyStore.newService({policy: policy});
  74. scytlKeyStoreWithElGamalKeys_ = keyStoreService.newScytlKeyStore(
  75. SCYTL_KEY_STORE_WITH_ELGAMAL_KEYS, PASSWORD);
  76. nonObject_ = 999;
  77. emptyObject_ = {};
  78. nonString_ = 999;
  79. nonJsonString_ = 'Not a JSON string';
  80. wrongPassword_ = 'Wrong password';
  81. wrongAlias_ = 'Wrong alias';
  82. wrongSubjectCn_ = 'Wrong subject common name';
  83. });
  84. describe('create a key store service that should be able to ..', function() {
  85. it('throw an error when loading a Scytl key store, using an invalid key store data object or an invalid JSON serialization',
  86. function() {
  87. expect(function() {
  88. keyStoreService_.newScytlKeyStore(undefined, PASSWORD);
  89. }).toThrow();
  90. expect(function() {
  91. keyStoreService_.newScytlKeyStore(null, PASSWORD);
  92. }).toThrow();
  93. expect(function() {
  94. keyStoreService_.newScytlKeyStore({}, PASSWORD);
  95. }).toThrow();
  96. expect(function() {
  97. keyStoreService_.newScytlKeyStore(keyStoreWithNoSalt_, PASSWORD);
  98. }).toThrow();
  99. expect(function() {
  100. keyStoreService_.newScytlKeyStore(
  101. keyStoreWithUndefinedSalt_, PASSWORD);
  102. }).toThrow();
  103. expect(function() {
  104. keyStoreService_.newScytlKeyStore(keyStoreWithNoStore_, PASSWORD);
  105. }).toThrow();
  106. expect(function() {
  107. keyStoreService_.newScytlKeyStore(
  108. keyStoreWithUndefinedStore_, PASSWORD);
  109. }).toThrow();
  110. expect(function() {
  111. keyStoreService_.newScytlKeyStore(nonJsonString_, PASSWORD);
  112. }).toThrow();
  113. });
  114. it('throw an error when loading a Scytl key store, using an invalid password',
  115. function() {
  116. expect(function() {
  117. keyStoreService_.newScytlKeyStore(SCYTL_KEY_STORE);
  118. }).toThrow();
  119. expect(function() {
  120. keyStoreService_.newScytlKeyStore(SCYTL_KEY_STORE, undefined);
  121. }).toThrow();
  122. expect(function() {
  123. keyStoreService_.newScytlKeyStore(SCYTL_KEY_STORE, null);
  124. }).toThrow();
  125. expect(function() {
  126. keyStoreService_.newScytlKeyStore(SCYTL_KEY_STORE, nonString_);
  127. }).toThrow();
  128. expect(function() {
  129. keyStoreService_.newScytlKeyStore(SCYTL_KEY_STORE, wrongPassword_);
  130. }).toThrow();
  131. });
  132. describe('load a Scytl key store that should be able to', function() {
  133. it('throw an error when retrieving a private key, using an invalid alias',
  134. function() {
  135. expect(function() {
  136. scytlKeyStore_.getPrivateKey(undefined, PASSWORD);
  137. }).toThrow();
  138. expect(function() {
  139. scytlKeyStore_.getPrivateKey(null, PASSWORD);
  140. }).toThrow();
  141. expect(function() {
  142. scytlKeyStore_.getPrivateKey('', PASSWORD);
  143. }).toThrow();
  144. expect(function() {
  145. scytlKeyStore_.getPrivateKey(nonString_, PASSWORD);
  146. }).toThrow();
  147. expect(function() {
  148. scytlKeyStore_.getPrivateKey(wrongAlias_, PASSWORD);
  149. }).toThrow();
  150. });
  151. it('throw an error when retrieving a private key, using an invalid password',
  152. function() {
  153. expect(function() {
  154. scytlKeyStore_.getPrivateKey(PRIVATE_KEY_ALIAS);
  155. }).toThrow();
  156. expect(function() {
  157. scytlKeyStore_.getPrivateKey(PRIVATE_KEY_ALIAS, undefined);
  158. }).toThrow();
  159. expect(function() {
  160. scytlKeyStore_.getPrivateKey(PRIVATE_KEY_ALIAS, null);
  161. }).toThrow();
  162. expect(function() {
  163. scytlKeyStore_.getPrivateKey(PRIVATE_KEY_ALIAS, nonString_);
  164. }).toThrow();
  165. expect(function() {
  166. scytlKeyStore_.getPrivateKey(PRIVATE_KEY_ALIAS, wrongPassword_);
  167. }).toThrow();
  168. });
  169. it('throw an error when retrieving a certificate, using invalid input data',
  170. function() {
  171. expect(function() {
  172. scytlKeyStore_.getCertificate();
  173. }).toThrow();
  174. expect(function() {
  175. scytlKeyStore_.getCertificate(undefined);
  176. }).toThrow();
  177. expect(function() {
  178. scytlKeyStore_.getCertificate(null);
  179. }).toThrow();
  180. expect(function() {
  181. scytlKeyStore_.getCertificate('');
  182. }).toThrow();
  183. expect(function() {
  184. scytlKeyStore_.getCertificate(nonString_);
  185. }).toThrow();
  186. expect(function() {
  187. scytlKeyStore_.getCertificate(wrongAlias_);
  188. }).toThrow();
  189. });
  190. it('throw an error when retrieving a certificate by subject, using invalid input data',
  191. function() {
  192. expect(function() {
  193. scytlKeyStore_.getCertificateBySubject();
  194. }).toThrow();
  195. expect(function() {
  196. scytlKeyStore_.getCertificateBySubject(undefined);
  197. }).toThrow();
  198. expect(function() {
  199. scytlKeyStore_.getCertificateBySubject(null);
  200. }).toThrow();
  201. expect(function() {
  202. scytlKeyStore_.getCertificateBySubject('');
  203. }).toThrow();
  204. expect(function() {
  205. scytlKeyStore_.getCertificateBySubject(nonString_);
  206. }).toThrow();
  207. expect(function() {
  208. scytlKeyStore_.getCertificateBySubject(wrongSubjectCn_);
  209. }).toThrow();
  210. });
  211. it('throw an error when retrieving a certificate chain, using invalid input data',
  212. function() {
  213. expect(function() {
  214. scytlKeyStore_.getCertificateChain();
  215. }).toThrow();
  216. expect(function() {
  217. scytlKeyStore_.getCertificateChain(undefined);
  218. }).toThrow();
  219. expect(function() {
  220. scytlKeyStore_.getCertificateChain(null);
  221. }).toThrow();
  222. expect(function() {
  223. scytlKeyStore_.getCertificateChain('');
  224. }).toThrow();
  225. expect(function() {
  226. scytlKeyStore_.getCertificateChain(nonString_);
  227. }).toThrow();
  228. expect(function() {
  229. scytlKeyStore_.getCertificateChain(wrongAlias_);
  230. }).toThrow();
  231. });
  232. it('throw an error when retrieving a secret key, using an invalid alias',
  233. function() {
  234. expect(function() {
  235. scytlKeyStore_.getSecretKey(undefined, PASSWORD);
  236. }).toThrow();
  237. expect(function() {
  238. scytlKeyStore_.getSecretKey(null, PASSWORD);
  239. }).toThrow();
  240. expect(function() {
  241. scytlKeyStore_.getSecretKey('', PASSWORD);
  242. }).toThrow();
  243. expect(function() {
  244. scytlKeyStore_.getSecretKey(nonString_, PASSWORD);
  245. }).toThrow();
  246. expect(function() {
  247. scytlKeyStore_.getSecretKey(wrongAlias_, PASSWORD);
  248. }).toThrow();
  249. });
  250. it('throw an error when retrieving a secret key, using an invalid password',
  251. function() {
  252. expect(function() {
  253. scytlKeyStore_.getSecretKey(SECRET_KEY_ALIAS);
  254. }).toThrow();
  255. expect(function() {
  256. scytlKeyStore_.getSecretKey(SECRET_KEY_ALIAS, undefined);
  257. }).toThrow();
  258. expect(function() {
  259. scytlKeyStore_.getSecretKey(SECRET_KEY_ALIAS, null);
  260. }).toThrow();
  261. expect(function() {
  262. scytlKeyStore_.getSecretKey(SECRET_KEY_ALIAS, nonString_);
  263. }).toThrow();
  264. expect(function() {
  265. scytlKeyStore_.getSecretKey(SECRET_KEY_ALIAS, wrongPassword_);
  266. }).toThrow();
  267. });
  268. it('throw an error when retrieving an ElGamal private key, using an invalid alias',
  269. function() {
  270. expect(function() {
  271. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  272. undefined, PASSWORD);
  273. }).toThrow();
  274. expect(function() {
  275. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(null, PASSWORD);
  276. }).toThrow();
  277. expect(function() {
  278. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey('', PASSWORD);
  279. }).toThrow();
  280. expect(function() {
  281. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  282. nonString_, PASSWORD);
  283. }).toThrow();
  284. expect(function() {
  285. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  286. wrongAlias_, PASSWORD);
  287. }).toThrow();
  288. });
  289. it('throw an error when retrieving an ElGamal private key, using an invalid password',
  290. function() {
  291. expect(function() {
  292. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  293. ELGAMAL_PRIVATE_KEY_ALIAS);
  294. }).toThrow();
  295. expect(function() {
  296. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  297. ELGAMAL_PRIVATE_KEY_ALIAS, undefined);
  298. }).toThrow();
  299. expect(function() {
  300. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  301. ELGAMAL_PRIVATE_KEY_ALIAS, null);
  302. }).toThrow();
  303. expect(function() {
  304. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  305. ELGAMAL_PRIVATE_KEY_ALIAS, nonString_);
  306. }).toThrow();
  307. expect(function() {
  308. scytlKeyStoreWithElGamalKeys_.getElGamalPrivateKey(
  309. ELGAMAL_PRIVATE_KEY_ALIAS, wrongPassword_);
  310. }).toThrow();
  311. });
  312. });
  313. });
  314. function clone(object) {
  315. return JSON.parse(JSON.stringify(object));
  316. }
  317. });