X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=crypto%2Flrw.c;h=358f80be2bf97d128ebd648887325a01ea051a70;hb=06164f3194e01ea4c76941ac60f541d656c8975f;hp=b4105080ac7aa9d5886ea28772cfea6101197d27;hpb=2e306ee016fd4750289e65c3b1856db569f1f3f2;p=safe%2Fjmp%2Flinux-2.6 diff --git a/crypto/lrw.c b/crypto/lrw.c index b410508..358f80b 100644 --- a/crypto/lrw.c +++ b/crypto/lrw.c @@ -45,7 +45,13 @@ struct priv { static inline void setbit128_bbe(void *b, int bit) { - __set_bit(bit ^ 0x78, b); + __set_bit(bit ^ (0x80 - +#ifdef __BIG_ENDIAN + BITS_PER_LONG +#else + BITS_PER_BYTE +#endif + ), b); } static int setkey(struct crypto_tfm *parent, const u8 *key, @@ -91,8 +97,9 @@ struct sinfo { static inline void inc(be128 *iv) { - if (!(iv->b = cpu_to_be64(be64_to_cpu(iv->b) + 1))) - iv->a = cpu_to_be64(be64_to_cpu(iv->a) + 1); + be64_add_cpu(&iv->b, 1); + if (!iv->b) + be64_add_cpu(&iv->a, 1); } static inline void lrw_round(struct sinfo *s, void *dst, const void *src) @@ -228,15 +235,20 @@ static void exit_tfm(struct crypto_tfm *tfm) crypto_free_cipher(ctx->child); } -static struct crypto_instance *alloc(void *param, unsigned int len) +static struct crypto_instance *alloc(struct rtattr **tb) { struct crypto_instance *inst; struct crypto_alg *alg; + int err; + + err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_BLKCIPHER); + if (err) + return ERR_PTR(err); - alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER, - CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); + alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER, + CRYPTO_ALG_TYPE_MASK); if (IS_ERR(alg)) - return ERR_PTR(PTR_ERR(alg)); + return ERR_CAST(alg); inst = crypto_alloc_instance("lrw", alg); if (IS_ERR(inst))