📄 crypto.h
字号:
return __crypto_blkcipher_cast(tfm);}static inline struct crypto_blkcipher *crypto_alloc_blkcipher( const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_BLKCIPHER; mask |= CRYPTO_ALG_TYPE_MASK; return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask));}static inline struct crypto_tfm *crypto_blkcipher_tfm( struct crypto_blkcipher *tfm){ return &tfm->base;}static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm){ crypto_free_tfm(crypto_blkcipher_tfm(tfm));}static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_BLKCIPHER; mask |= CRYPTO_ALG_TYPE_MASK; return crypto_has_alg(alg_name, type, mask);}static inline const char *crypto_blkcipher_name(struct crypto_blkcipher *tfm){ return crypto_tfm_alg_name(crypto_blkcipher_tfm(tfm));}static inline struct blkcipher_tfm *crypto_blkcipher_crt( struct crypto_blkcipher *tfm){ return &crypto_blkcipher_tfm(tfm)->crt_blkcipher;}static inline struct blkcipher_alg *crypto_blkcipher_alg( struct crypto_blkcipher *tfm){ return &crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher;}static inline unsigned int crypto_blkcipher_ivsize(struct crypto_blkcipher *tfm){ return crypto_blkcipher_alg(tfm)->ivsize;}static inline unsigned int crypto_blkcipher_blocksize( struct crypto_blkcipher *tfm){ return crypto_tfm_alg_blocksize(crypto_blkcipher_tfm(tfm));}static inline unsigned int crypto_blkcipher_alignmask( struct crypto_blkcipher *tfm){ return crypto_tfm_alg_alignmask(crypto_blkcipher_tfm(tfm));}static inline u32 crypto_blkcipher_get_flags(struct crypto_blkcipher *tfm){ return crypto_tfm_get_flags(crypto_blkcipher_tfm(tfm));}static inline void crypto_blkcipher_set_flags(struct crypto_blkcipher *tfm, u32 flags){ crypto_tfm_set_flags(crypto_blkcipher_tfm(tfm), flags);}static inline void crypto_blkcipher_clear_flags(struct crypto_blkcipher *tfm, u32 flags){ crypto_tfm_clear_flags(crypto_blkcipher_tfm(tfm), flags);}static inline int crypto_blkcipher_setkey(struct crypto_blkcipher *tfm, const u8 *key, unsigned int keylen){ return crypto_blkcipher_crt(tfm)->setkey(crypto_blkcipher_tfm(tfm), key, keylen);}static inline int crypto_blkcipher_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes){ desc->info = crypto_blkcipher_crt(desc->tfm)->iv; return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);}static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes){ return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);}static inline int crypto_blkcipher_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes){ desc->info = crypto_blkcipher_crt(desc->tfm)->iv; return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);}static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes){ return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);}static inline void crypto_blkcipher_set_iv(struct crypto_blkcipher *tfm, const u8 *src, unsigned int len){ memcpy(crypto_blkcipher_crt(tfm)->iv, src, len);}static inline void crypto_blkcipher_get_iv(struct crypto_blkcipher *tfm, u8 *dst, unsigned int len){ memcpy(dst, crypto_blkcipher_crt(tfm)->iv, len);}static inline struct crypto_cipher *__crypto_cipher_cast(struct crypto_tfm *tfm){ return (struct crypto_cipher *)tfm;}static inline struct crypto_cipher *crypto_cipher_cast(struct crypto_tfm *tfm){ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return __crypto_cipher_cast(tfm);}static inline struct crypto_cipher *crypto_alloc_cipher(const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_CIPHER; mask |= CRYPTO_ALG_TYPE_MASK; return __crypto_cipher_cast(crypto_alloc_base(alg_name, type, mask));}static inline struct crypto_tfm *crypto_cipher_tfm(struct crypto_cipher *tfm){ return tfm;}static inline void crypto_free_cipher(struct crypto_cipher *tfm){ crypto_free_tfm(crypto_cipher_tfm(tfm));}static inline int crypto_has_cipher(const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_CIPHER; mask |= CRYPTO_ALG_TYPE_MASK; return crypto_has_alg(alg_name, type, mask);}static inline struct cipher_tfm *crypto_cipher_crt(struct crypto_cipher *tfm){ return &crypto_cipher_tfm(tfm)->crt_cipher;}static inline unsigned int crypto_cipher_blocksize(struct crypto_cipher *tfm){ return crypto_tfm_alg_blocksize(crypto_cipher_tfm(tfm));}static inline unsigned int crypto_cipher_alignmask(struct crypto_cipher *tfm){ return crypto_tfm_alg_alignmask(crypto_cipher_tfm(tfm));}static inline u32 crypto_cipher_get_flags(struct crypto_cipher *tfm){ return crypto_tfm_get_flags(crypto_cipher_tfm(tfm));}static inline void crypto_cipher_set_flags(struct crypto_cipher *tfm, u32 flags){ crypto_tfm_set_flags(crypto_cipher_tfm(tfm), flags);}static inline void crypto_cipher_clear_flags(struct crypto_cipher *tfm, u32 flags){ crypto_tfm_clear_flags(crypto_cipher_tfm(tfm), flags);}static inline int crypto_cipher_setkey(struct crypto_cipher *tfm, const u8 *key, unsigned int keylen){ return crypto_cipher_crt(tfm)->cit_setkey(crypto_cipher_tfm(tfm), key, keylen);}static inline void crypto_cipher_encrypt_one(struct crypto_cipher *tfm, u8 *dst, const u8 *src){ crypto_cipher_crt(tfm)->cit_encrypt_one(crypto_cipher_tfm(tfm), dst, src);}static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm, u8 *dst, const u8 *src){ crypto_cipher_crt(tfm)->cit_decrypt_one(crypto_cipher_tfm(tfm), dst, src);}static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm){ return (struct crypto_hash *)tfm;}static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm){ BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_HASH) & CRYPTO_ALG_TYPE_HASH_MASK); return __crypto_hash_cast(tfm);}static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_HASH; mask |= CRYPTO_ALG_TYPE_HASH_MASK; return __crypto_hash_cast(crypto_alloc_base(alg_name, type, mask));}static inline struct crypto_tfm *crypto_hash_tfm(struct crypto_hash *tfm){ return &tfm->base;}static inline void crypto_free_hash(struct crypto_hash *tfm){ crypto_free_tfm(crypto_hash_tfm(tfm));}static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_HASH; mask |= CRYPTO_ALG_TYPE_HASH_MASK; return crypto_has_alg(alg_name, type, mask);}static inline struct hash_tfm *crypto_hash_crt(struct crypto_hash *tfm){ return &crypto_hash_tfm(tfm)->crt_hash;}static inline unsigned int crypto_hash_blocksize(struct crypto_hash *tfm){ return crypto_tfm_alg_blocksize(crypto_hash_tfm(tfm));}static inline unsigned int crypto_hash_alignmask(struct crypto_hash *tfm){ return crypto_tfm_alg_alignmask(crypto_hash_tfm(tfm));}static inline unsigned int crypto_hash_digestsize(struct crypto_hash *tfm){ return crypto_hash_crt(tfm)->digestsize;}static inline u32 crypto_hash_get_flags(struct crypto_hash *tfm){ return crypto_tfm_get_flags(crypto_hash_tfm(tfm));}static inline void crypto_hash_set_flags(struct crypto_hash *tfm, u32 flags){ crypto_tfm_set_flags(crypto_hash_tfm(tfm), flags);}static inline void crypto_hash_clear_flags(struct crypto_hash *tfm, u32 flags){ crypto_tfm_clear_flags(crypto_hash_tfm(tfm), flags);}static inline int crypto_hash_init(struct hash_desc *desc){ return crypto_hash_crt(desc->tfm)->init(desc);}static inline int crypto_hash_update(struct hash_desc *desc, struct scatterlist *sg, unsigned int nbytes){ return crypto_hash_crt(desc->tfm)->update(desc, sg, nbytes);}static inline int crypto_hash_final(struct hash_desc *desc, u8 *out){ return crypto_hash_crt(desc->tfm)->final(desc, out);}static inline int crypto_hash_digest(struct hash_desc *desc, struct scatterlist *sg, unsigned int nbytes, u8 *out){ return crypto_hash_crt(desc->tfm)->digest(desc, sg, nbytes, out);}static inline int crypto_hash_setkey(struct crypto_hash *hash, const u8 *key, unsigned int keylen){ return crypto_hash_crt(hash)->setkey(hash, key, keylen);}static int crypto_cipher_encrypt(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) __deprecated;static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes){ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);} static int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes, u8 *iv) __deprecated;static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes, u8 *iv){ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv);} static int crypto_cipher_decrypt(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes) __deprecated;static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes){ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);}static int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes, u8 *iv) __deprecated;static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm, struct scatterlist *dst, struct scatterlist *src, unsigned int nbytes, u8 *iv){ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv);}static void crypto_cipher_set_iv(struct crypto_tfm *tfm, const u8 *src, unsigned int len) __deprecated;static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm, const u8 *src, unsigned int len){ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(tfm->crt_cipher.cit_iv, src, len);}static void crypto_cipher_get_iv(struct crypto_tfm *tfm, u8 *dst, unsigned int len) __deprecated;static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm, u8 *dst, unsigned int len){ BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER); memcpy(dst, tfm->crt_cipher.cit_iv, len);}static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm){ return (struct crypto_comp *)tfm;}static inline struct crypto_comp *crypto_comp_cast(struct crypto_tfm *tfm){ BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_COMPRESS) & CRYPTO_ALG_TYPE_MASK); return __crypto_comp_cast(tfm);}static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_COMPRESS; mask |= CRYPTO_ALG_TYPE_MASK; return __crypto_comp_cast(crypto_alloc_base(alg_name, type, mask));}static inline struct crypto_tfm *crypto_comp_tfm(struct crypto_comp *tfm){ return tfm;}static inline void crypto_free_comp(struct crypto_comp *tfm){ crypto_free_tfm(crypto_comp_tfm(tfm));}static inline int crypto_has_comp(const char *alg_name, u32 type, u32 mask){ type &= ~CRYPTO_ALG_TYPE_MASK; type |= CRYPTO_ALG_TYPE_COMPRESS; mask |= CRYPTO_ALG_TYPE_MASK; return crypto_has_alg(alg_name, type, mask);}static inline const char *crypto_comp_name(struct crypto_comp *tfm){ return crypto_tfm_alg_name(crypto_comp_tfm(tfm));}static inline struct compress_tfm *crypto_comp_crt(struct crypto_comp *tfm){ return &crypto_comp_tfm(tfm)->crt_compress;}static inline int crypto_comp_compress(struct crypto_comp *tfm, const u8 *src, unsigned int slen, u8 *dst, unsigned int *dlen){ return crypto_comp_crt(tfm)->cot_compress(tfm, src, slen, dst, dlen);}static inline int crypto_comp_decompress(struct crypto_comp *tfm, const u8 *src, unsigned int slen, u8 *dst, unsigned int *dlen){ return crypto_comp_crt(tfm)->cot_decompress(tfm, src, slen, dst, dlen);}#endif /* _LINUX_CRYPTO_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -