]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/idea/i_cbc.c
2 * Copyright 1995-2020 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 * IDEA low level APIs are deprecated for public use, but still ok for internal
12 * use where we're using them to implement the higher level EVP interface, as is
15 #include "internal/deprecated.h"
17 #include <openssl/idea.h>
18 #include "idea_local.h"
20 void IDEA_cbc_encrypt(const unsigned char *in
, unsigned char *out
,
21 long length
, IDEA_KEY_SCHEDULE
*ks
, unsigned char *iv
,
24 register unsigned long tin0
, tin1
;
25 register unsigned long tout0
, tout1
, xor0
, xor1
;
26 register long l
= length
;
33 for (l
-= 8; l
>= 0; l
-= 8) {
40 IDEA_encrypt(tin
, ks
);
47 n2ln(in
, tin0
, tin1
, l
+ 8);
52 IDEA_encrypt(tin
, ks
);
64 for (l
-= 8; l
>= 0; l
-= 8) {
69 IDEA_encrypt(tin
, ks
);
70 tout0
= tin
[0] ^ xor0
;
71 tout1
= tin
[1] ^ xor1
;
82 IDEA_encrypt(tin
, ks
);
83 tout0
= tin
[0] ^ xor0
;
84 tout1
= tin
[1] ^ xor1
;
85 l2nn(tout0
, tout1
, out
, l
+ 8);
92 tin0
= tin1
= tout0
= tout1
= xor0
= xor1
= 0;
96 void IDEA_encrypt(unsigned long *d
, IDEA_KEY_SCHEDULE
*key
)
99 register unsigned long x1
, x2
, x3
, x4
, t0
, t1
, ul
;
106 p
= &(key
->data
[0][0]);
118 idea_mul(x1
, x1
, *p
, ul
);
125 idea_mul(x4
, x4
, *p
, ul
);
127 d
[0] = (t0
& 0xffff) | ((x1
& 0xffff) << 16);
128 d
[1] = (x4
& 0xffff) | ((t1
& 0xffff) << 16);