| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 <sys/mount.h> | 5 #include <sys/mount.h> |
| 6 #include <inttypes.h> | 6 #include <inttypes.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 ASSERT_EQ(kSignatureGeneratedShell, signature_test); | 142 ASSERT_EQ(kSignatureGeneratedShell, signature_test); |
| 143 } | 143 } |
| 144 ScopedPathUnlinker key_unlinker(private_key_path); | 144 ScopedPathUnlinker key_unlinker(private_key_path); |
| 145 key_unlinker.set_should_remove(signature_test == | 145 key_unlinker.set_should_remove(signature_test == |
| 146 kSignatureGeneratedShellBadKey); | 146 kSignatureGeneratedShellBadKey); |
| 147 // Generates a new private key that will not match the public key. | 147 // Generates a new private key that will not match the public key. |
| 148 if (signature_test == kSignatureGeneratedShellBadKey) { | 148 if (signature_test == kSignatureGeneratedShellBadKey) { |
| 149 LOG(INFO) << "Generating a mismatched private key."; | 149 LOG(INFO) << "Generating a mismatched private key."; |
| 150 ASSERT_EQ(0, | 150 ASSERT_EQ(0, |
| 151 System(StringPrintf( | 151 System(StringPrintf( |
| 152 "/usr/bin/openssl genrsa -out %s 1024", | 152 "/usr/bin/openssl genrsa -out %s 2048", |
| 153 private_key_path.c_str()))); | 153 private_key_path.c_str()))); |
| 154 } | 154 } |
| 155 int signature_size = GetSignatureSize(private_key_path); | 155 int signature_size = GetSignatureSize(private_key_path); |
| 156 string hash_file; | 156 string hash_file; |
| 157 ASSERT_TRUE(utils::MakeTempFile("/tmp/hash.XXXXXX", &hash_file, NULL)); | 157 ASSERT_TRUE(utils::MakeTempFile("/tmp/hash.XXXXXX", &hash_file, NULL)); |
| 158 ScopedPathUnlinker hash_unlinker(hash_file); | 158 ScopedPathUnlinker hash_unlinker(hash_file); |
| 159 ASSERT_EQ(0, | 159 ASSERT_EQ(0, |
| 160 System(StringPrintf( | 160 System(StringPrintf( |
| 161 "./delta_generator -in_file %s -signature_size %d " | 161 "./delta_generator -in_file %s -signature_size %d " |
| 162 "-out_hash_file %s", | 162 "-out_hash_file %s", |
| 163 payload_path.c_str(), | 163 payload_path.c_str(), |
| 164 signature_size, | 164 signature_size, |
| 165 hash_file.c_str()))); | 165 hash_file.c_str()))); |
| 166 | 166 |
| 167 // Pad the hash |
| 168 vector<char> hash; |
| 169 ASSERT_TRUE(utils::ReadFile(hash_file, &hash)); |
| 170 ASSERT_TRUE(PayloadSigner::PadRSA2048SHA256Hash(&hash)); |
| 171 ASSERT_TRUE(WriteFileVector(hash_file, hash)); |
| 172 |
| 167 string sig_file; | 173 string sig_file; |
| 168 ASSERT_TRUE(utils::MakeTempFile("/tmp/signature.XXXXXX", &sig_file, NULL)); | 174 ASSERT_TRUE(utils::MakeTempFile("/tmp/signature.XXXXXX", &sig_file, NULL)); |
| 169 ScopedPathUnlinker sig_unlinker(sig_file); | 175 ScopedPathUnlinker sig_unlinker(sig_file); |
| 170 ASSERT_EQ(0, | 176 ASSERT_EQ(0, |
| 171 System(StringPrintf( | 177 System(StringPrintf( |
| 172 "/usr/bin/openssl rsautl -pkcs -sign -inkey %s -in %s -out %s", | 178 "/usr/bin/openssl rsautl -raw -sign -inkey %s -in %s -out %s", |
| 173 private_key_path.c_str(), | 179 private_key_path.c_str(), |
| 174 hash_file.c_str(), | 180 hash_file.c_str(), |
| 175 sig_file.c_str()))); | 181 sig_file.c_str()))); |
| 176 ASSERT_EQ(0, | 182 ASSERT_EQ(0, |
| 177 System(StringPrintf( | 183 System(StringPrintf( |
| 178 "./delta_generator -in_file %s -signature_file %s " | 184 "./delta_generator -in_file %s -signature_file %s " |
| 179 "-out_file %s", | 185 "-out_file %s", |
| 180 payload_path.c_str(), | 186 payload_path.c_str(), |
| 181 sig_file.c_str(), | 187 sig_file.c_str(), |
| 182 payload_path.c_str()))); | 188 payload_path.c_str()))); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 op.clear_src_extents(); | 539 op.clear_src_extents(); |
| 534 *(op.add_src_extents()) = ExtentForRange(5, 3); | 540 *(op.add_src_extents()) = ExtentForRange(5, 3); |
| 535 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); | 541 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); |
| 536 *(op.add_dst_extents()) = ExtentForRange(20, 6); | 542 *(op.add_dst_extents()) = ExtentForRange(20, 6); |
| 537 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); | 543 EXPECT_TRUE(DeltaPerformer::IsIdempotentOperation(op)); |
| 538 *(op.add_src_extents()) = ExtentForRange(19, 2); | 544 *(op.add_src_extents()) = ExtentForRange(19, 2); |
| 539 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op)); | 545 EXPECT_FALSE(DeltaPerformer::IsIdempotentOperation(op)); |
| 540 } | 546 } |
| 541 | 547 |
| 542 } // namespace chromeos_update_engine | 548 } // namespace chromeos_update_engine |
| OLD | NEW |