ReactOS  0.4.15-dev-499-g1f31905
crypt_sha.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wine/test.h"
Include dependency graph for crypt_sha.c:

Go to the source code of this file.

Classes

struct  SHA_CTX
 

Typedefs

typedef struct SHA_CTXPSHA_CTX
 

Functions

static void test_sha_ctx (void)
 
 START_TEST (crypt_sha)
 

Typedef Documentation

◆ PSHA_CTX

typedef struct SHA_CTX * PSHA_CTX

Function Documentation

◆ START_TEST()

START_TEST ( crypt_sha  )

Definition at line 69 of file crypt_sha.c.

70 {
71  test_sha_ctx();
72 }
static void test_sha_ctx(void)
Definition: crypt_sha.c:36

◆ test_sha_ctx()

static void test_sha_ctx ( void  )
static

Definition at line 36 of file crypt_sha.c.

37 {
38  void (WINAPI *pA_SHAInit)(PSHA_CTX);
39  void (WINAPI *pA_SHAUpdate)(PSHA_CTX, const unsigned char *, UINT);
40  void (WINAPI *pA_SHAFinal)(PSHA_CTX, PULONG);
41  static const unsigned char test_buffer[] = "In our Life there's If"
42  "In our beliefs there's Lie"
43  "In our business there is Sin"
44  "In our bodies, there is Die";
45  HMODULE hmod;
46  SHA_CTX ctx;
47  ULONG result[5];
48  ULONG result_correct[5] = {0xe014f93, 0xe09791ec, 0x6dcf96c8, 0x8e9385fc, 0x1611c1bb};
49 
50  hmod = GetModuleHandleA("advapi32.dll");
51  pA_SHAInit = (void *)GetProcAddress(hmod, "A_SHAInit");
52  pA_SHAUpdate = (void *)GetProcAddress(hmod, "A_SHAUpdate");
53  pA_SHAFinal = (void *)GetProcAddress(hmod, "A_SHAFinal");
54 
55  if (!pA_SHAInit || !pA_SHAUpdate || !pA_SHAFinal)
56  {
57  win_skip("A_SHAInit and/or A_SHAUpdate and/or A_SHAFinal are not available\n");
58  return;
59  }
60 
61  RtlZeroMemory(&ctx, sizeof(ctx));
62  pA_SHAInit(&ctx);
63  pA_SHAUpdate(&ctx, test_buffer, sizeof(test_buffer)-1);
64  pA_SHAUpdate(&ctx, test_buffer, sizeof(test_buffer)-1);
65  pA_SHAFinal(&ctx, result);
66  ok(!memcmp(result, result_correct, sizeof(result)), "incorrect result\n");
67 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
Definition: addons.c:68
#define WINAPI
Definition: msvc.h:6
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
struct SHA_CTX * PSHA_CTX
static TCHAR test_buffer[TEST_BUFFER_SIZE]
Definition: _tfileio.c:53
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define ok(value,...)
Definition: atltest.h:57
unsigned int * PULONG
Definition: retypes.h:1
unsigned int UINT
Definition: ndis.h:50
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define GetProcAddress(x, y)
Definition: compat.h:419
GLuint64EXT * result
Definition: glext.h:11304
#define win_skip
Definition: test.h:149

Referenced by START_TEST().