2
0

key-usage-extension.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. module.exports = KeyUsageExtension;
  11. /**
  12. * @class KeyUsageExtension
  13. * @classdesc Encapsulates the key usage extension flags of an X.509
  14. * certificate. This object is instantiated internally by the method
  15. * {@link CertificateService.newX509Certificate} and made available
  16. * as a property of the returned {@link X509Certificate} object.
  17. * @property {boolean} digitalSignature <code>true</code> if the
  18. * <code>digital signature</code> flag is set, <code>false</code>
  19. * otherwise.
  20. * @property {boolean} nonRepudiation <code>true</code> if the
  21. * <code>non-repudiation</code> flag is set, <code>false</code>
  22. * otherwise.
  23. * @property {boolean} keyEncipherment <code>true</code> if the
  24. * <code>key encipherment</code> flag is set, <code>false</code>
  25. * otherwise.
  26. * @property {boolean} dataEncipherment <code>true</code> if the
  27. * <code>data encipherment</code> flag is set, <code>false</code>
  28. * otherwise.
  29. * @property {boolean} keyAgreement <code>true</code> if the
  30. * <code>key agreement</code> flag is set, <code>false</code>
  31. * otherwise.
  32. * @property {boolean} keyCertSign <code>true</code> if the
  33. * <code>key certificate sign</code> flag is set, <code>false</code>
  34. * otherwise.
  35. * @property {boolean} crlSign <code>true</code> if the <code>CRL sign</code>
  36. * flag is set, <code>false</code> otherwise.
  37. * @property {boolean} encipherOnly <code>true</code> if the
  38. * <code>encipher only</code> flag is set, <code>false</code>
  39. * otherwise.
  40. * @property {boolean} decipherOnly <code>true</code> if the
  41. * <code>decipher only</code> flag is set, <code>false</code>
  42. * otherwise.
  43. */
  44. function KeyUsageExtension(extension) {
  45. return Object.freeze({
  46. digitalSignature: extension.digitalSignature,
  47. nonRepudiation: extension.nonRepudiation,
  48. keyEncipherment: extension.keyEncipherment,
  49. dataEncipherment: extension.dataEncipherment,
  50. keyAgreement: extension.keyAgreement,
  51. keyCertSign: extension.keyCertSign,
  52. crlSign: extension.cRLSign,
  53. encipherOnly: extension.encipherOnly,
  54. decipherOnly: extension.decipherOnly
  55. });
  56. }