Commit 7e4f0114 authored by Niels Möller's avatar Niels Möller
Browse files

(crypto_invert): Deleted function.

(gcd): Deleted function.
(lcm): Deleted function.

Rev: src/abstract_crypto.c:1.19
Rev: src/abstract_crypto.h:1.37
parent 3e7a722f
......@@ -35,45 +35,6 @@
#include "abstract_crypto.h.x"
#undef GABA_DEFINE
#include "abstract_crypto.c.x"
/* Combining block cryptos */
/* Inverts the encryption mode (needed for the EDE-operation of
* triple DES). */
/* GABA:
(class
(name crypto_inverted)
(super crypto_algorithm)
(vars
(inner object crypto_algorithm)))
*/
static struct crypto_instance *
do_make_inverted(struct crypto_algorithm *s,
int mode, const UINT8 *key, const UINT8 *iv)
{
CAST(crypto_inverted, self, s);
return MAKE_CRYPT(self->inner, ( (mode == CRYPTO_ENCRYPT)
? CRYPTO_DECRYPT
: CRYPTO_ENCRYPT),
key, iv);
}
struct crypto_algorithm *crypto_invert(struct crypto_algorithm *inner)
{
NEW(crypto_inverted, algorithm);
algorithm->super.block_size = inner->block_size;
algorithm->super.key_size = inner->key_size;
algorithm->super.iv_size = inner->iv_size;
algorithm->inner = inner;
algorithm->super.make_crypt = do_make_inverted;
return &algorithm->super;
}
struct lsh_string *
hash_string(struct hash_algorithm *a,
......@@ -184,61 +145,3 @@ crypt_string_unpad(struct crypto_instance *c,
return NULL;
}
}
/* FIXME: These functions don't really belong here. */
UINT32 gcd(UINT32 x, UINT32 y)
{
UINT32 res = 1;
if (!x)
return y;
if (!y)
return x;
while (! (x%2) && !(y%2) )
{
x /= 2; y /= 2; res *= 2;
}
if (!(x % 2))
{
/* x is even. Swap */
UINT32 tmp = x;
x = y;
y = tmp;
}
for (;;)
{
/* During this loop, x is always odd */
assert(x % 2);
if (!y)
return x * res;
while (!(y % 2))
y /= 2;
if (x < y)
y -= x;
else
{ /* x >= y */
UINT32 d = x-y;
x = y;
y = d;
}
}
}
UINT32 lcm(UINT32 x, UINT32 y)
{
UINT32 g = gcd(x, y);
assert(!(x % g) && ! (y % g));
return x * (y / g);
}
......@@ -193,25 +193,6 @@
((a)->make_verifier((a), (i)))
/* Combining block cryptos */
/* Example: To create a tripple DES cbc encryptor:
*
* struct crypto_algorithm des3_cbc
* = make_cbc(crypto_cascade(3, des_algorithm,
* crypto_invert(des_algorithm)
* des_algorithm, -1));
*/
struct crypto_algorithm *crypto_cbc(struct crypto_algorithm *inner);
struct crypto_algorithm *crypto_invert(struct crypto_algorithm *inner);
struct crypto_algorithm *crypto_cascadel(struct object_list *cascade);
struct crypto_algorithm *crypto_cascade(unsigned n, ...);
/* Utility functions */
UINT32 gcd(UINT32 x, UINT32 y);
UINT32 lcm(UINT32 x, UINT32 y);
/* Simple hashing */
struct lsh_string *
hash_string(struct hash_algorithm *a,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment