- Timestamp:
- Mar 29, 2016 2:21:22 PM (9 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r60236 r60243 2986 2986 <interface 2987 2987 name="ICertificate" extends="$unknown" 2988 uuid=" c2b34d6f-7a10-4901-803e-05d5ef946567"2988 uuid="336064ce-c853-4bd0-ad6c-b42d8ed99e5e" 2989 2989 wsmap="managed" 2990 2990 reservedAttributes="4" reservedMethods="2" … … 3020 3020 <desc>Time stamp in milliseconds since 1970-01-01 UTC.</desc> 3021 3021 </attribute> 3022 <attribute name="publicKeyAlgorithmOID" type="wstring" readonly="yes"> 3023 <desc>The dotted OID of the public key algorithm.</desc> 3024 </attribute> 3022 3025 <attribute name="publicKeyAlgorithm" type="wstring" readonly="yes"> 3023 3026 <desc>The public key algorithm name (if known).</desc> … … 3026 3029 <desc>The raw public key bytes.</desc> 3027 3030 </attribute> 3028 <attribute name="issuerUniqueIdentifier" type=" octet" safearray="yes" readonly="yes">3029 <desc>Unique identifier of the issuer ( optional).</desc>3030 </attribute> 3031 <attribute name="subjectUniqueIdentifier" type=" octet" safearray="yes" readonly="yes">3032 <desc>Unique identifier of this certificate ( optional).</desc>3031 <attribute name="issuerUniqueIdentifier" type="wstring" readonly="yes"> 3032 <desc>Unique identifier of the issuer (empty string if not present).</desc> 3033 </attribute> 3034 <attribute name="subjectUniqueIdentifier" type="wstring" readonly="yes"> 3035 <desc>Unique identifier of this certificate (empty string if not present).</desc> 3033 3036 </attribute> 3034 3037 <attribute name="certificateAuthority" type="boolean" readonly="yes"> … … 3037 3040 </desc> 3038 3041 </attribute> 3039 <attribute name="keyUsage" type="unsigned long" safearray="yes"readonly="yes">3042 <attribute name="keyUsage" type="unsigned long" readonly="yes"> 3040 3043 <desc>Key usage mask. Will return 0 if not present.</desc> 3041 3044 </attribute> -
trunk/src/VBox/Main/include/CertificateImpl.h
r60239 r60243 1 /* $Id$ */ 1 2 /** @file 2 * VirtualBox COM class implementation3 * VirtualBox COM ICertificate implementation. 3 4 */ 4 5 5 6 /* 6 * Copyright (C) 2006-201 3Oracle Corporation7 * Copyright (C) 2006-2016 Oracle Corporation 7 8 * 8 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 19 #define ____H_CERTIFICATEIMPL 19 20 21 //#define DONT_DUPLICATE_ALL_THE_DATA 22 20 23 /* VBox includes */ 21 24 #include <VBox/settings.h> 22 23 25 #include <iprt/crypto/x509.h> 24 26 #include "CertificateWrap.h" 25 27 26 28 #include <vector> 27 29 30 28 31 using namespace std; 29 32 33 #ifndef DONT_DUPLICATE_ALL_THE_DATA 30 34 /* VBox forward declarations */ 31 35 class Appliance; 32 struct RTCRX509CERTIFICATE; 36 #endif 33 37 34 38 class ATL_NO_VTABLE Certificate : … … 40 44 DECLARE_EMPTY_CTOR_DTOR(Certificate) 41 45 46 #ifdef DONT_DUPLICATE_ALL_THE_DATA 47 HRESULT init(PCRTCRX509CERTIFICATE a_pCert); 48 #else 42 49 HRESULT init(Appliance* appliance); 50 #endif 43 51 void uninit(); 44 52 … … 46 54 void FinalRelease(); 47 55 48 HRESULT setData(RTCRX509CERTIFICATE *inCert); 56 #ifndef DONT_DUPLICATE_ALL_THE_DATA 57 HRESULT setData(RTCRX509CERTIFICATE const *inCert); 58 #endif 49 59 50 60 private: 61 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* This is a generic information object, not something that is exclusive to Appliance! */ 62 const Appliance* m_appliance; 63 #endif 51 64 52 const Appliance* m_appliance; 53 65 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* This is a generic information object, not something that is exclusive to Appliance! */ 54 66 HRESULT setVersionNumber(uint64_t inVersionNumber); 55 67 HRESULT setSerialNumber(uint64_t inSerialNumber); … … 71 83 // HRESULT setExtendedKeyUsage(std::vector<com::Utf8Str> aExtendedKeyUsage); 72 84 // HRESULT setRawCertData(std::vector<BYTE> aRawCertData); 85 #endif 73 86 74 87 // wrapped ICertificate properties … … 77 90 HRESULT getSignatureAlgorithmOID(com::Utf8Str &aSignatureAlgorithmOID); 78 91 HRESULT getSignatureAlgorithmName(com::Utf8Str &aSignatureAlgorithmName); 92 HRESULT getPublicKeyAlgorithmOID(com::Utf8Str &aPublicKeyAlgorithmOID); 79 93 HRESULT getPublicKeyAlgorithm(com::Utf8Str &aPublicKeyAlgorithm); 80 94 HRESULT getIssuerName(std::vector<com::Utf8Str> &aIssuerName); … … 83 97 HRESULT getValidityPeriodNotAfter(com::Utf8Str &aValidityPeriodNotAfter); 84 98 HRESULT getSubjectPublicKey(std::vector<BYTE> &aSubjectPublicKey); 85 HRESULT getIssuerUniqueIdentifier( std::vector<BYTE>&aIssuerUniqueIdentifier);86 HRESULT getSubjectUniqueIdentifier( std::vector<BYTE>&aSubjectUniqueIdentifier);99 HRESULT getIssuerUniqueIdentifier(com::Utf8Str &aIssuerUniqueIdentifier); 100 HRESULT getSubjectUniqueIdentifier(com::Utf8Str &aSubjectUniqueIdentifier); 87 101 HRESULT getCertificateAuthority(BOOL *aCertificateAuthority); 88 HRESULT getKeyUsage( std::vector<ULONG> &aKeyUsage);102 HRESULT getKeyUsage(ULONG *aKeyUsage); 89 103 HRESULT getExtendedKeyUsage(std::vector<com::Utf8Str> &aExtendedKeyUsage); 90 104 HRESULT getRawCertData(std::vector<BYTE> &aRawCertData); … … 94 108 // wrapped ICertificate methods 95 109 HRESULT queryInfo(LONG aWhat, com::Utf8Str &aResult); 110 #ifndef DONT_DUPLICATE_ALL_THE_DATA 96 111 HRESULT checkExistence(BOOL *aPresence); 97 112 HRESULT isVerified(BOOL *aVerified); 113 #endif 114 115 #ifdef DONT_DUPLICATE_ALL_THE_DATA 116 /** @name Methods extracting COM data from the certificate object 117 * @{ */ 118 HRESULT i_getAlgorithmName(PCRTCRX509ALGORITHMIDENTIFIER a_pAlgId, com::Utf8Str &a_rReturn); 119 HRESULT i_getX509Name(PCRTCRX509NAME a_pName, std::vector<com::Utf8Str> &a_rReturn); 120 HRESULT i_getTime(PCRTASN1TIME a_pTime, com::Utf8Str &a_rReturn); 121 HRESULT i_getUniqueIdentifier(PCRTCRX509UNIQUEIDENTIFIER a_pUniqueId, com::Utf8Str &a_rReturn); 122 HRESULT i_getEncodedBytes(PRTASN1CORE a_pAsn1Obj, std::vector<BYTE> &a_rReturn); 123 /** @} */ 124 #endif 98 125 //data 99 126 struct Data; -
trunk/src/VBox/Main/src-server/CertificateImpl.cpp
r60239 r60243 1 1 /* $Id$ */ 2 2 /** @file 3 3 * ICertificate COM class implementations. … … 26 26 #include "CertificateImpl.h" 27 27 #include "AutoCaller.h" 28 #include "Global.h" 28 29 #include "Logging.h" 29 30 … … 32 33 struct CertificateData 33 34 { 35 #ifdef DONT_DUPLICATE_ALL_THE_DATA 36 CertificateData() 37 : fTrusted(false) 38 , fValidX509(false) 39 { 40 RT_ZERO(X509); 41 } 42 43 ~CertificateData() 44 { 45 if (fValidX509) 46 { 47 RTCrX509Certificate_Delete(&X509); 48 RT_ZERO(X509); 49 fValidX509 = false; 50 } 51 } 52 53 /** Whether the certificate is trusted. */ 54 bool fTrusted; 55 /** Valid data in mX509. */ 56 bool fValidX509; 57 /** Clone of the X.509 certificate. */ 58 RTCRX509CERTIFICATE X509; 59 60 private: 61 CertificateData(const CertificateData &rTodo) { AssertFailed(); NOREF(rTodo); } 62 CertificateData &operator=(const CertificateData &rTodo) { AssertFailed(); NOREF(rTodo); return *this; } 63 64 #else 34 65 CertificateData() : 35 66 mVersionNumber(0), … … 60 91 std::vector<Utf8Str> mExtendedKeyUsage; 61 92 std::vector<BYTE> mRawCertData; 62 93 #endif 63 94 }; 64 95 … … 98 129 } 99 130 131 #ifdef DONT_DUPLICATE_ALL_THE_DATA 132 HRESULT Certificate::init(PCRTCRX509CERTIFICATE a_pCert) 133 #else 100 134 HRESULT Certificate::init(Appliance* appliance) 135 #endif 101 136 { 102 137 HRESULT rc = S_OK; … … 107 142 AssertReturn(autoInitSpan.isOk(), E_FAIL); 108 143 144 #ifndef DONT_DUPLICATE_ALL_THE_DATA 109 145 if(appliance!=NULL) 110 146 { … … 114 150 else 115 151 rc = E_FAIL; 152 #endif 116 153 117 154 mData = new Data(); 118 155 mData->m.allocate(); 156 #ifdef DONT_DUPLICATE_ALL_THE_DATA 157 int vrc = RTCrX509Certificate_Clone(&mData->m->X509, a_pCert, &g_RTAsn1DefaultAllocator); 158 if (RT_SUCCESS(vrc)) 159 mData->m->fValidX509 = true; 160 else 161 rc = Global::vboxStatusCodeToCOM(vrc); 162 #else 119 163 mData->m->mSignatureAlgorithmOID.setNull(); 120 164 mData->m->mSignatureAlgorithmName.setNull(); … … 130 174 mData->m->mExtendedKeyUsage.resize(0); 131 175 mData->m->mRawCertData.resize(0); 176 #endif 132 177 133 178 /* Confirm a successful initialization when it's the case */ … … 152 197 mData = NULL; 153 198 } 199 200 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* We'll query the data from the RTCrX509* API. */ 201 154 202 /** 155 203 * Public method implementation. … … 157 205 * @return 158 206 */ 159 HRESULT Certificate::setData( RTCRX509CERTIFICATE *inCert)207 HRESULT Certificate::setData(PCRTCRX509CERTIFICATE inCert) 160 208 { 161 209 … … 452 500 } 453 501 502 #endif /* !DONT_DUPLICATE_ALL_THE_DATA */ 503 454 504 /** 455 505 * Private method implementation. … … 460 510 { 461 511 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 512 #ifdef DONT_DUPLICATE_ALL_THE_DATA 513 Assert(mData->m->fValidX509); 514 /** @todo make this ULONG, or better, an ENUM. */ 515 aVersionNumber = Utf8StrFmt("%RU64", mData->m->X509.TbsCertificate.T0.Version.uValue.u + 1); /* version 1 has value 0, so +1. */ 516 #else 462 517 Utf8StrFmt strVer("%Lu", mData->m->mVersionNumber); 463 518 aVersionNumber = strVer; 519 #endif 464 520 return S_OK; 465 521 } … … 473 529 { 474 530 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 531 #ifdef DONT_DUPLICATE_ALL_THE_DATA 532 Assert(mData->m->fValidX509); 533 534 char szTmp[_2K]; 535 int vrc = RTAsn1Integer_ToString(&mData->m->X509.TbsCertificate.SerialNumber, szTmp, sizeof(szTmp), 0, NULL); 536 if (RT_SUCCESS(vrc)) 537 aSerialNumber = szTmp; 538 else 539 return Global::vboxStatusCodeToCOM(vrc); 540 #else 475 541 Utf8StrFmt strVer("%llx", mData->m->mSerialNumber); 476 542 aSerialNumber = strVer; 543 #endif 477 544 return S_OK; 478 545 } … … 486 553 { 487 554 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 488 555 #ifdef DONT_DUPLICATE_ALL_THE_DATA 556 Assert(mData->m->fValidX509); 557 aSignatureAlgorithmOID = mData->m->X509.TbsCertificate.Signature.Algorithm.szObjId; 558 #else 489 559 aSignatureAlgorithmOID = mData->m->mSignatureAlgorithmOID; 490 560 #endif 491 561 return S_OK; 492 562 } … … 500 570 { 501 571 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 502 572 #ifdef DONT_DUPLICATE_ALL_THE_DATA 573 Assert(mData->m->fValidX509); 574 return i_getAlgorithmName(&mData->m->X509.TbsCertificate.Signature, aSignatureAlgorithmName); 575 #else 503 576 aSignatureAlgorithmName = mData->m->mSignatureAlgorithmName; 504 577 505 578 return S_OK; 579 #endif 506 580 } 507 581 … … 514 588 { 515 589 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 516 590 #ifdef DONT_DUPLICATE_ALL_THE_DATA 591 Assert(mData->m->fValidX509); 592 return i_getX509Name(&mData->m->X509.TbsCertificate.Issuer, aIssuerName); 593 #else 517 594 aIssuerName = mData->m->mIssuerName; 518 595 519 596 return S_OK; 597 #endif 520 598 } 521 599 … … 528 606 { 529 607 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 608 #ifdef DONT_DUPLICATE_ALL_THE_DATA 609 Assert(mData->m->fValidX509); 610 return i_getX509Name(&mData->m->X509.TbsCertificate.Subject, aSubjectName); 611 #else 530 612 531 613 aSubjectName = mData->m->mSubjectName; 532 614 533 615 return S_OK; 616 #endif 534 617 } 535 618 … … 542 625 { 543 626 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 544 627 #ifdef DONT_DUPLICATE_ALL_THE_DATA 628 Assert(mData->m->fValidX509); 629 return i_getTime(&mData->m->X509.TbsCertificate.Validity.NotBefore, aValidityPeriodNotBefore); 630 #else 545 631 HRESULT rc = S_OK; 546 632 … … 558 644 559 645 return rc; 646 #endif 560 647 } 561 648 … … 568 655 { 569 656 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 657 #ifdef DONT_DUPLICATE_ALL_THE_DATA 658 Assert(mData->m->fValidX509); 659 return i_getTime(&mData->m->X509.TbsCertificate.Validity.NotAfter, aValidityPeriodNotAfter); 660 #else 570 661 571 662 HRESULT rc = S_OK; … … 582 673 delete[] charArr; 583 674 return rc; 675 #endif 676 } 677 678 HRESULT Certificate::getPublicKeyAlgorithmOID(com::Utf8Str &aPublicKeyAlgorithmOID) 679 { 680 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 681 #ifdef DONT_DUPLICATE_ALL_THE_DATA 682 Assert(mData->m->fValidX509); 683 aPublicKeyAlgorithmOID = mData->m->X509.TbsCertificate.SubjectPublicKeyInfo.Algorithm.Algorithm.szObjId; 684 return S_OK; 685 #else 686 return E_NOTIMPL; 687 #endif 584 688 } 585 689 … … 592 696 { 593 697 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 594 698 #ifdef DONT_DUPLICATE_ALL_THE_DATA 699 Assert(mData->m->fValidX509); 700 return i_getAlgorithmName(&mData->m->X509.TbsCertificate.SubjectPublicKeyInfo.Algorithm, aPublicKeyAlgorithm); 701 #else 595 702 aPublicKeyAlgorithm = mData->m->mPublicKeyAlgorithmName; 596 703 597 704 return S_OK; 705 #endif 598 706 } 599 707 … … 605 713 HRESULT Certificate::getSubjectPublicKey(std::vector<BYTE> &aSubjectPublicKey) 606 714 { 607 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 608 609 return S_OK; 715 #ifdef DONT_DUPLICATE_ALL_THE_DATA 716 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Getting encoded ASN.1 bytes may make changes to X509. */ 717 return i_getEncodedBytes(&mData->m->X509.TbsCertificate.SubjectPublicKeyInfo.SubjectPublicKey.Asn1Core, aSubjectPublicKey); 718 #else 719 return E_NOTIMPL; 720 #endif 610 721 } 611 722 … … 615 726 * @return 616 727 */ 617 HRESULT Certificate::getIssuerUniqueIdentifier(std::vector<BYTE> &aIssuerUniqueIdentifier) 618 { 619 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 620 621 return S_OK; 728 HRESULT Certificate::getIssuerUniqueIdentifier(com::Utf8Str &aIssuerUniqueIdentifier) 729 { 730 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 731 #ifdef DONT_DUPLICATE_ALL_THE_DATA 732 return i_getUniqueIdentifier(&mData->m->X509.TbsCertificate.T1.IssuerUniqueId, aIssuerUniqueIdentifier); 733 #else 734 return E_NOTIMPL; 735 #endif 622 736 } 623 737 … … 627 741 * @return 628 742 */ 629 HRESULT Certificate::getSubjectUniqueIdentifier(std::vector<BYTE> &aSubjectUniqueIdentifier) 630 { 631 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 632 633 return S_OK; 743 HRESULT Certificate::getSubjectUniqueIdentifier(com::Utf8Str &aSubjectUniqueIdentifier) 744 { 745 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 746 #ifdef DONT_DUPLICATE_ALL_THE_DATA 747 return i_getUniqueIdentifier(&mData->m->X509.TbsCertificate.T2.SubjectUniqueId, aSubjectUniqueIdentifier); 748 #else 749 return E_NOTIMPL; 750 #endif 634 751 } 635 752 … … 642 759 { 643 760 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 644 761 #ifdef DONT_DUPLICATE_ALL_THE_DATA 762 *aCertificateAuthority = mData->m->X509.TbsCertificate.T3.pBasicConstraints 763 && mData->m->X509.TbsCertificate.T3.pBasicConstraints->CA.fValue; 764 #else 645 765 *aCertificateAuthority = mData->m->mCertificateAuthority; 646 766 #endif 647 767 return S_OK; 648 768 } … … 653 773 * @return 654 774 */ 655 HRESULT Certificate::getKeyUsage(std::vector<ULONG> &aKeyUsage) 656 { 657 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 658 659 return S_OK; 775 HRESULT Certificate::getKeyUsage(ULONG *aKeyUsage) 776 { 777 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 778 #ifdef DONT_DUPLICATE_ALL_THE_DATA 779 *aKeyUsage = mData->m->X509.TbsCertificate.T3.fKeyUsage; 780 return S_OK; 781 #else 782 return E_NOTIMPL; 783 #endif 660 784 } 661 785 … … 668 792 { 669 793 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 670 671 return S_OK;794 NOREF(aExtendedKeyUsage); 795 return E_NOTIMPL; 672 796 } 673 797 … … 679 803 HRESULT Certificate::getRawCertData(std::vector<BYTE> &aRawCertData) 680 804 { 681 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 682 683 return S_OK; 805 #ifdef DONT_DUPLICATE_ALL_THE_DATA 806 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); /* Getting encoded ASN.1 bytes may make changes to X509. */ 807 return i_getEncodedBytes(&mData->m->X509.SeqCore.Asn1Core, aRawCertData); 808 #else 809 return E_NOTIMPL; 810 #endif 684 811 } 685 812 … … 692 819 { 693 820 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 694 821 #ifdef DONT_DUPLICATE_ALL_THE_DATA 822 Assert(mData->m->fValidX509); 823 *aSelfSigned = RTCrX509Certificate_IsSelfSigned(&mData->m->X509); 824 #else 695 825 *aSelfSigned = mData->m->mSelfSigned; 696 826 #endif 697 827 return S_OK; 698 828 } … … 706 836 { 707 837 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 708 838 #ifdef DONT_DUPLICATE_ALL_THE_DATA 839 *aTrusted = mData->m->fTrusted; 840 #else 709 841 *aTrusted = mData->m->mTrusted; 710 842 #endif 711 843 return S_OK; 712 844 } … … 721 853 { 722 854 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 723 724 return S_OK; 725 } 855 /* Insurance. */ 856 NOREF(aResult); 857 return setError(E_FAIL, "Unknown item %u", aWhat); 858 } 859 860 #ifndef DONT_DUPLICATE_ALL_THE_DATA /* These are out of place. */ 726 861 727 862 /** … … 755 890 } 756 891 892 #else /* DONT_DUPLICATE_ALL_THE_DATA */ 893 894 HRESULT Certificate::i_getAlgorithmName(PCRTCRX509ALGORITHMIDENTIFIER a_pAlgId, com::Utf8Str &a_rReturn) 895 { 896 /** @todo */ 897 NOREF(a_pAlgId); 898 NOREF(a_rReturn); 899 return E_NOTIMPL; 900 } 901 902 HRESULT Certificate::i_getX509Name(PCRTCRX509NAME a_pName, std::vector<com::Utf8Str> &a_rReturn) 903 { 904 /** @todo */ 905 NOREF(a_pName); 906 NOREF(a_rReturn); 907 return E_NOTIMPL; 908 } 909 910 HRESULT Certificate::i_getTime(PCRTASN1TIME a_pTime, com::Utf8Str &a_rReturn) 911 { 912 char szTmp[128]; 913 if (RTTimeToString(&a_pTime->Time, szTmp, sizeof(szTmp))) 914 { 915 a_rReturn = szTmp; 916 return S_OK; 917 } 918 AssertFailed(); 919 return E_FAIL; 920 } 921 922 HRESULT Certificate::i_getUniqueIdentifier(PCRTCRX509UNIQUEIDENTIFIER a_pUniqueId, com::Utf8Str &a_rReturn) 923 { 924 /* The a_pUniqueId may not be present! */ 925 if (RTCrX509UniqueIdentifier_IsPresent(a_pUniqueId)) 926 { 927 void const *pvData = RTASN1BITSTRING_GET_BIT0_PTR(a_pUniqueId); 928 size_t const cbData = RTASN1BITSTRING_GET_BYTE_SIZE(a_pUniqueId); 929 size_t const cbFormatted = cbData * 3 - 1 + 1; 930 a_rReturn.reserve(cbFormatted); /* throws */ 931 int vrc = RTStrPrintHexBytes(a_rReturn.mutableRaw(), cbFormatted, pvData, cbData, RTSTRPRINTHEXBYTES_F_SEP_COLON); 932 a_rReturn.jolt(); 933 AssertRCReturn(vrc, Global::vboxStatusCodeToCOM(vrc)); 934 } 935 else 936 Assert(a_rReturn.isEmpty()); 937 return S_OK; 938 } 939 940 HRESULT Certificate::i_getEncodedBytes(PRTASN1CORE a_pAsn1Obj, std::vector<BYTE> &a_rReturn) 941 { 942 HRESULT hrc = S_OK; 943 Assert(a_rReturn.size() == 0); 944 if (RTAsn1Core_IsPresent(a_pAsn1Obj)) 945 { 946 uint32_t cbEncoded; 947 int vrc = RTAsn1EncodePrepare(a_pAsn1Obj, 0, &cbEncoded, NULL); 948 if (RT_SUCCESS(vrc)) 949 { 950 a_rReturn.resize(cbEncoded); 951 Assert(a_rReturn.size() == cbEncoded); 952 if (cbEncoded) 953 { 954 vrc = RTAsn1EncodeToBuffer(a_pAsn1Obj, 0, &a_rReturn.front(), a_rReturn.size(), NULL); 955 if (RT_FAILURE(vrc)) 956 hrc = setErrorVrc(vrc, "RTAsn1EncodeToBuffer failed with %Rrc", vrc); 957 } 958 } 959 else 960 hrc = setErrorVrc(vrc, "RTAsn1EncodePrepare failed with %Rrc", vrc); 961 } 962 return hrc; 963 } 964 965 #endif /* DONT_DUPLICATE_ALL_THE_DATA */ 966
Note:
See TracChangeset
for help on using the changeset viewer.