summaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-02-04 20:26:29 +0100
committerTao Bao <tbao@google.com>2016-02-04 20:26:29 +0100
commit50aa63f9bd7a524c9923991a9f90334bbb9175fa (patch)
tree630b9657f29cb549fe690d9bdd437a04f3bed3df /updater
parentMerge "uncrypt: add options to setup bcb and clear bcb." am: e3434279c8 (diff)
parentMerge "Switch from mincrypt to BoringSSL in applypatch and updater." (diff)
downloadandroid_bootable_recovery-50aa63f9bd7a524c9923991a9f90334bbb9175fa.tar
android_bootable_recovery-50aa63f9bd7a524c9923991a9f90334bbb9175fa.tar.gz
android_bootable_recovery-50aa63f9bd7a524c9923991a9f90334bbb9175fa.tar.bz2
android_bootable_recovery-50aa63f9bd7a524c9923991a9f90334bbb9175fa.tar.lz
android_bootable_recovery-50aa63f9bd7a524c9923991a9f90334bbb9175fa.tar.xz
android_bootable_recovery-50aa63f9bd7a524c9923991a9f90334bbb9175fa.tar.zst
android_bootable_recovery-50aa63f9bd7a524c9923991a9f90334bbb9175fa.zip
Diffstat (limited to 'updater')
-rw-r--r--updater/Android.mk2
-rw-r--r--updater/blockimg.cpp19
-rw-r--r--updater/install.cpp14
3 files changed, 17 insertions, 18 deletions
diff --git a/updater/Android.mk b/updater/Android.mk
index d74dffc0c..d7aa613e9 100644
--- a/updater/Android.mk
+++ b/updater/Android.mk
@@ -46,7 +46,7 @@ endif
LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS)
LOCAL_STATIC_LIBRARIES += libapplypatch libbase libotafault libedify libmtdutils libminzip libz
-LOCAL_STATIC_LIBRARIES += libmincrypt libbz
+LOCAL_STATIC_LIBRARIES += libbz
LOCAL_STATIC_LIBRARIES += libcutils liblog libc
LOCAL_STATIC_LIBRARIES += libselinux
tune2fs_static_libraries := \
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp
index c898ac6f6..e9c8ddbc0 100644
--- a/updater/blockimg.cpp
+++ b/updater/blockimg.cpp
@@ -43,7 +43,7 @@
#include "applypatch/applypatch.h"
#include "edify/expr.h"
#include "install.h"
-#include "mincrypt/sha.h"
+#include "openssl/sha.h"
#include "minzip/Hash.h"
#include "otafault/ota_io.h"
#include "print_sha1.h"
@@ -408,10 +408,10 @@ static int LoadSrcTgtVersion1(CommandParameters& params, RangeSet& tgt, size_t&
static int VerifyBlocks(const std::string& expected, const std::vector<uint8_t>& buffer,
const size_t blocks, bool printerror) {
- uint8_t digest[SHA_DIGEST_SIZE];
+ uint8_t digest[SHA_DIGEST_LENGTH];
const uint8_t* data = buffer.data();
- SHA_hash(data, blocks * BLOCKSIZE, digest);
+ SHA1(data, blocks * BLOCKSIZE, digest);
std::string hexdigest = print_sha1(digest);
@@ -663,10 +663,8 @@ static int CreateStash(State* state, int maxblocks, const char* blockdev, std::s
// Stash directory should be different for each partition to avoid conflicts
// when updating multiple partitions at the same time, so we use the hash of
// the block device name as the base directory
- SHA_CTX ctx;
- SHA_init(&ctx);
- SHA_update(&ctx, blockdev, strlen(blockdev));
- const uint8_t* digest = SHA_final(&ctx);
+ uint8_t digest[SHA_DIGEST_LENGTH];
+ SHA1(reinterpret_cast<const uint8_t*>(blockdev), strlen(blockdev), digest);
base = print_sha1(digest);
std::string dirname = GetStashFileName(base, "", "");
@@ -1628,7 +1626,7 @@ Value* RangeSha1Fn(const char* name, State* state, int /* argc */, Expr* argv[])
parse_range(ranges->data, rs);
SHA_CTX ctx;
- SHA_init(&ctx);
+ SHA1_Init(&ctx);
std::vector<uint8_t> buffer(BLOCKSIZE);
for (size_t i = 0; i < rs.count; ++i) {
@@ -1644,10 +1642,11 @@ Value* RangeSha1Fn(const char* name, State* state, int /* argc */, Expr* argv[])
return StringValue(strdup(""));
}
- SHA_update(&ctx, buffer.data(), BLOCKSIZE);
+ SHA1_Update(&ctx, buffer.data(), BLOCKSIZE);
}
}
- const uint8_t* digest = SHA_final(&ctx);
+ uint8_t digest[SHA_DIGEST_LENGTH];
+ SHA1_Final(digest, &ctx);
return StringValue(strdup(print_sha1(digest).c_str()));
}
diff --git a/updater/install.cpp b/updater/install.cpp
index be9735595..0b8489694 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -44,7 +44,7 @@
#include "cutils/misc.h"
#include "cutils/properties.h"
#include "edify/expr.h"
-#include "mincrypt/sha.h"
+#include "openssl/sha.h"
#include "minzip/DirUtil.h"
#include "mtdutils/mounts.h"
#include "mtdutils/mtdutils.h"
@@ -92,10 +92,10 @@ void uiPrintf(State* state, const char* format, ...) {
// Take a sha-1 digest and return it as a newly-allocated hex string.
char* PrintSha1(const uint8_t* digest) {
- char* buffer = reinterpret_cast<char*>(malloc(SHA_DIGEST_SIZE*2 + 1));
+ char* buffer = reinterpret_cast<char*>(malloc(SHA_DIGEST_LENGTH*2 + 1));
const char* alphabet = "0123456789abcdef";
size_t i;
- for (i = 0; i < SHA_DIGEST_SIZE; ++i) {
+ for (i = 0; i < SHA_DIGEST_LENGTH; ++i) {
buffer[i*2] = alphabet[(digest[i] >> 4) & 0xf];
buffer[i*2+1] = alphabet[digest[i] & 0xf];
}
@@ -1358,8 +1358,8 @@ Value* Sha1CheckFn(const char* name, State* state, int argc, Expr* argv[]) {
if (args[0]->size < 0) {
return StringValue(strdup(""));
}
- uint8_t digest[SHA_DIGEST_SIZE];
- SHA_hash(args[0]->data, args[0]->size, digest);
+ uint8_t digest[SHA_DIGEST_LENGTH];
+ SHA1(reinterpret_cast<uint8_t*>(args[0]->data), args[0]->size, digest);
FreeValue(args[0]);
if (argc == 1) {
@@ -1367,7 +1367,7 @@ Value* Sha1CheckFn(const char* name, State* state, int argc, Expr* argv[]) {
}
int i;
- uint8_t* arg_digest = reinterpret_cast<uint8_t*>(malloc(SHA_DIGEST_SIZE));
+ uint8_t* arg_digest = reinterpret_cast<uint8_t*>(malloc(SHA_DIGEST_LENGTH));
for (i = 1; i < argc; ++i) {
if (args[i]->type != VAL_STRING) {
printf("%s(): arg %d is not a string; skipping",
@@ -1376,7 +1376,7 @@ Value* Sha1CheckFn(const char* name, State* state, int argc, Expr* argv[]) {
// Warn about bad args and skip them.
printf("%s(): error parsing \"%s\" as sha-1; skipping",
name, args[i]->data);
- } else if (memcmp(digest, arg_digest, SHA_DIGEST_SIZE) == 0) {
+ } else if (memcmp(digest, arg_digest, SHA_DIGEST_LENGTH) == 0) {
break;
}
FreeValue(args[i]);