123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- /*
- * Copyright 2018 Scytl Secure Electronic Voting SA
- *
- * All rights reserved
- *
- * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
- */
- /* jshint node:true */
- 'use strict';
- var keyStore = require('../lib/index');
- var certificate = require('scytl-certificate');
- var codec = require('scytl-codec');
- describe('The key store module that should be able to ...', function() {
- var PASSWORD = 'PM6XtkOTbefJmhHGFgbz';
- var PKCS12_DER_B64 =
- 'MIIaAQIBAzCCGbsGCSqGSIb3DQEHAaCCGawEghmoMIIZpDCCCvEGCSqGSIb3DQEHAaCCCuIEggreMIIK2jCCBWkGCyqGSIb3DQEMCgECoIIE+jCCBPYwKAYKKoZIhvcNAQwBAzAaBBSSjjJGUYGJDejWdN+I9JtoUS5GlwICBAAEggTIIm/j53Vt9JV14SyNUCY2Fe2FI0iwKRwr12N/4/mmLU6nSONnrp0awB5z+d5T4sLpekMUvayn8o3r0NTzzasdadH7tK3UDEgcSCuutGMk3JxZr2QbzRzHOr2qxUN6Y+069InDKO+8NNt+uC2vewPs8X3Q9qsrbhhQJdrjmKRwmmO9IJmYnbIBxl6Y3h0D3KZfCetYleKDuuv78Gx6Z2VFh+lw3Dx2CSaSNXwOWLGTfMxXbzKXfHu8GlT7s9I3qmgxluC1PTJUb1Kpc56sEhQ6kHSoDFXuC5fJRl5qhaMtcQmhZvRb6TIxWwIK6bNfxw2jQbK0ZkXOFtkZFAMKh34jW+F2xjEP49IqbH4e1buXY62KvUQLJwtb7pZehwWrf544ycX8eKNPf8tqepE5jZZVR/VPk8VgLYhgngzDsgPZvndGoG/UWQgzBbI3O9cx9pGmc0mcJBw68bg2BR6dLt3x6lvIdp7dBVFpyc5LvlKBT5dahhTeyO6HmxHwenKuR7NRCp7KNzjbON81dGkp0IW0e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2tdUNxhrwCgNaHUhwNK43kiLGH0U9innhL1i0jP1VHNkL1G/+ZCo1qzh/Usji/jtlurfAWtrXku6VRF9NP+itKOY5jJ91Ijkc7t4dgoeJq6iMHn6JbDKIQ88r/Ikd0GdF04o5Qjqq1HlUVmqyIOHeHFla4i4tOxTyUBj34eE1No/xmaKYV1QtR1dqSHblR7OagEo7Dd3fXp7iSrKrXaN0Ef/6zeF3zjU5SMKcUcU9d3CbhS/CrGb+UGlqTXgzPXQWESH9AqBNl67+HF3mYktDQOZYPT5WRO5IKSko2cy9pP9UCsLk4oU3xyOxacWDpk1k=-----END CERTIFICATE-----';
- var ROOT_PRIVATE_KEY_ALIAS = 'root_rsa_private_key';
- var LEAF_PRIVATE_KEY_ALIAS = 'user_rsa_private_key';
- var keyStoreService_;
- var certificateService_;
- var pkcs12KeyStore_;
- beforeAll(function() {
- keyStoreService_ = keyStore.newService();
- certificateService_ = certificate.newService();
- pkcs12KeyStore_ = keyStoreService_.newPkcs12KeyStore(
- codec.base64Decode(PKCS12_DER_B64), PASSWORD);
- });
- describe('create a key store service that should be able to ..', function() {
- describe('load a PKCS12 key store that should be able to', function() {
- it('retrieve a private key, given its storage alias name and password',
- function() {
- var rootPrivateKeyPem = removeNewLineChars(
- pkcs12KeyStore_.getPrivateKey(ROOT_PRIVATE_KEY_ALIAS, PASSWORD));
- expect(rootPrivateKeyPem).toBe(ROOT_PRIVATE_KEY_PEM);
- var leafPrivateKeyPem = removeNewLineChars(
- pkcs12KeyStore_.getPrivateKey(LEAF_PRIVATE_KEY_ALIAS, PASSWORD));
- expect(leafPrivateKeyPem).toBe(LEAF_PRIVATE_KEY_PEM);
- });
- it('retrieve a certificate, given the storage alias name of its associated private key entry',
- function() {
- var rootCertificatePem = removeNewLineChars(
- pkcs12KeyStore_.getCertificate(ROOT_PRIVATE_KEY_ALIAS));
- expect(rootCertificatePem).toBe(ROOT_CERTIFICATE_PEM);
- var rootCertificate =
- certificateService_.newX509Certificate(rootCertificatePem);
- var rootPublicKeyPem = removeNewLineChars(rootCertificate.publicKey);
- expect(rootPublicKeyPem).toBe(ROOT_PUBLIC_KEY_PEM);
- var leafCertificatePem = removeNewLineChars(
- pkcs12KeyStore_.getCertificate(LEAF_PRIVATE_KEY_ALIAS));
- expect(leafCertificatePem).toBe(LEAF_CERTIFICATE_PEM);
- var leafCertificate =
- certificateService_.newX509Certificate(leafCertificatePem);
- var leafPublicKeyPem = removeNewLineChars(leafCertificate.publicKey);
- expect(leafPublicKeyPem).toBe(LEAF_PUBLIC_KEY_PEM);
- expect(rootCertificate.verify(rootCertificatePem)).toBeTruthy();
- expect(rootCertificate.verify(leafCertificatePem)).toBeTruthy();
- });
- it('retrieve a certificate, given its subject common name', function() {
- var rootCertificatePem = removeNewLineChars(
- pkcs12KeyStore_.getCertificateBySubject(ROOT_COMMON_NAME));
- expect(rootCertificatePem).toBe(ROOT_CERTIFICATE_PEM);
- var rootCertificate =
- certificateService_.newX509Certificate(rootCertificatePem);
- var rootPublicKeyPem = removeNewLineChars(rootCertificate.publicKey);
- expect(rootPublicKeyPem).toBe(ROOT_PUBLIC_KEY_PEM);
- var leafCertificatePem = removeNewLineChars(
- pkcs12KeyStore_.getCertificateBySubject(LEAF_COMMON_NAME));
- expect(leafCertificatePem).toBe(LEAF_CERTIFICATE_PEM);
- var leafCertificate =
- certificateService_.newX509Certificate(leafCertificatePem);
- var leafPublicKeyPem = removeNewLineChars(leafCertificate.publicKey);
- expect(leafPublicKeyPem).toBe(LEAF_PUBLIC_KEY_PEM);
- expect(rootCertificate.verify(rootCertificatePem)).toBeTruthy();
- expect(rootCertificate.verify(leafCertificatePem)).toBeTruthy();
- });
- it('retrieve a certificate chain, given the storage alias name of its associated private key entry',
- function() {
- var rootCertificateChain =
- pkcs12KeyStore_.getCertificateChain(ROOT_PRIVATE_KEY_ALIAS);
- expect(rootCertificateChain.length).toBe(1);
- var rootCertificatePem = removeNewLineChars(rootCertificateChain[0]);
- expect(rootCertificatePem).toBe(ROOT_CERTIFICATE_PEM);
- var leafCertificateChain =
- pkcs12KeyStore_.getCertificateChain(LEAF_PRIVATE_KEY_ALIAS);
- expect(leafCertificateChain.length).toBe(2);
- var leafCertificatePem = removeNewLineChars(leafCertificateChain[0]);
- expect(leafCertificatePem).toBe(LEAF_CERTIFICATE_PEM);
- rootCertificatePem = removeNewLineChars(leafCertificateChain[1]);
- expect(rootCertificatePem).toBe(ROOT_CERTIFICATE_PEM);
- });
- });
- it('load a PKCS12 key store, in Base64 encoded format', function() {
- var pkcs12KeyStore =
- keyStoreService_.newPkcs12KeyStore(PKCS12_DER_B64, PASSWORD);
- expect(pkcs12KeyStore).toBeDefined();
- // Check private keys.
- var rootPrivateKeyPem = removeNewLineChars(
- pkcs12KeyStore.getPrivateKey(ROOT_PRIVATE_KEY_ALIAS, PASSWORD));
- expect(rootPrivateKeyPem).toBe(ROOT_PRIVATE_KEY_PEM);
- var leafPrivateKeyPem = removeNewLineChars(
- pkcs12KeyStore.getPrivateKey(LEAF_PRIVATE_KEY_ALIAS, PASSWORD));
- expect(leafPrivateKeyPem).toBe(LEAF_PRIVATE_KEY_PEM);
- // Check certificates.
- var rootCertificatePem = removeNewLineChars(
- pkcs12KeyStore.getCertificate(ROOT_PRIVATE_KEY_ALIAS));
- expect(rootCertificatePem).toBe(ROOT_CERTIFICATE_PEM);
- var leafCertificatePem = removeNewLineChars(
- pkcs12KeyStore.getCertificate(LEAF_PRIVATE_KEY_ALIAS));
- expect(leafCertificatePem).toBe(LEAF_CERTIFICATE_PEM);
- // Check certificate chains.
- var rootCertificateChain =
- pkcs12KeyStore_.getCertificateChain(ROOT_PRIVATE_KEY_ALIAS);
- rootCertificatePem = removeNewLineChars(rootCertificateChain[0]);
- expect(rootCertificatePem).toBe(ROOT_CERTIFICATE_PEM);
- var leafCertificateChain =
- pkcs12KeyStore_.getCertificateChain(LEAF_PRIVATE_KEY_ALIAS);
- leafCertificatePem = removeNewLineChars(leafCertificateChain[0]);
- expect(leafCertificatePem).toBe(LEAF_CERTIFICATE_PEM);
- rootCertificatePem = removeNewLineChars(leafCertificateChain[1]);
- expect(rootCertificatePem).toBe(ROOT_CERTIFICATE_PEM);
- });
- });
- function removeNewLineChars(str) {
- return str.replace(/(\r\n|\n|\r)/gm, '');
- }
- });
|