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
10 #include <openssl/idea.h>
13 void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out,
14 long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv,
17 register unsigned long tin0, tin1;
18 register unsigned long tout0, tout1, xor0, xor1;
19 register long l = length;
26 for (l -= 8; l >= 0; l -= 8) {
33 IDEA_encrypt(tin, ks);
40 n2ln(in, tin0, tin1, l + 8);
45 IDEA_encrypt(tin, ks);
57 for (l -= 8; l >= 0; l -= 8) {
62 IDEA_encrypt(tin, ks);
63 tout0 = tin[0] ^ xor0;
64 tout1 = tin[1] ^ xor1;
75 IDEA_encrypt(tin, ks);
76 tout0 = tin[0] ^ xor0;
77 tout1 = tin[1] ^ xor1;
78 l2nn(tout0, tout1, out, l + 8);
85 tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0;
89 void IDEA_encrypt(unsigned long *d, IDEA_KEY_SCHEDULE *key)
92 register unsigned long x1, x2, x3, x4, t0, t1, ul;
99 p = &(key->data[0][0]);
111 idea_mul(x1, x1, *p, ul);
118 idea_mul(x4, x4, *p, ul);
120 d[0] = (t0 & 0xffff) | ((x1 & 0xffff) << 16);
121 d[1] = (x4 & 0xffff) | ((t1 & 0xffff) << 16);