.Dd November 30, 2003 .Dt LIBBLOWFISH 3 .Os NetBSD 1.4T .Sh NAME .Nm blowfish_setkey , .Nm blowfish_encrypt , .Nm blowfish_decrypt .Nd BLOWFISH encryption/decryption routines .Sh SYNOPSIS .Fd #include .br .Nm cc .Op Ar arguments .Fl lblowfish .br .Ft void .Fn blowfish_setkey "BLOWFISH_KEY *key" "const void *key" "int len" .Ft void .Fn blowfish_encrypt "const BLOWFISH_KEY *key" "const void *in" "void *out" .Ft void .Fn blowfish_decrypt "const BLOWFISH_KEY *key" "const void *in" "void *out" .Sh DESCRIPTION These functions perform Blowfish encryption and decryption. .Pp .Fn blowfish_setkey takes a buffer containing a key, which for Blowfish is from 1 to 56 bytes of arbitrary data, performs various computations, and stores the result into the .Dv BLOWFISH_KEY passed in, in an internal format not documented here. The result is good for nothing but passing to the other functions. If the length passed in is less than 1, .Fn blowfish_setkey does nothing; if it is greater than 56, only the first 56 bytes are used. .Pp .Fn blowfish_encrypt and .Fn blowfish_decrypt take a .Dv BLOWFISH_KEY and perform encryption or decryption of a block of data. Blowfish data blocks are 64 bits, stored as 8 bytes. The input and output buffers may overlap arbitrarily without harm. .Pp The library promises that the contents of the .Dv BLOWFISH_KEY constitute all the state involved; there are no pointers to data elsewhere. (For example, sizeof(BLOWFISH_KEY) bytes may be written to a file and then read back in, in another run, rather than calling blowfish_setkey, and the result will work perfectly well.) Another implication of this is that there is no .Sq done call necessary; when finished with a .Dv BLOWFISH_KEY , you can simply drop the memory (deallocate the variable, call .Xr free 3 , whatever). .Pp Note that the key structure arguments to .Fn blowfish_encrypt and .Fn blowfish_decrypt are marked .Sq const ; a given .Dv BLOWFISH_KEY can be shared my multiple concurrent encryptions and/or decryptions without any interference therefrom. .Pp Corrupting the memory making up a BLOWFISH_KEY will not cause the library to crash or otherwise violate its interface spec, but using the resulting key structure with .Fn blowfish_encrypt or .Fn blowfish_decrypt may produce .Sq encryption or .Sq decryption that bears no particular resemblance to normal Blowfish operation. .Sh ERRORS These routines .Dq cannot fail ; the only failure modes possible for them are due to passing invalid pointers as arguments. Such incorrect calls will not be detected by the library; their effects can range from silent corruption of memory to core dumps. .Sh BUGS Code blindly assumes 8-bit .Do char .Dc Ns s. .Sh AUTHOR der Mouse, .Aq mouse@rodents.montreal.qc.ca .