ReactOS 0.4.15-dev-8434-g155a7c7
sha1.h File Reference
#include <ntdef.h>
Include dependency graph for sha1.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SHA_CTX
 

Typedefs

typedef struct SHA_CTXPSHA_CTX
 

Functions

VOID NTAPI A_SHAInit (PSHA_CTX Context)
 
VOID NTAPI A_SHAUpdate (PSHA_CTX Context, const unsigned char *Buffer, ULONG BufferSize)
 
VOID NTAPI A_SHAFinal (PSHA_CTX Context, PULONG Result)
 

Typedef Documentation

◆ PSHA_CTX

typedef struct SHA_CTX * PSHA_CTX

Function Documentation

◆ A_SHAFinal()

VOID NTAPI A_SHAFinal ( PSHA_CTX  Context,
PULONG  Result 
)

Definition at line 171 of file sha1.c.

172{
173 INT Pad, Index;
174 UCHAR Buffer[72];
175 ULONG *Count;
176 ULONG BufferContentSize, LengthHi, LengthLo;
177
178 BufferContentSize = Context->Count[1] & 63;
179 if (BufferContentSize >= 56)
180 Pad = 56 + 64 - BufferContentSize;
181 else
182 Pad = 56 - BufferContentSize;
183
184 LengthHi = (Context->Count[0] << 3) | (Context->Count[1] >> (32 - 3));
185 LengthLo = (Context->Count[1] << 3);
186
187 memset(Buffer + 1, 0, Pad - 1);
188 Buffer[0] = 0x80;
189 Count = (ULONG*)(Buffer + Pad);
190 Count[0] = DWORD2BE(LengthHi);
191 Count[1] = DWORD2BE(LengthLo);
193
194 for (Index = 0; Index < 5; Index++)
195 Result[Index] = DWORD2BE(Context->State[Index]);
196
197 memset(Context->Buffer, 0, sizeof(Context->Buffer));
199}
char * Pad(char *Str, char PadChar, ULONG Length)
Definition: cabman.cxx:29
Definition: bufpool.h:45
int Count
Definition: noreturn.cpp:7
VOID NTAPI A_SHAUpdate(PSHA_CTX Context, const unsigned char *Buffer, ULONG BufferSize)
Definition: sha1.c:128
#define DWORD2BE(x)
Definition: sha1.c:26
VOID NTAPI A_SHAInit(PSHA_CTX Context)
Definition: sha1.c:102
#define memset(x, y, z)
Definition: compat.h:39
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ A_SHAInit()

VOID NTAPI A_SHAInit ( PSHA_CTX  Context)

Definition at line 102 of file sha1.c.

103{
104 /* SHA1 initialization constants */
105 Context->State[0] = 0x67452301;
106 Context->State[1] = 0xEFCDAB89;
107 Context->State[2] = 0x98BADCFE;
108 Context->State[3] = 0x10325476;
109 Context->State[4] = 0xC3D2E1F0;
110 Context->Count[0] =
111 Context->Count[1] = 0;
112}

Referenced by A_SHAFinal().

◆ A_SHAUpdate()

VOID NTAPI A_SHAUpdate ( PSHA_CTX  Context,
const unsigned char Buffer,
ULONG  BufferSize 
)

Definition at line 128 of file sha1.c.

129{
130 ULONG BufferContentSize;
131
132 BufferContentSize = Context->Count[1] & 63;
133 Context->Count[1] += BufferSize;
134 if (Context->Count[1] < BufferSize)
135 Context->Count[0]++;
136 Context->Count[0] += (BufferSize >> 29);
137
138 if (BufferContentSize + BufferSize < 64)
139 {
140 memcpy(&Context->Buffer[BufferContentSize], Buffer,
141 BufferSize);
142 }
143 else
144 {
145 while (BufferContentSize + BufferSize >= 64)
146 {
147 memcpy(Context->Buffer + BufferContentSize, Buffer,
148 64 - BufferContentSize);
149 Buffer += 64 - BufferContentSize;
150 BufferSize -= 64 - BufferContentSize;
151 SHA1Transform(Context->State, Context->Buffer);
152 BufferContentSize = 0;
153 }
154 memcpy(Context->Buffer + BufferContentSize, Buffer, BufferSize);
155 }
156}
#define BufferSize
Definition: mmc.h:75
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void SHA1Transform(ULONG State[5], UCHAR Buffer[64])
Definition: sha1.c:42
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by A_SHAFinal().