iPXE
md5_sha1.h File Reference

Hybrid MD5+SHA1 hash as used by TLSv1.1 and earlier. More...

#include <stdint.h>
#include <ipxe/crypto.h>
#include <ipxe/md5.h>
#include <ipxe/sha1.h>

Go to the source code of this file.

Data Structures

struct  md5_sha1_context
 An MD5+SHA1 context. More...
struct  md5_sha1_digest
 An MD5+SHA1 digest. More...
union  md5_sha1_block
 An MD5+SHA1 data block. More...
struct  md5_sha1_hmac_keys
 An MD5+SHA1 HMAC key block. More...

Macros

#define MD5_SHA1_CTX_SIZE   sizeof ( struct md5_sha1_context )
 MD5+SHA1 context size.
#define MD5_SHA1_DIGEST_SIZE   sizeof ( struct md5_sha1_digest )
 MD5+SHA1 digest size.
#define MD5_SHA1_BLOCK_SIZE   sizeof ( union md5_sha1_block )
 MD5+SHA1 block size.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static int is_md5_sha1 (struct digest_algorithm *digest)
 Check if a digest algorithm is MD5+SHA1.

Variables

char md5_sha1_sentinel [1]
 Sentinel used to avoid explicit symbol references.
struct digest_algorithm md5_sha1_algorithm
 Hybrid MD5+SHA1 digest algorithm.

Detailed Description

Hybrid MD5+SHA1 hash as used by TLSv1.1 and earlier.

Definition in file md5_sha1.h.

Macro Definition Documentation

◆ MD5_SHA1_CTX_SIZE

#define MD5_SHA1_CTX_SIZE   sizeof ( struct md5_sha1_context )

MD5+SHA1 context size.

Definition at line 27 of file md5_sha1.h.

◆ MD5_SHA1_DIGEST_SIZE

#define MD5_SHA1_DIGEST_SIZE   sizeof ( struct md5_sha1_digest )

MD5+SHA1 digest size.

Definition at line 38 of file md5_sha1.h.

◆ MD5_SHA1_BLOCK_SIZE

#define MD5_SHA1_BLOCK_SIZE   sizeof ( union md5_sha1_block )

MD5+SHA1 block size.

Definition at line 49 of file md5_sha1.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ is_md5_sha1()

int is_md5_sha1 ( struct digest_algorithm * digest)
inlinestatic

Check if a digest algorithm is MD5+SHA1.

Parameters
digestDigest algorithm
is_md5_sha1Digest algorithm is MD5+SHA1

Definition at line 74 of file md5_sha1.h.

74 {
75
76 /* The MD5+SHA1 algorithm is hardcoded into various parts of
77 * the TLS specifications prior to TLSv1.2, which has knock-on
78 * effects on non-TLS code such as the RSA algorithm (which
79 * needs to be able to identify the PKCS#1 digestInfo prefix).
80 *
81 * Allow a digest algorithm to be tested to see if it is the
82 * MD5+SHA1 algorithm without creating an explicit symbol
83 * reference that will drag the algorithm into a build that
84 * otherwise does not need it.
85 */
86 return ( digest->priv == md5_sha1_sentinel );
87}
char md5_sha1_sentinel[1]
Sentinel used to avoid explicit symbol references.
Definition md5_sha1.c:38
void * priv
Algorithm private data.
Definition crypto.h:54

References md5_sha1_sentinel, and digest_algorithm::priv.

Referenced by rsa_pkcs1_encode().

Variable Documentation

◆ md5_sha1_sentinel

char md5_sha1_sentinel[1]
extern

Sentinel used to avoid explicit symbol references.

Definition at line 38 of file md5_sha1.c.

Referenced by is_md5_sha1().

◆ md5_sha1_algorithm

struct digest_algorithm md5_sha1_algorithm
extern

Hybrid MD5+SHA1 digest algorithm.

Definition at line 87 of file md5_sha1.c.

87 {
88 .name = "md5+sha1",
89 .ctxsize = sizeof ( struct md5_sha1_context ),
90 .blocksize = sizeof ( union md5_sha1_block ),
91 .digestsize = sizeof ( struct md5_sha1_digest ),
92 .init = md5_sha1_init,
93 .update = md5_sha1_update,
94 .final = md5_sha1_final,
95 .priv = md5_sha1_sentinel,
96};
static void md5_sha1_init(struct digest_algorithm *digest __unused, void *ctx)
Initialise MD5+SHA1 algorithm.
Definition md5_sha1.c:46
static void md5_sha1_update(struct digest_algorithm *digest __unused, void *ctx, const void *data, size_t len)
Accumulate data with MD5+SHA1 algorithm.
Definition md5_sha1.c:62
static void md5_sha1_final(struct digest_algorithm *digest __unused, void *ctx, void *out)
Generate MD5+SHA1 digest.
Definition md5_sha1.c:77
uint32_t digestsize
Digest size (i.e.
Definition pccrr.h:1
An MD5+SHA1 context.
Definition md5_sha1.h:19
An MD5+SHA1 digest.
Definition md5_sha1.h:30
An MD5+SHA1 data block.
Definition md5_sha1.h:41

Referenced by dummy_md5_sha1(), tls_select_cipher(), tls_send_certificate_verify(), tls_verify_signature(), tlskey_md5_sha1_apply(), tlskey_md5_sha1_expand(), tlskey_md5_sha1_save(), and tlskey_md5_sha1_secretsize().