Changeset 59625 in vbox
- Timestamp:
- Feb 10, 2016 8:55:22 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105464
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/crypto/pem.h
r57577 r59625 4 4 5 5 /* 6 * Copyright (C) 2006-201 5Oracle Corporation6 * Copyright (C) 2006-2016 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 */ 25 25 26 #ifndef ___iprt_crypto_ spc_h27 #define ___iprt_crypto_ spc_h26 #ifndef ___iprt_crypto_pem_h 27 #define ___iprt_crypto_pem_h 28 28 29 #include <iprt/asn1.h> 30 #include <iprt/crypto/x509.h> 31 #include <iprt/crypto/pkcs7.h> 32 #include <iprt/md5.h> 33 #include <iprt/sha.h> 29 #include <iprt/types.h> 34 30 35 31 … … 156 152 /** @} */ 157 153 154 /** 155 * Finds the beginning of first PEM section using the specified markers. 156 * 157 * This will not look any further than the first section. Nor will it check for 158 * binaries. 159 * 160 * @returns Pointer to the "-----BEGIN XXXX" sequence on success. 161 * NULL if not found. 162 * @param pvContent The content bytes to parse. 163 * @param cbContent The number of content bytes. 164 * @param paMarkers Array of one or more section markers to look for. 165 * @param cMarkers Number of markers in the array. 166 */ 167 RTDECL(const char *) RTCrPemFindFirstSectionInContent(void const *pvContent, size_t cbContent, 168 PCRTCRPEMMARKER paMarkers, size_t cMarkers); 169 158 170 /** @} */ 159 171 -
trunk/include/iprt/crypto/x509.h
r59620 r59625 28 28 29 29 #include <iprt/asn1.h> 30 #include <iprt/crypto/pem.h> 30 31 31 32 … … 965 966 PRTERRINFO pErrInfo, const char *pszErrorTag); 966 967 968 /** X509 Certificate markers for RTCrPemFindFirstSectionInContent et al. */ 969 extern RTDATADECL(RTCRPEMMARKER const) g_aRTCrX509CertificateMarkers[]; 970 /** Number of entries in g_aRTCrX509CertificateMarkers. */ 971 extern RTDATADECL(uint32_t const) g_cRTCrX509CertificateMarkers; 972 967 973 968 974 -
trunk/include/iprt/mangling.h
r59620 r59625 2743 2743 # define RTCrRsaPrivateKey_CheckSanity RT_MANGLER(RTCrRsaPrivateKey_CheckSanity) 2744 2744 # define RTCrRsaPublicKey_CheckSanity RT_MANGLER(RTCrRsaPublicKey_CheckSanity) 2745 # define RTCrPemFindFirstSectionInContent RT_MANGLER(RTCrPemFindFirstSectionInContent) 2745 2746 # define RTCrPemFreeSections RT_MANGLER(RTCrPemFreeSections) 2746 2747 # define RTCrPemParseContent RT_MANGLER(RTCrPemParseContent) … … 3314 3315 # define g_RTAsn1DefaultAllocator RT_MANGLER(g_RTAsn1DefaultAllocator) 3315 3316 # define g_RTAsn1EFenceAllocator RT_MANGLER(g_RTAsn1EFenceAllocator) 3317 # define g_aRTCrX509CertificateMarkers RT_MANGLER(g_aRTCrX509CertificateMarkers) 3318 # define g_cRTCrX509CertificateMarkers RT_MANGLER(g_cRTCrX509CertificateMarkers) 3319 3316 3320 #if 0 /* Disabled for now as I'm not sure the assmbler supports mangling yet. */ 3317 3321 # define g_abRTZeroPage RT_MANGLER(g_abRTZeroPage) -
trunk/src/VBox/Runtime/common/crypto/pemfile.cpp
r57641 r59625 271 271 * tab, newline, return, form feed 272 272 * 273 * However, if we wan 't to read PEM files which contains human readable273 * However, if we want to read PEM files which contains human readable 274 274 * certificate details before or after each base-64 section, we can't stick 275 275 * 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 control276 * limited as well. So, we'll settle for detecting binary files by control 277 277 * characters alone (safe enough for DER encoded stuff, I think). 278 278 */ … … 435 435 436 436 437 438 437 RTDECL(int) RTCrPemReadFile(const char *pszFilename, uint32_t fFlags, PCRTCRPEMMARKER paMarkers, size_t cMarkers, 439 438 PCRTCRPEMSECTION *ppSectionHead, PRTERRINFO pErrInfo) … … 455 454 } 456 455 456 457 RTDECL(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 43 43 static RTCRPEMMARKERWORD const g_aWords_Certificate[] = { { RT_STR_TUPLE("CERTIFICATE") } }; 44 44 /** X509 Certificate markers. */ 45 static RTCRPEMMARKER const g_aCertificateMarkers[] = { { g_aWords_Certificate, RT_ELEMENTS(g_aWords_Certificate) } }; 45 RT_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. */ 50 RT_DECL_DATA_CONST(uint32_t const) g_cRTCrX509CertificateMarkers = RT_ELEMENTS(g_aRTCrX509CertificateMarkers); 46 51 47 52 … … 51 56 AssertReturn(!fFlags, VERR_INVALID_FLAGS); 52 57 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); 54 60 if (RT_SUCCESS(rc)) 55 61 { … … 85 91 AssertReturn(!fFlags, VERR_INVALID_FLAGS); 86 92 PCRTCRPEMSECTION pSectionHead; 87 int rc = RTCrPemParseContent(pvBuf, cbBuf, 0, g_a CertificateMarkers, RT_ELEMENTS(g_aCertificateMarkers),93 int rc = RTCrPemParseContent(pvBuf, cbBuf, 0, g_aRTCrX509CertificateMarkers, g_cRTCrX509CertificateMarkers, 88 94 &pSectionHead, pErrInfo); 89 95 if (RT_SUCCESS(rc)) … … 121 127 AssertReturn(!fFlags, VERR_INVALID_FLAGS); 122 128 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); 124 131 if (RT_SUCCESS(rc)) 125 132 {
Note:
See TracChangeset
for help on using the changeset viewer.