2 * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/crypto.h>
11 #include "modes_lcl.h"
15 * The input and output encrypted as though 128bit ofb mode is being used.
16 * The extra state information to record how much of the 128bit block we have
17 * used is contained in *num;
19 void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
20 size_t len, const void *key,
21 unsigned char ivec[16], int *num, block128_f block)
28 #if !defined(OPENSSL_SMALL_FOOTPRINT)
29 if (16 % sizeof(size_t) == 0) { /* always true actually */
32 *(out++) = *(in++) ^ ivec[n];
36 # if defined(STRICT_ALIGNMENT)
37 if (((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) !=
42 (*block) (ivec, ivec, key);
43 for (; n < 16; n += sizeof(size_t))
44 *(size_t *)(out + n) =
45 *(size_t *)(in + n) ^ *(size_t *)(ivec + n);
52 (*block) (ivec, ivec, key);
54 out[n] = in[n] ^ ivec[n];
62 /* the rest would be commonly eliminated by x86* compiler */
66 (*block) (ivec, ivec, key);
68 out[l] = in[l] ^ ivec[n];