git.openpandora.org
/
pandora-kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[pandora-kernel.git]
/
crypto
/
serpent.c
diff --git
a/crypto/serpent.c
b/crypto/serpent.c
index
e366406
..
b651a55
100644
(file)
--- a/
crypto/serpent.c
+++ b/
crypto/serpent.c
@@
-215,20
+215,15
@@
struct serpent_ctx {
};
};
-static int serpent_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
+static int serpent_setkey(struct crypto_tfm *tfm, const u8 *key,
+ unsigned int keylen)
{
{
- u32 *k = ((struct serpent_ctx *)ctx)->expkey;
+ struct serpent_ctx *ctx = crypto_tfm_ctx(tfm);
+ u32 *k = ctx->expkey;
u8 *k8 = (u8 *)k;
u32 r0,r1,r2,r3,r4;
int i;
u8 *k8 = (u8 *)k;
u32 r0,r1,r2,r3,r4;
int i;
- if ((keylen < SERPENT_MIN_KEY_SIZE)
- || (keylen > SERPENT_MAX_KEY_SIZE))
- {
- *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
- return -EINVAL;
- }
-
/* Copy key, add padding */
for (i = 0; i < keylen; ++i)
/* Copy key, add padding */
for (i = 0; i < keylen; ++i)
@@
-365,13
+360,14
@@
static int serpent_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *fl
return 0;
}
return 0;
}
-static void serpent_encrypt(
void *ctx
, u8 *dst, const u8 *src)
+static void serpent_encrypt(
struct crypto_tfm *tfm
, u8 *dst, const u8 *src)
{
{
+ struct serpent_ctx *ctx = crypto_tfm_ctx(tfm);
const u32
const u32
- *k =
((struct serpent_ctx *)ctx)->expkey,
-
*s = (const u
32 *)src;
- u32 *d = (u32 *)dst,
-
r0, r1, r2, r3, r4;
+ *k =
ctx->expkey;
+
const __le32 *s = (const __le
32 *)src;
+ __le32 *d = (__le32 *)dst;
+
u32
r0, r1, r2, r3, r4;
/*
* Note: The conversions between u8* and u32* might cause trouble
/*
* Note: The conversions between u8* and u32* might cause trouble
@@
-423,13
+419,14
@@
static void serpent_encrypt(void *ctx, u8 *dst, const u8 *src)
d[3] = cpu_to_le32(r3);
}
d[3] = cpu_to_le32(r3);
}
-static void serpent_decrypt(
void *ctx
, u8 *dst, const u8 *src)
+static void serpent_decrypt(
struct crypto_tfm *tfm
, u8 *dst, const u8 *src)
{
{
+ struct serpent_ctx *ctx = crypto_tfm_ctx(tfm);
const u32
const u32
- *k = ((struct serpent_ctx *)ctx)->expkey
,
-
*s = (const u
32 *)src;
- u32 *d = (u32 *)dst,
-
r0, r1, r2, r3, r4;
+ *k = ((struct serpent_ctx *)ctx)->expkey
;
+
const __le32 *s = (const __le
32 *)src;
+ __le32 *d = (__le32 *)dst;
+
u32
r0, r1, r2, r3, r4;
r0 = le32_to_cpu(s[0]);
r1 = le32_to_cpu(s[1]);
r0 = le32_to_cpu(s[0]);
r1 = le32_to_cpu(s[1]);
@@
-492,24
+489,19
@@
static struct crypto_alg serpent_alg = {
.cia_decrypt = serpent_decrypt } }
};
.cia_decrypt = serpent_decrypt } }
};
-static int tnepres_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
+static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key,
+ unsigned int keylen)
{
u8 rev_key[SERPENT_MAX_KEY_SIZE];
int i;
{
u8 rev_key[SERPENT_MAX_KEY_SIZE];
int i;
- if ((keylen < SERPENT_MIN_KEY_SIZE)
- || (keylen > SERPENT_MAX_KEY_SIZE)) {
- *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
- return -EINVAL;
- }
-
for (i = 0; i < keylen; ++i)
rev_key[keylen - i - 1] = key[i];
for (i = 0; i < keylen; ++i)
rev_key[keylen - i - 1] = key[i];
- return serpent_setkey(
ctx, rev_key, keylen, flags
);
+ return serpent_setkey(
tfm, rev_key, keylen
);
}
}
-static void tnepres_encrypt(
void *ctx
, u8 *dst, const u8 *src)
+static void tnepres_encrypt(
struct crypto_tfm *tfm
, u8 *dst, const u8 *src)
{
const u32 * const s = (const u32 * const)src;
u32 * const d = (u32 * const)dst;
{
const u32 * const s = (const u32 * const)src;
u32 * const d = (u32 * const)dst;
@@
-521,7
+513,7
@@
static void tnepres_encrypt(void *ctx, u8 *dst, const u8 *src)
rs[2] = swab32(s[1]);
rs[3] = swab32(s[0]);
rs[2] = swab32(s[1]);
rs[3] = swab32(s[0]);
- serpent_encrypt(
ctx
, (u8 *)rd, (u8 *)rs);
+ serpent_encrypt(
tfm
, (u8 *)rd, (u8 *)rs);
d[0] = swab32(rd[3]);
d[1] = swab32(rd[2]);
d[0] = swab32(rd[3]);
d[1] = swab32(rd[2]);
@@
-529,7
+521,7
@@
static void tnepres_encrypt(void *ctx, u8 *dst, const u8 *src)
d[3] = swab32(rd[0]);
}
d[3] = swab32(rd[0]);
}
-static void tnepres_decrypt(
void *ctx
, u8 *dst, const u8 *src)
+static void tnepres_decrypt(
struct crypto_tfm *tfm
, u8 *dst, const u8 *src)
{
const u32 * const s = (const u32 * const)src;
u32 * const d = (u32 * const)dst;
{
const u32 * const s = (const u32 * const)src;
u32 * const d = (u32 * const)dst;
@@
-541,7
+533,7
@@
static void tnepres_decrypt(void *ctx, u8 *dst, const u8 *src)
rs[2] = swab32(s[1]);
rs[3] = swab32(s[0]);
rs[2] = swab32(s[1]);
rs[3] = swab32(s[0]);
- serpent_decrypt(
ctx
, (u8 *)rd, (u8 *)rs);
+ serpent_decrypt(
tfm
, (u8 *)rd, (u8 *)rs);
d[0] = swab32(rd[3]);
d[1] = swab32(rd[2]);
d[0] = swab32(rd[3]);
d[1] = swab32(rd[2]);
@@
-565,7
+557,7
@@
static struct crypto_alg tnepres_alg = {
.cia_decrypt = tnepres_decrypt } }
};
.cia_decrypt = tnepres_decrypt } }
};
-static int __init init(void)
+static int __init
serpent_mod_
init(void)
{
int ret = crypto_register_alg(&serpent_alg);
{
int ret = crypto_register_alg(&serpent_alg);
@@
-580,14
+572,14
@@
static int __init init(void)
return ret;
}
return ret;
}
-static void __exit fini(void)
+static void __exit
serpent_mod_
fini(void)
{
crypto_unregister_alg(&tnepres_alg);
crypto_unregister_alg(&serpent_alg);
}
{
crypto_unregister_alg(&tnepres_alg);
crypto_unregister_alg(&serpent_alg);
}
-module_init(init);
-module_exit(fini);
+module_init(
serpent_mod_
init);
+module_exit(
serpent_mod_
fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm");