Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.1 KiB

  1. // pkiX509Cert.h - Interface to X509Cert class
  2. //
  3. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  4. // 1999. This computer program includes Confidential, Proprietary
  5. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  6. // use, disclosure, and/or reproduction is prohibited unless authorized
  7. // in writing. All Rights Reserved.
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef SLBPKI_X509CERT_H
  10. #define SLBPKI_X509CERT_H
  11. #if defined(WIN32)
  12. #pragma warning(disable : 4786) // Suppress VC++ warnings
  13. #endif
  14. #include <string>
  15. #include <vector>
  16. #include "pkiBEROctet.h"
  17. namespace pki {
  18. class X509Cert
  19. {
  20. public:
  21. X509Cert();
  22. X509Cert(const X509Cert &cert);
  23. X509Cert(const std::string &buffer);
  24. X509Cert(const unsigned char *buffer, const unsigned long size);
  25. X509Cert& operator=(const X509Cert &cert);
  26. X509Cert& operator=(const std::string &buffer);
  27. std::string SerialNumber() const;
  28. std::string Issuer() const;
  29. std::vector<std::string> IssuerOrg() const;
  30. std::string Subject() const;
  31. std::vector<std::string> SubjectCommonName() const;
  32. std::string Modulus() const;
  33. std::string RawModulus() const;
  34. std::string PublicExponent() const;
  35. std::string RawPublicExponent() const;
  36. unsigned long KeyUsage() const;
  37. private:
  38. pki::BEROctet m_Cert;
  39. pki::BEROctet m_SerialNumber;
  40. pki::BEROctet m_Issuer;
  41. pki::BEROctet m_Subject;
  42. pki::BEROctet m_SubjectPublicKeyInfo;
  43. pki::BEROctet m_Extensions;
  44. void Decode();
  45. };
  46. // Key Usage flags from X.509 spec
  47. const unsigned long digitalSignature = 0x80000000;
  48. const unsigned long nonRepudiation = 0x40000000;
  49. const unsigned long keyEncipherment = 0x20000000;
  50. const unsigned long dataEncipherment = 0x10000000;
  51. const unsigned long keyAgreement = 0x08000000;
  52. const unsigned long keyCertSign = 0x04000000;
  53. const unsigned long cRLSign = 0x02000000;
  54. const unsigned long encipherOnly = 0x01000000;
  55. const unsigned long decipherOnly = 0x00800000;
  56. } // namespace pki
  57. #endif /* SLBPKI_X509CERT_H */