1 | /* $Id: CertificateImpl.h 60343 2016-04-06 00:05:54Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM ICertificate implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_CERTIFICATEIMPL
|
---|
19 | #define ____H_CERTIFICATEIMPL
|
---|
20 |
|
---|
21 | /* VBox includes */
|
---|
22 | #include <VBox/settings.h>
|
---|
23 | #include <iprt/crypto/x509.h>
|
---|
24 | #include "CertificateWrap.h"
|
---|
25 |
|
---|
26 | #include <vector>
|
---|
27 |
|
---|
28 | using namespace std;
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Implemenation of ICertificate.
|
---|
32 | *
|
---|
33 | * This implemenation is a very thin wrapper around an immutable
|
---|
34 | * RTCRX509CERTIFICATE and a few caller stated views.
|
---|
35 | *
|
---|
36 | * The views are whether the caller thinks the certificate is trustworthly, and
|
---|
37 | * whether the caller thinks it's expired or not. The caller could be sitting
|
---|
38 | * on more information, like timestamp and intermediate certificates, that helps
|
---|
39 | * inform the caller's view on these two topics.
|
---|
40 | *
|
---|
41 | * @remarks It could be helpful to let the caller also add certificate paths
|
---|
42 | * showing how this certificate ends up being trusted. However, that's
|
---|
43 | * possibly quite some work and will have to wait till required...
|
---|
44 | */
|
---|
45 | class ATL_NO_VTABLE Certificate
|
---|
46 | : public CertificateWrap
|
---|
47 | {
|
---|
48 |
|
---|
49 | public:
|
---|
50 |
|
---|
51 | DECLARE_EMPTY_CTOR_DTOR(Certificate)
|
---|
52 |
|
---|
53 | HRESULT initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted, bool a_fExpired);
|
---|
54 | void uninit();
|
---|
55 |
|
---|
56 | HRESULT FinalConstruct();
|
---|
57 | void FinalRelease();
|
---|
58 |
|
---|
59 | private:
|
---|
60 | // wrapped ICertificate properties
|
---|
61 | HRESULT getVersionNumber(CertificateVersion_T *aVersionNumber);
|
---|
62 | HRESULT getSerialNumber(com::Utf8Str &aSerialNumber);
|
---|
63 | HRESULT getSignatureAlgorithmOID(com::Utf8Str &aSignatureAlgorithmOID);
|
---|
64 | HRESULT getSignatureAlgorithmName(com::Utf8Str &aSignatureAlgorithmName);
|
---|
65 | HRESULT getPublicKeyAlgorithmOID(com::Utf8Str &aPublicKeyAlgorithmOID);
|
---|
66 | HRESULT getPublicKeyAlgorithm(com::Utf8Str &aPublicKeyAlgorithm);
|
---|
67 | HRESULT getIssuerName(std::vector<com::Utf8Str> &aIssuerName);
|
---|
68 | HRESULT getSubjectName(std::vector<com::Utf8Str> &aSubjectName);
|
---|
69 | HRESULT getFriendlyName(com::Utf8Str &aFriendlyName);
|
---|
70 | HRESULT getValidityPeriodNotBefore(com::Utf8Str &aValidityPeriodNotBefore);
|
---|
71 | HRESULT getValidityPeriodNotAfter(com::Utf8Str &aValidityPeriodNotAfter);
|
---|
72 | HRESULT getSubjectPublicKey(std::vector<BYTE> &aSubjectPublicKey);
|
---|
73 | HRESULT getIssuerUniqueIdentifier(com::Utf8Str &aIssuerUniqueIdentifier);
|
---|
74 | HRESULT getSubjectUniqueIdentifier(com::Utf8Str &aSubjectUniqueIdentifier);
|
---|
75 | HRESULT getCertificateAuthority(BOOL *aCertificateAuthority);
|
---|
76 | HRESULT getKeyUsage(ULONG *aKeyUsage);
|
---|
77 | HRESULT getExtendedKeyUsage(std::vector<com::Utf8Str> &aExtendedKeyUsage);
|
---|
78 | HRESULT getRawCertData(std::vector<BYTE> &aRawCertData);
|
---|
79 | HRESULT getSelfSigned(BOOL *aSelfSigned);
|
---|
80 | HRESULT getTrusted(BOOL *aTrusted);
|
---|
81 | HRESULT getExpired(BOOL *aExpired);
|
---|
82 | // wrapped ICertificate methods
|
---|
83 | HRESULT isCurrentlyExpired(BOOL *aResult);
|
---|
84 | HRESULT queryInfo(LONG aWhat, com::Utf8Str &aResult);
|
---|
85 |
|
---|
86 | /** @name Methods extracting COM data from the certificate object
|
---|
87 | * @{ */
|
---|
88 | HRESULT i_getAlgorithmName(PCRTCRX509ALGORITHMIDENTIFIER a_pAlgId, com::Utf8Str &a_rReturn);
|
---|
89 | HRESULT i_getX509Name(PCRTCRX509NAME a_pName, std::vector<com::Utf8Str> &a_rReturn);
|
---|
90 | HRESULT i_getTime(PCRTASN1TIME a_pTime, com::Utf8Str &a_rReturn);
|
---|
91 | HRESULT i_getUniqueIdentifier(PCRTCRX509UNIQUEIDENTIFIER a_pUniqueId, com::Utf8Str &a_rReturn);
|
---|
92 | HRESULT i_getEncodedBytes(PRTASN1CORE a_pAsn1Obj, std::vector<BYTE> &a_rReturn);
|
---|
93 | /** @} */
|
---|
94 |
|
---|
95 | struct Data;
|
---|
96 | /** Pointer to the private instance data */
|
---|
97 | Data *m;
|
---|
98 | };
|
---|
99 |
|
---|
100 | #endif // !____H_CERTIFICATEIMPL
|
---|
101 |
|
---|