-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes bug where specified checksums would be overwritten by SDK re-calculating checksum --------- Co-authored-by: sbiscigl <sbiscigl@amazon.com>
- Loading branch information
Showing
9 changed files
with
539 additions
and
25 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/aws-cpp-sdk-core/include/aws/core/utils/crypto/PrecalculatedHash.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <aws/core/Core_EXPORTS.h> | ||
#include <aws/core/utils/crypto/Hash.h> | ||
#include <aws/core/utils/crypto/HashResult.h> | ||
#include <aws/core/utils/Outcome.h> | ||
|
||
namespace Aws { | ||
namespace Utils { | ||
namespace Crypto { | ||
/** | ||
* A hash implementation that stores a pre-calculated hash | ||
* behind the Hash interface. It is a read through wrapper | ||
* around the checksum value and no hashing are actually done. | ||
*/ | ||
class AWS_CORE_API PrecalculatedHash : public Hash { | ||
public: | ||
explicit PrecalculatedHash(const Aws::String &hash); | ||
~PrecalculatedHash() override; | ||
HashResult Calculate(const Aws::String &str) override; | ||
HashResult Calculate(Aws::IStream &stream) override; | ||
void Update(unsigned char *string, size_t bufferSize) override; | ||
HashResult GetHash() override; | ||
|
||
private: | ||
Aws::String m_hashString; | ||
HashResult m_decodedHashString; | ||
|
||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/aws-cpp-sdk-core/source/utils/crypto/PrecalculatedHash.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
|
||
#include <aws/core/utils/crypto/PrecalculatedHash.h> | ||
#include <aws/core/utils/HashingUtils.h> | ||
|
||
using namespace Aws::Utils::Crypto; | ||
|
||
PrecalculatedHash::PrecalculatedHash(const Aws::String &hash) : m_hashString(hash), m_decodedHashString(HashingUtils::Base64Decode(hash)) {} | ||
|
||
PrecalculatedHash::~PrecalculatedHash() = default; | ||
|
||
HashResult PrecalculatedHash::Calculate(const Aws::String& str) | ||
{ | ||
AWS_UNREFERENCED_PARAM(str); | ||
return m_decodedHashString; | ||
} | ||
|
||
HashResult PrecalculatedHash::Calculate(Aws::IStream& stream) | ||
{ | ||
AWS_UNREFERENCED_PARAM(stream); | ||
return m_decodedHashString; | ||
} | ||
|
||
void PrecalculatedHash::Update(unsigned char* string, size_t bufferSize) | ||
{ | ||
AWS_UNREFERENCED_PARAM(string); | ||
AWS_UNREFERENCED_PARAM(bufferSize); | ||
} | ||
|
||
HashResult PrecalculatedHash::GetHash() | ||
{ | ||
return m_decodedHashString; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.