libfortuna  1
FortunalibraryfunctionsextractedfromPostgreSQLsource
 All Data Structures Files Functions Variables Typedefs Macros
blf.c File Reference
#include <assert.h>
#include "c.h"
#include "blf.h"

Macros

#define GET_32BIT_MSB_FIRST(p)
 
#define PUT_32BIT_MSB_FIRST(p, v)
 
#define Fprime(a, b, c, d)   ( ( (S0[a] + S1[b]) ^ S2[c] ) + S3[d] )
 
#define F(x)   Fprime( ((x>>24)&0xFF), ((x>>16)&0xFF), ((x>>8)&0xFF), (x&0xFF) )
 
#define ROUND(n)   ( xL ^= P[n], t = xL, xL = F(xL) ^ xR, xR = t )
 

Functions

void blowfish_encrypt (uint32 xL, uint32 xR, uint32 *output, BlowfishContext *ctx)
 
void blowfish_decrypt (uint32 xL, uint32 xR, uint32 *output, BlowfishContext *ctx)
 
void blowfish_encrypt_cbc (uint8 *blk, int len, BlowfishContext *ctx)
 
void blowfish_decrypt_cbc (uint8 *blk, int len, BlowfishContext *ctx)
 
void blowfish_encrypt_ecb (uint8 *blk, int len, BlowfishContext *ctx)
 
void blowfish_decrypt_ecb (uint8 *blk, int len, BlowfishContext *ctx)
 
void blowfish_setkey (BlowfishContext *ctx, const uint8 *key, short keybytes)
 
void blowfish_setiv (BlowfishContext *ctx, const uint8 *iv)
 

Variables

const uint32 parray []
 
const uint32 sbox0 []
 
const uint32 sbox1 []
 
const uint32 sbox2 []
 
const uint32 sbox3 []
 

Macro Definition Documentation

#define F (   x)    Fprime( ((x>>24)&0xFF), ((x>>16)&0xFF), ((x>>8)&0xFF), (x&0xFF) )
#define Fprime (   a,
  b,
  c,
 
)    ( ( (S0[a] + S1[b]) ^ S2[c] ) + S3[d] )
#define GET_32BIT_MSB_FIRST (   p)
Value:
( \
((p)[0] << 24) | ((p)[1] << 16) | ((p)[2] << 8) | ((p)[3]) )
#define PUT_32BIT_MSB_FIRST (   p,
 
)
Value:
do { \
(p)[0] = v >> 24; \
(p)[1] = v >> 16; \
(p)[2] = v >> 8; \
(p)[3] = v; \
} while (0)
#define ROUND (   n)    ( xL ^= P[n], t = xL, xL = F(xL) ^ xR, xR = t )

Function Documentation

void blowfish_decrypt ( uint32  xL,
uint32  xR,
uint32 output,
BlowfishContext ctx 
)
void blowfish_decrypt_cbc ( uint8 blk,
int  len,
BlowfishContext ctx 
)
void blowfish_decrypt_ecb ( uint8 blk,
int  len,
BlowfishContext ctx 
)
void blowfish_encrypt ( uint32  xL,
uint32  xR,
uint32 output,
BlowfishContext ctx 
)
void blowfish_encrypt_cbc ( uint8 blk,
int  len,
BlowfishContext ctx 
)
void blowfish_encrypt_ecb ( uint8 blk,
int  len,
BlowfishContext ctx 
)
void blowfish_setiv ( BlowfishContext ctx,
const uint8 iv 
)
void blowfish_setkey ( BlowfishContext ctx,
const uint8 key,
short  keybytes 
)

Variable Documentation

const uint32 parray[]
Initial value:
= {
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0,
0x082EFA98, 0xEC4E6C89, 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, 0x9216D5D9, 0x8979FB1B,
}
const uint32 sbox0[]
const uint32 sbox1[]
const uint32 sbox2[]
const uint32 sbox3[]