]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - include/crypto/skcipher.h
Update bcachefs sources to ef60854e99 bcachefs: More allocator startup improvements
[bcachefs-tools-debian] / include / crypto / skcipher.h
index c9e887c985ef8bf2983327e497075eebf959a910..5989855d1894bf28efa883a07d38233061af9399 100644 (file)
@@ -36,14 +36,29 @@ struct crypto_skcipher {
        struct crypto_tfm       base;
 };
 
+struct crypto_sync_skcipher {
+       struct crypto_skcipher base;
+};
+
 struct crypto_skcipher *crypto_alloc_skcipher(const char *alg_name,
                                              u32 type, u32 mask);
 
+static inline struct crypto_sync_skcipher *
+crypto_alloc_sync_skcipher(const char *alg_name, u32 type, u32 mask)
+{
+       return (void *) crypto_alloc_skcipher(alg_name, type, mask);
+}
+
 static inline void crypto_free_skcipher(struct crypto_skcipher *tfm)
 {
        kfree(tfm);
 }
 
+static inline void crypto_free_sync_skcipher(struct crypto_sync_skcipher *tfm)
+{
+       crypto_free_skcipher(&tfm->base);
+}
+
 struct skcipher_request {
        unsigned                cryptlen;
        u8                      *iv;
@@ -54,9 +69,14 @@ struct skcipher_request {
        struct crypto_tfm       *tfm;
 };
 
-#define SKCIPHER_REQUEST_ON_STACK(name, tfm)                   \
-       struct skcipher_request __##name##_desc;                \
-       struct skcipher_request *name = &__##name##_desc
+#define MAX_SYNC_SKCIPHER_REQSIZE      384
+#define SYNC_SKCIPHER_REQUEST_ON_STACK(name, tfm) \
+       char __##name##_desc[sizeof(struct skcipher_request) + \
+                            MAX_SYNC_SKCIPHER_REQSIZE + \
+                            (!(sizeof((struct crypto_sync_skcipher *)1 == \
+                                      (typeof(tfm))1))) \
+                           ] CRYPTO_MINALIGN_ATTR; \
+       struct skcipher_request *name = (void *)__##name##_desc
 
 static inline int crypto_skcipher_setkey(struct crypto_skcipher *tfm,
                                         const u8 *key, unsigned int keylen)
@@ -86,6 +106,12 @@ static inline void skcipher_request_set_tfm(struct skcipher_request *req,
        req->tfm = &tfm->base;
 }
 
+static inline void skcipher_request_set_sync_tfm(struct skcipher_request *req,
+                                           struct crypto_sync_skcipher *tfm)
+{
+       skcipher_request_set_tfm(req, &tfm->base);
+}
+
 static inline void skcipher_request_set_crypt(
        struct skcipher_request *req,
        struct scatterlist *src, struct scatterlist *dst,