SHA-1 algorithm.
Definition in file sha1.h.
void prf_sha1 |
( |
const void * |
key, |
|
|
size_t |
key_len, |
|
|
const char * |
label, |
|
|
const void * |
data, |
|
|
size_t |
data_len, |
|
|
void * |
prf, |
|
|
size_t |
prf_len |
|
) |
| |
SHA1 pseudorandom function for creating derived keys.
- Parameters
-
key | Master key with which this call is associated |
key_len | Length of key |
label | NUL-terminated ASCII string describing purpose of PRF data |
data | Further data that should be included in the PRF |
data_len | Length of further PRF data |
prf_len | Bytes of PRF to generate |
- Return values
-
prf | Pseudorandom function bytes |
This is the PRF variant used by 802.11, defined in IEEE 802.11-2007 8.5.5.1. EAP-FAST uses a different SHA1-based PRF, and TLS uses an MD5-based PRF.
Definition at line 44 of file sha1extra.c.
53 const size_t label_len =
strlen ( label );
63 in_blknr =
in + label_len + 1 + data_len;
65 for ( blk = 0 ;; blk++ ) {
72 if ( prf_len <=
sizeof (
out ) ) {
78 prf_len -=
sizeof (
out );
79 prf +=
sizeof (
out );
void hmac_init(struct digest_algorithm *digest, void *ctx, const void *key, size_t key_len)
Initialise HMAC.
struct golan_eq_context ctx
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void hmac_update(struct digest_algorithm *digest, void *ctx, const void *data, size_t len)
Update HMAC.
size_t strlen(const char *src)
Get length of string.
#define SHA1_CTX_SIZE
SHA-1 context size.
uint8_t data[48]
Additional event data.
void hmac_final(struct digest_algorithm *digest, void *ctx, void *hmac)
Finalise HMAC.
struct digest_algorithm sha1_algorithm
SHA-1 algorithm.
References ctx, data, hmac_final(), hmac_init(), hmac_update(), in, key, memcpy(), out, sha1_algorithm, SHA1_BLOCK_SIZE, SHA1_CTX_SIZE, SHA1_DIGEST_SIZE, and strlen().
Referenced by wpa_derive_ptk().
void pbkdf2_sha1 |
( |
const void * |
passphrase, |
|
|
size_t |
pass_len, |
|
|
const void * |
salt, |
|
|
size_t |
salt_len, |
|
|
int |
iterations, |
|
|
void * |
key, |
|
|
size_t |
key_len |
|
) |
| |
PBKDF2 key derivation function using SHA1.
- Parameters
-
passphrase | Passphrase from which to derive key |
pass_len | Length of passphrase |
salt | Salt to include in key |
salt_len | Length of salt |
iterations | Number of iterations of SHA1 to perform |
key_len | Length of key to generate |
- Return values
-
This is used most notably in 802.11 WPA passphrase hashing, in which case the salt is the SSID, 4096 iterations are used, and a 32-byte key is generated that serves as the Pairwise Master Key for EAPOL authentication.
The operation of this function is further described in RFC 2898.
Definition at line 148 of file sha1extra.c.
156 for ( blk = 1; blk <=
blocks; blk++ ) {
158 iterations, blk, buf );
159 if ( key_len <=
sizeof ( buf ) ) {
165 key_len -=
sizeof ( buf );
166 key +=
sizeof ( buf );
uint32_t blocks
Number of blocks within the block description.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
References blocks, key, memcpy(), pbkdf2_sha1_f(), and SHA1_DIGEST_SIZE.
Referenced by wpa_psk_start().