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

Go to the source code of this file.

Classes

struct  MD5_CTX
 

Macros

#define ctxcmp(a, b)   memcmp( a, b, FIELD_OFFSET( MD5_CTX, in ) )
 

Functions

static VOID (WINAPI *pMD5Init)(MD5_CTX *ctx)
 
static void test_md5_ctx (void)
 
 START_TEST (crypt_md5)
 

Variables

static const unsigned charsrc
 
static const unsigned char const int len
 

Macro Definition Documentation

◆ ctxcmp

#define ctxcmp (   a,
  b 
)    memcmp( a, b, FIELD_OFFSET( MD5_CTX, in ) )

Definition at line 40 of file crypt_md5.c.

Function Documentation

◆ START_TEST()

START_TEST ( crypt_md5  )

Definition at line 103 of file crypt_md5.c.

104 {
105  test_md5_ctx();
106 }
static void test_md5_ctx(void)
Definition: crypt_md5.c:42

◆ test_md5_ctx()

static void test_md5_ctx ( void  )
static

Definition at line 42 of file crypt_md5.c.

43 {
44  static unsigned char message[] =
45  "In our Life there's If"
46  "In our beliefs there's Lie"
47  "In our business there is Sin"
48  "In our bodies, there is Die";
49 
50  int size = sizeof(message) - 1;
52 
53  MD5_CTX ctx;
54  MD5_CTX ctx_initialized =
55  {
56  { 0, 0 },
57  { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }
58  };
59 
60  MD5_CTX ctx_update1 =
61  {
62  { 0x00000338, 0 },
63  { 0x068cb64d, 0xb7a05790, 0x426979ee, 0xed67e221 }
64  };
65 
66  MD5_CTX ctx_update2 =
67  {
68  { 0x00000670, 0 },
69  { 0x2f7afe58, 0xcc3e9315, 0x709c465c, 0xbf6414c8 }
70  };
71 
72  unsigned char expect[16] =
73  { 0x43, 0x03, 0xdd, 0x8c, 0x60, 0xd9, 0x3a, 0x22,
74  0x0b, 0x28, 0xd0, 0xb2, 0x65, 0x93, 0xd0, 0x36 };
75 
76  module = GetModuleHandleA("advapi32.dll");
77 
78  pMD5Init = (void *)GetProcAddress( module, "MD5Init" );
79  pMD5Update = (void *)GetProcAddress( module, "MD5Update" );
80  pMD5Final = (void *)GetProcAddress( module, "MD5Final" );
81 
82  if (!pMD5Init || !pMD5Update || !pMD5Final)
83  {
84  win_skip("Needed functions are not available\n");
85  return;
86  }
87 
88  memset( &ctx, 0, sizeof(ctx) );
89  pMD5Init( &ctx );
90  ok( !ctxcmp( &ctx, &ctx_initialized ), "invalid initialization\n" );
91 
92  pMD5Update( &ctx, message, size );
93  ok( !ctxcmp( &ctx, &ctx_update1 ), "update doesn't work correctly\n" );
94 
95  pMD5Update( &ctx, message, size );
96  ok( !ctxcmp( &ctx, &ctx_update2 ), "update doesn't work correctly\n" );
97 
98  pMD5Final( &ctx );
99  ok( ctxcmp( &ctx, &ctx_initialized ), "context has changed\n" );
100  ok( !memcmp( ctx.digest, expect, sizeof(expect) ), "incorrect result\n" );
101 }
Definition: tftpd.h:59
HMODULE module
Definition: main.cpp:47
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define ctxcmp(a, b)
Definition: crypt_md5.c:40
GLsizeiptr size
Definition: glext.h:5919
unsigned char digest[16]
Definition: msi.c:4083
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define ok(value,...)
Definition: atltest.h:57
#define expect(expected, got)
Definition: combo.c:36
#define GetProcAddress(x, y)
Definition: compat.h:419
Definition: msi.c:4078
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:149

Referenced by START_TEST().

◆ VOID()

static VOID ( WINAPI pMD5Init)
static

Variable Documentation

◆ len

Definition at line 37 of file crypt_md5.c.

◆ src

Definition at line 37 of file crypt_md5.c.