VirtualBox

Ignore:
Timestamp:
Jul 10, 2023 11:17:15 PM (19 months ago)
Author:
vboxsync
Message:

IPRT/PKCS8: Some corrections and adjustments (bugref:10299):

  • Always put curly brackets around case bodies that declares variables.
  • Removed copy & paste RTCRRSA_MAX_MODULUS_BITS define from pkcs8-internal.h.
  • We don't need to compile the PKCS8 files for ring-0 libraries, since these does not include the key-file.cpp that needs them.
  • Use RTCRX509ALGORITHMIDENTIFIERID_RSA instead of "1.2.840.113549.1.1.1".
  • rTCrPkcs8PrivateKeyInfo should be RTCrPkcs8PrivateKeyInfo in pkcs8-templace.h.
Location:
trunk/src/VBox/Runtime/common/crypto
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/crypto/key-file.cpp

    r100421 r100493  
    471471
    472472        case kKeyFormat_PrivateKeyInfo:
     473        {
    473474            RTAsn1CursorInitPrimary(&PrimaryCursor, pSection->pbData, (uint32_t)pSection->cbData,
    474475                                    pErrInfo, &g_RTAsn1DefaultAllocator, RTASN1CURSOR_FLAGS_DER, pszErrorTag);
     
    479480            if (RT_SUCCESS(rc))
    480481            {
    481                 /*
    482                  * Check if the algorithm is pkcs1-RsaEncryption
     482                /*
     483                 * Load the private key according to it's algorithm.
     484                 * We currently only support RSA (pkcs1-RsaEncryption).
    483485                 */
    484                 if (strcmp(PrivateKeyInfo.PrivateKeyAlgorithm.Algorithm.szObjId,"1.2.840.113549.1.1.1") == 0)
    485                 {
    486                     uint32_t cbContent = PrivateKeyInfo.PrivateKey.Asn1Core.cb;
    487                     rc = rtCrKeyCreateRsaPrivate(phKey, PrivateKeyInfo.PrivateKey.Asn1Core.uData.pv, cbContent, pErrInfo, pszErrorTag);
    488                 }
     486                if (RTAsn1ObjId_CompareWithString(&PrivateKeyInfo.PrivateKeyAlgorithm.Algorithm,
     487                                                  RTCRX509ALGORITHMIDENTIFIERID_RSA) == 0)
     488                    rc = rtCrKeyCreateRsaPrivate(phKey, PrivateKeyInfo.PrivateKey.Asn1Core.uData.pv,
     489                                                 PrivateKeyInfo.PrivateKey.Asn1Core.cb, pErrInfo, pszErrorTag);
    489490                else
    490                 {
    491491                    rc = RTErrInfoSet(pErrInfo, VERR_CR_KEY_FORMAT_NOT_SUPPORTED,
    492                                     "Support for PKCS#8 PrivateKeyInfo (with no RSA encryption) is not yet implemented");
    493                 }
     492                                      "Support for PKCS#8 PrivateKeyInfo for non-RSA keys is not yet implemented");
    494493            }
    495494            break;
     495        }
    496496
    497497        case kKeyFormat_EncryptedPrivateKeyInfo:
  • trunk/src/VBox/Runtime/common/crypto/pkcs8-internal.h

    r100421 r100493  
    4141#endif
    4242
    43 /** The max number of bits we support in the modulus. */
    44 #define RTCRRSA_MAX_MODULUS_BITS        16384
    45 
    4643#define RTASN1TMPL_TEMPLATE_FILE "../common/crypto/pkcs8-template.h"
    4744#include <iprt/asn1-generator-internal-header.h>
  • trunk/src/VBox/Runtime/common/crypto/pkcs8-template.h

    r100421 r100493  
    4242#define RTASN1TMPL_TYPE         RTCRPKCS8PRIVATEKEYINFO
    4343#define RTASN1TMPL_EXT_NAME     RTCrPkcs8PrivateKeyInfo
    44 #define RTASN1TMPL_INT_NAME     rTCrPkcs8PrivateKeyInfo
     44#define RTASN1TMPL_INT_NAME     RTCrPkcs8PrivateKeyInfo
    4545RTASN1TMPL_BEGIN_SEQCORE();
    4646RTASN1TMPL_MEMBER(              Version,                RTASN1INTEGER,                  RTAsn1Integer);
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