2
0

stores.sks.spec.js 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  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('Stores', function() {
  9. 'use strict';
  10. var testKeystore = {
  11. 'salt': 'AWnL9mtD1UoAQ58l+8GH9aHPlrDMgeMF8m+0wHyCPAI=',
  12. 'secrets': {
  13. 'symmetricalias1':
  14. '7mgsaxqwL1oBASLQ40bcP5btCcLF1kgo+382PsIeqkyw3JeQIYsEIdRuUxdmP/9lUqQj+2sxxlCk6XU=',
  15. 'symmetricalias2':
  16. 'hF+vhbcCy0odpXrpPAohUKrnX3LP1sLv9t7QCaBgdStg8rvx55opMrV+l3+ywOwx6u3jKfhTbmL4tnM='
  17. },
  18. 'store':
  19. 'MIIo1QIBAzCCKI8GCSqGSIb3DQEHAaCCKIAEgih8MIIoeDCCCrUGCSqGSIb3DQEHAaCCCqYEggqiMIIKnjCCBUsGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBQBIb74sxGRGMWR72h36eEyizGvmgICBAAEggTIpNG0MPgmBQSrCCP4Bz+S2WRuB1PmT+2HGFxQyfe39dUZTIIBVEurr7/F1emudb6kGO1YnNXvpVMQ4n18PQS7RFZdTWOUnaDi5ZZSsB+7m+cth8hJuYNsxt8mJs5e8sNQ6HtXdPh78XLxBLple9hWEoeJjUPQ8tkcacBGH/ePs5dANEvIsiNTXcH/Qb33GmprpIAAX1sAcewmWkxVHpy50b7VxHZMM+tz0475lFO8Fs4NYwplIP5FSbsqq2P8JD8dsntdc02rEaLjbIy2coWkUG6bi79wdA8IaZ7PdNlcTWs0navU3LaAC9rznqdUzqmfzA4zDFAVjG2iGzSvmZX1bFGs2ucWQWp01/eNXEb6oLRLkwNXfnEGxBUhAtBBG2kYf+qu9wES6U3e1lTz3JySzIoJoFPVvOUXcpsaQCPvRVqajqZtZEZ2vCq4gQE83e/5/8/shXN8FJLk2hynshgOXeCc/0YbLf29oWXWmu7YR6dc67btlC3kfsZIXBM1e8Egluun8iZwNquPHH/8usGgbHTSbjK50i009x3zIzZH9rzTSxalqkSrT4uLKTnq4OpNEuVm1+nWFpBZmr89Kv4qQvgI1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7F+Ex4tfxZy+IJEkU1NdNBztdxPC4whxxAx2FHlzwNj6BS/8rZVcmSOzfiqIdTpxrvDHy7KDtw5EIipTY5uZIZ0wPTAhMAkGBSsOAwIaBQAEFN8/+hqTNNrLi6iVazDqnxResURRBBRe3Z0mBQG7oRJl7k0p9XHUJLJI5QICBAA='
  20. };
  21. describe('sks', function() {
  22. var data = {
  23. salt: 'CpHq+38iqF3Ls7j97qBQ2A9Diy8=',
  24. secrets: {},
  25. store:
  26. 'MIIW1QIBAzCCFo8GCSqGSIb3DQEHAaCCFoAEghZ8MIIWeDCCCrUGCSqGSIb3DQEHAaCCCqYEggqiMIIKnjCCBUsGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBTi2se0MOLF/EwAkroUjfqP3o13LQICBAAEggTI3MsaE5UDYPZQi8//fWVQEu/Bs/qP7sMmFxey6nABtBjCx0Y5CNYyNXPbujpqGKSpuycw3cgMshhY6KCDsOezaWPJ9Fg2gxjsnoTibdM7G3BnKTkdF/FBYPZaa4Fn0DX9mOZ4/3dLlbID9Bapp1xtF04SBuf6f+Blv6tXXkzUqTMr2cXhVOuQFnT/48XqA9j3k+hFXwdjqH5C1mBX216Se0Rpwf/2YJweaW7z21w0BfcXeNUQB2jfHV11C016XmMVK4RI+gsicwCI3QK0FfmKkPdpuDJw8fVBPykHFN2YHa3k+jlD9UrAOb5MvgcV2EysYKPdfAux7Ih/vwWocAD0j5gIAbKiH4rpTr9l41lQbbi3VpTRGttrIr2rWB8E+ETnE19/ywmhqT+hslZQaW9H5hALKPqeC+JMYo7Kf9Y8YOPHUTYUtklnrmzM/nKEcZ0G+c5uoqiI6imZDypyxDeUdci5ZskNun7w/VV5NdqMOxTvPS1AJ1xo47PrSx41vXFrzTTNvHP1Ma1h02XACTL37bfM37kB5pBKFQbm6aAQkAzvkwoS3qFJDutAO096EVqJbtMtslW3kwh/CF7Eu/h+bHiGLCB3kklOA6T4zNhYAgJKWzFpI0opqIS/z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AGXuPuH7mfbgf4S2Eb5mNjfBeMR1UkL6yqnWkybl9fKkAG3ofn0+8AwnLh8TzL129555/lE+9jOVzh2zxz+nsDpdvjB4e9YIfhCZ1qY2e3Yc6ofkH6ZMZx2/yDSRWqePH8ncI89u27i9PyeWsnu3WS2DC05MYuGvbuaa6PXhYh49GTpJHWbO7bYNnk7IfUDm5PLQ0CQWM7dHcJY/NlaqmXpjNOARI1DOwlyH5wvFuUShN0szBgVcm2gcJ1Pkl+nlFRespcirC4aORHnXPY5zbUQdkPQVFxwxakGHznQtCgq3fHCDONtgVm/n8gsDbgAQIcIlpPkPjV8OiwzTTuQmn+La5EEl0JQ0ZmtvC3l93sUxvev39FSe0BbqWRhPG3JJPSLCddPN/bIF+eaYRsL2xcGyQHyZ92ZTP/4OKb9tzMwHqp9dIBuOKZa7TlgMIAzV1+f1YS7stq31jqYwPTAhMAkGBSsOAwIaBQAEFIL4ft7A4v6F7xHtL5968evRiWjOBBQsjehM4e7vvVXPa3SEHJ3pPWItIAICBAA='
  27. };
  28. describe('sks content', function() {
  29. it('throws an error if it does not have a property called salt',
  30. function() {
  31. cryptolib('stores.sks', function(box) {
  32. expect(function() {
  33. box.stores.sks.SksReader(Object.create(data, {salt: undefined}));
  34. }).toThrow();
  35. });
  36. });
  37. });
  38. describe('should have a sks keystore reader that', function() {
  39. it('opens a sks json object', function() {
  40. cryptolib('stores.sks', function(box) {
  41. var sksReader = new box.stores.sks.SksReader(data);
  42. expect(sksReader.keyStore).toBeDefined();
  43. });
  44. });
  45. it('opens a string containing a stringyfied sks keystore', function() {
  46. cryptolib('stores.sks', function(box) {
  47. var sksReader = new box.stores.sks.SksReader(JSON.stringify(data));
  48. expect(sksReader.keyStore).toBeDefined();
  49. });
  50. });
  51. it('throws an error when trying to open a string containing an invalid or corrupted stringyfied sks keystore',
  52. function() {
  53. cryptolib('stores.sks', function(box) {
  54. expect(function() {
  55. box.stores.sks.SksReader('corrupted keystore');
  56. }).toThrow();
  57. });
  58. });
  59. it('retrieves a secret key associated with a specified alias and password',
  60. function() {
  61. var f_main = function(box) {
  62. var secretKeyFactory =
  63. new box.symmetric.secretkey.factory.SecretKeyFactory();
  64. var secretKeyB64 =
  65. secretKeyFactory.getCryptoSecretKeyGeneratorForEncryption()
  66. .generate();
  67. var passwordBase64 =
  68. secretKeyFactory.getCryptoSecretKeyGeneratorForEncryption()
  69. .generate();
  70. var prepareKeyStore = function() {
  71. var data = {
  72. salt: 'CpHq+38iqF3Ls7j97qBQ2A9Diy8=',
  73. secrets: {},
  74. store:
  75. 'MIIW1QIBAzCCFo8GCSqGSIb3DQEHAaCCFoAEghZ8MIIWeDCCCrUGCSqGSIb3DQEHAaCCCqYEggqiMIIKnjCCBUsGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBTi2se0MOLF/EwAkroUjfqP3o13LQICBAAEggTI3MsaE5UDYPZQi8//fWVQEu/Bs/qP7sMmFxey6nABtBjCx0Y5CNYyNXPbujpqGKSpuycw3cgMshhY6KCDsOezaWPJ9Fg2gxjsnoTibdM7G3BnKTkdF/FBYPZaa4Fn0DX9mOZ4/3dLlbID9Bapp1xtF04SBuf6f+Blv6tXXkzUqTMr2cXhVOuQFnT/48XqA9j3k+hFXwdjqH5C1mBX216Se0Rpwf/2YJweaW7z21w0BfcXeNUQB2jfHV11C016XmMVK4RI+gsicwCI3QK0FfmKkPdpuDJw8fVBPykHFN2YHa3k+jlD9UrAOb5MvgcV2EysYKPdfAux7Ih/vwWocAD0j5gIAbKiH4rpTr9l41lQbbi3VpTRGttrIr2rWB8E+ETnE19/ywmhqT+hslZQaW9H5hALKPqeC+JMYo7Kf9Y8YOPHUTYUtklnrmzM/nKEcZ0G+c5uoqiI6imZDypyxDeUdci5ZskNun7w/VV5NdqMOxTvPS1AJ1xo47PrSx41vXFrzTTNvHP1Ma1h02XACTL37bfM37kB5pBKFQbm6aAQkAzvkwoS3qFJDutAO096EVqJbtMtslW3kwh/CF7Eu/h+bH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vNLN4jT53cqpnmAbX3CUoE/EQ2bu4O5+1AGXuPuH7mfbgf4S2Eb5mNjfBeMR1UkL6yqnWkybl9fKkAG3ofn0+8AwnLh8TzL129555/lE+9jOVzh2zxz+nsDpdvjB4e9YIfhCZ1qY2e3Yc6ofkH6ZMZx2/yDSRWqePH8ncI89u27i9PyeWsnu3WS2DC05MYuGvbuaa6PXhYh49GTpJHWbO7bYNnk7IfUDm5PLQ0CQWM7dHcJY/NlaqmXpjNOARI1DOwlyH5wvFuUShN0szBgVcm2gcJ1Pkl+nlFRespcirC4aORHnXPY5zbUQdkPQVFxwxakGHznQtCgq3fHCDONtgVm/n8gsDbgAQIcIlpPkPjV8OiwzTTuQmn+La5EEl0JQ0ZmtvC3l93sUxvev39FSe0BbqWRhPG3JJPSLCddPN/bIF+eaYRsL2xcGyQHyZ92ZTP/4OKb9tzMwHqp9dIBuOKZa7TlgMIAzV1+f1YS7stq31jqYwPTAhMAkGBSsOAwIaBQAEFIL4ft7A4v6F7xHtL5968evRiWjOBBQsjehM4e7vvVXPa3SEHJ3pPWItIAICBAA='
  76. };
  77. var f = function(box) {
  78. var cipherFactory =
  79. new box.symmetric.cipher.factory.SymmetricCipherFactory();
  80. var pbkdfGeneratorfactory =
  81. new box.primitives.derivation.factory
  82. .SecretKeyGeneratorFactory();
  83. var converters = new box.commons.utils.Converters();
  84. var aesCipher = cipherFactory.getCryptoSymmetricCipher();
  85. var cryptoPbkdfSecretKeyGenerator =
  86. pbkdfGeneratorfactory.createPBKDF();
  87. var saltB64 = 'CpHq+38iqF3Ls7j97qBQ2A9Diy8=';
  88. var passwordB64 = cryptoPbkdfSecretKeyGenerator.generateSecret(
  89. passwordBase64, saltB64);
  90. var aliasAndSecretKey =
  91. 'alias1' + converters.base64Decode(secretKeyB64);
  92. var aliasAndSecretKeyB64 =
  93. converters.base64Encode(aliasAndSecretKey);
  94. data.secrets.alias1 =
  95. aesCipher.encrypt(passwordB64, aliasAndSecretKeyB64);
  96. };
  97. f.policies = {
  98. primitives: {
  99. derivation: {
  100. pbkdf: {
  101. provider:
  102. Config.primitives.derivation.pbkdf.provider.FORGE,
  103. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  104. saltLengthBytes: 20,
  105. keyLengthBytes: 32,
  106. iterations:
  107. Config.primitives.derivation.pbkdf.iterations.I_1
  108. }
  109. }
  110. },
  111. symmetric: {
  112. cipher: {
  113. provider: Config.symmetric.cipher.provider.FORGE,
  114. algorithm: {
  115. AES128_GCM: {
  116. name:
  117. Config.symmetric.cipher.algorithm.AES128_GCM.name,
  118. keyLengthBytes: 32,
  119. tagLengthBytes: Config.symmetric.cipher.algorithm
  120. .AES128_GCM.tagLengthBytes
  121. }
  122. },
  123. initializationVectorLengthBytes:
  124. Config.symmetric.cipher.initializationVectorLengthBytes
  125. .IV_12,
  126. secureRandom: {
  127. provider:
  128. Config.symmetric.cipher.secureRandom.provider.SCYTL
  129. }
  130. }
  131. }
  132. };
  133. cryptolib(
  134. 'symmetric.cipher', 'commons.utils', 'primitives.derivation',
  135. f);
  136. return data;
  137. };
  138. var data = prepareKeyStore();
  139. var sksReader = new box.stores.sks.SksReader(data);
  140. var retrievedSecretKey =
  141. sksReader.getSecretKey('alias1', passwordBase64);
  142. expect(retrievedSecretKey).toEqual(secretKeyB64);
  143. };
  144. f_main.policies = {
  145. symmetric: {
  146. secretkey: {
  147. encryption: {lengthBytes: 32},
  148. mac: {
  149. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  150. },
  151. secureRandom: {
  152. provider:
  153. Config.symmetric.secretkey.secureRandom.provider.SCYTL
  154. }
  155. },
  156. cipher: {
  157. provider: Config.symmetric.cipher.provider.FORGE,
  158. algorithm: {
  159. AES128_GCM: {
  160. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  161. keyLengthBytes: 32,
  162. tagLengthBytes: Config.symmetric.cipher.algorithm
  163. .AES128_GCM.tagLengthBytes
  164. }
  165. },
  166. initializationVectorLengthBytes:
  167. Config.symmetric.cipher.initializationVectorLengthBytes
  168. .IV_12,
  169. secureRandom: {
  170. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  171. }
  172. }
  173. },
  174. primitives: {
  175. derivation: {
  176. pbkdf: {
  177. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  178. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  179. saltLengthBytes: 20,
  180. keyLengthBytes:
  181. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_32,
  182. iterations: Config.primitives.derivation.pbkdf.iterations.I_1
  183. }
  184. }
  185. }
  186. };
  187. cryptolib(
  188. 'stores.sks', 'commons.utils', 'symmetric.secretkey', f_main);
  189. });
  190. it('throws an error if you try to retrieve a secret key providing an alias not defined in the keyStore',
  191. function() {
  192. cryptolib('stores.sks', function(box) {
  193. var sksReader = new box.stores.sks.SksReader(data);
  194. var thrownError = false;
  195. try {
  196. sksReader.getSecretKey('alias2');
  197. } catch (error) {
  198. thrownError = true;
  199. }
  200. expect(thrownError).toBeTruthy();
  201. });
  202. });
  203. it('retrieves a secret key and a private key from a real .sks key store',
  204. function() {
  205. var f_main = function(box) {
  206. var data = {
  207. 'salt': 'xwZO9BDmu+rREWpt3lGWsWL8Pp9lHYf+5upIllTmWKw=',
  208. 'secrets': {
  209. 'symmetric':
  210. '4ok9VK1L+DNRYACKC2CpyEFaIr8HDAA8L4UFCO/luSjO/5O8XFPeYMx03PUEHZ3kVy/+3vM='
  211. },
  212. 'store':
  213. 'MIIbKQIBAzCCGuMGCSqGSIb3DQEHAaCCGtQEghrQMIIazDCCCrEGCSqGSIb3DQEHAaCCCqIEggqeMIIKmjCCBUkGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBT/H16QimzbCtIynQNTqFntOVZKOwICBAAEggTIMxv+kiaAseUg7dMpfI7UDN5VtnqIUKUkcDq5YcOIPlvOqteeHN6mp8LU+6Ur6k3mQNDcCIu2FMLXaLatmsvhSUHrzCf3h+10vjAaE8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ntuOBqVx9qjrSr5DL/KRIkLr4vSjumFa995k0t9lNh4Fh4TgDSdVnTnGd/7U8ZxWXDVEiGPXzIenQHvi6n+/AsOwYKe4wHbs3GNyoytvvupzwF6h9SSD6kyLObzDhcXyw3F0BnIbhoOlcADB2MFEnHuFiiA2FjakYwTJ4gx9sXGdGpyldnnLprKyDmscU21EgK4+qO8pOQe2ThrknqgzRHgViOjcaTzJ1+OGYA2zEaQuTNMAC50EVZkGwBMkPcWe/AMD0wITAJBgUrDgMCGgUABBSB1iwNkYzcmk6DSmuVuT42y9I+KwQUBqnV3PqGKa2wYwazLM/OwCCc3P0CAgQA'
  214. };
  215. var sksReader = new box.stores.sks.SksReader(data);
  216. var passwordBase64 = 'UUtKTzZLT1ZCQkY0VzNaWVpPN0M2V1IzRzY=';
  217. var retrievedSecretKeyB64 =
  218. sksReader.getSecretKey('symmetric', passwordBase64);
  219. expect(retrievedSecretKeyB64).toBeDefined();
  220. var converters = new box.commons.utils.Converters();
  221. var secretKey = converters.base64Decode(retrievedSecretKeyB64);
  222. expect(secretKey.length === 16).toBeTruthy();
  223. var privateKeyChain = sksReader.getPrivateKeyChain(passwordBase64);
  224. expect(privateKeyChain).toBeDefined();
  225. for (var key in privateKeyChain.map) {
  226. if (typeof key !== 'undefined') {
  227. expect(privateKeyChain.map[key]).toBeDefined();
  228. }
  229. }
  230. };
  231. f_main.policies = {
  232. symmetric: {
  233. secretkey: {
  234. encryption: {lengthBytes: 16},
  235. mac: {
  236. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  237. },
  238. secureRandom: {
  239. provider:
  240. Config.symmetric.secretkey.secureRandom.provider.SCYTL
  241. }
  242. },
  243. cipher: {
  244. provider: Config.symmetric.cipher.provider.FORGE,
  245. algorithm: {
  246. AES128_GCM: {
  247. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  248. keyLengthBytes: 16,
  249. tagLengthBytes: Config.symmetric.cipher.algorithm
  250. .AES128_GCM.tagLengthBytes
  251. }
  252. },
  253. initializationVectorLengthBytes:
  254. Config.symmetric.cipher.initializationVectorLengthBytes
  255. .IV_12,
  256. secureRandom: {
  257. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  258. }
  259. }
  260. },
  261. primitives: {
  262. derivation: {
  263. pbkdf: {
  264. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  265. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  266. saltLengthBytes: 32,
  267. keyLengthBytes:
  268. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  269. iterations:
  270. Config.primitives.derivation.pbkdf.iterations.I_32000
  271. }
  272. }
  273. }
  274. };
  275. cryptolib('stores.sks', 'commons.utils', f_main);
  276. });
  277. it('retrieves an ElGamal private key from a real .sks key store JSON', function() {
  278. var f_main = function(box) {
  279. var data = {
  280. 'salt': '7Q951QtBynbVfljodmtQmg351nq/kmxcHfCwdrTUdng=',
  281. 'egPrivKeys': {
  282. 'elgamalprivatekeyalias1':
  283. 'HA5aI6+JCB1/AIeb70bcMetz+1AuY9zTh4GJAS2Xr9A1EN6N5qj9pLCwXneozTyuOi8mp0sHg1bZfWKuehBH+8kjYDlKzexbqmXiDhf2jw7mX991x0KVpeQ7oJJMGIPAv+Ff3lGHZxZYEdAy72Nttt5HZWkX7jPGI9ZeqT8aQhB3mNuGMhFnfMFMdEFGr9AVa8ZeXfLVpuVkGoHVj8mkN9PHUy+NLQc3dyh1ggfHNrUlYD21SOEp+4GTNxVNjsMPiOhi7LTHabXfliq3KdVltpo2IAZ0uvlmIj2cxZC+qFXv1BNiypPYkPRYSCfthWjhkz8iUSJUek5ve5sewVAMFZc5cRXEesvP5AH7tRwmv+63Ht7ktv8W5SKCm+ycVmqx3Tzo4NEEsxDqwBilTLhbcokANljO3iyR3HgVIrvwEJGMm79AfH8RYe5rhCUbLZ/KF+XCVm3TZ2ux0zWgynZi7d/1rzqae9nM5vBfdK6YMmT+AuEoXxKDzvV/9cqlRNg+EWF+vpfIit203fSiSv8f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NsLvE8zqUFX7HXeP/yK07gQUQaC4BDlbcjaPJxp4KTcJh9wSzMMCAgQA'
  289. };
  290. var sksReader = new box.stores.sks.SksReader(data);
  291. var converters = new box.commons.utils.Converters();
  292. var passwordBase64 =
  293. converters.base64Encode('01234567890abcdefghijk');
  294. var retrievedElGamalPrivateKey = sksReader.getElGamalPrivateKey(
  295. 'elgamalprivatekeyalias1', passwordBase64);
  296. expect(retrievedElGamalPrivateKey).toBeDefined();
  297. var group = retrievedElGamalPrivateKey.getGroup();
  298. var elGamalPrivKeyP =
  299. '25878792566670842099842137716422866466252991028815773139028451679515364679624923581358662655689289205766441980239548823737806954397019411202244121935752456749381769565031670387914863935577896116425654849306598185507995737892509839616944496073707445338806101425467388977937489020456783676102620561970644684015868766028080049372849872115052208214439472603355483095640041515460851475971118272125133224007949688443680429668091313474118875081620746919907567682398209044343652147328622866834600839878114285018818463110227111614032671442085465843940709084719667865761125514800243342061732684028802646193202210299179139410607';
  300. var elGamalPrivKeyQ =
  301. '12939396283335421049921068858211433233126495514407886569514225839757682339812461790679331327844644602883220990119774411868903477198509705601122060967876228374690884782515835193957431967788948058212827424653299092753997868946254919808472248036853722669403050712733694488968744510228391838051310280985322342007934383014040024686424936057526104107219736301677741547820020757730425737985559136062566612003974844221840214834045656737059437540810373459953783841199104522171826073664311433417300419939057142509409231555113555807016335721042732921970354542359833932880562757400121671030866342014401323096601105149589569705303';
  302. var elGamalPrivKeyG =
  303. '23337993065784550228812110720552652305178266477392633588884900695706615523553977368516877521940228584865573144621632575456086035440118913707895716109366641541746808409917179478292952139273396531060021729985473121368590574110220870149822495151519706210399569901298027813383104891697930149341258267962490850297875794622068418425473578455187344232698462829084010585324877420343904740081787639502967515631687068869545665294697583750184911025514712871193837246483893950501015755683415509019863976071649325968623617568219864744389709563087949389080252971419711636380986100047871404548371112472694814597772988558887480308242';
  304. var elGamalPrivKeyExponent =
  305. '4859259447320592668819568962669961246561051865212874540681243424367801394774393725734829250015941495215558771019728908939132002055237814853650010734496771955581048260699707147620967124841995608460226547395857304134089405473568889471419858106512603895297560717994246768950866491384823569118637582497519403351819609184883390558852906911976387433283350856334618005481106148226480670760580586739976814586223883428847209532777965666220529265035157816712732743895240103023779784827727286610206045924297284258748757461471125260095895029712193814187300268672295894546694634423997510695194818714918502470470193799175083856878';
  306. expect(group.getP().toString())
  307. .toEqual(
  308. converters.base64ToBigInteger(elGamalPrivKeyP).toString());
  309. expect(group.getQ().toString())
  310. .toEqual(
  311. converters.base64ToBigInteger(elGamalPrivKeyQ).toString());
  312. expect(group.getGenerator().getElementValue().toString())
  313. .toEqual(
  314. converters.base64ToBigInteger(elGamalPrivKeyG).toString());
  315. var exponents = retrievedElGamalPrivateKey.getExponentsArray();
  316. expect(exponents.length).toBe(1);
  317. expect(exponents[0].getValue().toString())
  318. .toEqual(converters.base64ToBigInteger(elGamalPrivKeyExponent)
  319. .toString());
  320. };
  321. f_main.policies = {
  322. symmetric: {
  323. secretkey: {
  324. encryption: {lengthBytes: 16},
  325. mac: {
  326. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  327. },
  328. secureRandom: {
  329. provider: Config.symmetric.secretkey.secureRandom.provider.SCYTL
  330. }
  331. },
  332. cipher: {
  333. provider: Config.symmetric.cipher.provider.FORGE,
  334. algorithm: {
  335. AES128_GCM: {
  336. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  337. keyLengthBytes: 16,
  338. tagLengthBytes: Config.symmetric.cipher.algorithm.AES128_GCM
  339. .tagLengthBytes
  340. }
  341. },
  342. initializationVectorLengthBytes:
  343. Config.symmetric.cipher.initializationVectorLengthBytes.IV_12,
  344. secureRandom: {
  345. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  346. }
  347. }
  348. },
  349. primitives: {
  350. derivation: {
  351. pbkdf: {
  352. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  353. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  354. saltLengthBytes: 32,
  355. keyLengthBytes:
  356. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  357. iterations:
  358. Config.primitives.derivation.pbkdf.iterations.I_32000
  359. }
  360. }
  361. }
  362. };
  363. cryptolib('stores.sks', 'commons.utils', f_main);
  364. });
  365. it('opens a keystore and gets the full certificate chain', function() {
  366. var f_main = function(box) {
  367. var data = testKeystore;
  368. // open the keystore
  369. var sksReader = new box.stores.sks.SksReader(data);
  370. var converters = new box.commons.utils.Converters();
  371. var passwordBase64 =
  372. converters.base64Encode('01234567890abcdefghijk');
  373. // get all certificate chains
  374. var certificateChain = sksReader.getCertificateChain(passwordBase64);
  375. expect(certificateChain.length).toEqual(7);
  376. };
  377. f_main.policies = {
  378. symmetric: {
  379. secretkey: {
  380. encryption: {lengthBytes: 32},
  381. mac: {
  382. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  383. },
  384. secureRandom: {
  385. provider: Config.symmetric.secretkey.secureRandom.provider.SCYTL
  386. }
  387. },
  388. cipher: {
  389. provider: Config.symmetric.cipher.provider.FORGE,
  390. algorithm: {
  391. AES128_GCM: {
  392. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  393. keyLengthBytes: 16,
  394. tagLengthBytes: Config.symmetric.cipher.algorithm.AES128_GCM
  395. .tagLengthBytes
  396. }
  397. },
  398. initializationVectorLengthBytes:
  399. Config.symmetric.cipher.initializationVectorLengthBytes.IV_12,
  400. secureRandom: {
  401. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  402. }
  403. }
  404. },
  405. primitives: {
  406. derivation: {
  407. pbkdf: {
  408. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  409. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  410. saltLengthBytes: 32,
  411. keyLengthBytes:
  412. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  413. iterations: Config.primitives.derivation.pbkdf.iterations.I_1
  414. }
  415. }
  416. }
  417. };
  418. cryptolib('stores.sks', 'commons.utils', f_main);
  419. });
  420. it('opens a keystore and gets a certificate chain, by private key alias',
  421. function() {
  422. var f_main = function(box) {
  423. var data = testKeystore;
  424. // open the keystore
  425. var sksReader = new box.stores.sks.SksReader(data);
  426. var converters = new box.commons.utils.Converters();
  427. var passwordBase64 =
  428. converters.base64Encode('01234567890abcdefghijk');
  429. // get all certificate chains
  430. var user1CertificateChain =
  431. sksReader.getCertificateChainByAlias(passwordBase64, 'user1');
  432. var user2CertificateChain =
  433. sksReader.getCertificateChainByAlias(passwordBase64, 'user2');
  434. expect(user1CertificateChain.length).toEqual(3);
  435. expect(user2CertificateChain.length).toEqual(4);
  436. };
  437. f_main.policies = {
  438. symmetric: {
  439. secretkey: {
  440. encryption: {lengthBytes: 32},
  441. mac: {
  442. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  443. },
  444. secureRandom: {
  445. provider:
  446. Config.symmetric.secretkey.secureRandom.provider.SCYTL
  447. }
  448. },
  449. cipher: {
  450. provider: Config.symmetric.cipher.provider.FORGE,
  451. algorithm: {
  452. AES128_GCM: {
  453. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  454. keyLengthBytes: 16,
  455. tagLengthBytes: Config.symmetric.cipher.algorithm
  456. .AES128_GCM.tagLengthBytes
  457. }
  458. },
  459. initializationVectorLengthBytes:
  460. Config.symmetric.cipher.initializationVectorLengthBytes
  461. .IV_12,
  462. secureRandom: {
  463. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  464. }
  465. }
  466. },
  467. primitives: {
  468. derivation: {
  469. pbkdf: {
  470. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  471. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  472. saltLengthBytes: 20,
  473. keyLengthBytes:
  474. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  475. iterations: Config.primitives.derivation.pbkdf.iterations.I_1
  476. }
  477. }
  478. }
  479. };
  480. cryptolib('stores.sks', 'commons.utils', f_main);
  481. });
  482. it('opens a keystore and gets a certificate, by subject common name',
  483. function() {
  484. var f_main = function(box) {
  485. var data = testKeystore;
  486. var sksReader = new box.stores.sks.SksReader(data);
  487. var converters = new box.commons.utils.Converters();
  488. var passwordBase64 =
  489. converters.base64Encode('01234567890abcdefghijk');
  490. // retrieve certificate from key store, with subject common name
  491. // 'SecDev'.
  492. var certificatePem =
  493. sksReader.getCertificateBySubject(passwordBase64, 'SecDev');
  494. // verify contents of certificate (which is self-signed in this
  495. // example).
  496. var certificate =
  497. new box.certificates.service.load(certificatePem);
  498. expect(certificate.getSubjectCN()).toBe('SecDev');
  499. expect(certificate.getSubjectOrgUnit()).toBe('QA');
  500. expect(certificate.getSubjectOrg()).toBe('Scytl');
  501. expect(certificate.getSubjectCountry()).toBe('ES');
  502. expect(certificate.verify(certificatePem)).toBe(true);
  503. };
  504. f_main.policies = {
  505. symmetric: {
  506. secretkey: {
  507. encryption: {lengthBytes: 32},
  508. mac: {
  509. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  510. },
  511. secureRandom: {
  512. provider:
  513. Config.symmetric.secretkey.secureRandom.provider.SCYTL
  514. }
  515. },
  516. cipher: {
  517. provider: Config.symmetric.cipher.provider.FORGE,
  518. algorithm: {
  519. AES128_GCM: {
  520. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  521. keyLengthBytes: 16,
  522. tagLengthBytes: Config.symmetric.cipher.algorithm
  523. .AES128_GCM.tagLengthBytes
  524. }
  525. },
  526. initializationVectorLengthBytes:
  527. Config.symmetric.cipher.initializationVectorLengthBytes
  528. .IV_12,
  529. secureRandom: {
  530. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  531. }
  532. }
  533. },
  534. primitives: {
  535. derivation: {
  536. pbkdf: {
  537. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  538. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  539. saltLengthBytes: 20,
  540. keyLengthBytes:
  541. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  542. iterations: Config.primitives.derivation.pbkdf.iterations.I_1
  543. }
  544. }
  545. }
  546. };
  547. cryptolib(
  548. 'stores.sks', 'certificates.service', 'commons.utils', f_main);
  549. });
  550. it('should derive the key only once', function() {
  551. var f_main = function(box) {
  552. var data = testKeystore;
  553. var sksReader = new box.stores.sks.SksReader(data);
  554. var converters = new box.commons.utils.Converters();
  555. var passwordBase64 =
  556. converters.base64Encode('01234567890abcdefghijk');
  557. var spy = spyOn(sksReader, '_deriveKey').and.callThrough();
  558. // Retrieve a certificate a few times.
  559. for (var i = 0; i < 5; i++) {
  560. sksReader.getCertificateBySubject(passwordBase64, 'SecDev');
  561. }
  562. expect(spy).toHaveBeenCalledTimes(1);
  563. };
  564. f_main.policies = {
  565. symmetric: {
  566. secretkey: {
  567. encryption: {lengthBytes: 32},
  568. mac: {
  569. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  570. },
  571. secureRandom: {
  572. provider: Config.symmetric.secretkey.secureRandom.provider.SCYTL
  573. }
  574. },
  575. cipher: {
  576. provider: Config.symmetric.cipher.provider.FORGE,
  577. algorithm: {
  578. AES128_GCM: {
  579. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  580. keyLengthBytes: 16,
  581. tagLengthBytes: Config.symmetric.cipher.algorithm.AES128_GCM
  582. .tagLengthBytes
  583. }
  584. },
  585. initializationVectorLengthBytes:
  586. Config.symmetric.cipher.initializationVectorLengthBytes.IV_12,
  587. secureRandom: {
  588. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  589. }
  590. }
  591. },
  592. primitives: {
  593. derivation: {
  594. pbkdf: {
  595. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  596. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  597. saltLengthBytes: 20,
  598. keyLengthBytes:
  599. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  600. iterations: Config.primitives.derivation.pbkdf.iterations.I_1
  601. }
  602. }
  603. }
  604. };
  605. cryptolib('stores.sks', 'commons.utils', f_main);
  606. });
  607. });
  608. });
  609. describe('bugfix 102362', function() {
  610. var sksBug102362 = testKeystore;
  611. it('must retrieve a private key by alias', function() {
  612. cryptolibPolicies = {
  613. symmetric: {
  614. secretkey: {
  615. encryption: {lengthBytes: 32},
  616. mac:
  617. {lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32},
  618. secureRandom: {
  619. provider: Config.symmetric.secretkey.secureRandom.provider.SCYTL
  620. }
  621. },
  622. cipher: {
  623. provider: Config.symmetric.cipher.provider.FORGE,
  624. algorithm: {
  625. AES128_GCM: {
  626. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  627. keyLengthBytes: 16,
  628. tagLengthBytes:
  629. Config.symmetric.cipher.algorithm.AES128_GCM.tagLengthBytes
  630. }
  631. },
  632. initializationVectorLengthBytes:
  633. Config.symmetric.cipher.initializationVectorLengthBytes.IV_12,
  634. secureRandom: {
  635. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  636. }
  637. }
  638. },
  639. primitives: {
  640. derivation: {
  641. pbkdf: {
  642. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  643. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  644. saltLengthBytes: 20,
  645. keyLengthBytes:
  646. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  647. iterations: 1
  648. }
  649. }
  650. }
  651. };
  652. cryptolib('stores.sks', 'commons.utils', function(box) {
  653. var converters = new box.commons.utils.Converters();
  654. var sksReader = new box.stores.sks.SksReader(sksBug102362);
  655. var passwordBase64 = converters.base64Encode('01234567890abcdefghijk');
  656. var privateKey = sksReader.getPrivateKeys(passwordBase64, 'user1');
  657. expect(privateKey.user1).toBeDefined();
  658. });
  659. });
  660. it('must retrieve only the requested key/keys', function() {
  661. cryptolibPolicies = {
  662. symmetric: {
  663. secretkey: {
  664. encryption: {lengthBytes: 32},
  665. mac:
  666. {lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32},
  667. secureRandom: {
  668. provider: Config.symmetric.secretkey.secureRandom.provider.SCYTL
  669. }
  670. },
  671. cipher: {
  672. provider: Config.symmetric.cipher.provider.FORGE,
  673. algorithm: {
  674. AES128_GCM: {
  675. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  676. keyLengthBytes: 16,
  677. tagLengthBytes:
  678. Config.symmetric.cipher.algorithm.AES128_GCM.tagLengthBytes
  679. }
  680. },
  681. initializationVectorLengthBytes:
  682. Config.symmetric.cipher.initializationVectorLengthBytes.IV_12,
  683. secureRandom: {
  684. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  685. }
  686. }
  687. },
  688. primitives: {
  689. derivation: {
  690. pbkdf: {
  691. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  692. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  693. saltLengthBytes: 20,
  694. keyLengthBytes:
  695. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  696. iterations: 1
  697. }
  698. }
  699. }
  700. };
  701. cryptolib('stores.sks', 'commons.utils', function(box) {
  702. var converters = new box.commons.utils.Converters();
  703. var sksReader = new box.stores.sks.SksReader(sksBug102362);
  704. var passwordBase64 = converters.base64Encode('01234567890abcdefghijk');
  705. var privateKey = sksReader.getPrivateKeys(passwordBase64, 'user2');
  706. expect(privateKey.user1).not.toBeDefined();
  707. });
  708. });
  709. it('if not alias is specified, it must retrieve all the secret key in the keystore',
  710. function() {
  711. cryptolibPolicies = {
  712. symmetric: {
  713. secretkey: {
  714. encryption: {lengthBytes: 32},
  715. mac: {
  716. lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32
  717. },
  718. secureRandom: {
  719. provider:
  720. Config.symmetric.secretkey.secureRandom.provider.SCYTL
  721. }
  722. },
  723. cipher: {
  724. provider: Config.symmetric.cipher.provider.FORGE,
  725. algorithm: {
  726. AES128_GCM: {
  727. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  728. keyLengthBytes: 16,
  729. tagLengthBytes: Config.symmetric.cipher.algorithm.AES128_GCM
  730. .tagLengthBytes
  731. }
  732. },
  733. initializationVectorLengthBytes:
  734. Config.symmetric.cipher.initializationVectorLengthBytes
  735. .IV_12,
  736. secureRandom: {
  737. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  738. }
  739. }
  740. },
  741. primitives: {
  742. derivation: {
  743. pbkdf: {
  744. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  745. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  746. saltLengthBytes: 20,
  747. keyLengthBytes:
  748. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  749. iterations: 1
  750. }
  751. }
  752. }
  753. };
  754. cryptolib('stores.sks', 'commons.utils', function(box) {
  755. var converters = new box.commons.utils.Converters();
  756. var sksReader = new box.stores.sks.SksReader(sksBug102362);
  757. var passwordBase64 =
  758. converters.base64Encode('01234567890abcdefghijk');
  759. var privateKey = sksReader.getPrivateKeys(passwordBase64);
  760. expect(privateKey.user1).toBeDefined();
  761. expect(privateKey.user2).toBeDefined();
  762. });
  763. });
  764. });
  765. describe('bugfix #102457', function() {
  766. it('sks should manage invalid symmetric aliases', function() {
  767. cryptolibPolicies = {
  768. symmetric: {
  769. secretkey: {
  770. encryption: {lengthBytes: 32},
  771. mac:
  772. {lengthBytes: Config.symmetric.secretkey.mac.lengthBytes.SK_32},
  773. secureRandom: {
  774. provider: Config.symmetric.secretkey.secureRandom.provider.SCYTL
  775. }
  776. },
  777. cipher: {
  778. provider: Config.symmetric.cipher.provider.FORGE,
  779. algorithm: {
  780. AES128_GCM: {
  781. name: Config.symmetric.cipher.algorithm.AES128_GCM.name,
  782. keyLengthBytes: 16,
  783. tagLengthBytes:
  784. Config.symmetric.cipher.algorithm.AES128_GCM.tagLengthBytes
  785. }
  786. },
  787. initializationVectorLengthBytes:
  788. Config.symmetric.cipher.initializationVectorLengthBytes.IV_12,
  789. secureRandom: {
  790. provider: Config.symmetric.cipher.secureRandom.provider.SCYTL
  791. }
  792. }
  793. },
  794. primitives: {
  795. derivation: {
  796. pbkdf: {
  797. provider: Config.primitives.derivation.pbkdf.provider.FORGE,
  798. hash: Config.primitives.derivation.pbkdf.hash.SHA256,
  799. saltLengthBytes: 20,
  800. keyLengthBytes:
  801. Config.primitives.derivation.pbkdf.keyLengthBytes.KL_16,
  802. iterations: Config.primitives.derivation.pbkdf.iterations.I_1
  803. }
  804. }
  805. }
  806. };
  807. cryptolib('stores.sks', 'commons.utils', function(box) {
  808. var data = testKeystore;
  809. var sksReader = new box.stores.sks.SksReader(data);
  810. var converters = new box.commons.utils.Converters();
  811. var passwordBase64 = converters.base64Encode('01234567890abcdefghijk');
  812. expect(function() {
  813. sksReader.getSecretKey('werypvqwenprqv', passwordBase64);
  814. }).toThrow();
  815. });
  816. });
  817. });
  818. });