Path: blob/master/include/crypto/internal/skcipher.h
10818 views
/*1* Symmetric key ciphers.2*3* Copyright (c) 2007 Herbert Xu <[email protected]>4*5* This program is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License as published by the Free7* Software Foundation; either version 2 of the License, or (at your option)8* any later version.9*10*/1112#ifndef _CRYPTO_INTERNAL_SKCIPHER_H13#define _CRYPTO_INTERNAL_SKCIPHER_H1415#include <crypto/algapi.h>16#include <crypto/skcipher.h>17#include <linux/types.h>1819struct rtattr;2021struct crypto_skcipher_spawn {22struct crypto_spawn base;23};2425extern const struct crypto_type crypto_givcipher_type;2627static inline void crypto_set_skcipher_spawn(28struct crypto_skcipher_spawn *spawn, struct crypto_instance *inst)29{30crypto_set_spawn(&spawn->base, inst);31}3233int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name,34u32 type, u32 mask);3536static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn)37{38crypto_drop_spawn(&spawn->base);39}4041static inline struct crypto_alg *crypto_skcipher_spawn_alg(42struct crypto_skcipher_spawn *spawn)43{44return spawn->base.alg;45}4647static inline struct crypto_ablkcipher *crypto_spawn_skcipher(48struct crypto_skcipher_spawn *spawn)49{50return __crypto_ablkcipher_cast(51crypto_spawn_tfm(&spawn->base, crypto_skcipher_type(0),52crypto_skcipher_mask(0)));53}5455int skcipher_null_givencrypt(struct skcipher_givcrypt_request *req);56int skcipher_null_givdecrypt(struct skcipher_givcrypt_request *req);57const char *crypto_default_geniv(const struct crypto_alg *alg);5859struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl,60struct rtattr **tb, u32 type,61u32 mask);62void skcipher_geniv_free(struct crypto_instance *inst);63int skcipher_geniv_init(struct crypto_tfm *tfm);64void skcipher_geniv_exit(struct crypto_tfm *tfm);6566static inline struct crypto_ablkcipher *skcipher_geniv_cipher(67struct crypto_ablkcipher *geniv)68{69return crypto_ablkcipher_crt(geniv)->base;70}7172static inline int skcipher_enqueue_givcrypt(73struct crypto_queue *queue, struct skcipher_givcrypt_request *request)74{75return ablkcipher_enqueue_request(queue, &request->creq);76}7778static inline struct skcipher_givcrypt_request *skcipher_dequeue_givcrypt(79struct crypto_queue *queue)80{81return __crypto_dequeue_request(82queue, offsetof(struct skcipher_givcrypt_request, creq.base));83}8485static inline void *skcipher_givcrypt_reqctx(86struct skcipher_givcrypt_request *req)87{88return ablkcipher_request_ctx(&req->creq);89}9091static inline void ablkcipher_request_complete(struct ablkcipher_request *req,92int err)93{94req->base.complete(&req->base, err);95}9697static inline void skcipher_givcrypt_complete(98struct skcipher_givcrypt_request *req, int err)99{100ablkcipher_request_complete(&req->creq, err);101}102103static inline u32 ablkcipher_request_flags(struct ablkcipher_request *req)104{105return req->base.flags;106}107108#endif /* _CRYPTO_INTERNAL_SKCIPHER_H */109110111112