[PATCH] superhyway: multiple block support and VCR rework
[linux/fpc-iii.git] / crypto / internal.h
blob37aa652ce5ce6f89e4738ac07dd770b8df4a6ac9
1 /*
2 * Cryptographic API.
4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
12 #ifndef _CRYPTO_INTERNAL_H
13 #define _CRYPTO_INTERNAL_H
14 #include <linux/crypto.h>
15 #include <linux/mm.h>
16 #include <linux/highmem.h>
17 #include <linux/interrupt.h>
18 #include <linux/init.h>
19 #include <linux/kernel.h>
20 #include <linux/slab.h>
21 #include <asm/kmap_types.h>
23 extern enum km_type crypto_km_types[];
25 static inline enum km_type crypto_kmap_type(int out)
27 return crypto_km_types[(in_softirq() ? 2 : 0) + out];
30 static inline void *crypto_kmap(struct page *page, int out)
32 return kmap_atomic(page, crypto_kmap_type(out));
35 static inline void crypto_kunmap(void *vaddr, int out)
37 kunmap_atomic(vaddr, crypto_kmap_type(out));
40 static inline void crypto_yield(struct crypto_tfm *tfm)
42 if (tfm->crt_flags & CRYPTO_TFM_REQ_MAY_SLEEP)
43 cond_resched();
46 #ifdef CONFIG_CRYPTO_HMAC
47 int crypto_alloc_hmac_block(struct crypto_tfm *tfm);
48 void crypto_free_hmac_block(struct crypto_tfm *tfm);
49 #else
50 static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
52 return 0;
55 static inline void crypto_free_hmac_block(struct crypto_tfm *tfm)
56 { }
57 #endif
59 #ifdef CONFIG_PROC_FS
60 void __init crypto_init_proc(void);
61 #else
62 static inline void crypto_init_proc(void)
63 { }
64 #endif
66 static inline unsigned int crypto_digest_ctxsize(struct crypto_alg *alg,
67 int flags)
69 return alg->cra_ctxsize;
72 static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg,
73 int flags)
75 unsigned int len = alg->cra_ctxsize;
77 switch (flags & CRYPTO_TFM_MODE_MASK) {
78 case CRYPTO_TFM_MODE_CBC:
79 len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);
80 len += alg->cra_blocksize;
81 break;
84 return len;
87 static inline unsigned int crypto_compress_ctxsize(struct crypto_alg *alg,
88 int flags)
90 return alg->cra_ctxsize;
93 int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
94 int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
95 int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
97 int crypto_init_digest_ops(struct crypto_tfm *tfm);
98 int crypto_init_cipher_ops(struct crypto_tfm *tfm);
99 int crypto_init_compress_ops(struct crypto_tfm *tfm);
101 void crypto_exit_digest_ops(struct crypto_tfm *tfm);
102 void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
103 void crypto_exit_compress_ops(struct crypto_tfm *tfm);
105 #endif /* _CRYPTO_INTERNAL_H */