VirtualBox

Changeset 90283 in vbox for trunk/include


Ignore:
Timestamp:
Jul 22, 2021 11:37:25 AM (4 years ago)
Author:
vboxsync
Message:

Runtime/efi: Started implementing the functionality to parse, create and modify EFI signature databases, bugref:9580

Location:
trunk/include/iprt
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/efi.h

    r90061 r90283  
    8888 */
    8989RTDECL(PEFI_GUID) RTEfiGuidFromUuid(PEFI_GUID pEfiGuid, PCRTUUID pUuid);
     90
     91
     92/**
     93 * Compares two EFI GUID values.
     94 *
     95 * @returns 0 if eq, < 0 or > 0.
     96 * @param   pGuid1          First value to compare.
     97 * @param   pGuid2          Second value to compare.
     98 */
     99RTDECL(int)  RTEfiGuidCompare(PCEFI_GUID pGuid1, PCEFI_GUID pGuid2);
    90100
    91101
     
    131141                                PRTERRINFO pErrInfo);
    132142
     143
     144/**
     145 * EFI signature type.
     146 */
     147typedef enum RTEFISIGTYPE
     148{
     149    /** Invalid type, do not use. */
     150    RTEFISIGTYPE_INVALID = 0,
     151    /** First valid signature type. */
     152    RTEFISIGTYPE_FIRST_VALID,
     153    /** Signature contains a SHA256 hash. */
     154    RTEFISIGTYPE_SHA256 = RTEFISIGTYPE_FIRST_VALID,
     155    /** Signature contains a RSA2048 key (only the modulus in big endian form,
     156     * the exponent is always 65537/0x10001). */
     157    RTEFISIGTYPE_RSA2048,
     158    /** Signature contains a RSA2048 signature of a SHA256 hash. */
     159    RTEFISIGTYPE_RSA2048_SHA256,
     160    /** Signature contains a SHA1 hash. */
     161    RTEFISIGTYPE_SHA1,
     162    /** Signature contains a RSA2048 signature of a SHA1 hash. */
     163    RTEFISIGTYPE_RSA2048_SHA1,
     164    /** Signature contains a DER encoded X.509 certificate. */
     165    RTEFISIGTYPE_X509,
     166    /** First invalid type (do not use). */
     167    RTEFISIGTYPE_FIRST_INVALID,
     168    /** 32bit blowup hack.*/
     169    RTEFISIGTYPE_32BIT_HACK = 0x7fffffff,
     170} RTEFISIGTYPE;
     171
     172
     173/**
     174 * EFI signature database enumeration callback.
     175 *
     176 * @returns IPRT status code, any status code other than VINF_SUCCESS will abort the enumeration.
     177 * @param   hEfiSigDb           Handle to the EFI signature database this callback is called on.
     178 * @param   enmSigType          The signature type.
     179 * @param   pUuidOwner          Signature owner UUID.
     180 * @param   pvSig               The signature data (dependent on the type).
     181 * @param   cbSig               Size of the signature in bytes.
     182 * @param   pvUser              Opaque user data passed in RTEfiSigDbEnum().
     183 */
     184typedef DECLCALLBACKTYPE(int, FNRTEFISIGDBENUMSIG,(RTEFISIGDB hEfiSigDb, RTEFISIGTYPE enmSigType, PCRTUUID pUuidOwner,
     185                                                   const void *pvSig, size_t cbSig, void *pvUser));
     186/** Pointer to a EFI signature database enumeration callback. */
     187typedef FNRTEFISIGDBENUMSIG *PFNRTEFISIGDBENUMSIG;
     188
     189
     190/**
     191 * Creates an empty EFI signature database.
     192 *
     193 * @returns IPRT status code.
     194 * @param   phEfiSigDb          Where to store the handle to the empty EFI signature database on success.
     195 */
     196RTDECL(int) RTEfiSigDbCreate(PRTEFISIGDB phEfiSigDb);
     197
     198
     199/**
     200 * Destroys the given EFI signature database handle.
     201 *
     202 * @returns IPRT status code.
     203 * @param   hEfiSigDb           The EFI signature database handle to destroy.
     204 */
     205RTDECL(int) RTEfiSigDbDestroy(RTEFISIGDB hEfiSigDb);
     206
     207
     208/**
     209 * Adds the signatures from an existing signature database contained in the given file.
     210 *
     211 * @returns IPRT status code.
     212 * @param   hEfiSigDb           The EFI signature database handle.
     213 * @param   hVfsFile            The file handle containing the existing signature database.
     214 */
     215RTDECL(int) RTEfiSigDbAddFromExistingDb(RTEFISIGDB hEfiSigDb, RTVFSFILE hVfsFileIn);
     216
     217
     218/**
     219 * Adds a new signature to the given signature database from the given file.
     220 *
     221 * @returns IPRT status code.
     222 * @param   hEfiSigDb           The EFI signature database handle.
     223 * @param   enmSigType          Type of the signature.
     224 * @param   pUuidOwner          The UUID of the signature owner.
     225 * @param   hVfsFileIn          File handle containing the signature data.
     226 */
     227RTDECL(int) RTEfiSigDbAddSignatureFromFile(RTEFISIGDB hEfiSigDb, RTEFISIGTYPE enmSigType, PCRTUUID pUuidOwner, RTVFSFILE hVfsFileIn);
     228
     229
     230/**
     231 * Adds a new signature to the given signature database from the given buffer.
     232 *
     233 * @returns IPRT status code.
     234 * @param   hEfiSigDb           The EFI signature database handle.
     235 * @param   enmSigType          Type of the signature.
     236 * @param   pUuidOwner          The UUID of the signature owner.
     237 * @param   pvBuf               Pointer to the signature data.
     238 * @param   cbBuf               Size of the signature data in bytes.
     239 */
     240RTDECL(int) RTEfiSigDbAddSignatureFromBuf(RTEFISIGDB hEfiSigDb, RTEFISIGTYPE enmSigType, PCRTUUID pUuidOwner,
     241                                          const void *pvBuf, size_t cbBuf);
     242
     243
     244/**
     245 * Writes the given EFI signature database to the given file.
     246 *
     247 * @returns IPRT status code.
     248 * @param   hEfiSigDb           The EFI signature database handle.
     249 * @param   hVfsFileOut         The file handle to write the signature database to.
     250 */
     251RTDECL(int) RTEfiSigDbWriteToFile(RTEFISIGDB hEfiSigDb, RTVFSFILE hVfsFileOut);
     252
     253
     254/**
     255 * Enumerate all signatures in the given EFI signature database.
     256 *
     257 * @returns IPRT status code.
     258 * @param   hEfiSigDb           The EFI signature database handle.
     259 * @param   pfnEnumSig          The callback to call for each signature.
     260 * @param   pvUser              Opaque user data to pass to the callback.
     261 */
     262RTDECL(int) RTEfiSigDbEnum(RTEFISIGDB hEfiSigDb, PFNRTEFISIGDBENUMSIG pfnEnumSig, void *pvUser);
     263
     264
     265/**
     266 * Returns a human readable string of the given signature type.
     267 *
     268 * @returns Human readable string.
     269 * @param   enmSigType          The signature type.
     270 */
     271RTDECL(const char *) RTEfiSigDbTypeStringify(RTEFISIGTYPE enmSigType);
     272
     273
     274/**
     275 * Returns a pointer to the EFI GUID identifying the given signature type.
     276 *
     277 * @returns Pointer to the EFI GUID.
     278 * @param   enmSigType          The signature type.
     279 */
     280RTDECL(PCEFI_GUID) RTEfiSigDbTypeGetGuid(RTEFISIGTYPE enmSigType);
     281
    133282#endif /* IN_RING3 */
    134283
  • trunk/include/iprt/formats/efi-common.h

    r90061 r90283  
    5151
    5252
     53/** A Null GUID. */
     54#define EFI_NULL_GUID { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 }}
     55
     56
    5357/**
    5458 * EFI time value.
  • trunk/include/iprt/mangling.h

    r90062 r90283  
    855855# define RTDvmVolumeTypeGetDescr                        RT_MANGLER(RTDvmVolumeTypeGetDescr)
    856856# define RTDvmVolumeCreateVfsFile                       RT_MANGLER(RTDvmVolumeCreateVfsFile)
     857# define RTEfiGuidCompare                               RT_MANGLER(RTEfiGuidCompare)
    857858# define RTEfiGuidFromUuid                              RT_MANGLER(RTEfiGuidFromUuid)
    858859# define RTEfiGuidToUuid                                RT_MANGLER(RTEfiGuidToUuid)
     860# define RTEfiSigDbAddFromExistingDb                    RT_MANGLER(RTEfiSigDbAddFromExistingDb)
     861# define RTEfiSigDbAddSignatureFromFile                 RT_MANGLER(RTEfiSigDbAddSignatureFromFile)
     862# define RTEfiSigDbAddSignatureFromBuf                  RT_MANGLER(RTEfiSigDbAddSignatureFromBuf)
     863# define RTEfiSigDbCreate                               RT_MANGLER(RTEfiSigDbCreate)
     864# define RTEfiSigDbDestroy                              RT_MANGLER(RTEfiSigDbDestroy)
     865# define RTEfiSigDbEnum                                 RT_MANGLER(RTEfiSigDbEnum)
     866# define RTEfiSigDbTypeGetGuid                          RT_MANGLER(RTEfiSigDbTypeGetGuid)
     867# define RTEfiSigDbTypeStringify                        RT_MANGLER(RTEfiSigDbTypeStringify)
     868# define RTEfiSigDbWriteToFile                          RT_MANGLER(RTEfiSigDbWriteToFile)
    859869# define RTEfiTimeFromTimeSpec                          RT_MANGLER(RTEfiTimeFromTimeSpec)
    860870# define RTEfiTimeToTimeSpec                            RT_MANGLER(RTEfiTimeToTimeSpec)
  • trunk/include/iprt/types.h

    r85614 r90283  
    25732573#define NIL_RTSHMEM                                ((RTSHMEM)~(uintptr_t)0)
    25742574
     2575/** EFI signature database handle. */
     2576typedef struct RTEFISIGDBINT                RT_FAR *RTEFISIGDB;
     2577/** Pointer to a EFI signature database handle. */
     2578typedef RTEFISIGDB                          RT_FAR *PRTEFISIGDB;
     2579/** A NIL EFI signature database handle. */
     2580#define NIL_RTEFISIGDB                             ((RTEFISIGDB)~(uintptr_t)0)
     2581
     2582
    25752583/**
    25762584 * Handle type.
Note: See TracChangeset for help on using the changeset viewer.

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