2 * Copyright 1995-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
13 * The input and output are loaded in multiples of 8 bits. What this means is
14 * that if you have numbits=12 and length=2 the first 12 bits will be
15 * retrieved from the first byte and half the second. The second 12 bits
16 * will come from the 3rd and half the 4th byte.
18 void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
19 long length, DES_key_schedule *schedule,
22 register DES_LONG d0, d1, vv0, vv1, v0, v1, n = (numbits + 7) / 8;
23 register DES_LONG mask0, mask1;
24 register long l = length;
25 register int num = numbits;
36 mask1 = (1L << (num - 32)) - 1;
41 mask0 = (1L << num) - 1;
53 DES_encrypt1((DES_LONG *)ti, schedule, DES_ENCRYPT);
58 d0 = (d0 ^ vv0) & mask0;
59 d1 = (d1 ^ vv1) & mask1;
66 } else if (num == 64) {
69 } else if (num > 32) { /* && num != 64 */
70 v0 = ((v1 >> (num - 32)) | (vv0 << (64 - num))) & 0xffffffffL;
71 v1 = ((vv0 >> (num - 32)) | (vv1 << (64 - num))) & 0xffffffffL;
72 } else { /* num < 32 */
74 v0 = ((v0 >> num) | (v1 << (32 - num))) & 0xffffffffL;
75 v1 = ((v1 >> num) | (vv0 << (32 - num))) & 0xffffffffL;
81 v0 = v1 = d0 = d1 = ti[0] = ti[1] = vv0 = vv1 = 0;