190792Sgshapiro/* crypto/camellia/camellia_cfb.c */ 2112810Sgshapiro/* ==================================================================== 390792Sgshapiro * Copyright (c) 2006 The OpenSSL Project. All rights reserved. 490792Sgshapiro * 590792Sgshapiro * Redistribution and use in source and binary forms, with or without 690792Sgshapiro * modification, are permitted provided that the following conditions 790792Sgshapiro * are met: 890792Sgshapiro * 990792Sgshapiro * 1. Redistributions of source code must retain the above copyright 1090792Sgshapiro * notice, this list of conditions and the following disclaimer. 1190792Sgshapiro * 1290792Sgshapiro * 2. Redistributions in binary form must reproduce the above copyright 1390792Sgshapiro * notice, this list of conditions and the following disclaimer in 1490792Sgshapiro * the documentation and/or other materials provided with the 1590792Sgshapiro * distribution. 1690792Sgshapiro * 1790792Sgshapiro * 3. All advertising materials mentioning features or use of this 1890792Sgshapiro * software must display the following acknowledgment: 1990792Sgshapiro * "This product includes software developed by the OpenSSL Project 2090792Sgshapiro * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 2190792Sgshapiro * 2290792Sgshapiro * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 2390792Sgshapiro * endorse or promote products derived from this software without 2490792Sgshapiro * prior written permission. For written permission, please contact 2590792Sgshapiro * openssl-core@openssl.org. 2690792Sgshapiro * 2790792Sgshapiro * 5. Products derived from this software may not be called "OpenSSL" 2890792Sgshapiro * nor may "OpenSSL" appear in their names without prior written 2990792Sgshapiro * permission of the OpenSSL Project. 3090792Sgshapiro * 3190792Sgshapiro * 6. Redistributions of any form whatsoever must retain the following 3290792Sgshapiro * acknowledgment: 3390792Sgshapiro * "This product includes software developed by the OpenSSL Project 3490792Sgshapiro * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 3590792Sgshapiro * 3690792Sgshapiro * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 3790792Sgshapiro * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 3890792Sgshapiro * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 3990792Sgshapiro * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 4090792Sgshapiro * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4190792Sgshapiro * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 4290792Sgshapiro * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 4390792Sgshapiro * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 4490792Sgshapiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 4590792Sgshapiro * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 4690792Sgshapiro * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 4790792Sgshapiro * OF THE POSSIBILITY OF SUCH DAMAGE. 4890792Sgshapiro * ==================================================================== 49112810Sgshapiro * 5090792Sgshapiro */ 5190792Sgshapiro/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 5290792Sgshapiro * All rights reserved. 5390792Sgshapiro * 5490792Sgshapiro * This package is an SSL implementation written 5590792Sgshapiro * by Eric Young (eay@cryptsoft.com). 5690792Sgshapiro * The implementation was written so as to conform with Netscapes SSL. 5790792Sgshapiro * 5890792Sgshapiro * This library is free for commercial and non-commercial use as long as 5990792Sgshapiro * the following conditions are aheared to. The following conditions 6090792Sgshapiro * apply to all code found in this distribution, be it the RC4, RSA, 6190792Sgshapiro * lhash, DES, etc., code; not just the SSL code. The SSL documentation 6290792Sgshapiro * included with this distribution is covered by the same copyright terms 6390792Sgshapiro * except that the holder is Tim Hudson (tjh@cryptsoft.com). 6490792Sgshapiro * 6590792Sgshapiro * Copyright remains Eric Young's, and as such any Copyright notices in 6690792Sgshapiro * the code are not to be removed. 6790792Sgshapiro * If this package is used in a product, Eric Young should be given attribution 6890792Sgshapiro * as the author of the parts of the library used. 6990792Sgshapiro * This can be in the form of a textual message at program startup or 7090792Sgshapiro * in documentation (online or textual) provided with the package. 7190792Sgshapiro * 7290792Sgshapiro * Redistribution and use in source and binary forms, with or without 7390792Sgshapiro * modification, are permitted provided that the following conditions 7490792Sgshapiro * are met: 7590792Sgshapiro * 1. Redistributions of source code must retain the copyright 7690792Sgshapiro * notice, this list of conditions and the following disclaimer. 7790792Sgshapiro * 2. Redistributions in binary form must reproduce the above copyright 7890792Sgshapiro * notice, this list of conditions and the following disclaimer in the 7990792Sgshapiro * documentation and/or other materials provided with the distribution. 8090792Sgshapiro * 3. All advertising materials mentioning features or use of this software 8190792Sgshapiro * must display the following acknowledgement: 8290792Sgshapiro * "This product includes cryptographic software written by 8390792Sgshapiro * Eric Young (eay@cryptsoft.com)" 8490792Sgshapiro * The word 'cryptographic' can be left out if the rouines from the library 8590792Sgshapiro * being used are not cryptographic related :-). 8690792Sgshapiro * 4. If you include any Windows specific code (or a derivative thereof) from 8790792Sgshapiro * the apps directory (application code) you must include an acknowledgement: 8890792Sgshapiro * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 8990792Sgshapiro * 9090792Sgshapiro * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 9190792Sgshapiro * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 9290792Sgshapiro * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 9390792Sgshapiro * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 9490792Sgshapiro * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 9590792Sgshapiro * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 9690792Sgshapiro * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 9790792Sgshapiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 9890792Sgshapiro * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 9990792Sgshapiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 10090792Sgshapiro * SUCH DAMAGE. 10190792Sgshapiro * 10290792Sgshapiro * The licence and distribution terms for any publically available version or 10390792Sgshapiro * derivative of this code cannot be changed. i.e. this code cannot simply be 10490792Sgshapiro * copied and put under another distribution licence 10590792Sgshapiro * [including the GNU Public Licence.] 10690792Sgshapiro */ 10790792Sgshapiro 10890792Sgshapiro#include <openssl/camellia.h> 10990792Sgshapiro#include <openssl/modes.h> 11090792Sgshapiro 11190792Sgshapiro/* 11290792Sgshapiro * The input and output encrypted as though 128bit cfb mode is being used. 11390792Sgshapiro * The extra state information to record how much of the 128bit block we have 11490792Sgshapiro * used is contained in *num; 11590792Sgshapiro */ 11690792Sgshapiro 11790792Sgshapirovoid Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, 11890792Sgshapiro size_t length, const CAMELLIA_KEY *key, 11990792Sgshapiro unsigned char *ivec, int *num, const int enc) 12090792Sgshapiro{ 12190792Sgshapiro 12290792Sgshapiro CRYPTO_cfb128_encrypt(in, out, length, key, ivec, num, enc, 12390792Sgshapiro (block128_f) Camellia_encrypt); 12490792Sgshapiro} 12590792Sgshapiro 12690792Sgshapiro/* N.B. This expects the input to be packed, MS bit first */ 12790792Sgshapirovoid Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, 12890792Sgshapiro size_t length, const CAMELLIA_KEY *key, 12990792Sgshapiro unsigned char *ivec, int *num, const int enc) 13090792Sgshapiro{ 13190792Sgshapiro CRYPTO_cfb128_1_encrypt(in, out, length, key, ivec, num, enc, 13290792Sgshapiro (block128_f) Camellia_encrypt); 13390792Sgshapiro} 13490792Sgshapiro 13590792Sgshapirovoid Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, 13690792Sgshapiro size_t length, const CAMELLIA_KEY *key, 13790792Sgshapiro unsigned char *ivec, int *num, const int enc) 13890792Sgshapiro{ 13990792Sgshapiro CRYPTO_cfb128_8_encrypt(in, out, length, key, ivec, num, enc, 14090792Sgshapiro (block128_f) Camellia_encrypt); 14190792Sgshapiro} 14290792Sgshapiro