Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
[linux-2.6-block.git] / crypto / poly1305_generic.c
index b1c2d57dc734a3dab70c6321ef80790477c3dbbf..b7a3a0613a30781a62d730e3b1b61a74d17ee53b 100644 (file)
@@ -47,17 +47,6 @@ int crypto_poly1305_init(struct shash_desc *desc)
 }
 EXPORT_SYMBOL_GPL(crypto_poly1305_init);
 
-int crypto_poly1305_setkey(struct crypto_shash *tfm,
-                          const u8 *key, unsigned int keylen)
-{
-       /* Poly1305 requires a unique key for each tag, which implies that
-        * we can't set it on the tfm that gets accessed by multiple users
-        * simultaneously. Instead we expect the key as the first 32 bytes in
-        * the update() call. */
-       return -ENOTSUPP;
-}
-EXPORT_SYMBOL_GPL(crypto_poly1305_setkey);
-
 static void poly1305_setrkey(struct poly1305_desc_ctx *dctx, const u8 *key)
 {
        /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
@@ -76,6 +65,11 @@ static void poly1305_setskey(struct poly1305_desc_ctx *dctx, const u8 *key)
        dctx->s[3] = get_unaligned_le32(key + 12);
 }
 
+/*
+ * Poly1305 requires a unique key for each tag, which implies that we can't set
+ * it on the tfm that gets accessed by multiple users simultaneously. Instead we
+ * expect the key as the first 32 bytes in the update() call.
+ */
 unsigned int crypto_poly1305_setdesckey(struct poly1305_desc_ctx *dctx,
                                        const u8 *src, unsigned int srclen)
 {
@@ -210,7 +204,6 @@ EXPORT_SYMBOL_GPL(crypto_poly1305_update);
 int crypto_poly1305_final(struct shash_desc *desc, u8 *dst)
 {
        struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
-       __le32 *mac = (__le32 *)dst;
        u32 h0, h1, h2, h3, h4;
        u32 g0, g1, g2, g3, g4;
        u32 mask;
@@ -267,10 +260,10 @@ int crypto_poly1305_final(struct shash_desc *desc, u8 *dst)
        h3 = (h3 >> 18) | (h4 <<  8);
 
        /* mac = (h + s) % (2^128) */
-       f = (f >> 32) + h0 + dctx->s[0]; mac[0] = cpu_to_le32(f);
-       f = (f >> 32) + h1 + dctx->s[1]; mac[1] = cpu_to_le32(f);
-       f = (f >> 32) + h2 + dctx->s[2]; mac[2] = cpu_to_le32(f);
-       f = (f >> 32) + h3 + dctx->s[3]; mac[3] = cpu_to_le32(f);
+       f = (f >> 32) + h0 + dctx->s[0]; put_unaligned_le32(f, dst +  0);
+       f = (f >> 32) + h1 + dctx->s[1]; put_unaligned_le32(f, dst +  4);
+       f = (f >> 32) + h2 + dctx->s[2]; put_unaligned_le32(f, dst +  8);
+       f = (f >> 32) + h3 + dctx->s[3]; put_unaligned_le32(f, dst + 12);
 
        return 0;
 }
@@ -281,14 +274,12 @@ static struct shash_alg poly1305_alg = {
        .init           = crypto_poly1305_init,
        .update         = crypto_poly1305_update,
        .final          = crypto_poly1305_final,
-       .setkey         = crypto_poly1305_setkey,
        .descsize       = sizeof(struct poly1305_desc_ctx),
        .base           = {
                .cra_name               = "poly1305",
                .cra_driver_name        = "poly1305-generic",
                .cra_priority           = 100,
                .cra_flags              = CRYPTO_ALG_TYPE_SHASH,
-               .cra_alignmask          = sizeof(u32) - 1,
                .cra_blocksize          = POLY1305_BLOCK_SIZE,
                .cra_module             = THIS_MODULE,
        },