| 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 <cryptohi.h> | 7 #include <cryptohi.h> |
| 8 #include <keyhi.h> | 8 #include <keyhi.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (rv != SECSuccess) { | 83 if (rv != SECSuccess) { |
| 84 NOTREACHED(); | 84 NOTREACHED(); |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SignatureVerifier::VerifyUpdate(const uint8* data_part, | 90 void SignatureVerifier::VerifyUpdate(const uint8* data_part, |
| 91 int data_part_len) { | 91 int data_part_len) { |
| 92 SECStatus rv = VFY_Update(vfy_context_, data_part, data_part_len); | 92 SECStatus rv = VFY_Update(vfy_context_, data_part, data_part_len); |
| 93 DCHECK(rv == SECSuccess); | 93 DCHECK_EQ(SECSuccess, rv); |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool SignatureVerifier::VerifyFinal() { | 96 bool SignatureVerifier::VerifyFinal() { |
| 97 SECStatus rv = VFY_End(vfy_context_); | 97 SECStatus rv = VFY_End(vfy_context_); |
| 98 Reset(); | 98 Reset(); |
| 99 | 99 |
| 100 // If signature verification fails, the error code is | 100 // If signature verification fails, the error code is |
| 101 // SEC_ERROR_BAD_SIGNATURE (-8182). | 101 // SEC_ERROR_BAD_SIGNATURE (-8182). |
| 102 return (rv == SECSuccess); | 102 return (rv == SECSuccess); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void SignatureVerifier::Reset() { | 105 void SignatureVerifier::Reset() { |
| 106 if (vfy_context_) { | 106 if (vfy_context_) { |
| 107 VFY_DestroyContext(vfy_context_, PR_TRUE); | 107 VFY_DestroyContext(vfy_context_, PR_TRUE); |
| 108 vfy_context_ = NULL; | 108 vfy_context_ = NULL; |
| 109 } | 109 } |
| 110 signature_.clear(); | 110 signature_.clear(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace crypto | 113 } // namespace crypto |
| OLD | NEW |