iPXE
der_test.c File Reference

DER self-tests. More...

#include <string.h>
#include <assert.h>
#include <ipxe/test.h>
#include <ipxe/der.h>
#include "asn1_test.h"

Go to the source code of this file.

Macros

#define DATA(...)
 Define inline data.
#define DIGEST(...)
 Define inline expected digest.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 ASN1 (rsa32, &der_image_type, DATA(0x30, 0x2c, 0x02, 0x01, 0x00, 0x02, 0x05, 0x00, 0xb7, 0x56, 0x5c, 0xb1, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x04, 0x66, 0xa4, 0xc4, 0x35, 0x02, 0x03, 0x00, 0xda, 0x9f, 0x02, 0x03, 0x00, 0xd6, 0xaf, 0x02, 0x02, 0x01, 0x59, 0x02, 0x02, 0x4e, 0xe1, 0x02, 0x03, 0x00, 0xa6, 0x5a), DIGEST(0x82, 0x66, 0x24, 0xd9, 0xc3, 0x98, 0x1e, 0x5e, 0x56, 0xed, 0xd0, 0xd0, 0x2a, 0x5e, 0x9c, 0x3a, 0x58, 0xdf, 0x76, 0x0d))
 32-bit RSA private key
 ASN1 (rsa64, &der_image_type, DATA(0x30, 0x3e, 0x02, 0x01, 0x00, 0x02, 0x09, 0x00, 0xa1, 0xba, 0xb5, 0x70, 0x00, 0x89, 0xc0, 0x43, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x08, 0x43, 0x98, 0xc6, 0x3c, 0x5f, 0xdc, 0x98, 0x01, 0x02, 0x05, 0x00, 0xcf, 0x91, 0x1c, 0x5d, 0x02, 0x05, 0x00, 0xc7, 0x77, 0x85, 0x1f, 0x02, 0x05, 0x00, 0xbc, 0xb3, 0x33, 0x91, 0x02, 0x04, 0x1b, 0xf9, 0x38, 0x13, 0x02, 0x04, 0x19, 0xf2, 0x58, 0x86), DIGEST(0xee, 0x17, 0x32, 0x31, 0xf0, 0x3d, 0xfd, 0xaa, 0x9b, 0x47, 0xaf, 0x7b, 0x4b, 0x52, 0x0b, 0xb1, 0xab, 0x25, 0x3f, 0x11))
 64-bit RSA private key
static void der_test_exec (void)
 Perform DER self-test.

Variables

struct self_test der_test __self_test
 DER self-test.

Detailed Description

DER self-tests.

Definition in file der_test.c.

Macro Definition Documentation

◆ DATA

#define DATA ( ...)
Value:
{ __VA_ARGS__ }

Define inline data.

Definition at line 42 of file der_test.c.

◆ DIGEST

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ ASN1() [1/2]

ASN1 ( rsa32 ,
& der_image_type,
DATA(0x30, 0x2c, 0x02, 0x01, 0x00, 0x02, 0x05, 0x00, 0xb7, 0x56, 0x5c, 0xb1, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x04, 0x66, 0xa4, 0xc4, 0x35, 0x02, 0x03, 0x00, 0xda, 0x9f, 0x02, 0x03, 0x00, 0xd6, 0xaf, 0x02, 0x02, 0x01, 0x59, 0x02, 0x02, 0x4e, 0xe1, 0x02, 0x03, 0x00, 0xa6, 0x5a) ,
DIGEST(0x82, 0x66, 0x24, 0xd9, 0xc3, 0x98, 0x1e, 0x5e, 0x56, 0xed, 0xd0, 0xd0, 0x2a, 0x5e, 0x9c, 0x3a, 0x58, 0xdf, 0x76, 0x0d)  )

32-bit RSA private key

References DATA, and DIGEST.

◆ ASN1() [2/2]

ASN1 ( rsa64 ,
& der_image_type,
DATA(0x30, 0x3e, 0x02, 0x01, 0x00, 0x02, 0x09, 0x00, 0xa1, 0xba, 0xb5, 0x70, 0x00, 0x89, 0xc0, 0x43, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x08, 0x43, 0x98, 0xc6, 0x3c, 0x5f, 0xdc, 0x98, 0x01, 0x02, 0x05, 0x00, 0xcf, 0x91, 0x1c, 0x5d, 0x02, 0x05, 0x00, 0xc7, 0x77, 0x85, 0x1f, 0x02, 0x05, 0x00, 0xbc, 0xb3, 0x33, 0x91, 0x02, 0x04, 0x1b, 0xf9, 0x38, 0x13, 0x02, 0x04, 0x19, 0xf2, 0x58, 0x86) ,
DIGEST(0xee, 0x17, 0x32, 0x31, 0xf0, 0x3d, 0xfd, 0xaa, 0x9b, 0x47, 0xaf, 0x7b, 0x4b, 0x52, 0x0b, 0xb1, 0xab, 0x25, 0x3f, 0x11)  )

64-bit RSA private key

References DATA, and DIGEST.

◆ der_test_exec()

void der_test_exec ( void )
static

Perform DER self-test.

Definition at line 73 of file der_test.c.

73 {
74
75 /* Perform tests */
76 asn1_ok ( &rsa32 );
77 asn1_ok ( &rsa64 );
78}
#define asn1_ok(test)
Report ASN.1 test result.
Definition asn1_test.h:72

References asn1_ok.

Variable Documentation

◆ __self_test

struct self_test der_test __self_test
Initial value:
= {
.name = "der",
.exec = der_test_exec,
}
static void der_test_exec(void)
Perform DER self-test.
Definition der_test.c:73

DER self-test.

Definition at line 81 of file der_test.c.

81 {
82 .name = "der",
83 .exec = der_test_exec,
84};