]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/rc5/rc5_skey.c
2 * Copyright 1995-2016 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 * RC5 low level APIs are deprecated for public use, but still ok for internal
14 #include "internal/deprecated.h"
16 #include <openssl/rc5.h>
17 #include "rc5_local.h"
19 int RC5_32_set_key(RC5_32_KEY
*key
, int len
, const unsigned char *data
,
22 RC5_32_INT L
[64], l
, ll
, A
, B
, *S
, k
;
23 int i
, j
, m
, c
, t
, ii
, jj
;
28 if ((rounds
!= RC5_16_ROUNDS
) &&
29 (rounds
!= RC5_12_ROUNDS
) && (rounds
!= RC5_8_ROUNDS
))
30 rounds
= RC5_16_ROUNDS
;
35 for (i
= 0; i
<= (len
- 8); i
+= 8) {
52 for (i
= 1; i
< t
; i
++)
53 S
[i
] = (S
[i
- 1] + RC5_32_Q
) & RC5_32_MASK
;
59 for (i
= 0; i
< j
; i
++) {
60 k
= (S
[ii
] + A
+ B
) & RC5_32_MASK
;
61 A
= S
[ii
] = ROTATE_l32(k
, 3);
63 k
= (L
[jj
] + A
+ B
) & RC5_32_MASK
;
64 B
= L
[jj
] = ROTATE_l32(k
, m
);