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/encryptor.h" | 5 #include "crypto/encryptor.h" |
6 | 6 |
7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 const base::StringPiece& iv) { | 46 const base::StringPiece& iv) { |
47 DCHECK(key); | 47 DCHECK(key); |
48 DCHECK(CBC == mode || CTR == mode) << "Unsupported mode of operation"; | 48 DCHECK(CBC == mode || CTR == mode) << "Unsupported mode of operation"; |
49 | 49 |
50 key_ = key; | 50 key_ = key; |
51 mode_ = mode; | 51 mode_ = mode; |
52 | 52 |
53 if (mode == CBC && iv.size() != AES_BLOCK_SIZE) | 53 if (mode == CBC && iv.size() != AES_BLOCK_SIZE) |
54 return false; | 54 return false; |
55 | 55 |
56 slot_.reset(PK11_GetBestSlot(GetMechanism(mode), NULL)); | 56 slot_.reset(PK11_GetInternalSlot()); |
Ryan Sleevi
2012/10/16 19:25:09
wtc: It's not immediately clear to me why we even
wtc
2012/10/16 21:26:57
We should remove the unused slot_ member. I guess
| |
57 if (!slot_.get()) | 57 if (!slot_.get()) |
58 return false; | 58 return false; |
59 | 59 |
60 switch (mode) { | 60 switch (mode) { |
61 case CBC: | 61 case CBC: |
62 SECItem iv_item; | 62 SECItem iv_item; |
63 iv_item.type = siBuffer; | 63 iv_item.type = siBuffer; |
64 iv_item.data = reinterpret_cast<unsigned char*>( | 64 iv_item.data = reinterpret_cast<unsigned char*>( |
65 const_cast<char *>(iv.data())); | 65 const_cast<char *>(iv.data())); |
66 iv_item.len = iv.size(); | 66 iv_item.len = iv.size(); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 | 188 |
189 // Use |output_data| to mask |input|. | 189 // Use |output_data| to mask |input|. |
190 MaskMessage( | 190 MaskMessage( |
191 reinterpret_cast<uint8*>(const_cast<char*>(input.data())), | 191 reinterpret_cast<uint8*>(const_cast<char*>(input.data())), |
192 input.length(), output_data, output_data); | 192 input.length(), output_data, output_data); |
193 output->resize(input.length()); | 193 output->resize(input.length()); |
194 return true; | 194 return true; |
195 } | 195 } |
196 | 196 |
197 } // namespace crypto | 197 } // namespace crypto |
OLD | NEW |