VirtualBox

vbox的更動 59625 路徑 trunk/src/VBox/Runtime


忽略:
時間撮記:
2016-2-10 上午08:55:22 (9 年 以前)
作者:
vboxsync
訊息:

IPRT: Added RTCrPemFindFirstSectionInContent and exposed certificate PEM markers (g_aRTCrX509CertificateMarkers).

位置:
trunk/src/VBox/Runtime/common/crypto
檔案:
修改 2 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/common/crypto/pemfile.cpp

    r57641 r59625  
    271271     *      tab, newline, return, form feed
    272272     *
    273      * However, if we wan't to read PEM files which contains human readable
     273     * However, if we want to read PEM files which contains human readable
    274274     * certificate details before or after each base-64 section, we can't stick
    275275     * to 7-bit ASCII.  We could say it must be UTF-8, but that's probably to
    276      * limited too.  So, we'll settle for detecting binary files by control
     276     * limited as well.  So, we'll settle for detecting binary files by control
    277277     * characters alone (safe enough for DER encoded stuff, I think).
    278278     */
     
    435435
    436436
    437 
    438437RTDECL(int) RTCrPemReadFile(const char *pszFilename, uint32_t fFlags, PCRTCRPEMMARKER paMarkers, size_t cMarkers,
    439438                            PCRTCRPEMSECTION *ppSectionHead, PRTERRINFO pErrInfo)
     
    455454}
    456455
     456
     457RTDECL(const char *) RTCrPemFindFirstSectionInContent(void const *pvContent, size_t cbContent,
     458                                                      PCRTCRPEMMARKER paMarkers, size_t cMarkers)
     459{
     460    size_t offBegin;
     461    if (rtCrPemFindMarker((uint8_t *)pvContent, cbContent, 0, "BEGIN", 5, paMarkers, cMarkers, NULL, &offBegin, NULL))
     462        return (const char *)pvContent + offBegin;
     463    return NULL;
     464}
  • trunk/src/VBox/Runtime/common/crypto/x509-file.cpp

    r59620 r59625  
    4343static RTCRPEMMARKERWORD const g_aWords_Certificate[]  = { { RT_STR_TUPLE("CERTIFICATE") } };
    4444/** X509 Certificate markers. */
    45 static RTCRPEMMARKER     const g_aCertificateMarkers[] = { { g_aWords_Certificate, RT_ELEMENTS(g_aWords_Certificate) } };
     45RT_DECL_DATA_CONST(RTCRPEMMARKER const) g_aRTCrX509CertificateMarkers[] =
     46{
     47    { g_aWords_Certificate, RT_ELEMENTS(g_aWords_Certificate) }
     48};
     49/** Number of entries in g_aRTCrX509CertificateMarkers. */
     50RT_DECL_DATA_CONST(uint32_t const) g_cRTCrX509CertificateMarkers = RT_ELEMENTS(g_aRTCrX509CertificateMarkers);
    4651
    4752
     
    5156    AssertReturn(!fFlags, VERR_INVALID_FLAGS);
    5257    PCRTCRPEMSECTION pSectionHead;
    53     int rc = RTCrPemReadFile(pszFilename, 0, g_aCertificateMarkers, RT_ELEMENTS(g_aCertificateMarkers), &pSectionHead, pErrInfo);
     58    int rc = RTCrPemReadFile(pszFilename, 0, g_aRTCrX509CertificateMarkers, g_cRTCrX509CertificateMarkers,
     59                             &pSectionHead, pErrInfo);
    5460    if (RT_SUCCESS(rc))
    5561    {
     
    8591    AssertReturn(!fFlags, VERR_INVALID_FLAGS);
    8692    PCRTCRPEMSECTION pSectionHead;
    87     int rc = RTCrPemParseContent(pvBuf, cbBuf, 0, g_aCertificateMarkers, RT_ELEMENTS(g_aCertificateMarkers),
     93    int rc = RTCrPemParseContent(pvBuf, cbBuf, 0, g_aRTCrX509CertificateMarkers, g_cRTCrX509CertificateMarkers,
    8894                                 &pSectionHead, pErrInfo);
    8995    if (RT_SUCCESS(rc))
     
    121127    AssertReturn(!fFlags, VERR_INVALID_FLAGS);
    122128    PCRTCRPEMSECTION pSectionHead;
    123     int rc = RTCrPemReadFile(pszFilename, 0, g_aCertificateMarkers, RT_ELEMENTS(g_aCertificateMarkers), &pSectionHead, pErrInfo);
     129    int rc = RTCrPemReadFile(pszFilename, 0, g_aRTCrX509CertificateMarkers, g_cRTCrX509CertificateMarkers,
     130                             &pSectionHead, pErrInfo);
    124131    if (RT_SUCCESS(rc))
    125132    {
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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