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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 CTLogVerifier::~CTLogVerifier() { | 61 CTLogVerifier::~CTLogVerifier() { |
62 if (public_key_) | 62 if (public_key_) |
63 SECKEY_DestroyPublicKey(public_key_); | 63 SECKEY_DestroyPublicKey(public_key_); |
64 } | 64 } |
65 | 65 |
| 66 CTLogVerifier::CTLogVerifier(const CTLogVerifier& other) |
| 67 : key_id_(other.key_id_), |
| 68 description_(other.description_), |
| 69 url_(other.url_), |
| 70 hash_algorithm_(other.hash_algorithm_), |
| 71 signature_algorithm_(other.signature_algorithm_), |
| 72 public_key_(NULL) { |
| 73 public_key_ = SECKEY_CopyPublicKey(other.public_key_); |
| 74 } |
| 75 |
66 bool CTLogVerifier::Init(const base::StringPiece& public_key) { | 76 bool CTLogVerifier::Init(const base::StringPiece& public_key) { |
67 SECItem key_data; | 77 SECItem key_data; |
68 | 78 |
69 crypto::EnsureNSSInit(); | 79 crypto::EnsureNSSInit(); |
70 | 80 |
71 key_data.data = reinterpret_cast<unsigned char*>( | 81 key_data.data = reinterpret_cast<unsigned char*>( |
72 const_cast<char*>(public_key.data())); | 82 const_cast<char*>(public_key.data())); |
73 key_data.len = public_key.size(); | 83 key_data.len = public_key.size(); |
74 | 84 |
75 CERTSubjectPublicKeyInfo* public_key_info = | 85 CERTSubjectPublicKeyInfo* public_key_info = |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 SECStatus rv = VFY_VerifyDataDirect( | 136 SECStatus rv = VFY_VerifyDataDirect( |
127 reinterpret_cast<const unsigned char*>(data_to_sign.data()), | 137 reinterpret_cast<const unsigned char*>(data_to_sign.data()), |
128 data_to_sign.size(), public_key_, &sig_data, | 138 data_to_sign.size(), public_key_, &sig_data, |
129 GetNSSSigAlg(signature_algorithm_), GetNSSHashAlg(hash_algorithm_), | 139 GetNSSSigAlg(signature_algorithm_), GetNSSHashAlg(hash_algorithm_), |
130 NULL, NULL); | 140 NULL, NULL); |
131 DVLOG(1) << "Signature verification result: " << (rv == SECSuccess); | 141 DVLOG(1) << "Signature verification result: " << (rv == SECSuccess); |
132 return rv == SECSuccess; | 142 return rv == SECSuccess; |
133 } | 143 } |
134 | 144 |
135 } // namespace net | 145 } // namespace net |
OLD | NEW |