Changeset 84311 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- May 14, 2020 5:42:13 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137978
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r84144 r84311 147 147 { "import", USAGE_IMPORTAPPLIANCE, VBMG_CMD_TODO, handleImportAppliance, 0 }, 148 148 { "export", USAGE_EXPORTAPPLIANCE, VBMG_CMD_TODO, handleExportAppliance, 0 }, 149 { "signova", USAGE_S_NEWCMD, HELP_CMD_SIGNOVA, handleSignAppliance, 0},149 { "signova", USAGE_S_NEWCMD, HELP_CMD_SIGNOVA, handleSignAppliance, VBMG_CMD_F_NO_COM }, 150 150 #ifdef VBOX_WITH_NETFLT 151 151 { "hostonlyif", USAGE_HOSTONLYIFS, VBMG_CMD_TODO, handleHostonlyIf, 0 }, -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageAppliance.cpp
r84264 r84311 1990 1990 1991 1991 /** 1992 * Worker for doCheckPkcs7Signature. 1993 */ 1994 static int doCheckPkcs7SignatureWorker(PRTCRPKCS7CONTENTINFO pContentInfo, void const *pvManifest, size_t cbManifest, 1995 unsigned iVerbosity, const char *pszTag, PRTERRINFOSTATIC pErrInfo) 1996 { 1997 int rc; 1998 1999 /* 2000 * It must be signedData. 2001 */ 2002 if (RTCrPkcs7ContentInfo_IsSignedData(pContentInfo)) 2003 { 2004 PRTCRPKCS7SIGNEDDATA pSignedData = pContentInfo->u.pSignedData; 2005 2006 /* 2007 * Inside the signedData there must be just 'data'. 2008 */ 2009 if (!strcmp(pSignedData->ContentInfo.ContentType.szObjId, RTCR_PKCS7_DATA_OID)) 2010 { 2011 /* 2012 * Check that things add up. 2013 */ 2014 rc = RTCrPkcs7SignedData_CheckSanity(pSignedData, 2015 RTCRPKCS7SIGNEDDATA_SANITY_F_ONLY_KNOWN_HASH 2016 | RTCRPKCS7SIGNEDDATA_SANITY_F_SIGNING_CERT_PRESENT, 2017 RTErrInfoInitStatic(pErrInfo), "SD"); 2018 if (RT_SUCCESS(rc)) 2019 { 2020 if (iVerbosity > 2 && pszTag == NULL) 2021 RTMsgInfo(" Successfully decoded the PKCS#7/CMS signature..."); 2022 2023 /* 2024 * Check that we can verify the signed data, but skip certificate validate as 2025 * we probably don't necessarily have the correct root certs handy here. 2026 */ 2027 RTTIMESPEC Now; 2028 rc = RTCrPkcs7VerifySignedDataWithExternalData(pContentInfo, RTCRPKCS7VERIFY_SD_F_TRUST_ALL_CERTS, 2029 NIL_RTCRSTORE /*hAdditionalCerts*/, 2030 NIL_RTCRSTORE /*hTrustedCerts*/, 2031 RTTimeNow(&Now), 2032 NULL /*pfnVerifyCert*/, NULL /*pvUser*/, 2033 pvManifest, cbManifest, RTErrInfoInitStatic(pErrInfo)); 2034 if (RT_SUCCESS(rc)) 2035 { 2036 if (iVerbosity > 1 && pszTag != NULL) 2037 RTMsgInfo(" Successfully verified the PKCS#7/CMS signature"); 2038 } 2039 else 2040 rc = RTMsgErrorRc(rc, "Failed to verify the PKCS#7/CMS signature: %Rrc%RTeim", rc, &pErrInfo->Core); 2041 } 2042 else 2043 RTMsgError("RTCrPkcs7SignedData_CheckSanity failed on PKCS#7/CMS signature: %Rrc%RTeim", 2044 rc, &pErrInfo->Core); 2045 2046 } 2047 else 2048 rc = RTMsgErrorRc(VERR_WRONG_TYPE, "PKCS#7/CMS signature inner ContentType isn't 'data' but: %s", 2049 pSignedData->ContentInfo.ContentType.szObjId); 2050 } 2051 else 2052 rc = RTMsgErrorRc(VERR_WRONG_TYPE, "PKCS#7/CMD signature is not 'signedData': %s", pContentInfo->ContentType.szObjId); 2053 return rc; 2054 } 2055 2056 /** 1992 2057 * For testing the decoding side. 1993 2058 */ 1994 2059 static int doCheckPkcs7Signature(void const *pvSignature, size_t cbSignature, PCRTCRX509CERTIFICATE pCertificate, 1995 RTCRSTORE hIntermediateCerts, unsigned iVerbosity, PRTERRINFOSTATIC pErrInfo) 2060 RTCRSTORE hIntermediateCerts, void const *pvManifest, size_t cbManifest, 2061 unsigned iVerbosity, PRTERRINFOSTATIC pErrInfo) 1996 2062 { 2063 RT_NOREF(pCertificate, hIntermediateCerts); 2064 1997 2065 RTASN1CURSORPRIMARY PrimaryCursor; 1998 2066 RTAsn1CursorInitPrimary(&PrimaryCursor, pvSignature, (uint32_t)cbSignature, RTErrInfoInitStatic(pErrInfo), … … 2007 2075 RTAsn1Dump(&ContentInfo.SeqCore.Asn1Core, 0 /*fFlags*/, 0 /*uLevel*/, RTStrmDumpPrintfV, g_pStdOut); 2008 2076 2009 /* 2010 * It must be signedData. 2011 */ 2012 if (RTCrPkcs7ContentInfo_IsSignedData(&ContentInfo)) 2077 rc = doCheckPkcs7SignatureWorker(&ContentInfo, pvManifest, cbManifest, iVerbosity, NULL, pErrInfo); 2078 if (RT_SUCCESS(rc)) 2013 2079 { 2014 PRTCRPKCS7SIGNEDDATA pSignedData = ContentInfo.u.pSignedData;2015 2016 2080 /* 2017 * Inside the signedData there must be just 'data'. 2081 * Clone it and repeat. This is to catch IPRT paths assuming 2082 * that encoded data is always on hand. 2018 2083 */ 2019 if (!strcmp(pSignedData->ContentInfo.ContentType.szObjId, RTCR_PKCS7_DATA_OID)) 2084 RTCRPKCS7CONTENTINFO ContentInfo2; 2085 rc = RTCrPkcs7ContentInfo_Clone(&ContentInfo2, &ContentInfo, &g_RTAsn1DefaultAllocator); 2086 if (RT_SUCCESS(rc)) 2020 2087 { 2021 /* 2022 * Check that things add up. 2023 */ 2024 rc = RTCrPkcs7SignedData_CheckSanity(pSignedData, 2025 RTCRPKCS7SIGNEDDATA_SANITY_F_ONLY_KNOWN_HASH 2026 | RTCRPKCS7SIGNEDDATA_SANITY_F_SIGNING_CERT_PRESENT, 2027 RTErrInfoInitStatic(pErrInfo), "SD"); 2028 if (RT_SUCCESS(rc)) 2029 { 2030 if (iVerbosity > 2) 2031 RTMsgInfo(" Successfully decoded the PKCS#7/CMS signature..."); 2032 RT_NOREF(pCertificate, hIntermediateCerts); 2033 } 2034 else 2035 RTMsgError("RTCrPkcs7SignedData_CheckSanity failed on PKCS#7/CMS signature: %Rrc%RTeim", 2036 rc, &pErrInfo->Core); 2037 2088 rc = doCheckPkcs7SignatureWorker(&ContentInfo2, pvManifest, cbManifest, iVerbosity, "cloned", pErrInfo); 2089 RTCrPkcs7ContentInfo_Delete(&ContentInfo2); 2038 2090 } 2039 2091 else 2040 rc = RTMsgErrorRc(VERR_WRONG_TYPE, "PKCS#7/CMS signature inner ContentType isn't 'data' but: %s", 2041 pSignedData->ContentInfo.ContentType.szObjId); 2092 rc = RTMsgErrorRc(rc, "RTCrPkcs7ContentInfo_Clone failed: %Rrc", rc); 2042 2093 } 2043 else2044 rc = RTMsgErrorRc(VERR_WRONG_TYPE, "PKCS#7/CMD signature is not 'signedData': %s", ContentInfo.ContentType.szObjId);2045 2094 } 2046 2095 else … … 2063 2112 * Add a blank line, just for good measure. 2064 2113 */ 2065 int rc = RTVfsFileWrite(hVfsFile Manifest, " ", 1, NULL);2114 int rc = RTVfsFileWrite(hVfsFileSignature, " ", 1, NULL); 2066 2115 if (RT_FAILURE(rc)) 2067 2116 return RTMsgErrorRc(rc, "RTVfsFileWrite/signature: %Rrc", rc); … … 2143 2192 */ 2144 2193 rc = doCheckPkcs7Signature(pvResult, cbResult, pCertificate, hIntermediateCerts, 2145 iVerbosity, pErrInfo);2194 pvManifest, (size_t)cbManifest, iVerbosity, pErrInfo); 2146 2195 } 2147 2196 else
Note:
See TracChangeset
for help on using the changeset viewer.