iPXE
Functions | Variables
md5_test.c File Reference

MD5 tests. More...

#include <ipxe/md5.h>
#include <ipxe/test.h>
#include "digest_test.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 DIGEST_TEST (md5_empty, &md5_algorithm, DIGEST_EMPTY, DIGEST(0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e))
 
 DIGEST_TEST (md5_nist_abc, &md5_algorithm, DIGEST_NIST_ABC, DIGEST(0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72))
 
 DIGEST_TEST (md5_nist_abc_opq, &md5_algorithm, DIGEST_NIST_ABC_OPQ, DIGEST(0x82, 0x15, 0xef, 0x07, 0x96, 0xa2, 0x0b, 0xca, 0xaa, 0xe1, 0x16, 0xd3, 0x87, 0x6c, 0x66, 0x4a))
 
static void md5_test_exec (void)
 Perform MD5 self-test. More...
 

Variables

struct self_test md5_test __self_test
 MD5 self-test. More...
 

Detailed Description

MD5 tests.

Test inputs borrowed from NIST SHA-1 tests, with results calculated using md5sum.

Definition in file md5_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ DIGEST_TEST() [1/3]

DIGEST_TEST ( md5_empty  ,
md5_algorithm,
DIGEST_EMPTY  ,
DIGEST(0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e)   
)

◆ DIGEST_TEST() [2/3]

DIGEST_TEST ( md5_nist_abc  ,
md5_algorithm,
DIGEST_NIST_ABC  ,
DIGEST(0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72)   
)

◆ DIGEST_TEST() [3/3]

DIGEST_TEST ( md5_nist_abc_opq  ,
md5_algorithm,
DIGEST_NIST_ABC_OPQ  ,
DIGEST(0x82, 0x15, 0xef, 0x07, 0x96, 0xa2, 0x0b, 0xca, 0xaa, 0xe1, 0x16, 0xd3, 0x87, 0x6c, 0x66, 0x4a)   
)

◆ md5_test_exec()

static void md5_test_exec ( void  )
static

Perform MD5 self-test.

Definition at line 60 of file md5_test.c.

60  {
61 
62  /* Correctness tests */
63  digest_ok ( &md5_empty );
64  digest_ok ( &md5_nist_abc );
65  digest_ok ( &md5_nist_abc_opq );
66 
67  /* Speed tests */
68  DBG ( "MD5 required %ld cycles per byte\n",
70 }
unsigned long digest_cost(struct digest_algorithm *digest)
Calculate digest algorithm cost.
Definition: digest_test.c:131
#define digest_ok(test)
Report a digest test result.
Definition: digest_test.h:109
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct digest_algorithm md5_algorithm
MD5 algorithm.
Definition: md5.c:287

References DBG, digest_cost(), digest_ok, and md5_algorithm.

Variable Documentation

◆ __self_test

struct self_test md5_test __self_test
Initial value:
= {
.name = "md5",
.exec = md5_test_exec,
}
static void md5_test_exec(void)
Perform MD5 self-test.
Definition: md5_test.c:60

MD5 self-test.

Definition at line 73 of file md5_test.c.