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/*
11SymCryptXxxAppend( _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 //
22
23 //
24 // If previous data in buffer, buffer new input and transform if possible.
25 //
27 {
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;
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 //
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*/
static int state
Definition: maze.c:121
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SYMCRYPT_XXX_INPUT_BLOCK_SIZE
Definition: sc_lib.h:151
#define SYMCRYPT_XxxAppendBlocks
Definition: sc_lib.h:126
SIZE_T bytesInBuffer
PCBYTE PBYTE SIZE_T cbData
PCBYTE pbData
ULONG_PTR SIZE_T
Definition: typedefs.h:80