示例#1
0
boost::test_tools::predicate_result
compare_uuids( boost::uuids::uuid const& a, boost::uuids::uuid const& b )
{
    if (a.is_nil())
    {
        boost::test_tools::predicate_result res( false );

        res.message() << "UUID a was nil";

        return res;
    
    }

    if (b.is_nil())
    {
        boost::test_tools::predicate_result res( false );

        res.message() << "UUID b was nil";

        return res;
    
    }

    if (a == b)
    {
        boost::test_tools::predicate_result res( false );

        res.message() << "UUID A and B are equal with value '" << a << "'";

        return res;
    }

    return true;
}
示例#2
0
LPCTSTR Dispatcher::className(const std::string& name) {
	// Convert to wide
	std::basic_stringstream<TCHAR> stream;
	stream << name.c_str();

#ifdef DWT_SHARED
	/* in a shared library, classes registered by the lib can't clash with those regged by the host
	or by other dynamically loaded libs. append a unique string to that end. */
	static boost::uuids::uuid uuid;
	if(uuid.is_nil()) {
		uuid = boost::uuids::random_generator()();
	}
	stream << uuid;
#endif

	classNames.push_back(stream.str());
	return classNames.back().c_str();
}
示例#3
0
void test_uuid_equal_array(char const * file, int line, char const * function,
                           boost::uuids::uuid const& lhs, const unsigned char (&rhs)[16])
{
    for (size_t i=0; i<16; i++) {
        if ( *(lhs.begin()+i) != rhs[i]) {
            std::cerr << file << "(" << line << "): uuid " << lhs << " not equal " << "{";
            for (size_t j=0; j<16; j++) {
                if (j != 0) {
                    std::cerr << " ";
                }
                std::cerr << std::hex << (int)rhs[j];
            }
            std::cerr << "} in function '" << function << "'" << std::endl;
            ++boost::detail::test_errors();
            return;
        }
    }
}
示例#4
0
 static bool is_null(boost::uuids::uuid const& id)
 {
     return id.is_nil();
 }
示例#5
0
void SelectWeightsDlg::SetDetailsForId(boost::uuids::uuid id)
{
	LOG_MSG("In SelectWeightsDlg::SetDetailsForItem");
	if (id.is_nil()) {
		SetDetailsWin(std::vector<wxString>(0), std::vector<wxString>(0));
		return;
	}
	std::vector<wxString> row_title;
	std::vector<wxString> row_content;
	
	WeightsMetaInfo wmi = w_man_int->GetMetaInfo(id);
	
	row_title.push_back("type");
	row_content.push_back(wmi.TypeToStr());
	
	row_title.push_back("symmetry");
	row_content.push_back(wmi.SymToStr());
	
	row_title.push_back("file");
	if (wmi.filename.IsEmpty()) {
		row_content.push_back("not saved");
	} else {
        wxFileName fm(wmi.filename);
		row_content.push_back(fm.GetFullName());
	}
	
	row_title.push_back("id variable");
	row_content.push_back(wmi.id_var);
	
	if (wmi.weights_type == WeightsMetaInfo::WT_rook ||
		wmi.weights_type == WeightsMetaInfo::WT_queen) {
		row_title.push_back("order");
		wxString rs;
		rs << wmi.order;
		row_content.push_back(rs);
		if (wmi.order > 1) {
			row_title.push_back("include lower orders");
			if (wmi.inc_lower_orders) {
				row_content.push_back("true");
			} else {
				row_content.push_back("false");
			}
		}
	} else if (wmi.weights_type == WeightsMetaInfo::WT_knn ||
			   wmi.weights_type == WeightsMetaInfo::WT_threshold) {
		row_title.push_back("distance metric");
		row_content.push_back(wmi.DistMetricToStr());

		row_title.push_back("distance vars");
		row_content.push_back(wmi.DistValsToStr());
		
		if (wmi.weights_type == WeightsMetaInfo::WT_threshold) {
			row_title.push_back("distance unit");
			row_content.push_back(wmi.DistUnitsToStr());
		}
		
		if (wmi.weights_type == WeightsMetaInfo::WT_knn) {
			row_title.push_back("neighbors");
			wxString rs;
			rs << wmi.num_neighbors;
			row_content.push_back(rs);
		} else {
			row_title.push_back("threshold value");
			wxString rs;
			rs << wmi.threshold_val;
			row_content.push_back(rs);
		}
	}
	LOG(row_title.size());
	LOG(row_content.size());
	SetDetailsWin(row_title, row_content);
}
示例#6
0
	inline 	
	std::vector<unsigned char> create_req_blob(stcrypt::cert_name_t const& name, NCRYPT_KEY_HANDLE const subject_public_key, boost::optional<stcrypt::cert_name_t const&> const& issuer = boost::none){

		auto const& subject_name_2 = name.x500_string();
		auto const subject_name = subject_name_2.c_str();

		wchar_t const*const dummy_issuer_name = L"";

		boost::uuids::uuid const serial_and_unique_id( (boost::uuids::random_generator()()) );

		std::vector<BYTE> serial_blob_data;
		serial_blob_data.reserve( serial_and_unique_id.static_size() );
		std::copy(serial_and_unique_id.begin(), serial_and_unique_id.end(), std::back_inserter(serial_blob_data) );


 		CERT_INFO	cert_info={0};
 
 		cert_info.dwVersion = CERT_V3;
 
		cert_info.SerialNumber.pbData = serial_blob_data.data();
		cert_info.SerialNumber.cbData = serial_blob_data.size();

		cert_info.SubjectUniqueId.pbData = serial_blob_data.data();
		cert_info.SubjectUniqueId.cbData = serial_blob_data.size();

		CRYPT_ALGORITHM_IDENTIFIER signature_alg={OID_G34311_DSTU4145_SIGN,0};

		cert_info.SignatureAlgorithm = signature_alg;

 		SYSTEMTIME cs;
 		GetSystemTime(&cs);
 		{auto const r = SystemTimeToFileTime(&cs, &cert_info.NotBefore); assert(r);}
 		cs.wYear += 1; 
 		{auto const r = SystemTimeToFileTime(&cs, &cert_info.NotAfter); assert(r);}

		std::vector<unsigned char> subject_name_blob_data;
		std::vector<unsigned char> issuer_name_blob_data;

		ms_cert::cert_str_to_name_blob(subject_name, cert_info.Subject, subject_name_blob_data);

		if(issuer){
			auto const& issuer_x500_string = issuer->x500_string();
			ms_cert::cert_str_to_name_blob(issuer_x500_string.c_str(), cert_info.Issuer, issuer_name_blob_data);
		} else {
			ms_cert::cert_str_to_name_blob(dummy_issuer_name, cert_info.Issuer, issuer_name_blob_data);
		}
 
  		DWORD pub_key_size;
  		if( !CryptExportPublicKeyInfoEx(subject_public_key, 0, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, OID_DSTU4145_PUBKEY, 0, 0, 0, &pub_key_size) ){
  			STCRYPT_UNEXPECTED();
 		}
		STCRYPT_CHECK(pub_key_size!=0);
		
		std::vector<unsigned char> subject_pub_key_info_data(pub_key_size);
		if( !CryptExportPublicKeyInfoEx(subject_public_key, 0, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, OID_DSTU4145_PUBKEY, 0, 0,  static_cast<CERT_PUBLIC_KEY_INFO*>( static_cast<void*>(subject_pub_key_info_data.data())), &pub_key_size) ){
			STCRYPT_UNEXPECTED();
		}
		subject_pub_key_info_data.resize(pub_key_size);

		CERT_PUBLIC_KEY_INFO * subject_pub_key_info = static_cast<CERT_PUBLIC_KEY_INFO*>( static_cast<void*>( subject_pub_key_info_data.data() ) );
		cert_info.SubjectPublicKeyInfo = *subject_pub_key_info;

		DWORD cert_encoded_size = 0;
		STCRYPT_CHECK( CryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &cert_info, 0, 0, 0, &cert_encoded_size)!=0 );
		STCRYPT_CHECK( cert_encoded_size!=0 );

		std::vector<unsigned char> cert_to_be_signed_blob(cert_encoded_size);
		STCRYPT_CHECK( CryptEncodeObjectEx(X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, &cert_info, 0, 0, cert_to_be_signed_blob.data(), &cert_encoded_size)!=0 );
		cert_to_be_signed_blob.resize( cert_encoded_size );

		return cert_to_be_signed_blob;
	}