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 /* 307c478bd9Sstevel@tonic-gate * Common definitions used by Blowfish. 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 37*23c57df7Smcpowers #define BLOWFISH_COPY_BLOCK(src, dst) \ 38*23c57df7Smcpowers (dst)[0] = (src)[0]; \ 39*23c57df7Smcpowers (dst)[1] = (src)[1]; \ 40*23c57df7Smcpowers (dst)[2] = (src)[2]; \ 41*23c57df7Smcpowers (dst)[3] = (src)[3]; \ 42*23c57df7Smcpowers (dst)[4] = (src)[4]; \ 43*23c57df7Smcpowers (dst)[5] = (src)[5]; \ 44*23c57df7Smcpowers (dst)[6] = (src)[6]; \ 45*23c57df7Smcpowers (dst)[7] = (src)[7] 46*23c57df7Smcpowers 47*23c57df7Smcpowers #define BLOWFISH_XOR_BLOCK(src, dst) \ 48*23c57df7Smcpowers (dst)[0] ^= (src)[0]; \ 49*23c57df7Smcpowers (dst)[1] ^= (src)[1]; \ 50*23c57df7Smcpowers (dst)[2] ^= (src)[2]; \ 51*23c57df7Smcpowers (dst)[3] ^= (src)[3]; \ 52*23c57df7Smcpowers (dst)[4] ^= (src)[4]; \ 53*23c57df7Smcpowers (dst)[5] ^= (src)[5]; \ 54*23c57df7Smcpowers (dst)[6] ^= (src)[6]; \ 55*23c57df7Smcpowers (dst)[7] ^= (src)[7] 56*23c57df7Smcpowers 577c478bd9Sstevel@tonic-gate #define BLOWFISH_MINBITS 32 587c478bd9Sstevel@tonic-gate #define BLOWFISH_MINBYTES (BLOWFISH_MINBITS >> 3) 597c478bd9Sstevel@tonic-gate #define BLOWFISH_MAXBITS 448 607c478bd9Sstevel@tonic-gate #define BLOWFISH_MAXBYTES (BLOWFISH_MAXBITS >> 3) 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate #define BLOWFISH_IV_LEN 8 637c478bd9Sstevel@tonic-gate #define BLOWFISH_BLOCK_LEN 8 647c478bd9Sstevel@tonic-gate #define BLOWFISH_KEY_INCREMENT 8 657c478bd9Sstevel@tonic-gate #define BLOWFISH_DEFAULT 128 667c478bd9Sstevel@tonic-gate 67*23c57df7Smcpowers extern int blowfish_encrypt_contiguous_blocks(void *, char *, size_t, 68*23c57df7Smcpowers crypto_data_t *); 69*23c57df7Smcpowers extern int blowfish_decrypt_contiguous_blocks(void *, char *, size_t, 70*23c57df7Smcpowers crypto_data_t *); 71*23c57df7Smcpowers extern int blowfish_encrypt_block(const void *, const uint8_t *, uint8_t *); 72*23c57df7Smcpowers extern int blowfish_decrypt_block(const void *, const uint8_t *, uint8_t *); 737c478bd9Sstevel@tonic-gate extern void blowfish_init_keysched(uint8_t *, uint_t, void *); 747c478bd9Sstevel@tonic-gate extern void *blowfish_alloc_keysched(size_t *, int); 75*23c57df7Smcpowers extern void blowfish_copy_block(uint8_t *, uint8_t *); 76*23c57df7Smcpowers extern void blowfish_xor_block(uint8_t *, uint8_t *); 777c478bd9Sstevel@tonic-gate #ifdef __cplusplus 787c478bd9Sstevel@tonic-gate } 797c478bd9Sstevel@tonic-gate #endif 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate #endif /* _BLOWFISH_IMPL_H */ 82