xref: /onnv-gate/usr/src/common/crypto/blowfish/blowfish_impl.h (revision 7188:b5eb53fb3905)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
56125Sbubbva  * Common Development and Distribution License (the "License").
66125Sbubbva  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
226125Sbubbva  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_BLOWFISH_IMPL_H
270Sstevel@tonic-gate #define	_BLOWFISH_IMPL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  * Common definitions used by Blowfish.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef	__cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
39*7188Smcpowers #define	BLOWFISH_COPY_BLOCK(src, dst) \
40*7188Smcpowers 	(dst)[0] = (src)[0]; \
41*7188Smcpowers 	(dst)[1] = (src)[1]; \
42*7188Smcpowers 	(dst)[2] = (src)[2]; \
43*7188Smcpowers 	(dst)[3] = (src)[3]; \
44*7188Smcpowers 	(dst)[4] = (src)[4]; \
45*7188Smcpowers 	(dst)[5] = (src)[5]; \
46*7188Smcpowers 	(dst)[6] = (src)[6]; \
47*7188Smcpowers 	(dst)[7] = (src)[7]
48*7188Smcpowers 
49*7188Smcpowers #define	BLOWFISH_XOR_BLOCK(src, dst) \
50*7188Smcpowers 	(dst)[0] ^= (src)[0]; \
51*7188Smcpowers 	(dst)[1] ^= (src)[1]; \
52*7188Smcpowers 	(dst)[2] ^= (src)[2]; \
53*7188Smcpowers 	(dst)[3] ^= (src)[3]; \
54*7188Smcpowers 	(dst)[4] ^= (src)[4]; \
55*7188Smcpowers 	(dst)[5] ^= (src)[5]; \
56*7188Smcpowers 	(dst)[6] ^= (src)[6]; \
57*7188Smcpowers 	(dst)[7] ^= (src)[7]
58*7188Smcpowers 
590Sstevel@tonic-gate #define	BLOWFISH_MINBITS	32
600Sstevel@tonic-gate #define	BLOWFISH_MINBYTES	(BLOWFISH_MINBITS >> 3)
610Sstevel@tonic-gate #define	BLOWFISH_MAXBITS	448
620Sstevel@tonic-gate #define	BLOWFISH_MAXBYTES	(BLOWFISH_MAXBITS >> 3)
630Sstevel@tonic-gate 
640Sstevel@tonic-gate #define	BLOWFISH_IV_LEN		8
650Sstevel@tonic-gate #define	BLOWFISH_BLOCK_LEN	8
660Sstevel@tonic-gate #define	BLOWFISH_KEY_INCREMENT	8
670Sstevel@tonic-gate #define	BLOWFISH_DEFAULT	128
680Sstevel@tonic-gate 
69*7188Smcpowers extern int blowfish_encrypt_contiguous_blocks(void *, char *, size_t,
70*7188Smcpowers     crypto_data_t *);
71*7188Smcpowers extern int blowfish_decrypt_contiguous_blocks(void *, char *, size_t,
72*7188Smcpowers     crypto_data_t *);
73*7188Smcpowers extern int blowfish_encrypt_block(const void *, const uint8_t *, uint8_t *);
74*7188Smcpowers extern int blowfish_decrypt_block(const void *, const uint8_t *, uint8_t *);
750Sstevel@tonic-gate extern void blowfish_init_keysched(uint8_t *, uint_t, void *);
760Sstevel@tonic-gate extern void *blowfish_alloc_keysched(size_t *, int);
77*7188Smcpowers extern void blowfish_copy_block(uint8_t *, uint8_t *);
78*7188Smcpowers extern void blowfish_xor_block(uint8_t *, uint8_t *);
790Sstevel@tonic-gate #ifdef	__cplusplus
800Sstevel@tonic-gate }
810Sstevel@tonic-gate #endif
820Sstevel@tonic-gate 
830Sstevel@tonic-gate #endif	/* _BLOWFISH_IMPL_H */
84