summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 06:01:59 +0000
committerrsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 06:01:59 +0000
commit68da887c6a2acc6dac295bf27930eaeba8da0eed (patch)
tree1f2b6b6c608eeda607386c075107ee7797d3f8f4 /crypto
parenta9891b44234b0037a60a280de36f35d584e13cc1 (diff)
downloadchromium_src-68da887c6a2acc6dac295bf27930eaeba8da0eed.zip
chromium_src-68da887c6a2acc6dac295bf27930eaeba8da0eed.tar.gz
chromium_src-68da887c6a2acc6dac295bf27930eaeba8da0eed.tar.bz2
Properly parse UTF8Strings in certificates on Windows.
BUG=114168 TEST=https://www.verisign.co.jp appears correctly regardless of system locale. Additionally, net_unittests:X509TypesTest* should cover this. Review URL: https://chromiumcodereview.appspot.com/9358080 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto')
-rw-r--r--crypto/capi_util.cc8
-rw-r--r--crypto/capi_util.h6
-rw-r--r--crypto/signature_verifier_win.cc23
3 files changed, 19 insertions, 18 deletions
diff --git a/crypto/capi_util.cc b/crypto/capi_util.cc
index 7593f39..2cf1062 100644
--- a/crypto/capi_util.cc
+++ b/crypto/capi_util.cc
@@ -46,4 +46,12 @@ BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
return CryptAcquireContext(prov, container, provider, prov_type, flags);
}
+void* WINAPI CryptAlloc(size_t size) {
+ return malloc(size);
+}
+
+void WINAPI CryptFree(void* p) {
+ free(p);
+}
+
} // namespace crypto
diff --git a/crypto/capi_util.h b/crypto/capi_util.h
index 3aa681e..1786a24 100644
--- a/crypto/capi_util.h
+++ b/crypto/capi_util.h
@@ -29,6 +29,12 @@ CRYPTO_EXPORT BOOL CryptAcquireContextLocked(HCRYPTPROV* prov,
DWORD prov_type,
DWORD flags);
+// Wrappers of malloc and free for CryptoAPI routines that need memory
+// allocators, such as in CRYPT_DECODE_PARA. Such routines require WINAPI
+// calling conventions.
+CRYPTO_EXPORT void* WINAPI CryptAlloc(size_t size);
+CRYPTO_EXPORT void WINAPI CryptFree(void* p);
+
} // namespace crypto
#endif // CRYPTO_CAPI_UTIL_H_
diff --git a/crypto/signature_verifier_win.cc b/crypto/signature_verifier_win.cc
index d294c4d..dfb17a4 100644
--- a/crypto/signature_verifier_win.cc
+++ b/crypto/signature_verifier_win.cc
@@ -5,23 +5,10 @@
#include "crypto/signature_verifier.h"
#include "base/logging.h"
+#include "crypto/capi_util.h"
#pragma comment(lib, "crypt32.lib")
-namespace {
-
-// Wrappers of malloc and free for CRYPT_DECODE_PARA, which requires the
-// WINAPI calling convention.
-void* WINAPI MyCryptAlloc(size_t size) {
- return malloc(size);
-}
-
-void WINAPI MyCryptFree(void* p) {
- free(p);
-}
-
-} // namespace
-
namespace crypto {
SignatureVerifier::SignatureVerifier() : hash_object_(0), public_key_(0) {
@@ -47,8 +34,8 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
CRYPT_DECODE_PARA decode_para;
decode_para.cbSize = sizeof(decode_para);
- decode_para.pfnAlloc = MyCryptAlloc;
- decode_para.pfnFree = MyCryptFree;
+ decode_para.pfnAlloc = crypto::CryptAlloc;
+ decode_para.pfnFree = crypto::CryptFree;
CERT_PUBLIC_KEY_INFO* cert_public_key_info = NULL;
DWORD struct_len = 0;
BOOL ok;
@@ -66,7 +53,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
ok = CryptImportPublicKeyInfo(provider_,
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
cert_public_key_info, public_key_.receive());
- free(cert_public_key_info);
+ crypto::CryptFree(cert_public_key_info);
if (!ok)
return false;
@@ -89,7 +76,7 @@ bool SignatureVerifier::VerifyInit(const uint8* signature_algorithm,
hash_alg_id = CALG_SHA1;
else if (!strcmp(signature_algorithm_id->pszObjId, szOID_RSA_MD5RSA))
hash_alg_id = CALG_MD5;
- free(signature_algorithm_id);
+ crypto::CryptFree(signature_algorithm_id);
DCHECK_NE(static_cast<ALG_ID>(CALG_MD4), hash_alg_id);
if (hash_alg_id == CALG_MD4)
return false; // Unsupported hash algorithm.