aws-crt-cpp
include
aws
crt
crypto
Hash.h
Go to the documentation of this file.
1
#pragma once
2
/*
3
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License").
6
* You may not use this file except in compliance with the License.
7
* A copy of the License is located at
8
*
9
* http://aws.amazon.com/apache2.0
10
*
11
* or in the "license" file accompanying this file. This file is distributed
12
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
* express or implied. See the License for the specific language governing
14
* permissions and limitations under the License.
15
*/
16
#include <
aws/crt/Exports.h
>
17
#include <
aws/crt/Types.h
>
18
19
struct
aws_hash;
20
namespace
Aws
21
{
22
namespace
Crt
23
{
24
namespace
Crypto
25
{
26
static
const
size_t
SHA256_DIGEST_SIZE = 32;
27
static
const
size_t
MD5_DIGEST_SIZE = 16;
28
35
bool
AWS_CRT_CPP_API
ComputeSHA256
(
36
Allocator
*allocator,
37
const
ByteCursor
&input,
38
ByteBuf
&output,
39
size_t
truncateTo = 0) noexcept;
40
47
bool
AWS_CRT_CPP_API
48
ComputeSHA256
(
const
ByteCursor
&input,
ByteBuf
&output,
size_t
truncateTo = 0) noexcept;
49
56
bool
AWS_CRT_CPP_API
ComputeMD5
(
57
Allocator
*allocator,
58
const
ByteCursor
&input,
59
ByteBuf
&output,
60
size_t
truncateTo = 0) noexcept;
61
68
bool
AWS_CRT_CPP_API
ComputeMD5
(
const
ByteCursor
&input,
ByteBuf
&output,
size_t
truncateTo = 0) noexcept;
69
75
class
AWS_CRT_CPP_API
Hash
final
76
{
77
public
:
78
~
Hash
();
79
Hash
(
const
Hash
&) =
delete
;
80
Hash
&
operator=
(
const
Hash
&) =
delete
;
81
Hash
(
Hash
&&toMove);
82
Hash
&operator=(
Hash
&&toMove);
83
87
inline
operator
bool() const noexcept {
return
m_good; }
88
92
inline
int
LastError
() const noexcept {
return
m_lastError; }
93
97
static
Hash
CreateSHA256(
Allocator
*allocator =
g_allocator
) noexcept;
98
102
static
Hash
CreateMD5(
Allocator
*allocator =
g_allocator
) noexcept;
103
108
bool
Update(
const
ByteCursor
&toHash) noexcept;
109
116
bool
Digest(
ByteBuf
&output,
size_t
truncateTo = 0) noexcept;
117
118
private:
119
Hash
(aws_hash *hash) noexcept;
120
Hash
() = delete;
121
122
aws_hash *m_hash;
123
bool
m_good;
124
int
m_lastError;
125
};
126
127
}
// namespace Crypto
128
}
// namespace Crt
129
}
// namespace Aws
Aws::Crt::Allocator
aws_allocator Allocator
Definition:
StlAllocator.h:25
Types.h
Aws::Crt::Crypto::Hash::operator=
Hash & operator=(const Hash &)=delete
AWS_CRT_CPP_API
#define AWS_CRT_CPP_API
Definition:
Exports.h:34
Aws::Crt::Crypto::Hash::Hash
Hash(const Hash &)=delete
Aws::Crt::ByteCursor
aws_byte_cursor ByteCursor
Definition:
Types.h:44
Aws::Crt::Crypto::Hash::LastError
int LastError() const noexcept
Definition:
Hash.h:92
Aws::Crt::g_allocator
Allocator * g_allocator
Definition:
Api.cpp:28
Aws::Crt::Crypto::ComputeMD5
bool AWS_CRT_CPP_API ComputeMD5(Allocator *allocator, const ByteCursor &input, ByteBuf &output, size_t truncateTo=0) noexcept
Definition:
Hash.cpp:39
Aws::Crt::ByteBuf
aws_byte_buf ByteBuf
Definition:
Types.h:43
Aws::Crt::Crypto::Hash
Definition:
Hash.h:76
Aws::Crt::Crypto::ComputeSHA256
bool AWS_CRT_CPP_API ComputeSHA256(Allocator *allocator, const ByteCursor &input, ByteBuf &output, size_t truncateTo=0) noexcept
Definition:
Hash.cpp:25
Aws
Definition:
Api.h:25
Exports.h
Generated by
1.8.18