diff options
author | Matt Ellis <matell@microsoft.com> | 2015-07-15 11:22:39 -0700 |
---|---|---|
committer | Matt Ellis <matell@microsoft.com> | 2015-09-25 14:41:23 -0700 |
commit | 62faf7e4cbbc74e89632a22c3c1b50dc114ba2d2 (patch) | |
tree | 771959a6eecc9da1a1942065eecd4c54618d2c77 /src/vm/comutilnative.cpp | |
parent | f4560c6e113741d2296f2ebbc4cd6e6427b57a88 (diff) | |
download | coreclr-62faf7e4cbbc74e89632a22c3c1b50dc114ba2d2.tar.gz coreclr-62faf7e4cbbc74e89632a22c3c1b50dc114ba2d2.tar.bz2 coreclr-62faf7e4cbbc74e89632a22c3c1b50dc114ba2d2.zip |
Implement basic collation on top of ICU
This change adds support for basic Unicode collation support, built on
top of ICU. Windows and ICU have different collation models, and the
windows model does not correspond 1:1 with the ICU model, so in addition
to differences in sort weights between the two platforms, the
CompareOptions enum does not map nicely to ICU options.
For now, we only map CompareOptions.None, CompareOptions.IgnoreCase as
well as CompareOptions.Ordinal and CompareOptions.OrdinalIngoreCase,
other CompareOptions are ignored during collation.
In addition to collation support, I have enabed the randomized string
hashing code (using Marvin32 + a per app domain seed) so that string
hashcodes are not predictable across runs.
Diffstat (limited to 'src/vm/comutilnative.cpp')
-rw-r--r-- | src/vm/comutilnative.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/vm/comutilnative.cpp b/src/vm/comutilnative.cpp index 55a7a1f73a..9664bf9325 100644 --- a/src/vm/comutilnative.cpp +++ b/src/vm/comutilnative.cpp @@ -3067,7 +3067,7 @@ void COMNlsHashProvider::InitializeDefaultSeed() CONTRACTL_END; PCBYTE pEntropy = GetEntropy(); - AllocMemHolder<SYMCRYPT_MARVIN32_EXPANDED_SEED> pSeed = GetAppDomain()->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(SYMCRYPT_MARVIN32_EXPANDED_SEED))); + AllocMemHolder<SYMCRYPT_MARVIN32_EXPANDED_SEED> pSeed(GetAppDomain()->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(SYMCRYPT_MARVIN32_EXPANDED_SEED)))); SymCryptMarvin32ExpandSeed(pSeed, pEntropy, SYMCRYPT_MARVIN32_SEED_SIZE); if(InterlockedCompareExchangeT(&pDefaultSeed, (PCSYMCRYPT_MARVIN32_EXPANDED_SEED) pSeed, NULL) == NULL) @@ -3104,12 +3104,16 @@ PCBYTE COMNlsHashProvider::GetEntropy() if(pEntropy == NULL) { + AllocMemHolder<BYTE> pNewEntropy(GetAppDomain()->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(SYMCRYPT_MARVIN32_SEED_SIZE)))); + +#ifdef FEATURE_PAL + PAL_Random(TRUE, pNewEntropy, SYMCRYPT_MARVIN32_SEED_SIZE); +#else HCRYPTPROV hCryptProv; - AllocMemHolder<BYTE> pNewEntropy = GetAppDomain()->GetLowFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(SYMCRYPT_MARVIN32_SEED_SIZE))); - WszCryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT); CryptGenRandom(hCryptProv, SYMCRYPT_MARVIN32_SEED_SIZE, pNewEntropy); CryptReleaseContext(hCryptProv, 0); +#endif if(InterlockedCompareExchangeT(&pEntropy, (PBYTE) pNewEntropy, NULL) == NULL) { @@ -3138,3 +3142,20 @@ void COMNlsHashProvider::CreateMarvin32Seed(INT64 additionalEntropy, PSYMCRYPT_M SymCryptMarvin32ExpandSeed(pExpandedMarvinSeed, (PCBYTE) &entropy, SYMCRYPT_MARVIN32_SEED_SIZE); } #endif // FEATURE_RANDOMIZED_STRING_HASHING + +#ifdef FEATURE_COREFX_GLOBALIZATION +INT32 QCALLTYPE CoreFxGlobalization::HashSortKey(PCBYTE pSortKey, INT32 cbSortKey, BOOL forceRandomizedHashing, INT64 additionalEntropy) +{ + QCALL_CONTRACT; + + INT32 retVal = 0; + + BEGIN_QCALL; + + retVal = COMNlsHashProvider::s_NlsHashProvider.HashSortKey(pSortKey, cbSortKey, forceRandomizedHashing, additionalEntropy); + + END_QCALL; + + return retVal; +} +#endif //FEATURE_COREFX_GLOBALIZATION |