OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/crypto/signature_verifier.h" | 5 #include "crypto/signature_verifier.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 #pragma comment(lib, "crypt32.lib") | 9 #pragma comment(lib, "crypt32.lib") |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 // Wrappers of malloc and free for CRYPT_DECODE_PARA, which requires the | 13 // Wrappers of malloc and free for CRYPT_DECODE_PARA, which requires the |
14 // WINAPI calling convention. | 14 // WINAPI calling convention. |
15 void* WINAPI MyCryptAlloc(size_t size) { | 15 void* WINAPI MyCryptAlloc(size_t size) { |
16 return malloc(size); | 16 return malloc(size); |
17 } | 17 } |
18 | 18 |
19 void WINAPI MyCryptFree(void* p) { | 19 void WINAPI MyCryptFree(void* p) { |
20 free(p); | 20 free(p); |
21 } | 21 } |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 namespace base { | 25 namespace crypto { |
26 | 26 |
27 SignatureVerifier::SignatureVerifier() : hash_object_(0), public_key_(0) { | 27 SignatureVerifier::SignatureVerifier() : hash_object_(0), public_key_(0) { |
28 if (!CryptAcquireContext(provider_.receive(), NULL, NULL, | 28 if (!CryptAcquireContext(provider_.receive(), NULL, NULL, |
29 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) | 29 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) |
30 provider_.reset(); | 30 provider_.reset(); |
31 } | 31 } |
32 | 32 |
33 SignatureVerifier::~SignatureVerifier() { | 33 SignatureVerifier::~SignatureVerifier() { |
34 } | 34 } |
35 | 35 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return false; | 123 return false; |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 void SignatureVerifier::Reset() { | 127 void SignatureVerifier::Reset() { |
128 hash_object_.reset(); | 128 hash_object_.reset(); |
129 public_key_.reset(); | 129 public_key_.reset(); |
130 signature_.clear(); | 130 signature_.clear(); |
131 } | 131 } |
132 | 132 |
133 } // namespace base | 133 } // namespace crypto |
134 | 134 |
OLD | NEW |