smvl_main.c
来自「Next BIOS Source code : Extensible Firmw」· C语言 代码 · 共 512 行 · 第 1/2 页
C
512 行
/*-----------------------------------------------------------------------
* File: smvl_main.c
*
Copyright (c) 1999 - 2002 Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.
*-----------------------------------------------------------------------
*/
/*
* INTEL CONFIDENTIAL
* This file, software, or program is supplied under the terms of a
* license agreement or nondisclosure agreement with Intel Corporation
* and may not be copied or disclosed except in accordance with the
* terms of that agreement. This file, software, or program contains
* copyrighted material and/or trade secret information of Intel
* Corporation, and must be treated as such. Intel reserves all rights
* in this material, except as the license agreement or nondisclosure
* agreement specifically indicate.
*/
/*
* WARNING: EXPORT RESTRICTED.
* This software is subject to the U.S. Export Administration Regulations
* and other U.S. law, and may not be exported or re-exported to certain
* countries (currently Afghanistan (Taliban-controlled areas), Cuba, Iran,
* Iraq, Libya, North Korea, Serbia (except Kosovo), Sudan and Syria) or to
* persons or entities prohibited from receiving U.S. exports (including Denied
* Parties, Specially Designated Nationals, and entities on the Bureau of
* Export Administration Entity List or involved with missile technology or
* nuclear, chemical or biological weapons).
*/
/*
* This file implements all of the global module functions
*/
/* Windows & CSSM includes */
#include "cssm.h"
#include "cssmspi.h"
#include "cssmport.h"
#include "guids.h"
/* VL-specific includes */
#include "smvl.h"
CSSM_RETURN
CSSMVLI
VL_Initialize(
CSSM_MODULE_HANDLE Handle,
uint32 VerMajor,
uint32 VerMinor);
CSSM_RETURN
CSSMVLI
VL_Uninitialize(
CSSM_MODULE_HANDLE Handle);
/* VL Global Data Structures */
CSSM_SPI_MEMORY_FUNCS g_fx;
ISL_MEMORY_METHODS gISL_mem_funcs;
SMVL_CONTEXT_PTR gsContextPtr = NULL;
/* VL wrapper memory functions */
static void * isl_malloc(uint32 Size, void *AllocRef)
{
return g_fx.malloc_func((CSSM_HANDLE)AllocRef, Size);
}
static void isl_free(void *MemPtr, void *AllocRef)
{
g_fx.free_func((CSSM_HANDLE)AllocRef, MemPtr);
}
static void * isl_realloc(void *MemPtr, uint32 Size, void *AllocRef)
{
return g_fx.realloc_func((CSSM_HANDLE)AllocRef, MemPtr, Size);
}
static void * isl_calloc(uint32 Num, uint32 Size, void *AllocRef)
{
return g_fx.calloc_func((CSSM_HANDLE)AllocRef, Num, Size);
}
/* Local #defines */
#define USE_CSSM_MEM_FUNCS
static const CSSM_SPI_VL_FUNCS FunctionTable =
{
VL_InstantiateVoFromLocation,
VL_FreeVo,
VL_GetDoInfoByName,
VL_FreeDoInfos,
VL_GetFirstSignatureInfo,
VL_AbortScan,
VL_FreeSignatureInfo,
VL_SetDoLMapEntries,
VL_VerifyRootCredentialsDataAndContainment,
VL_SelfVerifyCertificate
};
/*-----------------------------------------------------------------------------
* Name: AddInAuthenticate
*
* Description:
*
* Parameters:
*
* Return value:
*
* Error Codes:
*---------------------------------------------------------------------------*/
CSSM_RETURN CSSMAPI B2CC8C10_F00B_11d1_878B_00A0C91A2629_AddInAuthenticate
(const char* cssmCredentialPath,
const char* cssmSection,
const char* AppCredential,
const char* AppSection)
{
CSSM_REGISTRATION_INFO VLRegInfo;
CSSM_MODULE_FUNCS Services;
cssmCredentialPath; cssmSection;
AppCredential; AppSection;
/* Register the VL function table with the authenticated CSSM */
/* Fill in Registration information */
VLRegInfo.Initialize = VL_Initialize;
VLRegInfo.Terminate = VL_Uninitialize;
VLRegInfo.EventNotify = NULL;
VLRegInfo.GetModuleInfo = NULL;
VLRegInfo.FreeModuleInfo = NULL;
VLRegInfo.ThreadSafe = CSSM_FALSE;
VLRegInfo.ServiceSummary = CSSM_SERVICE_VL;
VLRegInfo.NumberOfServiceTables = 1;
VLRegInfo.Services = &Services;
/* Fill in Services */
Services.ServiceType = CSSM_SERVICE_VL;
Services.FunctionTable.VlFuncs = (CSSM_SPI_VL_FUNCS_PTR)&FunctionTable;
/* Fill in Function Table */
/* register its services with the CSSM */
return CSSM_RegisterServices(
&intel_preos_vlm_guid,
&VLRegInfo,
&g_fx, NULL);
}
/*-----------------------------------------------------------------------------
* Name: CloneSignVerifyMethod
*
* Description:
*
* Parameters:
* Handle (input)
* TemplatePtr (input)
* CSPHandle (input)
*
* Return value:
* ISL_SIGN_VERIFY_METHODS_PTR
* NULL - if call is unable to clone sign/verify methods
*
* Error Codes:
*---------------------------------------------------------------------------*/
#pragma warning (disable: 4100)
ISL_SIGN_VERIFY_METHODS_PTR
CloneSignVerifyMethod(
CSSM_MODULE_HANDLE Handle,
ISL_SIGN_VERIFY_METHODS_PTR TemplatePtr,
CSSM_CSP_HANDLE CSPHandle)
{
ISL_SIGN_VERIFY_METHODS_PTR MethodPtr;
if (TemplatePtr == NULL) return NULL;
#ifdef USE_CSSM_MEM_FUNCS
MethodPtr = cssm_malloc(sizeof(ISL_SIGN_VERIFY_METHODS), NULL);
#else
MethodPtr = g_fx.malloc_func(Handle, sizeof(ISL_SIGN_VERIFY_METHODS));
#endif
if (MethodPtr == NULL) goto FAIL;
cssm_memcpy(MethodPtr, TemplatePtr, sizeof(ISL_SIGN_VERIFY_METHODS));
MethodPtr->CSPHandle = CSPHandle;
return MethodPtr;
FAIL:
{
#ifdef USE_CSSM_MEM_FUNCS
cssm_free(MethodPtr, NULL);
#else
g_fx.free_func(Handle, MethodPtr);
#endif
return NULL;
}
}
#pragma warning (default: 4100)
/*-----------------------------------------------------------------------------
* Name: CloneDigestMethod
*
* Description:
*
* Parameters:
* Handle (input)
* TemplatePtr (input)
* CSPHandle (input)
*
* Return value:
* ISL_DIGEST_METHODS_PTR
* NULL - if unable to clone digest method
*
* Error Codes:
*---------------------------------------------------------------------------*/
#pragma warning (disable: 4100)
ISL_DIGEST_METHODS_PTR
CloneDigestMethod(
CSSM_MODULE_HANDLE Handle,
ISL_DIGEST_METHODS_PTR TemplatePtr,
CSSM_MODULE_HANDLE CSPHandle)
{
ISL_DIGEST_METHODS_PTR MethodPtr = NULL;
if (TemplatePtr == NULL) return NULL;
#ifdef USE_CSSM_MEM_FUNCS
MethodPtr = cssm_malloc(sizeof(ISL_DIGEST_METHODS), NULL);
#else
MethodPtr = g_fx.malloc_func(Handle, sizeof(ISL_DIGEST_METHODS));
#endif
if (MethodPtr == NULL) goto FAIL;
cssm_memcpy(MethodPtr, TemplatePtr, sizeof(ISL_DIGEST_METHODS));
MethodPtr->CSPHandle = CSPHandle;
return MethodPtr;
FAIL:
{
#ifdef USE_CSSM_MEM_FUNCS
cssm_free(MethodPtr, NULL);
#else
g_fx.free_func(Handle, MethodPtr);
#endif
return NULL;
}
}
#pragma warning (default: 4100)
/*-----------------------------------------------------------------------------
* Name: InitializeArchiveConfig
*
* Description:
*
* Parameters:
* Handle (input)
* smvlContextPtr (input)
*
* Return value:
* CSSM_OK
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?