#include "polarssl/config.h"
#include "polarssl/blowfish.h"
Go to the source code of this file.
Defines | |
#define | GET_UINT32_BE(n, b, i) |
#define | PUT_UINT32_BE(n, b, i) |
Functions | |
static uint32_t | F (blowfish_context *ctx, uint32_t x) |
static void | blowfish_enc (blowfish_context *ctx, uint32_t *xl, uint32_t *xr) |
static void | blowfish_dec (blowfish_context *ctx, uint32_t *xl, uint32_t *xr) |
int | blowfish_setkey (blowfish_context *ctx, const unsigned char *key, unsigned int keysize) |
Blowfish key schedule. | |
int | blowfish_crypt_ecb (blowfish_context *ctx, int mode, const unsigned char input[BLOWFISH_BLOCKSIZE], unsigned char output[BLOWFISH_BLOCKSIZE]) |
Blowfish-ECB block encryption/decryption. | |
int | blowfish_crypt_cbc (blowfish_context *ctx, int mode, size_t length, unsigned char iv[BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output) |
int | blowfish_crypt_cfb64 (blowfish_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output) |
int | blowfish_crypt_ctr (blowfish_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[BLOWFISH_BLOCKSIZE], unsigned char stream_block[BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output) |
Variables | |
static const uint32_t | P [BLOWFISH_ROUNDS+2] |
static const uint32_t | S [4][256] |
#define GET_UINT32_BE | ( | n, | |||
b, | |||||
i | ) |
{ \ (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ | ( (uint32_t) (b)[(i) + 1] << 16 ) \ | ( (uint32_t) (b)[(i) + 2] << 8 ) \ | ( (uint32_t) (b)[(i) + 3] ); \ }
Definition at line 44 of file blowfish.c.
Referenced by blowfish_crypt_ecb(), camellia_crypt_ecb(), camellia_setkey_enc(), des3_crypt_ecb(), des_crypt_ecb(), des_setkey(), gcm_gen_table(), sha1_process(), sha256_process(), xtea_crypt_ecb(), and xtea_setup().
#define PUT_UINT32_BE | ( | n, | |||
b, | |||||
i | ) |
{ \ (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ (b)[(i) + 3] = (unsigned char) ( (n) ); \ }
Definition at line 54 of file blowfish.c.
Referenced by blowfish_crypt_ecb(), camellia_crypt_ecb(), des3_crypt_ecb(), des_crypt_ecb(), gcm_finish(), gcm_mult(), gcm_starts(), rnd_pseudo_rand(), sha1_finish(), sha256_finish(), and xtea_crypt_ecb().
int blowfish_crypt_cbc | ( | blowfish_context * | ctx, | |
int | mode, | |||
size_t | length, | |||
unsigned char | iv[BLOWFISH_BLOCKSIZE], | |||
const unsigned char * | input, | |||
unsigned char * | output | |||
) |
Definition at line 240 of file blowfish.c.
References blowfish_crypt_ecb(), BLOWFISH_DECRYPT, iv, and POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH.
Referenced by blowfish_crypt_cbc_wrap(), test_suite_blowfish_decrypt_cbc(), and test_suite_blowfish_encrypt_cbc().
int blowfish_crypt_cfb64 | ( | blowfish_context * | ctx, | |
int | mode, | |||
size_t | length, | |||
size_t * | iv_off, | |||
unsigned char | iv[BLOWFISH_BLOCKSIZE], | |||
const unsigned char * | input, | |||
unsigned char * | output | |||
) |
Definition at line 294 of file blowfish.c.
References blowfish_crypt_ecb(), BLOWFISH_DECRYPT, BLOWFISH_ENCRYPT, and iv.
Referenced by blowfish_crypt_cfb64_wrap(), test_suite_blowfish_decrypt_cfb64(), and test_suite_blowfish_encrypt_cfb64().
int blowfish_crypt_ctr | ( | blowfish_context * | ctx, | |
size_t | length, | |||
size_t * | nc_off, | |||
unsigned char | nonce_counter[BLOWFISH_BLOCKSIZE], | |||
unsigned char | stream_block[BLOWFISH_BLOCKSIZE], | |||
const unsigned char * | input, | |||
unsigned char * | output | |||
) |
Definition at line 342 of file blowfish.c.
References blowfish_crypt_ecb(), and BLOWFISH_ENCRYPT.
Referenced by blowfish_crypt_ctr_wrap(), and test_suite_blowfish_encrypt_ctr().
int blowfish_crypt_ecb | ( | blowfish_context * | ctx, | |
int | mode, | |||
const unsigned char | input[BLOWFISH_BLOCKSIZE], | |||
unsigned char | output[BLOWFISH_BLOCKSIZE] | |||
) |
Blowfish-ECB block encryption/decryption.
ctx | Blowfish context | |
mode | BLOWFISH_ENCRYPT or BLOWFISH_DECRYPT | |
input | 8-byte input block | |
output | 8-byte output block |
Definition at line 211 of file blowfish.c.
References blowfish_dec(), BLOWFISH_DECRYPT, blowfish_enc(), GET_UINT32_BE, and PUT_UINT32_BE.
Referenced by blowfish_crypt_cbc(), blowfish_crypt_cfb64(), blowfish_crypt_ctr(), blowfish_crypt_ecb_wrap(), test_suite_blowfish_decrypt_ecb(), and test_suite_blowfish_encrypt_ecb().
static void blowfish_dec | ( | blowfish_context * | ctx, | |
uint32_t * | xl, | |||
uint32_t * | xr | |||
) | [static] |
Definition at line 122 of file blowfish.c.
References BLOWFISH_ROUNDS, F, and blowfish_context::P.
Referenced by blowfish_crypt_ecb().
static void blowfish_enc | ( | blowfish_context * | ctx, | |
uint32_t * | xl, | |||
uint32_t * | xr | |||
) | [static] |
Definition at line 93 of file blowfish.c.
References BLOWFISH_ROUNDS, F, and blowfish_context::P.
Referenced by blowfish_crypt_ecb(), and blowfish_setkey().
int blowfish_setkey | ( | blowfish_context * | ctx, | |
const unsigned char * | key, | |||
unsigned int | keysize | |||
) |
Blowfish key schedule.
ctx | Blowfish context to be initialized | |
key | encryption key | |
keysize | must be between 32 and 448 bits |
Definition at line 154 of file blowfish.c.
References blowfish_enc(), BLOWFISH_MAX_KEY, BLOWFISH_ROUNDS, P, blowfish_context::P, POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH, S, and blowfish_context::S.
Referenced by blowfish_setkey_wrap(), test_suite_blowfish_decrypt_cbc(), test_suite_blowfish_decrypt_cfb64(), test_suite_blowfish_decrypt_ecb(), test_suite_blowfish_encrypt_cbc(), test_suite_blowfish_encrypt_cfb64(), test_suite_blowfish_encrypt_ctr(), and test_suite_blowfish_encrypt_ecb().
static uint32_t F | ( | blowfish_context * | ctx, | |
uint32_t | x | |||
) | [static] |
Definition at line 74 of file blowfish.c.
References F, and blowfish_context::S.
const uint32_t P[BLOWFISH_ROUNDS+2] [static] |
{ 0x243F6A88L, 0x85A308D3L, 0x13198A2EL, 0x03707344L, 0xA4093822L, 0x299F31D0L, 0x082EFA98L, 0xEC4E6C89L, 0x452821E6L, 0x38D01377L, 0xBE5466CFL, 0x34E90C6CL, 0xC0AC29B7L, 0xC97C50DDL, 0x3F84D5B5L, 0xB5470917L, 0x9216D5D9L, 0x8979FB1BL }
Definition at line 63 of file blowfish.c.
static const uint32_t S [static] |
Definition at line 72 of file blowfish.c.