summaryrefslogtreecommitdiffstats
path: root/install/include/private
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-03-29 22:23:49 +0100
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-03-29 22:23:49 +0100
commita232d9dccbf39856824ad783cc2d66812f581d95 (patch)
tree7bad452d0d5b0ae6eca9adf18c7bf8b8966a318f /install/include/private
parentMerge "Use flags = 0 to avoid fd closing for child updater process" (diff)
parentMove install to separate module (diff)
downloadandroid_bootable_recovery-a232d9dccbf39856824ad783cc2d66812f581d95.tar
android_bootable_recovery-a232d9dccbf39856824ad783cc2d66812f581d95.tar.gz
android_bootable_recovery-a232d9dccbf39856824ad783cc2d66812f581d95.tar.bz2
android_bootable_recovery-a232d9dccbf39856824ad783cc2d66812f581d95.tar.lz
android_bootable_recovery-a232d9dccbf39856824ad783cc2d66812f581d95.tar.xz
android_bootable_recovery-a232d9dccbf39856824ad783cc2d66812f581d95.tar.zst
android_bootable_recovery-a232d9dccbf39856824ad783cc2d66812f581d95.zip
Diffstat (limited to 'install/include/private')
-rw-r--r--install/include/private/asn1_decoder.h56
-rw-r--r--install/include/private/setup_commands.h39
2 files changed, 95 insertions, 0 deletions
diff --git a/install/include/private/asn1_decoder.h b/install/include/private/asn1_decoder.h
new file mode 100644
index 000000000..e5337d9c4
--- /dev/null
+++ b/install/include/private/asn1_decoder.h
@@ -0,0 +1,56 @@
+/*
+ * 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_ */
diff --git a/install/include/private/setup_commands.h b/install/include/private/setup_commands.h
new file mode 100644
index 000000000..7fdc741d6
--- /dev/null
+++ b/install/include/private/setup_commands.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+// Private headers exposed for testing purpose only.
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include <ziparchive/zip_archive.h>
+
+// Sets up the commands for a non-A/B update. Extracts the updater binary from the open zip archive
+// |zip| located at |package|. Stores the command line that should be called into |cmd|. The
+// |status_fd| is the file descriptor the child process should use to report back the progress of
+// the update.
+int SetUpNonAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, int retry_count,
+ int status_fd, std::vector<std::string>* cmd);
+
+// Sets up the commands for an A/B update. Extracts the needed entries from the open zip archive
+// |zip| located at |package|. Stores the command line that should be called into |cmd|. The
+// |status_fd| is the file descriptor the child process should use to report back the progress of
+// the update. Note that since this applies to the sideloading flow only, it takes one less
+// parameter |retry_count| than the non-A/B version.
+int SetUpAbUpdateCommands(const std::string& package, ZipArchiveHandle zip, int status_fd,
+ std::vector<std::string>* cmd);