Linux-2.6.12-rc2
[linux-2.6/next.git] / crypto / internal.h
blobe68e43886d3cc23439f30210e88b517911bf395e
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/kmod.h>
20 #include <asm/kmap_types.h>
22 extern enum km_type crypto_km_types[];
24 static inline enum km_type crypto_kmap_type(int out)
26 return crypto_km_types[(in_softirq() ? 2 : 0) + out];
29 static inline void *crypto_kmap(struct page *page, int out)
31 return kmap_atomic(page, crypto_kmap_type(out));
34 static inline void crypto_kunmap(void *vaddr, int out)
36 kunmap_atomic(vaddr, crypto_kmap_type(out));
39 static inline void crypto_yield(struct crypto_tfm *tfm)
41 if (!in_softirq())
42 cond_resched();
45 static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
47 return (void *)&tfm[1];
50 struct crypto_alg *crypto_alg_lookup(const char *name);
52 /* A far more intelligent version of this is planned. For now, just
53 * try an exact match on the name of the algorithm. */
54 static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
56 return try_then_request_module(crypto_alg_lookup(name), name);
59 #ifdef CONFIG_CRYPTO_HMAC
60 int crypto_alloc_hmac_block(struct crypto_tfm *tfm);
61 void crypto_free_hmac_block(struct crypto_tfm *tfm);
62 #else
63 static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
65 return 0;
68 static inline void crypto_free_hmac_block(struct crypto_tfm *tfm)
69 { }
70 #endif
72 #ifdef CONFIG_PROC_FS
73 void __init crypto_init_proc(void);
74 #else
75 static inline void crypto_init_proc(void)
76 { }
77 #endif
79 int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
80 int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
81 int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
83 int crypto_init_digest_ops(struct crypto_tfm *tfm);
84 int crypto_init_cipher_ops(struct crypto_tfm *tfm);
85 int crypto_init_compress_ops(struct crypto_tfm *tfm);
87 void crypto_exit_digest_ops(struct crypto_tfm *tfm);
88 void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
89 void crypto_exit_compress_ops(struct crypto_tfm *tfm);
91 #endif /* _CRYPTO_INTERNAL_H */