X509KeyUsage.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  5. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
  6. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.X509
  7. {
  8. /**
  9. * A holding class for constructing an X509 Key Usage extension.
  10. *
  11. * <pre>
  12. * id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }
  13. *
  14. * KeyUsage ::= BIT STRING {
  15. * digitalSignature (0),
  16. * nonRepudiation (1),
  17. * keyEncipherment (2),
  18. * dataEncipherment (3),
  19. * keyAgreement (4),
  20. * keyCertSign (5),
  21. * cRLSign (6),
  22. * encipherOnly (7),
  23. * decipherOnly (8) }
  24. * </pre>
  25. */
  26. public class X509KeyUsage
  27. : Asn1Encodable
  28. {
  29. public const int DigitalSignature = 1 << 7;
  30. public const int NonRepudiation = 1 << 6;
  31. public const int KeyEncipherment = 1 << 5;
  32. public const int DataEncipherment = 1 << 4;
  33. public const int KeyAgreement = 1 << 3;
  34. public const int KeyCertSign = 1 << 2;
  35. public const int CrlSign = 1 << 1;
  36. public const int EncipherOnly = 1 << 0;
  37. public const int DecipherOnly = 1 << 15;
  38. private readonly int usage;
  39. /**
  40. * Basic constructor.
  41. *
  42. * @param usage - the bitwise OR of the Key Usage flags giving the
  43. * allowed uses for the key.
  44. * e.g. (X509KeyUsage.keyEncipherment | X509KeyUsage.dataEncipherment)
  45. */
  46. public X509KeyUsage(
  47. int usage)
  48. {
  49. this.usage = usage;
  50. }
  51. public override Asn1Object ToAsn1Object()
  52. {
  53. return new KeyUsage(usage);
  54. }
  55. }
  56. }
  57. #pragma warning restore
  58. #endif