#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
| struct | digest_algorithm |
| A message digest algorithm. More... | |
| struct | cipher_algorithm |
| A cipher algorithm. More... | |
| struct | pubkey_algorithm |
| A public key algorithm. More... | |
Defines | |
| #define | cipher_encrypt(cipher, ctx, src, dst, len) |
| #define | cipher_decrypt(cipher, ctx, src, dst, len) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static void | digest_init (struct digest_algorithm *digest, void *ctx) |
| static void | digest_update (struct digest_algorithm *digest, void *ctx, const void *data, size_t len) |
| static void | digest_final (struct digest_algorithm *digest, void *ctx, void *out) |
| static int | cipher_setkey (struct cipher_algorithm *cipher, void *ctx, const void *key, size_t keylen) |
| static void | cipher_setiv (struct cipher_algorithm *cipher, void *ctx, const void *iv) |
| static void | cipher_encrypt (struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len) |
| static void | cipher_decrypt (struct cipher_algorithm *cipher, void *ctx, const void *src, void *dst, size_t len) |
| static int | is_stream_cipher (struct cipher_algorithm *cipher) |
| void | get_random_bytes (void *buf, size_t len) |
| Get cryptographically strong random bytes. | |
Variables | |
| struct digest_algorithm | digest_null |
| struct cipher_algorithm | cipher_null |
| struct pubkey_algorithm | pubkey_null |
Definition in file crypto.h.
| #define cipher_encrypt | ( | cipher, | |||
| ctx, | |||||
| src, | |||||
| dst, | |||||
| len | ) |
Value:
do { \ assert ( ( (len) & ( (cipher)->blocksize - 1 ) ) == 0 ); \ cipher_encrypt ( (cipher), (ctx), (src), (dst), (len) ); \ } while ( 0 )
Definition at line 131 of file crypto.h.
Referenced by aes_wrap(), cbc_encrypt(), ccmp_cbc_mac(), ccmp_ctr_xor(), ccmp_feed_cbc_mac(), tkip_encrypt(), tls_send_plaintext(), and wep_encrypt().
| #define cipher_decrypt | ( | cipher, | |||
| ctx, | |||||
| src, | |||||
| dst, | |||||
| len | ) |
Value:
do { \ assert ( ( (len) & ( (cipher)->blocksize - 1 ) ) == 0 ); \ cipher_decrypt ( (cipher), (ctx), (src), (dst), (len) ); \ } while ( 0 )
Definition at line 141 of file crypto.h.
Referenced by aes_unwrap(), cbc_decrypt(), tkip_decrypt(), tls_new_ciphertext(), and wep_decrypt().
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static void digest_init | ( | struct digest_algorithm * | digest, | |
| void * | ctx | |||
| ) | [inline, static] |
Definition at line 101 of file crypto.h.
References digest_algorithm::init.
Referenced by add_tls(), chap_init(), digest_exec(), hmac_final(), hmac_init(), and hmac_reduce_key().
00102 { 00103 digest->init ( ctx ); 00104 }
| static void digest_update | ( | struct digest_algorithm * | digest, | |
| void * | ctx, | |||
| const void * | data, | |||
| size_t | len | |||
| ) | [inline, static] |
Definition at line 106 of file crypto.h.
References digest_algorithm::update.
Referenced by chap_update(), digest_exec(), hmac_final(), hmac_init(), hmac_reduce_key(), hmac_update(), and tls_add_handshake().
00107 { 00108 digest->update ( ctx, data, len ); 00109 }
| static void digest_final | ( | struct digest_algorithm * | digest, | |
| void * | ctx, | |||
| void * | out | |||
| ) | [inline, static] |
Definition at line 111 of file crypto.h.
References digest_algorithm::final.
Referenced by chap_respond(), digest_exec(), hmac_final(), hmac_reduce_key(), and tls_verify_handshake().
00112 { 00113 digest->final ( ctx, out ); 00114 }
| static int cipher_setkey | ( | struct cipher_algorithm * | cipher, | |
| void * | ctx, | |||
| const void * | key, | |||
| size_t | keylen | |||
| ) | [inline, static] |
Definition at line 116 of file crypto.h.
References cipher_algorithm::setkey.
Referenced by aes_unwrap(), aes_wrap(), cbc_setkey(), ccmp_init(), tkip_decrypt(), tkip_encrypt(), tls_generate_keys(), wep_decrypt(), and wep_encrypt().
00117 { 00118 return cipher->setkey ( ctx, key, keylen ); 00119 }
| static void cipher_setiv | ( | struct cipher_algorithm * | cipher, | |
| void * | ctx, | |||
| const void * | iv | |||
| ) | [inline, static] |
Definition at line 121 of file crypto.h.
References cipher_algorithm::setiv.
Referenced by tls_generate_keys().
00122 { 00123 cipher->setiv ( ctx, iv ); 00124 }
| static void cipher_encrypt | ( | struct cipher_algorithm * | cipher, | |
| void * | ctx, | |||
| const void * | src, | |||
| void * | dst, | |||
| size_t | len | |||
| ) | [inline, static] |
| static void cipher_decrypt | ( | struct cipher_algorithm * | cipher, | |
| void * | ctx, | |||
| const void * | src, | |||
| void * | dst, | |||
| size_t | len | |||
| ) | [inline, static] |
| static int is_stream_cipher | ( | struct cipher_algorithm * | cipher | ) | [inline, static] |
Definition at line 146 of file crypto.h.
References cipher_algorithm::blocksize.
Referenced by tls_new_ciphertext(), and tls_send_plaintext().
00146 { 00147 return ( cipher->blocksize == 1 ); 00148 }
| void get_random_bytes | ( | void * | buf, | |
| size_t | len | |||
| ) |
Get cryptographically strong random bytes.
| buf | Buffer in which to store random bytes | |
| len | Number of random bytes to generate |
Definition at line 41 of file crandom.c.
Referenced by forcedeth_probe(), and wpa_handle_1_of_4().
00042 { 00043 u8 *bufp = buf; 00044 00045 /* 00046 * Somewhat arbitrarily, choose the 0x00FF0000-masked byte 00047 * returned by random() as having good entropy. PRNGs often 00048 * don't provide good entropy in lower bits, and the top byte 00049 * might show a pattern because of sign issues. 00050 */ 00051 00052 while ( len-- ) { 00053 *bufp++ = ( random() >> 16 ) & 0xFF; 00054 } 00055 }
| struct digest_algorithm digest_null |
Definition at line 43 of file crypto_null.c.
Referenced by tls_change_cipher(), tls_clear_cipher(), and tls_select_cipher().
| struct cipher_algorithm cipher_null |
Definition at line 74 of file crypto_null.c.
Referenced by tls_change_cipher(), tls_clear_cipher(), and tls_select_cipher().
| struct pubkey_algorithm pubkey_null |
Definition at line 84 of file crypto_null.c.
Referenced by tls_clear_cipher(), and tls_select_cipher().
1.5.7.1