diff options
author | Tao Bao <tbao@google.com> | 2016-02-04 20:16:20 +0100 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-02-04 20:16:20 +0100 |
commit | 6e71c90fadbae68824116276d4dd536d962838f8 (patch) | |
tree | b6db9b5f6f80dfe4b8d4a5333d851a0eb14927bf /updater/blockimg.cpp | |
parent | Merge "uncrypt: add options to setup bcb and clear bcb." (diff) | |
parent | Switch from mincrypt to BoringSSL in applypatch and updater. (diff) | |
download | android_bootable_recovery-6e71c90fadbae68824116276d4dd536d962838f8.tar android_bootable_recovery-6e71c90fadbae68824116276d4dd536d962838f8.tar.gz android_bootable_recovery-6e71c90fadbae68824116276d4dd536d962838f8.tar.bz2 android_bootable_recovery-6e71c90fadbae68824116276d4dd536d962838f8.tar.lz android_bootable_recovery-6e71c90fadbae68824116276d4dd536d962838f8.tar.xz android_bootable_recovery-6e71c90fadbae68824116276d4dd536d962838f8.tar.zst android_bootable_recovery-6e71c90fadbae68824116276d4dd536d962838f8.zip |
Diffstat (limited to 'updater/blockimg.cpp')
-rw-r--r-- | updater/blockimg.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index c6daf7db5..6e056006c 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 "print_sha1.h" #include "unique_fd.h" @@ -407,10 +407,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); @@ -662,10 +662,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, "", ""); @@ -1627,7 +1625,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) { @@ -1643,10 +1641,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())); } |