1 | /** @file
|
---|
2 | * IPRT - Cryptographic (Certificate) Store.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2014 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_crypto_store_h
|
---|
27 | #define ___iprt_crypto_store_h
|
---|
28 |
|
---|
29 | #include <iprt/crypto/x509.h>
|
---|
30 | #include <iprt/crypto/taf.h>
|
---|
31 |
|
---|
32 |
|
---|
33 | RT_C_DECLS_BEGIN
|
---|
34 |
|
---|
35 | /** @defgroup grp_rt_crstore RTCrStore - Crypotgraphic (Certificate) Store.
|
---|
36 | * @ingroup grp_rt_crypto
|
---|
37 | * @{
|
---|
38 | */
|
---|
39 |
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * A certificate store search.
|
---|
43 | *
|
---|
44 | * Used by the store provider to keep track of the current location of a
|
---|
45 | * certificate search.
|
---|
46 | */
|
---|
47 | typedef struct RTCRSTORECERTSEARCH
|
---|
48 | {
|
---|
49 | /** Opaque provider specific storage.
|
---|
50 | *
|
---|
51 | * Provider restriction: The provider is only allowed to use the two first
|
---|
52 | * entries for the find-all searches, because the front-end API may want the
|
---|
53 | * last two for implementing specific searches on top of it. */
|
---|
54 | uintptr_t auOpaque[4];
|
---|
55 | } RTCRSTORECERTSEARCH;
|
---|
56 | /** Pointer to a certificate store search. */
|
---|
57 | typedef RTCRSTORECERTSEARCH *PRTCRSTORECERTSEARCH;
|
---|
58 |
|
---|
59 |
|
---|
60 | RTDECL(int) RTCrStoreCreateInMem(PRTCRSTORE phStore, uint32_t cSizeHint);
|
---|
61 |
|
---|
62 | RTDECL(uint32_t) RTCrStoreRetain(RTCRSTORE hStore);
|
---|
63 | RTDECL(uint32_t) RTCrStoreRelease(RTCRSTORE hStore);
|
---|
64 | RTDECL(PCRTCRCERTCTX) RTCrStoreCertByIssuerAndSerialNo(RTCRSTORE hStore, PCRTCRX509NAME pIssuer, PCRTASN1INTEGER pSerialNo);
|
---|
65 | RTDECL(int) RTCrStoreCertAddEncoded(RTCRSTORE hStore, uint32_t fFlags, void const *pvSrc, size_t cbSrc, PRTERRINFO pErrInfo);
|
---|
66 | RTDECL(int) RTCrStoreCertAddFromFile(RTCRSTORE hStore, uint32_t fFlags, const char *pszFilename, PRTERRINFO pErrInfo);
|
---|
67 |
|
---|
68 | RTDECL(int) RTCrStoreCertFindAll(RTCRSTORE hStore, PRTCRSTORECERTSEARCH pSearch);
|
---|
69 | RTDECL(int) RTCrStoreCertFindBySubjectOrAltSubjectByRfc5280(RTCRSTORE hStore, PCRTCRX509NAME pSubject,
|
---|
70 | PRTCRSTORECERTSEARCH pSearch);
|
---|
71 | RTDECL(PCRTCRCERTCTX) RTCrStoreCertSearchNext(RTCRSTORE hStore, PRTCRSTORECERTSEARCH pSearch);
|
---|
72 | RTDECL(int) RTCrStoreCertSearchDestroy(RTCRSTORE hStore, PRTCRSTORECERTSEARCH pSearch);
|
---|
73 |
|
---|
74 | RTDECL(int) RTCrStoreConvertToOpenSslCertStore(RTCRSTORE hStore, uint32_t fFlags, void **ppvOpenSslStore);
|
---|
75 | RTDECL(int) RTCrStoreConvertToOpenSslCertStack(RTCRSTORE hStore, uint32_t fFlags, void **ppvOpenSslStack);
|
---|
76 |
|
---|
77 |
|
---|
78 | /** @} */
|
---|
79 |
|
---|
80 |
|
---|
81 | /** @defgroup grp_rt_crcertctx RTCrCertCtx - (Store) Certificate Context.
|
---|
82 | * @{ */
|
---|
83 |
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Certificate context.
|
---|
87 | *
|
---|
88 | * This is returned by the certificate store APIs and is part of a larger
|
---|
89 | * reference counted structure. All the data is read only.
|
---|
90 | */
|
---|
91 | typedef struct RTCRCERTCTX
|
---|
92 | {
|
---|
93 | /** Flags, RTCRCERTCTX_F_XXX. */
|
---|
94 | uint32_t fFlags;
|
---|
95 | /** The size of the (DER) encoded certificate. */
|
---|
96 | uint32_t cbEncoded;
|
---|
97 | /** Pointer to the (DER) encoded certificate. */
|
---|
98 | uint8_t const *pabEncoded;
|
---|
99 | /** Pointer to the decoded X.509 representation of the certificate.
|
---|
100 | * This can be NULL when pTaInfo is present. */
|
---|
101 | PCRTCRX509CERTIFICATE pCert;
|
---|
102 | /** Pointer to the decoded TrustAnchorInfo for the certificate. This can be
|
---|
103 | * NULL, even for trust anchors, as long as pCert isn't. */
|
---|
104 | PCRTCRTAFTRUSTANCHORINFO pTaInfo;
|
---|
105 | /** Reserved for future use. */
|
---|
106 | void *paReserved[2];
|
---|
107 | } RTCRCERTCTX;
|
---|
108 |
|
---|
109 | /** @name RTCRCERTCTX_F_XXX.
|
---|
110 | * @{ */
|
---|
111 | /** Encoding mask. */
|
---|
112 | #define RTCRCERTCTX_F_ENC_MASK UINT32_C(0x000000ff)
|
---|
113 | /** X.509 certificate, DER encoded. */
|
---|
114 | #define RTCRCERTCTX_F_ENC_X509_DER UINT32_C(0x00000000)
|
---|
115 | /** RTF-5914 trust anchor info, DER encoded. */
|
---|
116 | #define RTCRCERTCTX_F_ENC_TAF_DER UINT32_C(0x00000001)
|
---|
117 | #if 0
|
---|
118 | /** Extended certificate, DER encoded. */
|
---|
119 | #define RTCRCERTCTX_F_ENC_PKCS6_DER UINT32_C(0x00000002)
|
---|
120 | #endif
|
---|
121 | /** @} */
|
---|
122 |
|
---|
123 |
|
---|
124 | RTDECL(uint32_t) RTCrCertCtxRetain(PCRTCRCERTCTX pCertCtx);
|
---|
125 | RTDECL(uint32_t) RTCrCertCtxRelease(PCRTCRCERTCTX pCertCtx);
|
---|
126 |
|
---|
127 | /** @} */
|
---|
128 |
|
---|
129 | RT_C_DECLS_END
|
---|
130 |
|
---|
131 | #endif
|
---|
132 |
|
---|