1 /*
2  * Cryptographic API.
3  *
4  * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5  *
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.
10  *
11  */
12 #ifndef _CRYPTO_INTERNAL_H
13 #define _CRYPTO_INTERNAL_H
14 
15 
16 //#include <linux/crypto.h>
17 #include "rtl_crypto.h"
18 #include <linux/mm.h>
19 #include <linux/highmem.h>
20 #include <linux/init.h>
21 #include <asm/hardirq.h>
22 #include <asm/softirq.h>
23 #include <asm/kmap_types.h>
24 
25 
26 extern enum km_type crypto_km_types[];
27 
crypto_kmap_type(int out)28 static inline enum km_type crypto_kmap_type(int out)
29 {
30 	return crypto_km_types[(in_softirq() ? 2 : 0) + out];
31 }
32 
crypto_kmap(struct page * page,int out)33 static inline void *crypto_kmap(struct page *page, int out)
34 {
35 	return kmap_atomic(page, crypto_kmap_type(out));
36 }
37 
crypto_kunmap(void * vaddr,int out)38 static inline void crypto_kunmap(void *vaddr, int out)
39 {
40 	kunmap_atomic(vaddr, crypto_kmap_type(out));
41 }
42 
crypto_yield(struct crypto_tfm * tfm)43 static inline void crypto_yield(struct crypto_tfm *tfm)
44 {
45 	if (!in_softirq())
46 		cond_resched();
47 }
48 
crypto_tfm_ctx(struct crypto_tfm * tfm)49 static inline void *crypto_tfm_ctx(struct crypto_tfm *tfm)
50 {
51 	return (void *)&tfm[1];
52 }
53 
54 struct crypto_alg *crypto_alg_lookup(const char *name);
55 
56 #ifdef CONFIG_KMOD
57 void crypto_alg_autoload(const char *name);
58 struct crypto_alg *crypto_alg_mod_lookup(const char *name);
59 #else
crypto_alg_mod_lookup(const char * name)60 static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
61 {
62 	return crypto_alg_lookup(name);
63 }
64 #endif
65 
66 #ifdef CONFIG_CRYPTO_HMAC
67 int crypto_alloc_hmac_block(struct crypto_tfm *tfm);
68 void crypto_free_hmac_block(struct crypto_tfm *tfm);
69 #else
crypto_alloc_hmac_block(struct crypto_tfm * tfm)70 static inline int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
71 {
72 	return 0;
73 }
74 
crypto_free_hmac_block(struct crypto_tfm * tfm)75 static inline void crypto_free_hmac_block(struct crypto_tfm *tfm)
76 { }
77 #endif
78 
79 #ifdef CONFIG_PROC_FS
80 void __init crypto_init_proc(void);
81 #else
crypto_init_proc(void)82 static inline void crypto_init_proc(void)
83 { }
84 #endif
85 
86 int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
87 int crypto_init_cipher_flags(struct crypto_tfm *tfm, u32 flags);
88 int crypto_init_compress_flags(struct crypto_tfm *tfm, u32 flags);
89 
90 int crypto_init_digest_ops(struct crypto_tfm *tfm);
91 int crypto_init_cipher_ops(struct crypto_tfm *tfm);
92 int crypto_init_compress_ops(struct crypto_tfm *tfm);
93 
94 void crypto_exit_digest_ops(struct crypto_tfm *tfm);
95 void crypto_exit_cipher_ops(struct crypto_tfm *tfm);
96 void crypto_exit_compress_ops(struct crypto_tfm *tfm);
97 
98 #endif	/* _CRYPTO_INTERNAL_H */
99 
100