ReactOS 0.4.17-dev-1321-g5c122a9
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_CTX * PSHA_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}
Definition: bufpool.h:45
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
macro TEXTAREA section xr p2align endm macro DATAAREA section dw endm macro RODATAAREA section dr endm macro EXPORT Attribute global Name endm macro IMPORT Target ifc WEAK weak Name set Target endif endm set macro SET_COMDAT_ALIGNMENT Alignment set Alignment endm macro NESTED_ENTRY Name global Name p2align xr p2align __ComdatAlignment NESTED_ENTRY Name endm macro ALTERNATE_ENTRY Name global Name Params endm macro ALIGN Pad
Definition: kxarm64.h:158
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
unsigned char UCHAR
Definition: typedefs.h:53
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
USHORT Count
Definition: userreq.cpp:200
_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

◆ 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
_In_ ULONG BufferSize
Definition: dispmprt.h:490
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void SHA1Transform(ULONG State[5], UCHAR Buffer[64])
Definition: sha1.c:42

Referenced by A_SHAFinal().