VirtualBox

Ignore:
Timestamp:
Sep 16, 2022 9:10:51 AM (2 years ago)
Author:
vboxsync
Message:

IPRT/crypto: Put the optional OpenSSL related members in RTCRKEYINT at the end of the structure and added a flag to indicate whether they're there or not. This means users of the structure other than key.cpp and key-openssl.cpp can safely ignore the IPRT_WITH_OPENSSL flag. This is relevant for build programs like bldRTSignTool. bugref:8691

Location:
trunk/src/VBox/Runtime/common/crypto
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/key-internal.h

    r96407 r96763  
    6161    uint32_t                    cBits;
    6262
    63 #if defined(IPRT_WITH_OPENSSL)
    64     /** Size of raw key copy. */
    65     uint32_t                    cbEncoded;
    66     /** Raw copy of the key, for openssl and such.
    67      * If sensitive, this is a safer allocation, otherwise it follows the structure. */
    68     uint8_t                    *pbEncoded;
    69 #endif
    70 
    7163    /** Type specific data. */
    7264    union
     
    9385        } RsaPublic;
    9486    } u;
     87
     88#if defined(IPRT_WITH_OPENSSL)
     89    /** Size of raw key copy. */
     90    uint32_t                    cbEncoded;
     91    /** Raw copy of the key, for openssl and such.
     92     * If sensitive, this is a safer allocation, otherwise it follows the structure. */
     93    uint8_t                    *pbEncoded;
     94#endif
    9595} RTCRKEYINT;
    9696/** Pointer to a crypographic key. */
     
    109109/** Set if public key bits are present. */
    110110#define RTCRKEYINT_F_PUBLIC             UINT32_C(0x00000004)
     111/** Set if the cbEncoded/pbEncoded members are present. */
     112#define RTCRKEYINT_F_INCLUDE_ENCODED    UINT32_C(0x00000008)
    111113/** @} */
    112114
  • trunk/src/VBox/Runtime/common/crypto/key-openssl.cpp

    r96407 r96763  
    7777    AssertReturn(hKey->u32Magic == RTCRKEYINT_MAGIC, VERR_INVALID_HANDLE);
    7878    AssertReturn(fNeedPublic == !(hKey->fFlags & RTCRKEYINT_F_PRIVATE), VERR_WRONG_TYPE);
     79    AssertReturn(hKey->fFlags & RTCRKEYINT_F_INCLUDE_ENCODED, VERR_WRONG_TYPE); /* build misconfig */
    7980
    8081    rtCrOpenSslInit();
     
    140141    AssertReturn(hKey->u32Magic == RTCRKEYINT_MAGIC, VERR_INVALID_HANDLE);
    141142    AssertReturn(fNeedPublic == !(hKey->fFlags & RTCRKEYINT_F_PRIVATE), VERR_WRONG_TYPE);
     143    AssertReturn(hKey->fFlags & RTCRKEYINT_F_INCLUDE_ENCODED, VERR_WRONG_TYPE); /* build misconfig */
    142144
    143145    rtCrOpenSslInit();
  • trunk/src/VBox/Runtime/common/crypto/key.cpp

    r96407 r96763  
    7676        pThis->fFlags       = fFlags;
    7777#if defined(IPRT_WITH_OPENSSL)
     78        pThis->fFlags      |= RTCRKEYINT_F_INCLUDE_ENCODED;
    7879        pThis->cbEncoded    = cbEncoded;
    7980        if (!(fFlags & RTCRKEYINT_F_SENSITIVE))
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