| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/crypto/rsa_private_key.h" | 5 #include "base/crypto/rsa_private_key.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 // The version should be zero. | 154 // The version should be zero. |
| 155 for (uint32 i = 0; i < length; ++i) { | 155 for (uint32 i = 0; i < length; ++i) { |
| 156 READ_ASSERT(**pos == 0x00); | 156 READ_ASSERT(**pos == 0x00); |
| 157 (*pos)++; | 157 (*pos)++; |
| 158 } | 158 } |
| 159 | 159 |
| 160 return true; | 160 return true; |
| 161 } | 161 } |
| 162 | 162 |
| 163 PrivateKeyInfoCodec::PrivateKeyInfoCodec(bool big_endian) |
| 164 : big_endian_(big_endian) {} |
| 165 |
| 166 PrivateKeyInfoCodec::~PrivateKeyInfoCodec() {} |
| 167 |
| 163 bool PrivateKeyInfoCodec::Export(std::vector<uint8>* output) { | 168 bool PrivateKeyInfoCodec::Export(std::vector<uint8>* output) { |
| 164 std::list<uint8> content; | 169 std::list<uint8> content; |
| 165 | 170 |
| 166 // Version (always zero) | 171 // Version (always zero) |
| 167 uint8 version = 0; | 172 uint8 version = 0; |
| 168 | 173 |
| 169 PrependInteger(coefficient_, &content); | 174 PrependInteger(coefficient_, &content); |
| 170 PrependInteger(exponent2_, &content); | 175 PrependInteger(exponent2_, &content); |
| 171 PrependInteger(exponent1_, &content); | 176 PrependInteger(exponent1_, &content); |
| 172 PrependInteger(prime2_, &content); | 177 PrependInteger(prime2_, &content); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 370 } |
| 366 out->insert(out->end(), temp.begin(), temp.end()); | 371 out->insert(out->end(), temp.begin(), temp.end()); |
| 367 | 372 |
| 368 // Reverse output if little-endian. | 373 // Reverse output if little-endian. |
| 369 if (!big_endian_) | 374 if (!big_endian_) |
| 370 reverse(out->begin(), out->end()); | 375 reverse(out->begin(), out->end()); |
| 371 return true; | 376 return true; |
| 372 } | 377 } |
| 373 | 378 |
| 374 } // namespace base | 379 } // namespace base |
| OLD | NEW |