| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/cert/ct_log_verifier.h" | 5 #include "net/cert/ct_log_verifier.h" |
| 6 | 6 |
| 7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
| 8 #include <keyhi.h> | 8 #include <keyhi.h> |
| 9 #include <nss.h> | 9 #include <nss.h> |
| 10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (signature_algorithm_ == ct::DigitallySigned::SIG_ALGO_RSA && | 110 if (signature_algorithm_ == ct::DigitallySigned::SIG_ALGO_RSA && |
| 111 SECKEY_PublicKeyStrengthInBits(public_key_) < 2048) { | 111 SECKEY_PublicKeyStrengthInBits(public_key_) < 2048) { |
| 112 DVLOG(1) << "Too small a public key."; | 112 DVLOG(1) << "Too small a public key."; |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 return true; | 116 return true; |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool CTLogVerifier::VerifySignature(const base::StringPiece& data_to_sign, | 119 bool CTLogVerifier::VerifySignature(const base::StringPiece& data_to_sign, |
| 120 const base::StringPiece& signature) { | 120 const base::StringPiece& signature) const { |
| 121 SECItem sig_data; | 121 SECItem sig_data; |
| 122 sig_data.data = reinterpret_cast<unsigned char*>(const_cast<char*>( | 122 sig_data.data = reinterpret_cast<unsigned char*>(const_cast<char*>( |
| 123 signature.data())); | 123 signature.data())); |
| 124 sig_data.len = signature.size(); | 124 sig_data.len = signature.size(); |
| 125 | 125 |
| 126 SECStatus rv = VFY_VerifyDataDirect( | 126 SECStatus rv = VFY_VerifyDataDirect( |
| 127 reinterpret_cast<const unsigned char*>(data_to_sign.data()), | 127 reinterpret_cast<const unsigned char*>(data_to_sign.data()), |
| 128 data_to_sign.size(), public_key_, &sig_data, | 128 data_to_sign.size(), public_key_, &sig_data, |
| 129 GetNSSSigAlg(signature_algorithm_), GetNSSHashAlg(hash_algorithm_), | 129 GetNSSSigAlg(signature_algorithm_), GetNSSHashAlg(hash_algorithm_), |
| 130 NULL, NULL); | 130 NULL, NULL); |
| 131 DVLOG(1) << "Signature verification result: " << (rv == SECSuccess); | 131 DVLOG(1) << "Signature verification result: " << (rv == SECSuccess); |
| 132 return rv == SECSuccess; | 132 return rv == SECSuccess; |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace net | 135 } // namespace net |
| OLD | NEW |