]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - linux/crypto/poly1305_generic.c
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.
[bcachefs-tools-debian] / linux / crypto / poly1305_generic.c
index 5d385d5415fdfa571b6711aa7fa3a391fb6fc1c7..acb554c04015d5ff87b7b5d23d8e5e2acf7b500c 100644 (file)
 
 #include <linux/crypto.h>
 #include <crypto/algapi.h>
-#include <crypto/internal/hash.h>
+#include <crypto/hash.h>
 #include <crypto/poly1305.h>
 
+static struct shash_alg poly1305_alg;
+
 struct poly1305_desc_ctx {
        bool                                    key_done;
        crypto_onetimeauth_poly1305_state       s;
 };
 
-
 static int poly1305_init(struct shash_desc *desc)
 {
-       struct poly1305_desc_ctx *state = shash_desc_ctx(desc);
+       struct poly1305_desc_ctx *state = (void *) desc->ctx;
 
        state->key_done = false;
        return 0;
@@ -38,7 +39,7 @@ static int poly1305_init(struct shash_desc *desc)
 static int poly1305_update(struct shash_desc *desc,
                           const u8 *src, unsigned len)
 {
-       struct poly1305_desc_ctx *state = shash_desc_ctx(desc);
+       struct poly1305_desc_ctx *state = (void *) desc->ctx;
 
        if (!state->key_done) {
                BUG_ON(len != crypto_onetimeauth_poly1305_KEYBYTES);
@@ -52,21 +53,32 @@ static int poly1305_update(struct shash_desc *desc,
 
 static int poly1305_final(struct shash_desc *desc, u8 *out)
 {
-       struct poly1305_desc_ctx *state = shash_desc_ctx(desc);
+       struct poly1305_desc_ctx *state = (void *) desc->ctx;
 
        return crypto_onetimeauth_poly1305_final(&state->s, out);
 }
 
+static void *poly1305_alloc_tfm(void)
+{
+       struct crypto_shash *tfm = kzalloc(sizeof(*tfm), GFP_KERNEL);
+
+       if (!tfm)
+               return NULL;
+
+       tfm->base.alg = &poly1305_alg.base;
+       tfm->descsize = sizeof(struct poly1305_desc_ctx);
+       return tfm;
+}
+
 static struct shash_alg poly1305_alg = {
        .digestsize     = crypto_onetimeauth_poly1305_BYTES,
        .init           = poly1305_init,
        .update         = poly1305_update,
        .final          = poly1305_final,
        .descsize       = sizeof(struct poly1305_desc_ctx),
-       .base           = {
-               .cra_name       = "poly1305",
-               .cra_flags      = CRYPTO_ALG_TYPE_SHASH,
-       },
+
+       .base.cra_name  = "poly1305",
+       .base.alloc_tfm = poly1305_alloc_tfm,
 };
 
 __attribute__((constructor(110)))