]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/modes/ofb128.c
2 * Copyright 2008-2021 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
11 #include <openssl/crypto.h>
12 #include "crypto/modes.h"
14 #if defined(__GNUC__) && !defined(STRICT_ALIGNMENT)
15 typedef size_t size_t_aX
__attribute((__aligned__(1)));
17 typedef size_t size_t_aX
;
21 * The input and output encrypted as though 128bit ofb mode is being used.
22 * The extra state information to record how much of the 128bit block we have
23 * used is contained in *num;
25 void CRYPTO_ofb128_encrypt(const unsigned char *in
, unsigned char *out
,
26 size_t len
, const void *key
,
27 unsigned char ivec
[16], int *num
, block128_f block
)
33 /* There is no good way to signal an error return from here */
39 #if !defined(OPENSSL_SMALL_FOOTPRINT)
40 if (16 % sizeof(size_t) == 0) { /* always true actually */
43 *(out
++) = *(in
++) ^ ivec
[n
];
47 # if defined(STRICT_ALIGNMENT)
48 if (((size_t)in
| (size_t)out
| (size_t)ivec
) % sizeof(size_t) !=
53 (*block
) (ivec
, ivec
, key
);
54 for (; n
< 16; n
+= sizeof(size_t))
55 *(size_t_aX
*)(out
+ n
) =
56 *(size_t_aX
*)(in
+ n
)
57 ^ *(size_t_aX
*)(ivec
+ n
);
64 (*block
) (ivec
, ivec
, key
);
66 out
[n
] = in
[n
] ^ ivec
[n
];
74 /* the rest would be commonly eliminated by x86* compiler */
78 (*block
) (ivec
, ivec
, key
);
80 out
[l
] = in
[l
] ^ ivec
[n
];