xref: /titanic_41/usr/src/common/crypto/blowfish/blowfish_impl.h (revision 23c57df72989c916b3e98084eb88d48777999691)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5b6c3f786Sbubbva  * Common Development and Distribution License (the "License").
6b6c3f786Sbubbva  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22b6c3f786Sbubbva  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_BLOWFISH_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_BLOWFISH_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Common definitions used by Blowfish.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
39*23c57df7Smcpowers #define	BLOWFISH_COPY_BLOCK(src, dst) \
40*23c57df7Smcpowers 	(dst)[0] = (src)[0]; \
41*23c57df7Smcpowers 	(dst)[1] = (src)[1]; \
42*23c57df7Smcpowers 	(dst)[2] = (src)[2]; \
43*23c57df7Smcpowers 	(dst)[3] = (src)[3]; \
44*23c57df7Smcpowers 	(dst)[4] = (src)[4]; \
45*23c57df7Smcpowers 	(dst)[5] = (src)[5]; \
46*23c57df7Smcpowers 	(dst)[6] = (src)[6]; \
47*23c57df7Smcpowers 	(dst)[7] = (src)[7]
48*23c57df7Smcpowers 
49*23c57df7Smcpowers #define	BLOWFISH_XOR_BLOCK(src, dst) \
50*23c57df7Smcpowers 	(dst)[0] ^= (src)[0]; \
51*23c57df7Smcpowers 	(dst)[1] ^= (src)[1]; \
52*23c57df7Smcpowers 	(dst)[2] ^= (src)[2]; \
53*23c57df7Smcpowers 	(dst)[3] ^= (src)[3]; \
54*23c57df7Smcpowers 	(dst)[4] ^= (src)[4]; \
55*23c57df7Smcpowers 	(dst)[5] ^= (src)[5]; \
56*23c57df7Smcpowers 	(dst)[6] ^= (src)[6]; \
57*23c57df7Smcpowers 	(dst)[7] ^= (src)[7]
58*23c57df7Smcpowers 
597c478bd9Sstevel@tonic-gate #define	BLOWFISH_MINBITS	32
607c478bd9Sstevel@tonic-gate #define	BLOWFISH_MINBYTES	(BLOWFISH_MINBITS >> 3)
617c478bd9Sstevel@tonic-gate #define	BLOWFISH_MAXBITS	448
627c478bd9Sstevel@tonic-gate #define	BLOWFISH_MAXBYTES	(BLOWFISH_MAXBITS >> 3)
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate #define	BLOWFISH_IV_LEN		8
657c478bd9Sstevel@tonic-gate #define	BLOWFISH_BLOCK_LEN	8
667c478bd9Sstevel@tonic-gate #define	BLOWFISH_KEY_INCREMENT	8
677c478bd9Sstevel@tonic-gate #define	BLOWFISH_DEFAULT	128
687c478bd9Sstevel@tonic-gate 
69*23c57df7Smcpowers extern int blowfish_encrypt_contiguous_blocks(void *, char *, size_t,
70*23c57df7Smcpowers     crypto_data_t *);
71*23c57df7Smcpowers extern int blowfish_decrypt_contiguous_blocks(void *, char *, size_t,
72*23c57df7Smcpowers     crypto_data_t *);
73*23c57df7Smcpowers extern int blowfish_encrypt_block(const void *, const uint8_t *, uint8_t *);
74*23c57df7Smcpowers extern int blowfish_decrypt_block(const void *, const uint8_t *, uint8_t *);
757c478bd9Sstevel@tonic-gate extern void blowfish_init_keysched(uint8_t *, uint_t, void *);
767c478bd9Sstevel@tonic-gate extern void *blowfish_alloc_keysched(size_t *, int);
77*23c57df7Smcpowers extern void blowfish_copy_block(uint8_t *, uint8_t *);
78*23c57df7Smcpowers extern void blowfish_xor_block(uint8_t *, uint8_t *);
797c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
807c478bd9Sstevel@tonic-gate }
817c478bd9Sstevel@tonic-gate #endif
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate #endif	/* _BLOWFISH_IMPL_H */
84