Changeset 73662 in vbox
- Timestamp:
- Aug 14, 2018 4:13:43 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asn1.h
r69105 r73662 158 158 extern RTDATADECL(RTASN1ALLOCATORVTABLE const) g_RTAsn1EFenceAllocator; 159 159 160 /** The safer ASN.1 allocator for sensitive data. */ 161 extern RTDATADECL(RTASN1ALLOCATORVTABLE const) g_RTAsn1SaferAllocator; 162 160 163 161 164 /** … … 1756 1759 * Checks that we've reached the end of the data for the cursor. 1757 1760 * 1761 * This differs from RTAsn1CursorCheckEnd in that it does not consider the end 1762 * an error and therefore leaves the error buffer alone. 1763 * 1764 * @returns True if end, otherwise false. 1765 * @param pCursor The cursor we're decoding from. 1766 */ 1767 RTDECL(bool) RTAsn1CursorIsEnd(PRTASN1CURSOR pCursor); 1768 1769 /** 1770 * Checks that we've reached the end of the data for the cursor. 1771 * 1758 1772 * @returns IPRT status code. 1759 1773 * @param pCursor The cursor we're decoding from. -
trunk/include/iprt/mangling.h
r73587 r73662 2754 2754 # define RTAsn1CursorInitSubFromCore RT_MANGLER(RTAsn1CursorInitSubFromCore) 2755 2755 # define RTAsn1CursorIsNextEx RT_MANGLER(RTAsn1CursorIsNextEx) 2756 # define RTAsn1CursorIsEnd RT_MANGLER(RTAsn1CursorIsEnd) 2756 2757 # define RTAsn1CursorMatchTagClassFlagsEx RT_MANGLER(RTAsn1CursorMatchTagClassFlagsEx) 2757 2758 # define RTAsn1CursorPeek RT_MANGLER(RTAsn1CursorPeek) … … 3250 3251 # define RTCrPkixSignatureVerifyOctetString RT_MANGLER(RTCrPkixSignatureVerifyOctetString) 3251 3252 # define RTCrPkixGetCiperOidFromSignatureAlgorithm RT_MANGLER(RTCrPkixGetCiperOidFromSignatureAlgorithm) 3253 # define RTCrPkixPubKeySignDigest RT_MANGLER(RTCrPkixPubKeySignDigest) 3252 3254 # define RTCrPkixPubKeyVerifySignature RT_MANGLER(RTCrPkixPubKeyVerifySignature) 3253 3255 # define RTCrPkixPubKeyVerifySignedDigest RT_MANGLER(RTCrPkixPubKeyVerifySignedDigest) 3256 # define RTCrPkixPubKeyVerifySignedDigestByCertPubKeyInfo RT_MANGLER(RTCrPkixPubKeyVerifySignedDigestByCertPubKeyInfo) 3254 3257 # define RTCrSpcAttributeTypeAndOptionalValue_DecodeAsn1 RT_MANGLER(RTCrSpcAttributeTypeAndOptionalValue_DecodeAsn1) 3255 3258 # define RTCrSpcIndirectDataContent_DecodeAsn1 RT_MANGLER(RTCrSpcIndirectDataContent_DecodeAsn1) … … 3524 3527 # define RTCrX509PolicyQualifierInfos_Clone RT_MANGLER(RTCrX509PolicyQualifierInfos_Clone) 3525 3528 # define RTCrX509PolicyQualifierInfos_Init RT_MANGLER(RTCrX509PolicyQualifierInfos_Init) 3529 # define RTCrRsaPrivateKey_ReadFromFile RT_MANGLER(RTCrRsaPrivateKey_ReadFromFile) 3530 # define RTCrRsaPrivateKey_ReadFromBuffer RT_MANGLER(RTCrRsaPrivateKey_ReadFromBuffer) 3531 # define RTCrRsaPublicKey_ReadFromFile RT_MANGLER(RTCrRsaPublicKey_ReadFromFile) 3532 # define RTCrRsaPublicKey_ReadFromBuffer RT_MANGLER(RTCrRsaPublicKey_ReadFromBuffer) 3526 3533 # define RTCrX509SubjectPublicKeyInfo_Clone RT_MANGLER(RTCrX509SubjectPublicKeyInfo_Clone) 3527 3534 # define RTCrX509SubjectPublicKeyInfo_Init RT_MANGLER(RTCrX509SubjectPublicKeyInfo_Init) … … 3797 3804 # define g_RTAsn1DefaultAllocator RT_MANGLER(g_RTAsn1DefaultAllocator) 3798 3805 # define g_RTAsn1EFenceAllocator RT_MANGLER(g_RTAsn1EFenceAllocator) 3806 # define g_RTAsn1SaferAllocator RT_MANGLER(g_RTAsn1SaferAllocator) 3799 3807 # define g_aRTCrX509CertificateMarkers RT_MANGLER(g_aRTCrX509CertificateMarkers) 3800 3808 # define g_cRTCrX509CertificateMarkers RT_MANGLER(g_cRTCrX509CertificateMarkers) 3809 # define g_aRTCrRsaPrivateKeyMarkers RT_MANGLER(g_aRTCrRsaPrivateKeyMarkers) 3810 # define g_cRTCrRsaPrivateKeyMarkers RT_MANGLER(g_cRTCrRsaPrivateKeyMarkers) 3811 # define g_aRTCrRsaPublicKeyMarkers RT_MANGLER(g_aRTCrRsaPublicKeyMarkers) 3812 # define g_cRTCrRsaPublicKeyMarkers RT_MANGLER(g_cRTCrRsaPublicKeyMarkers) 3801 3813 3802 3814 #if 0 /* Disabled for now as I'm not sure the assmbler supports mangling yet. */ -
trunk/src/VBox/Runtime/common/asn1/asn1-cursor.cpp
r69111 r73662 184 184 va_end(va); 185 185 return rc; 186 } 187 188 189 RTDECL(bool) RTAsn1CursorIsEnd(PRTASN1CURSOR pCursor) 190 { 191 return pCursor->cbLeft == 0; 186 192 } 187 193 -
trunk/src/VBox/Runtime/common/asn1/asn1-safer-allocator.cpp
r73643 r73662 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - ASN.1, Default Allocator.3 * IPRT - ASN.1, Safer Allocator, for sensitive data. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 #include <iprt/asn1.h> 33 33 34 #include <iprt/mem .h>34 #include <iprt/memsafer.h> 35 35 #include <iprt/err.h> 36 36 #include <iprt/string.h> … … 43 43 * @param cb Requested size. 44 44 */ 45 static size_t rtAsn1 DefaultAllocator_AlignSize(size_t cb)45 static size_t rtAsn1SaferAllocator_AlignSize(size_t cb) 46 46 { 47 47 if (cb >= 64) … … 56 56 57 57 /** @interface_method_impl{RTASN1ALLOCATORVTABLE,pfnFree} */ 58 static DECLCALLBACK(void) rtAsn1 DefaultAllocator_Free(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ALLOCATION pAllocation, void *pv)59 { 60 RT_NOREF_PV(pThis); 61 RTMem Free(pv);58 static DECLCALLBACK(void) rtAsn1SaferAllocator_Free(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ALLOCATION pAllocation, void *pv) 59 { 60 RT_NOREF_PV(pThis); 61 RTMemSaferFree(pv, pAllocation->cbAllocated); 62 62 pAllocation->cbAllocated = 0; 63 63 } … … 65 65 66 66 /** @interface_method_impl{RTASN1ALLOCATORVTABLE,pfnAlloc} */ 67 static DECLCALLBACK(int) rtAsn1 DefaultAllocator_Alloc(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ALLOCATION pAllocation,68 69 { 70 size_t cbAlloc = rtAsn1 DefaultAllocator_AlignSize(cb);71 void *pv = RTMem AllocZ(cbAlloc);67 static DECLCALLBACK(int) rtAsn1SaferAllocator_Alloc(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ALLOCATION pAllocation, 68 void **ppv, size_t cb) 69 { 70 size_t cbAlloc = rtAsn1SaferAllocator_AlignSize(cb); 71 void *pv = RTMemSaferAllocZ(cbAlloc); 72 72 if (pv) 73 73 { … … 82 82 83 83 /** @interface_method_impl{RTASN1ALLOCATORVTABLE,pfnRealloc} */ 84 static DECLCALLBACK(int) rtAsn1 DefaultAllocator_Realloc(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ALLOCATION pAllocation,85 84 static DECLCALLBACK(int) rtAsn1SaferAllocator_Realloc(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ALLOCATION pAllocation, 85 void *pvOld, void **ppvNew, size_t cbNew) 86 86 { 87 87 Assert(pvOld); 88 88 Assert(cbNew); 89 size_t cbAlloc = rtAsn1 DefaultAllocator_AlignSize(cbNew);90 void *pv = RTMem Realloc(pvOld, cbAlloc);89 size_t cbAlloc = rtAsn1SaferAllocator_AlignSize(cbNew); 90 void *pv = RTMemSaferReallocZ(pAllocation->cbAllocated, pvOld, cbAlloc); 91 91 if (pv) 92 92 { … … 101 101 102 102 /** @interface_method_impl{RTASN1ALLOCATORVTABLE,pfnFreeArray} */ 103 static DECLCALLBACK(void) rtAsn1 DefaultAllocator_FreeArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,104 103 static DECLCALLBACK(void) rtAsn1SaferAllocator_FreeArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation, 104 void **papvArray) 105 105 { 106 106 RT_NOREF_PV(pThis); … … 110 110 uint32_t i = pAllocation->cEntriesAllocated; 111 111 while (i-- > 0) 112 RTMem Free(papvArray[i]);112 RTMemSaferFree(papvArray[i], pAllocation->cbEntry); 113 113 RTMemFree(papvArray); 114 114 … … 119 119 120 120 /** @interface_method_impl{RTASN1ALLOCATORVTABLE,pfnGrowArray} */ 121 static DECLCALLBACK(int) rtAsn1 DefaultAllocator_GrowArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,121 static DECLCALLBACK(int) rtAsn1SaferAllocator_GrowArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation, 122 122 void ***ppapvArray, uint32_t cMinEntries) 123 123 { … … 173 173 { 174 174 void *pv; 175 papvArray[pAllocation->cEntriesAllocated] = pv = RTMem AllocZ(pAllocation->cbEntry);175 papvArray[pAllocation->cEntriesAllocated] = pv = RTMemSaferAllocZ(pAllocation->cbEntry); 176 176 if (pv) 177 177 pAllocation->cEntriesAllocated++; … … 187 187 188 188 /** @interface_method_impl{RTASN1ALLOCATORVTABLE,pfnShrinkArray} */ 189 static DECLCALLBACK(void) rtAsn1 DefaultAllocator_ShrinkArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation,189 static DECLCALLBACK(void) rtAsn1SaferAllocator_ShrinkArray(PCRTASN1ALLOCATORVTABLE pThis, PRTASN1ARRAYALLOCATION pAllocation, 190 190 void ***ppapvArray, uint32_t cNew, uint32_t cCurrent) 191 191 { … … 198 198 while (cNew < cCurrent) 199 199 { 200 RTMemWipeThoroughly(papvArray[cNew], pAllocation->cbEntry, 3); 200 201 RT_BZERO(papvArray[cNew], pAllocation->cbEntry); 201 202 cNew++; … … 205 206 206 207 207 /** The defaultASN.1 allocator. */208 /** The Safer ASN.1 allocator. */ 208 209 #if 1 || !defined(IN_RING3) || defined(DOXYGEN_RUNNING) 209 RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1 DefaultAllocator =210 RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1SaferAllocator = 210 211 #else 211 RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1 DefaultAllocatorDisabled =212 RT_DECL_DATA_CONST(RTASN1ALLOCATORVTABLE const) g_RTAsn1SaferAllocatorDisabled = 212 213 #endif 213 214 { 214 rtAsn1 DefaultAllocator_Free,215 rtAsn1 DefaultAllocator_Alloc,216 rtAsn1 DefaultAllocator_Realloc,217 rtAsn1 DefaultAllocator_FreeArray,218 rtAsn1 DefaultAllocator_GrowArray,219 rtAsn1 DefaultAllocator_ShrinkArray215 rtAsn1SaferAllocator_Free, 216 rtAsn1SaferAllocator_Alloc, 217 rtAsn1SaferAllocator_Realloc, 218 rtAsn1SaferAllocator_FreeArray, 219 rtAsn1SaferAllocator_GrowArray, 220 rtAsn1SaferAllocator_ShrinkArray 220 221 }; 221 222
Note:
See TracChangeset
for help on using the changeset viewer.