Andrew de los Reyes | 0c44005 | 2010-08-20 11:25:54 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PAYLOAD_SIGNER_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_PAYLOAD_SIGNER_H__ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | #include "base/basictypes.h" |
| 11 | |
| 12 | // This function signs a payload with the OS vendor's private key. |
| 13 | // It takes an update up to the signature blob and returns the signature |
| 14 | // blob, which should be appended. See update_metadata.proto for more info. |
| 15 | |
| 16 | namespace chromeos_update_engine { |
| 17 | |
| 18 | extern const uint32_t kSignatureMessageVersion; |
| 19 | |
| 20 | class PayloadSigner { |
| 21 | public: |
| 22 | static bool SignPayload(const std::string& unsigned_payload_path, |
| 23 | const std::string& private_key_path, |
| 24 | std::vector<char>* out_signature_blob); |
| 25 | |
| 26 | // Returns the length of out_signature_blob that will result in a call |
| 27 | // to SignPayload with a given private key. Returns true on success. |
| 28 | static bool SignatureBlobLength(const std::string& private_key_path, |
| 29 | uint64_t* out_length); |
| 30 | |
| 31 | private: |
| 32 | // This should never be constructed |
| 33 | DISALLOW_IMPLICIT_CONSTRUCTORS(PayloadSigner); |
| 34 | }; |
| 35 | |
| 36 | } // namespace chromeos_update_engine |
| 37 | |
| 38 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PAYLOAD_SIGNER_H__ |