| OLD | NEW |
| 1 /* crypto/seed/seed_cfb.c -*- mode:C; c-file-style: "eay" -*- */ | 1 /* crypto/seed/seed_cfb.c -*- mode:C; c-file-style: "eay" -*- */ |
| 2 /* ==================================================================== | 2 /* ==================================================================== |
| 3 * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. | 3 * Copyright (c) 1998-2007 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 #include "seed_locl.h" | 108 #include <openssl/seed.h> |
| 109 #include <string.h> | 109 #include <openssl/modes.h> |
| 110 | 110 |
| 111 void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, | 111 void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, |
| 112 size_t len, const SEED_KEY_SCHEDULE *ks, | 112 size_t len, const SEED_KEY_SCHEDULE *ks, |
| 113 unsigned char ivec[SEED_BLOCK_SIZE], int *num, int enc) | 113 unsigned char ivec[SEED_BLOCK_SIZE], int *num, int enc) |
| 114 { | 114 { |
| 115 » int n; | 115 » CRYPTO_cfb128_encrypt(in,out,len,ks,ivec,num,enc,(block128_f)SEED_encryp
t); |
| 116 » unsigned char c; | |
| 117 | |
| 118 » n = *num; | |
| 119 | |
| 120 » if (enc) | |
| 121 » » { | |
| 122 » » while (len--) | |
| 123 » » » { | |
| 124 » » » if (n == 0) | |
| 125 » » » » SEED_encrypt(ivec, ivec, ks); | |
| 126 » » » ivec[n] = *(out++) = *(in++) ^ ivec[n]; | |
| 127 » » » n = (n+1) % SEED_BLOCK_SIZE; | |
| 128 » » » } | |
| 129 » » } | |
| 130 » else | |
| 131 » » { | |
| 132 » » while (len--) | |
| 133 » » » { | |
| 134 » » » if (n == 0) | |
| 135 » » » » SEED_encrypt(ivec, ivec, ks); | |
| 136 » » » c = *(in); | |
| 137 » » » *(out++) = *(in++) ^ ivec[n]; | |
| 138 » » » ivec[n] = c; | |
| 139 » » » n = (n+1) % SEED_BLOCK_SIZE; | |
| 140 » » » } | |
| 141 » » } | |
| 142 | |
| 143 » *num = n; | |
| 144 } | 116 } |
| OLD | NEW |