summaryrefslogtreecommitdiffstats
path: root/install/include
diff options
context:
space:
mode:
Diffstat (limited to 'install/include')
-rw-r--r--install/include/install/fuse_install.h2
-rw-r--r--install/include/install/install.h6
-rw-r--r--install/include/install/package.h62
-rw-r--r--install/include/install/verifier.h101
-rw-r--r--install/include/install/wipe_data.h2
-rw-r--r--install/include/install/wipe_device.h2
-rw-r--r--install/include/private/asn1_decoder.h56
7 files changed, 7 insertions, 224 deletions
diff --git a/install/include/install/fuse_install.h b/install/include/install/fuse_install.h
index 63b116aeb..29c283f40 100644
--- a/install/include/install/fuse_install.h
+++ b/install/include/install/fuse_install.h
@@ -25,6 +25,6 @@
// Starts FUSE with the package from |path| as the data source. And installs the package from
// |FUSE_SIDELOAD_HOST_PATHNAME|. The |path| can point to the location of a package zip file or a
// block map file with the prefix '@'; e.g. /sdcard/package.zip, @/cache/recovery/block.map.
-InstallResult InstallWithFuseFromPath(std::string_view path, RecoveryUI* ui);
+InstallResult InstallWithFuseFromPath(std::string_view path, Device* device);
InstallResult ApplyFromSdcard(Device* device);
diff --git a/install/include/install/install.h b/install/include/install/install.h
index bef23e9ca..0f5102f82 100644
--- a/install/include/install/install.h
+++ b/install/include/install/install.h
@@ -24,7 +24,8 @@
#include <ziparchive/zip_archive.h>
-#include "package.h"
+#include "otautil/package.h"
+#include "recovery_ui/device.h"
#include "recovery_ui/ui.h"
enum InstallResult {
@@ -49,7 +50,8 @@ enum class OtaType {
// cache partition after a successful installation if |should_wipe_cache| is true or an updater
// command asks to wipe the cache.
InstallResult InstallPackage(Package* package, const std::string_view package_id,
- bool should_wipe_cache, int retry_count, RecoveryUI* ui);
+ bool should_wipe_cache, int retry_count,
+ Device* ui);
// Verifies the package by ota keys. Returns true if the package is verified successfully,
// otherwise returns false.
diff --git a/install/include/install/package.h b/install/include/install/package.h
deleted file mode 100644
index 0b4233238..000000000
--- a/install/include/install/package.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <stdint.h>
-
-#include <functional>
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <ziparchive/zip_archive.h>
-
-#include "verifier.h"
-
-enum class PackageType {
- kMemory,
- kFile,
-};
-
-// This class serves as a wrapper for an OTA update package. It aims to provide the common
-// interface for both packages loaded in memory and packages read from fd.
-class Package : public VerifierInterface {
- public:
- static std::unique_ptr<Package> CreateMemoryPackage(
- const std::string& path, const std::function<void(float)>& set_progress);
- static std::unique_ptr<Package> CreateMemoryPackage(
- std::vector<uint8_t> content, const std::function<void(float)>& set_progress);
- static std::unique_ptr<Package> CreateFilePackage(const std::string& path,
- const std::function<void(float)>& set_progress);
-
- virtual ~Package() = default;
-
- virtual PackageType GetType() const = 0;
-
- virtual std::string GetPath() const = 0;
-
- // Opens the package as a zip file and returns the ZipArchiveHandle.
- virtual ZipArchiveHandle GetZipArchiveHandle() = 0;
-
- // Updates the progress in fraction during package verification.
- void SetProgress(float progress) override;
-
- protected:
- // An optional function to update the progress.
- std::function<void(float)> set_progress_;
-};
diff --git a/install/include/install/verifier.h b/install/include/install/verifier.h
deleted file mode 100644
index f9e947580..000000000
--- a/install/include/install/verifier.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <stdint.h>
-
-#include <functional>
-#include <memory>
-#include <vector>
-
-#include <openssl/ec_key.h>
-#include <openssl/rsa.h>
-#include <openssl/sha.h>
-
-constexpr size_t MiB = 1024 * 1024;
-
-using HasherUpdateCallback = std::function<void(const uint8_t* addr, uint64_t size)>;
-
-struct RSADeleter {
- void operator()(RSA* rsa) const {
- RSA_free(rsa);
- }
-};
-
-struct ECKEYDeleter {
- void operator()(EC_KEY* ec_key) const {
- EC_KEY_free(ec_key);
- }
-};
-
-struct Certificate {
- typedef enum {
- KEY_TYPE_RSA,
- KEY_TYPE_EC,
- } KeyType;
-
- Certificate(int hash_len_, KeyType key_type_, std::unique_ptr<RSA, RSADeleter>&& rsa_,
- std::unique_ptr<EC_KEY, ECKEYDeleter>&& ec_)
- : hash_len(hash_len_), key_type(key_type_), rsa(std::move(rsa_)), ec(std::move(ec_)) {}
-
- // SHA_DIGEST_LENGTH (SHA-1) or SHA256_DIGEST_LENGTH (SHA-256)
- int hash_len;
- KeyType key_type;
- std::unique_ptr<RSA, RSADeleter> rsa;
- std::unique_ptr<EC_KEY, ECKEYDeleter> ec;
-};
-
-class VerifierInterface {
- public:
- virtual ~VerifierInterface() = default;
-
- // Returns the package size in bytes.
- virtual uint64_t GetPackageSize() const = 0;
-
- // Reads |byte_count| data starting from |offset|, and puts the result in |buffer|.
- virtual bool ReadFullyAtOffset(uint8_t* buffer, uint64_t byte_count, uint64_t offset) = 0;
-
- // Updates the hash contexts for |length| bytes data starting from |start|.
- virtual bool UpdateHashAtOffset(const std::vector<HasherUpdateCallback>& hashers, uint64_t start,
- uint64_t length) = 0;
-
- // Updates the progress in fraction during package verification.
- virtual void SetProgress(float progress) = 0;
-};
-
-// Looks for an RSA signature embedded in the .ZIP file comment given the path to the zip.
-// Verifies that it matches one of the given public keys. Returns VERIFY_SUCCESS or
-// VERIFY_FAILURE (if any error is encountered or no key matches the signature).
-int verify_file(VerifierInterface* package, const std::vector<Certificate>& keys);
-
-// Checks that the RSA key has a modulus of 2048 or 4096 bits long, and public exponent is 3 or
-// 65537.
-bool CheckRSAKey(const std::unique_ptr<RSA, RSADeleter>& rsa);
-
-// Checks that the field size of the curve for the EC key is 256 bits.
-bool CheckECKey(const std::unique_ptr<EC_KEY, ECKEYDeleter>& ec_key);
-
-// Parses a PEM-encoded x509 certificate from the given buffer and saves it into |cert|. Returns
-// false if there is a parsing failure or the signature's encryption algorithm is not supported.
-bool LoadCertificateFromBuffer(const std::vector<uint8_t>& pem_content, Certificate* cert);
-
-// Iterates over the zip entries with the suffix "x509.pem" and returns a list of recognized
-// certificates. Returns an empty list if we fail to parse any of the entries.
-std::vector<Certificate> LoadKeysFromZipfile(const std::string& zip_name);
-
-#define VERIFY_SUCCESS 0
-#define VERIFY_FAILURE 1
diff --git a/install/include/install/wipe_data.h b/install/include/install/wipe_data.h
index b34891f3d..42cad871e 100644
--- a/install/include/install/wipe_data.h
+++ b/install/include/install/wipe_data.h
@@ -27,4 +27,4 @@ struct selabel_handle;
bool WipeCache(RecoveryUI* ui, const std::function<bool()>& confirm);
// Returns true on success.
-bool WipeData(Device* device, bool convert_fbe);
+bool WipeData(Device* device);
diff --git a/install/include/install/wipe_device.h b/install/include/install/wipe_device.h
index c60b99997..903ddfdcd 100644
--- a/install/include/install/wipe_device.h
+++ b/install/include/install/wipe_device.h
@@ -19,7 +19,7 @@
#include <string>
#include <vector>
-#include "install/package.h"
+#include "otautil/package.h"
#include "recovery_ui/device.h"
// Wipes the current A/B device, with a secure wipe of all the partitions in RECOVERY_WIPE.
diff --git a/install/include/private/asn1_decoder.h b/install/include/private/asn1_decoder.h
deleted file mode 100644
index e5337d9c4..000000000
--- a/install/include/private/asn1_decoder.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ASN1_DECODER_H_
-#define ASN1_DECODER_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-class asn1_context {
- public:
- asn1_context(const uint8_t* buffer, size_t length) : p_(buffer), length_(length), app_type_(0) {}
- int asn1_constructed_type() const;
- asn1_context* asn1_constructed_get();
- bool asn1_constructed_skip_all();
- asn1_context* asn1_sequence_get();
- asn1_context* asn1_set_get();
- bool asn1_sequence_next();
- bool asn1_oid_get(const uint8_t** oid, size_t* length);
- bool asn1_octet_string_get(const uint8_t** octet_string, size_t* length);
-
- private:
- static constexpr int kMaskConstructed = 0xE0;
- static constexpr int kMaskTag = 0x7F;
- static constexpr int kMaskAppType = 0x1F;
-
- static constexpr int kTagOctetString = 0x04;
- static constexpr int kTagOid = 0x06;
- static constexpr int kTagSequence = 0x30;
- static constexpr int kTagSet = 0x31;
- static constexpr int kTagConstructed = 0xA0;
-
- int peek_byte() const;
- int get_byte();
- bool skip_bytes(size_t num_skip);
- bool decode_length(size_t* out_len);
-
- const uint8_t* p_;
- size_t length_;
- int app_type_;
-};
-
-#endif /* ASN1_DECODER_H_ */