projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added SILC Thread Queue API
[silc.git]
/
lib
/
silccrypt
/
rc5.c
diff --git
a/lib/silccrypt/rc5.c
b/lib/silccrypt/rc5.c
index 34afc43fac0064b0dd8448ab8050330378f4939e..290d311089e27306fdc4a0b4c2c2cfc76dd9b2ac 100644
(file)
--- a/
lib/silccrypt/rc5.c
+++ b/
lib/silccrypt/rc5.c
@@
-30,27
+30,27
@@
*/
/*
*/
/*
- * Based on RC5 reference code and on description of Bruce Schneier's
+ * Based on RC5 reference code and on description of Bruce Schneier's
* Applied Cryptography.
*
* Applied Cryptography.
*
- * This implementation has a word size of 32 bits, a rounds of 16 and
+ * This implementation has a word size of 32 bits, a rounds of 16 and
* variable key length from 128 and 192 up to 256 bits.
*
*/
* variable key length from 128 and 192 up to 256 bits.
*
*/
-#include "silc
includes
.h"
+#include "silc.h"
#include "rc5_internal.h"
#include "rc5.h"
#include "rc5_internal.h"
#include "rc5.h"
-/*
+/*
* SILC Crypto API for RC5
*/
/* Sets the key for the cipher. */
* SILC Crypto API for RC5
*/
/* Sets the key for the cipher. */
-SILC_CIPHER_API_SET_KEY(rc5)
+SILC_CIPHER_API_SET_KEY(rc5
_cbc
)
{
{
-
ui
nt32 k[8];
+
SilcUI
nt32 k[8];
SILC_GET_WORD_KEY(key, k, keylen);
rc5_set_key((RC5Context *)context, k, keylen);
SILC_GET_WORD_KEY(key, k, keylen);
rc5_set_key((RC5Context *)context, k, keylen);
@@
-58,17
+58,16
@@
SILC_CIPHER_API_SET_KEY(rc5)
return TRUE;
}
return TRUE;
}
-/* Sets the string as a new key for the cipher. The string is first
- hashed and then used as a new key. */
+/* Sets IV for the cipher. */
-SILC_CIPHER_API_SET_
KEY_WITH_STRING(rc5
)
+SILC_CIPHER_API_SET_
IV(rc5_cbc
)
{
{
- return 1;
+
}
/* Returns the size of the cipher context. */
}
/* Returns the size of the cipher context. */
-SILC_CIPHER_API_CONTEXT_LEN(rc5)
+SILC_CIPHER_API_CONTEXT_LEN(rc5
_cbc
)
{
return sizeof(RC5Context);
}
{
return sizeof(RC5Context);
}
@@
-76,9
+75,9
@@
SILC_CIPHER_API_CONTEXT_LEN(rc5)
/* Encrypts with the cipher in CBC mode. Source and destination buffers
maybe one and same. */
/* Encrypts with the cipher in CBC mode. Source and destination buffers
maybe one and same. */
-SILC_CIPHER_API_ENCRYPT
_CBC(rc5
)
+SILC_CIPHER_API_ENCRYPT
(rc5_cbc
)
{
{
-
ui
nt32 tiv[4];
+
SilcUI
nt32 tiv[4];
int i;
SILC_CBC_GET_IV(tiv, iv);
int i;
SILC_CBC_GET_IV(tiv, iv);
@@
-101,9
+100,9
@@
SILC_CIPHER_API_ENCRYPT_CBC(rc5)
/* Decrypts with the cipher in CBC mode. Source and destination buffers
maybe one and same. */
/* Decrypts with the cipher in CBC mode. Source and destination buffers
maybe one and same. */
-SILC_CIPHER_API_DECRYPT
_CBC(rc5
)
+SILC_CIPHER_API_DECRYPT
(rc5_cbc
)
{
{
-
ui
nt32 tmp[4], tmp2[4], tiv[4];
+
SilcUI
nt32 tmp[4], tmp2[4], tiv[4];
int i;
SILC_CBC_GET_IV(tiv, iv);
int i;
SILC_CBC_GET_IV(tiv, iv);
@@
-114,12
+113,12
@@
SILC_CIPHER_API_DECRYPT_CBC(rc5)
for (i = 16; i < len; i += 16) {
SILC_CBC_DEC_PRE(tmp, src);
for (i = 16; i < len; i += 16) {
SILC_CBC_DEC_PRE(tmp, src);
- rc5_decrypt((RC5Context *)context, tmp, tmp2);
+ rc5_decrypt((RC5Context *)context, tmp, tmp2);
SILC_CBC_DEC_POST(tmp2, dst, src, tmp, tiv);
}
SILC_CBC_DEC_POST(tmp2, dst, src, tmp, tiv);
}
-
+
SILC_CBC_PUT_IV(tiv, iv);
SILC_CBC_PUT_IV(tiv, iv);
-
+
return TRUE;
}
return TRUE;
}
@@
-139,7
+138,7
@@
SILC_CIPHER_API_DECRYPT_CBC(rc5)
/* Sets RC5 key */
/* Sets RC5 key */
-int rc5_set_key(RC5Context *ctx, const
ui
nt32 in_key[], int key_len)
+int rc5_set_key(RC5Context *ctx, const
SilcUI
nt32 in_key[], int key_len)
{
u32 i, j, k, A, B, L[c];
u32 *out_key = ctx->out_key;
{
u32 i, j, k, A, B, L[c];
u32 *out_key = ctx->out_key;
@@
-206,9
+205,9
@@
int rc5_decrypt(RC5Context *ctx, u32 *in, u32 *out)
A = in[0];
B = in[1];
A = in[0];
B = in[1];
- RC5D(32, A, B); RC5D(30, A, B);
- RC5D(28, A, B); RC5D(26, A, B);
- RC5D(24, A, B); RC5D(22, A, B);
+ RC5D(32, A, B); RC5D(30, A, B);
+ RC5D(28, A, B); RC5D(26, A, B);
+ RC5D(24, A, B); RC5D(22, A, B);
RC5D(20, A, B); RC5D(18, A, B);
RC5D(16, A, B); RC5D(14, A, B);
RC5D(12, A, B); RC5D(10, A, B);
RC5D(20, A, B); RC5D(18, A, B);
RC5D(16, A, B); RC5D(14, A, B);
RC5D(12, A, B); RC5D(10, A, B);
@@
-219,4
+218,4
@@
int rc5_decrypt(RC5Context *ctx, u32 *in, u32 *out)
out[1] = B - S[1];
return 0;
out[1] = B - S[1];
return 0;
-}
+}