ReactOS
0.4.17-dev-1005-g171e1de
hash_buffer_pattern.c
Go to the documentation of this file.
1
//
2
// hash_buffer_pattern.c
3
// Copyright (c) Microsoft Corporation. Licensed under the MIT license.
4
//
5
6
#if 0
7
#pragma makedep header
8
#endif
9
10
/*
11
SymCryptXxxAppend( _Inout_ SYMCRYPT_Xxx_STATE * state,
12
_In_reads_bytes_( cbData ) PCBYTE pbData,
13
SIZE_T cbData )
14
{
15
<Set up a SIZE_T variable 'bytesInBuffer' that contains the # bytes in the buffer>
16
*/
17
18
//
19
// Truncate bytesInBuffer so that we never have an integer overflow.
20
//
21
bytesInBuffer
&=
SYMCRYPT_XXX_INPUT_BLOCK_SIZE
- 1;
22
23
//
24
// If previous data in buffer, buffer new input and transform if possible.
25
//
26
if
(
bytesInBuffer
> 0)
27
{
28
SIZE_T
freeInBuffer =
SYMCRYPT_XXX_INPUT_BLOCK_SIZE
-
bytesInBuffer
;
29
if
(
cbData
< freeInBuffer )
30
{
31
//
32
// All the data will fit in the buffer.
33
// We don't do anything here.
34
// As cbData < INPUT_BLOCK_SIZE the bulk data processing is skipped,
35
// and the data will be copied to the buffer at the end
36
// of this code.
37
}
else
{
38
//
39
// Enough data to fill the whole buffer & process it
40
//
41
memcpy
(&
state
->buffer[
bytesInBuffer
],
pbData
, freeInBuffer);
42
pbData
+= freeInBuffer;
43
cbData
-= freeInBuffer;
44
SYMCRYPT_XxxAppendBlocks
( &
state
->chain,
state
->buffer,
SYMCRYPT_XXX_INPUT_BLOCK_SIZE
);
45
46
//
47
// Set bytesInBuffer to zero to ensure that the trailing data in the
48
// buffer will be copied to the right location of the buffer below.
49
//
50
bytesInBuffer
= 0;
51
}
52
}
53
54
//
55
// Internal buffer is empty; process all remaining whole blocks in the input
56
//
57
if
(
cbData
>=
SYMCRYPT_XXX_INPUT_BLOCK_SIZE
)
58
{
59
SIZE_T
cbDataRoundedDown =
cbData
& ~(
SIZE_T
)(
SYMCRYPT_XXX_INPUT_BLOCK_SIZE
- 1);
60
SYMCRYPT_XxxAppendBlocks
( &
state
->chain,
pbData
, cbDataRoundedDown );
61
pbData
+= cbDataRoundedDown;
62
cbData
-= cbDataRoundedDown;
63
}
64
65
//
66
// buffer remaining input if necessary.
67
//
68
if
(
cbData
> 0 )
69
{
70
memcpy
( &
state
->buffer[
bytesInBuffer
],
pbData
,
cbData
);
71
}
72
73
/*
74
}
75
*/
state
static int state
Definition:
maze.c:121
memcpy
#define memcpy(s1, s2, n)
Definition:
mkisofs.h:878
SYMCRYPT_XXX_INPUT_BLOCK_SIZE
#define SYMCRYPT_XXX_INPUT_BLOCK_SIZE
Definition:
sc_lib.h:151
SYMCRYPT_XxxAppendBlocks
#define SYMCRYPT_XxxAppendBlocks
Definition:
sc_lib.h:126
bytesInBuffer
SIZE_T bytesInBuffer
Definition:
symcrypt_internal.h:1693
cbData
PCBYTE PBYTE SIZE_T cbData
Definition:
symcrypt_internal.h:1989
pbData
PCBYTE pbData
Definition:
symcrypt_internal.h:1246
SIZE_T
ULONG_PTR SIZE_T
Definition:
typedefs.h:80
sdk
lib
3rdparty
symcrypt
lib
hash_buffer_pattern.c
Generated on Tue Oct 6 2026 06:20:06 for ReactOS by
1.9.6