iPXE
Functions | Variables
sha1_test.c File Reference

SHA-1 tests. More...

#include <ipxe/sha1.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 (sha1_empty, &sha1_algorithm, DIGEST_EMPTY, DIGEST(0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09))
 
 DIGEST_TEST (sha1_nist_abc, &sha1_algorithm, DIGEST_NIST_ABC, DIGEST(0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d))
 
 DIGEST_TEST (sha1_nist_abc_opq, &sha1_algorithm, DIGEST_NIST_ABC_OPQ, DIGEST(0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae, 0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1))
 
static void sha1_test_exec (void)
 Perform SHA-1 self-test. More...
 

Variables

struct self_test sha1_test __self_test
 SHA-1 self-test. More...
 

Detailed Description

SHA-1 tests.

NIST test vectors are taken from

http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA1.pdf

Definition in file sha1_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ DIGEST_TEST() [1/3]

DIGEST_TEST ( sha1_empty  ,
sha1_algorithm,
DIGEST_EMPTY  ,
DIGEST(0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09)   
)

◆ DIGEST_TEST() [2/3]

DIGEST_TEST ( sha1_nist_abc  ,
sha1_algorithm,
DIGEST_NIST_ABC  ,
DIGEST(0xa9, 0x99, 0x3e, 0x36, 0x47, 0x06, 0x81, 0x6a, 0xba, 0x3e, 0x25, 0x71, 0x78, 0x50, 0xc2, 0x6c, 0x9c, 0xd0, 0xd8, 0x9d)   
)

◆ DIGEST_TEST() [3/3]

DIGEST_TEST ( sha1_nist_abc_opq  ,
sha1_algorithm,
DIGEST_NIST_ABC_OPQ  ,
DIGEST(0x84, 0x98, 0x3e, 0x44, 0x1c, 0x3b, 0xd2, 0x6e, 0xba, 0xae, 0x4a, 0xa1, 0xf9, 0x51, 0x29, 0xe5, 0xe5, 0x46, 0x70, 0xf1)   
)

◆ sha1_test_exec()

static void sha1_test_exec ( void  )
static

Perform SHA-1 self-test.

Definition at line 65 of file sha1_test.c.

65  {
66 
67  /* Correctness tests */
68  digest_ok ( &sha1_empty );
69  digest_ok ( &sha1_nist_abc );
70  digest_ok ( &sha1_nist_abc_opq );
71 
72  /* Speed tests */
73  DBG ( "SHA1 required %ld cycles per byte\n",
75 }
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 sha1_algorithm
SHA-1 algorithm.
Definition: sha1.c:258

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

Variable Documentation

◆ __self_test

struct self_test sha1_test __self_test
Initial value:
= {
.name = "sha1",
.exec = sha1_test_exec,
}
static void sha1_test_exec(void)
Perform SHA-1 self-test.
Definition: sha1_test.c:65

SHA-1 self-test.

Definition at line 78 of file sha1_test.c.