| OLD | NEW |
| 1 /* crypto/camellia/camellia_ofb.c -*- mode:C; c-file-style: "eay" -*- */ | 1 /* crypto/camellia/camellia_ofb.c -*- mode:C; c-file-style: "eay" -*- */ |
| 2 /* ==================================================================== | 2 /* ==================================================================== |
| 3 * Copyright (c) 2006 The OpenSSL Project. All rights reserved. | 3 * Copyright (c) 2006 The OpenSSL Project. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 100 * SUCH DAMAGE. | 100 * SUCH DAMAGE. |
| 101 * | 101 * |
| 102 * The licence and distribution terms for any publically available version or | 102 * The licence and distribution terms for any publically available version or |
| 103 * derivative of this code cannot be changed. i.e. this code cannot simply be | 103 * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 104 * copied and put under another distribution licence | 104 * copied and put under another distribution licence |
| 105 * [including the GNU Public Licence.] | 105 * [including the GNU Public Licence.] |
| 106 */ | 106 */ |
| 107 | 107 |
| 108 #ifndef CAMELLIA_DEBUG | |
| 109 # ifndef NDEBUG | |
| 110 # define NDEBUG | |
| 111 # endif | |
| 112 #endif | |
| 113 #include <assert.h> | |
| 114 #include <openssl/camellia.h> | 108 #include <openssl/camellia.h> |
| 115 #include "cmll_locl.h" | 109 #include <openssl/modes.h> |
| 116 | 110 |
| 117 /* The input and output encrypted as though 128bit ofb mode is being | 111 /* The input and output encrypted as though 128bit ofb mode is being |
| 118 * used. The extra state information to record how much of the | 112 * used. The extra state information to record how much of the |
| 119 * 128bit block we have used is contained in *num; | 113 * 128bit block we have used is contained in *num; |
| 120 */ | 114 */ |
| 121 void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, | 115 void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, |
| 122 » const unsigned long length, const CAMELLIA_KEY *key, | 116 » size_t length, const CAMELLIA_KEY *key, |
| 123 unsigned char *ivec, int *num) { | 117 unsigned char *ivec, int *num) { |
| 124 | 118 » CRYPTO_ofb128_encrypt(in,out,length,key,ivec,num,(block128_f)Camellia_en
crypt); |
| 125 » unsigned int n; | |
| 126 » unsigned long l=length; | |
| 127 | |
| 128 » assert(in && out && key && ivec && num); | |
| 129 | |
| 130 » n = *num; | |
| 131 | |
| 132 » while (l--) { | |
| 133 » » if (n == 0) { | |
| 134 » » » Camellia_encrypt(ivec, ivec, key); | |
| 135 » » } | |
| 136 » » *(out++) = *(in++) ^ ivec[n]; | |
| 137 » » n = (n+1) % CAMELLIA_BLOCK_SIZE; | |
| 138 » } | |
| 139 | |
| 140 » *num=n; | |
| 141 } | 119 } |
| OLD | NEW |