RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
cpukit
include
rtems
score
hash.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
11
12
/*
13
* Copyright (C) 2021 embedded brains GmbH & Co. KG
14
*
15
* Redistribution and use in source and binary forms, with or without
16
* modification, are permitted provided that the following conditions
17
* are met:
18
* 1. Redistributions of source code must retain the above copyright
19
* notice, this list of conditions and the following disclaimer.
20
* 2. Redistributions in binary form must reproduce the above copyright
21
* notice, this list of conditions and the following disclaimer in the
22
* documentation and/or other materials provided with the distribution.
23
*
24
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGE.
35
*/
36
37
#ifndef _RTEMS_SCORE_HASH_H
38
#define _RTEMS_SCORE_HASH_H
39
40
#include <
rtems/score/basedefs.h
>
41
42
#include <
sha256.h
>
43
#include <string.h>
44
45
#ifdef __cplusplus
46
extern
"C"
{
47
#endif
48
58
64
#define HASH_CONTROL_STRING_SIZE 45
65
71
typedef
struct
{
77
char
chars
[
HASH_CONTROL_STRING_SIZE
];
78
}
Hash_Control
;
79
87
static
inline
const
char
*_Hash_Get_string(
const
Hash_Control
*hash )
88
{
89
return
&hash->
chars
[ 0 ];
90
}
91
95
typedef
struct
{
99
SHA256_CTX
Context
;
100
104
Hash_Control
*
hash
;
105
109
size_t
index
;
110
}
Hash_Context
;
111
117
static
inline
void
_Hash_Initialize(
Hash_Context
*
context
)
118
{
119
SHA256_Init( &
context
->Context );
120
}
121
131
static
inline
void
_Hash_Add_data(
132
Hash_Context
*
context
,
133
const
void
*begin,
134
size_t
size
135
)
136
{
137
SHA256_Update( &
context
->Context, begin, size );
138
}
139
147
static
inline
void
_Hash_Add_string(
148
Hash_Context
*
context
,
149
const
char
*str
150
)
151
{
152
SHA256_Update( &
context
->Context, str, strlen( str ) );
153
}
154
162
void
_Hash_Finalize
(
Hash_Context
*
context
,
Hash_Control
*hash );
163
165
166
#ifdef __cplusplus
167
}
168
#endif
169
170
#endif
/* _RTEMS_SCORE_HASH_H */
basedefs.h
This header file provides basic definitions used by the API and the implementation.
HASH_CONTROL_STRING_SIZE
#define HASH_CONTROL_STRING_SIZE
This constant represents the size of a hash string.
Definition
hash.h:64
_Hash_Finalize
void _Hash_Finalize(Hash_Context *context, Hash_Control *hash)
Finalizes the hash value computation and produces the hash value.
Definition
hash.c:58
sha256.h
This header file contains interfaces of the SHA256 hash algorithm support.
Hash_Context
This type represents the context to compute a hash value.
Definition
hash.h:95
Hash_Context::hash
Hash_Control * hash
This member references a hash value if needed.
Definition
hash.h:104
Hash_Context::Context
SHA256_CTX Context
This member contains the hash algorithm context.
Definition
hash.h:99
Hash_Context::index
size_t index
This member contains an index into the hash value bytes if needed.
Definition
hash.h:109
Hash_Control
This type represents a hash value.
Definition
hash.h:71
Hash_Control::chars
char chars[HASH_CONTROL_STRING_SIZE]
This member contains the hash value encoded as a base64url string.
Definition
hash.h:77
context
unsigned context
Definition
tlb.h:1
Generated by
1.18.0