OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcStorageLib.h File Reference
#include <Library/BaseOverflowLib.h>
#include <Library/OcCryptoLib.h>
#include <Library/OcFileLib.h>
#include <Library/OcSerializeLib.h>

Go to the source code of this file.

Data Structures

struct  OC_STORAGE_CONTEXT
 

Macros

#define OC_STORAGE_VAULT_PATH   L"vault.plist"
 
#define OC_STORAGE_VAULT_SIGNATURE_PATH   L"vault.sig"
 
#define OC_STORAGE_VAULT_VERSION   1
 
#define OC_STORAGE_SAFE_PATH_MAX   128
 
#define OC_STORAGE_VAULT_HASH_FIELDS(_, __)
 
#define OC_STORAGE_VAULT_FILES_FIELDS(_, __)
 
#define OC_STORAGE_VAULT_FIELDS(_, __)
 

Functions

EFI_STATUS OcStorageInitFromFs (OUT OC_STORAGE_CONTEXT *Context, IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem, IN EFI_HANDLE StorageHandle OPTIONAL, IN EFI_DEVICE_PATH_PROTOCOL *StoragePath OPTIONAL, IN CONST CHAR16 *StorageRoot, IN OC_RSA_PUBLIC_KEY *StorageKey OPTIONAL)
 
VOID OcStorageFree (IN OUT OC_STORAGE_CONTEXT *Context)
 
BOOLEAN OcStorageExistsFileUnicode (IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath)
 
VOID * OcStorageReadFileUnicode (IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath, OUT UINT32 *FileSize OPTIONAL)
 
EFI_STATUS OcStorageGetInfo (IN OC_STORAGE_CONTEXT *Context, IN CONST CHAR16 *FilePath, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT EFI_HANDLE *StorageHandle, OUT EFI_DEVICE_PATH_PROTOCOL **StoragePath, IN BOOLEAN RealPath)
 

Detailed Description

Copyright (C) 2019, vit9696. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcStorageLib.h.

Macro Definition Documentation

◆ OC_STORAGE_SAFE_PATH_MAX

#define OC_STORAGE_SAFE_PATH_MAX   128

Safe maximum file path in the storage.

Definition at line 41 of file OcStorageLib.h.

◆ OC_STORAGE_VAULT_FIELDS

#define OC_STORAGE_VAULT_FIELDS ( _,
__ )
Value:
_(UINT32 , Version , , 0 , () ) \
_(OC_STORAGE_VAULT_FILES , Files , , OC_CONSTR (OC_STORAGE_VAULT_FILES, _, __) , OC_DESTR (OC_STORAGE_VAULT_FILES))
UINT32 Version
#define OC_DESTR(A)
#define OC_CONSTR(A, _, __)

Definition at line 54 of file OcStorageLib.h.

◆ OC_STORAGE_VAULT_FILES_FIELDS

#define OC_STORAGE_VAULT_FILES_FIELDS ( _,
__ )
Value:
OC_MAP (OC_STRING, OC_STORAGE_VAULT_HASH, _, __)
#define OC_MAP(KeyType, Type, _, __)

Definition at line 50 of file OcStorageLib.h.

◆ OC_STORAGE_VAULT_HASH_FIELDS

#define OC_STORAGE_VAULT_HASH_FIELDS ( _,
__ )
Value:
_(UINT8 , Hash , [SHA256_DIGEST_SIZE] , {0} , () )
#define SHA256_DIGEST_SIZE
Definition OcCryptoLib.h:45

Structure declaration for vault file.

Definition at line 46 of file OcStorageLib.h.

◆ OC_STORAGE_VAULT_PATH

#define OC_STORAGE_VAULT_PATH   L"vault.plist"

Storage vault file containing a dictionary with SHA-256 hashes for all files.

Definition at line 26 of file OcStorageLib.h.

◆ OC_STORAGE_VAULT_SIGNATURE_PATH

#define OC_STORAGE_VAULT_SIGNATURE_PATH   L"vault.sig"

RSA-2048 signature of SHA-256 hash of vault.plist.

Definition at line 31 of file OcStorageLib.h.

◆ OC_STORAGE_VAULT_VERSION

#define OC_STORAGE_VAULT_VERSION   1

Storage vault version declaring vault compatibility.

Definition at line 36 of file OcStorageLib.h.

Function Documentation

◆ OcStorageExistsFileUnicode()

BOOLEAN OcStorageExistsFileUnicode ( IN OC_STORAGE_CONTEXT * Context,
IN CONST CHAR16 * FilePath )

Check whether file exists.

Parameters
[in]ContextStorage context.
[in]FilePathThe full path to the file on the device.
Return values
TRUEif file is present in vault or ondisk.

Definition at line 340 of file OcStorageLib.c.

◆ OcStorageFree()

VOID OcStorageFree ( IN OUT OC_STORAGE_CONTEXT * Context)

Free storage context resources.

Parameters
[in,out]ContextStorage context.

Definition at line 315 of file OcStorageLib.c.

◆ OcStorageGetInfo()

EFI_STATUS OcStorageGetInfo ( IN OC_STORAGE_CONTEXT * Context,
IN CONST CHAR16 * FilePath,
OUT EFI_DEVICE_PATH_PROTOCOL ** DevicePath,
OUT EFI_HANDLE * StorageHandle,
OUT EFI_DEVICE_PATH_PROTOCOL ** StoragePath,
IN BOOLEAN RealPath )

Get information about the storage file when possible.

Parameters
[in]ContextStorage context.
[in]FilePathThe full path to the file on the device.
[out]DevicePathFull storage file device path.
[out]StorageHandleStorage handle.
[out]StoragePathPath on the storage.
[in]RealPathProvide real paths instead of dummy.
Return values
EFI_SUCCESSon success.

◆ OcStorageInitFromFs()

EFI_STATUS OcStorageInitFromFs ( OUT OC_STORAGE_CONTEXT * Context,
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * FileSystem,
IN EFI_HANDLE StorageHandle OPTIONAL,
IN EFI_DEVICE_PATH_PROTOCOL *StoragePath OPTIONAL,
IN CONST CHAR16 * StorageRoot,
IN OC_RSA_PUBLIC_KEY *StorageKey OPTIONAL )

Create storage context from UEFI file system at specified path.

Parameters
[out]ContextResulting storage context.
[in]FileSystemStorage file system.
[in]StorageHandleStorage handle, optional.
[in]StoragePathActual storage device path, optional.
[in]StorageRootStorage file system root (e.g. L"\\").
[in]StorageKeyStorage signature verification key, optional.
Return values
EFI_SUCCESSon success.

Definition at line 215 of file OcStorageLib.c.

◆ OcStorageReadFileUnicode()

VOID * OcStorageReadFileUnicode ( IN OC_STORAGE_CONTEXT * Context,
IN CONST CHAR16 * FilePath,
OUT UINT32 *FileSize OPTIONAL )

Read file from storage with implicit double (2 byte) null termination. Null termination does not affect the returned file size. Depending on the implementation 0 byte files may return null. If storage context was created with valid storage key, then signature checking will be performed

Parameters
[in]ContextStorage context.
[in]FilePathThe full path to the file on the device.
[out]FileSizeThe size of the file read (optional).
Return values
Apointer to a buffer containing file read or NULL.

Definition at line 383 of file OcStorageLib.c.