/* $Id$ */
/** @file
* IPRT - Cryptographic (Certificate) Store.
*/
/*
* Copyright (C) 2006-2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#ifdef IPRT_WITH_OPENSSL
#endif
#include "store-internal.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Internal representation of a (certificate,++) store.
*/
typedef struct RTCRSTOREINT
{
/** Magic number (RTCRSTOREINT_MAGIC). */
/** Reference counter. */
/** Pointer to the store provider. */
/** Provider specific data. */
void *pvProvider;
} RTCRSTOREINT;
/** Pointer to the internal representation of a store. */
/** Magic value for RTCRSTOREINT::u32Magic (Alfred Dillwyn "Dilly" Knox). */
/** Dead magic value for RTCRSTOREINT::u32Magic. */
/**
* Internal method a store provider uses to create a store handle.
*
* @returns IPRT status code
* @param pProvider Pointer to the store provider callback table.
* @param pvProvider Pointer to the provider specific instance data.
* @param phStore Where to return the store handle.
*/
DECLHIDDEN(int) rtCrStoreCreate(PCRTCRSTOREPROVIDER pProvider, void *pvProvider, PRTCRSTORE phStore)
{
if (pThis)
{
return VINF_SUCCESS;
}
return VERR_NO_MEMORY;
}
{
return cRet;
}
{
if (hStore == NIL_RTCRSTORE)
return 0;
if (!cStore)
{
}
return cStore;
}
RTDECL(PCRTCRCERTCTX) RTCrStoreCertByIssuerAndSerialNo(RTCRSTORE hStore, PCRTCRX509NAME pIssuer, PCRTASN1INTEGER pSerialNo)
{
int rc;
rc = pThis->pProvider->pfnCertFindByIssuerAndSerialNo(pThis->pvProvider, pIssuer, pSerialNo, &Search);
else
if (RT_SUCCESS(rc))
{
for (;;)
{
if (!pCertCtx)
break;
break;
}
}
else
return pCertCtx;
}
RTDECL(int) RTCrStoreCertAddEncoded(RTCRSTORE hStore, uint32_t fFlags, void const *pvSrc, size_t cbSrc, PRTERRINFO pErrInfo)
{
int rc;
rc = pThis->pProvider->pfnCertAddEncoded(pThis->pvProvider, fFlags, (uint8_t const *)pvSrc, (uint32_t)cbSrc, pErrInfo);
else
return rc;
}
/*
* Searching.
* Searching.
* Searching.
*/
{
}
/** Indicator for RTCrStoreCertFindBySubjectOrAltSubjectByRfc5280 searches
* implemented by this front-end code. */
RTDECL(int) RTCrStoreCertFindBySubjectOrAltSubjectByRfc5280(RTCRSTORE hStore, PCRTCRX509NAME pSubject,
{
if (RT_SUCCESS(rc))
{
}
return rc;
}
{
{
default:
break;
{
for (;;)
{
if (!pRet)
break;
{
break;
}
{
break;
}
}
break;
}
}
return pRet;
}
{
if (pSearch)
{
}
return VINF_SUCCESS;
}
#ifdef IPRT_WITH_OPENSSL
/*
* OpenSSL helper.
* OpenSSL helper.
* OpenSSL helper.
*/
RTDECL(int) RTCrStoreConvertToOpenSslCertStore(RTCRSTORE hStore, uint32_t fFlags, void **ppvOpenSslStore)
{
/*
* Use the pfnCertFindAll method to add all certificates to the store we're returning.
*/
int rc;
if (pOsslStore)
{
if (RT_SUCCESS(rc))
{
do
{
if (!pCertCtx)
break;
{
{
rc = VERR_NO_MEMORY;
}
}
} while (RT_SUCCESS(rc));
if (RT_SUCCESS(rc))
{
return VINF_SUCCESS;
}
}
}
else
rc = VERR_NO_MEMORY;
return rc;
}
RTDECL(int) RTCrStoreConvertToOpenSslCertStack(RTCRSTORE hStore, uint32_t fFlags, void **ppvOpenSslStack)
{
/*
* Use the pfnCertFindAll method to add all certificates to the store we're returning.
*/
int rc;
if (pOsslStack)
{
if (RT_SUCCESS(rc))
{
do
{
if (!pCertCtx)
break;
{
{
{
rc = VERR_NO_MEMORY;
}
}
}
} while (RT_SUCCESS(rc));
if (RT_SUCCESS(rc))
{
return VINF_SUCCESS;
}
}
}
else
rc = VERR_NO_MEMORY;
return rc;
}
#endif /* IPRT_WITH_OPENSSL */
/*
* Certificate context.
* Certificate context.
* Certificate context.
*/
{
return cRet;
}
{
if (!pCertCtx)
return 0;
if (!cRet)
{
}
return cRet;
}