| OLD | NEW |
| 1 // Copyright (c) 2011 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 "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 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 DCHECK(ok || GetLastError() == ERROR_FILE_NOT_FOUND); | 83 DCHECK(ok || GetLastError() == ERROR_FILE_NOT_FOUND); |
| 84 ALG_ID hash_alg_id; | 84 ALG_ID hash_alg_id; |
| 85 if (ok) { | 85 if (ok) { |
| 86 hash_alg_id = CALG_MD4; // Initialize to a weak hash algorithm that we | 86 hash_alg_id = CALG_MD4; // Initialize to a weak hash algorithm that we |
| 87 // don't support. | 87 // don't support. |
| 88 if (!strcmp(signature_algorithm_id->pszObjId, szOID_RSA_SHA1RSA)) | 88 if (!strcmp(signature_algorithm_id->pszObjId, szOID_RSA_SHA1RSA)) |
| 89 hash_alg_id = CALG_SHA1; | 89 hash_alg_id = CALG_SHA1; |
| 90 else if (!strcmp(signature_algorithm_id->pszObjId, szOID_RSA_MD5RSA)) | 90 else if (!strcmp(signature_algorithm_id->pszObjId, szOID_RSA_MD5RSA)) |
| 91 hash_alg_id = CALG_MD5; | 91 hash_alg_id = CALG_MD5; |
| 92 free(signature_algorithm_id); | 92 free(signature_algorithm_id); |
| 93 DCHECK(hash_alg_id != CALG_MD4); | 93 DCHECK_NE(static_cast<ALG_ID>(CALG_MD4), hash_alg_id); |
| 94 if (hash_alg_id == CALG_MD4) | 94 if (hash_alg_id == CALG_MD4) |
| 95 return false; // Unsupported hash algorithm. | 95 return false; // Unsupported hash algorithm. |
| 96 } else if (GetLastError() == ERROR_FILE_NOT_FOUND) { | 96 } else if (GetLastError() == ERROR_FILE_NOT_FOUND) { |
| 97 // TODO(wtc): X509_ALGORITHM_IDENTIFIER isn't supported on XP SP2. We | 97 // TODO(wtc): X509_ALGORITHM_IDENTIFIER isn't supported on XP SP2. We |
| 98 // may be able to encapsulate signature_algorithm in a dummy SignedContent | 98 // may be able to encapsulate signature_algorithm in a dummy SignedContent |
| 99 // and decode it with X509_CERT into a CERT_SIGNED_CONTENT_INFO. For now, | 99 // and decode it with X509_CERT into a CERT_SIGNED_CONTENT_INFO. For now, |
| 100 // just hardcode the hash algorithm to be SHA-1. | 100 // just hardcode the hash algorithm to be SHA-1. |
| 101 hash_alg_id = CALG_SHA1; | 101 hash_alg_id = CALG_SHA1; |
| 102 } else { | 102 } else { |
| 103 return false; | 103 return false; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 crypto | 133 } // namespace crypto |
| 134 | 134 |
| OLD | NEW |