VirtualBox

source: vbox/trunk/src/VBox/Main/include/CertificateImpl.h@ 98694

Last change on this file since 98694 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: CertificateImpl.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VirtualBox COM ICertificate implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef MAIN_INCLUDED_CertificateImpl_h
29#define MAIN_INCLUDED_CertificateImpl_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* VBox includes */
35#include <iprt/crypto/x509.h>
36#include "CertificateWrap.h"
37
38#include <vector>
39
40using namespace std;
41
42/**
43 * Implemenation of ICertificate.
44 *
45 * This implemenation is a very thin wrapper around an immutable
46 * RTCRX509CERTIFICATE and a few caller stated views.
47 *
48 * The views are whether the caller thinks the certificate is trustworthly, and
49 * whether the caller thinks it's expired or not. The caller could be sitting
50 * on more information, like timestamp and intermediate certificates, that helps
51 * inform the caller's view on these two topics.
52 *
53 * @remarks It could be helpful to let the caller also add certificate paths
54 * showing how this certificate ends up being trusted. However, that's
55 * possibly quite some work and will have to wait till required...
56 */
57class ATL_NO_VTABLE Certificate
58 : public CertificateWrap
59{
60
61public:
62
63 DECLARE_COMMON_CLASS_METHODS(Certificate)
64
65 HRESULT initCertificate(PCRTCRX509CERTIFICATE a_pCert, bool a_fTrusted, bool a_fExpired);
66 void uninit();
67
68 HRESULT FinalConstruct();
69 void FinalRelease();
70
71private:
72 // Wrapped ICertificate properties
73 HRESULT getVersionNumber(CertificateVersion_T *aVersionNumber);
74 HRESULT getSerialNumber(com::Utf8Str &aSerialNumber);
75 HRESULT getSignatureAlgorithmOID(com::Utf8Str &aSignatureAlgorithmOID);
76 HRESULT getSignatureAlgorithmName(com::Utf8Str &aSignatureAlgorithmName);
77 HRESULT getPublicKeyAlgorithmOID(com::Utf8Str &aPublicKeyAlgorithmOID);
78 HRESULT getPublicKeyAlgorithm(com::Utf8Str &aPublicKeyAlgorithm);
79 HRESULT getIssuerName(std::vector<com::Utf8Str> &aIssuerName);
80 HRESULT getSubjectName(std::vector<com::Utf8Str> &aSubjectName);
81 HRESULT getFriendlyName(com::Utf8Str &aFriendlyName);
82 HRESULT getValidityPeriodNotBefore(com::Utf8Str &aValidityPeriodNotBefore);
83 HRESULT getValidityPeriodNotAfter(com::Utf8Str &aValidityPeriodNotAfter);
84 HRESULT getSubjectPublicKey(std::vector<BYTE> &aSubjectPublicKey);
85 HRESULT getIssuerUniqueIdentifier(com::Utf8Str &aIssuerUniqueIdentifier);
86 HRESULT getSubjectUniqueIdentifier(com::Utf8Str &aSubjectUniqueIdentifier);
87 HRESULT getCertificateAuthority(BOOL *aCertificateAuthority);
88 HRESULT getKeyUsage(ULONG *aKeyUsage);
89 HRESULT getExtendedKeyUsage(std::vector<com::Utf8Str> &aExtendedKeyUsage);
90 HRESULT getRawCertData(std::vector<BYTE> &aRawCertData);
91 HRESULT getSelfSigned(BOOL *aSelfSigned);
92 HRESULT getTrusted(BOOL *aTrusted);
93 HRESULT getExpired(BOOL *aExpired);
94
95 // Wrapped ICertificate methods
96 HRESULT isCurrentlyExpired(BOOL *aResult);
97 HRESULT queryInfo(LONG aWhat, com::Utf8Str &aResult);
98
99 // Methods extracting COM data from the certificate object
100 HRESULT i_getAlgorithmName(PCRTCRX509ALGORITHMIDENTIFIER a_pAlgId, com::Utf8Str &a_rReturn);
101 HRESULT i_getX509Name(PCRTCRX509NAME a_pName, std::vector<com::Utf8Str> &a_rReturn);
102 HRESULT i_getTime(PCRTASN1TIME a_pTime, com::Utf8Str &a_rReturn);
103 HRESULT i_getUniqueIdentifier(PCRTCRX509UNIQUEIDENTIFIER a_pUniqueId, com::Utf8Str &a_rReturn);
104 HRESULT i_getEncodedBytes(PRTASN1CORE a_pAsn1Obj, std::vector<BYTE> &a_rReturn);
105
106 struct Data;
107 /** Pointer to the private instance data */
108 Data *m;
109};
110
111#endif /* !MAIN_INCLUDED_CertificateImpl_h */
112
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette