.. | .. |
---|
39 | 39 | # define RPCDBG_FACILITY RPCDBG_AUTH |
---|
40 | 40 | #endif |
---|
41 | 41 | |
---|
42 | | -static s32 |
---|
43 | | -krb5_make_rc4_seq_num(struct krb5_ctx *kctx, int direction, s32 seqnum, |
---|
44 | | - unsigned char *cksum, unsigned char *buf) |
---|
45 | | -{ |
---|
46 | | - struct crypto_skcipher *cipher; |
---|
47 | | - unsigned char *plain; |
---|
48 | | - s32 code; |
---|
49 | | - |
---|
50 | | - dprintk("RPC: %s:\n", __func__); |
---|
51 | | - cipher = crypto_alloc_skcipher(kctx->gk5e->encrypt_name, 0, |
---|
52 | | - CRYPTO_ALG_ASYNC); |
---|
53 | | - if (IS_ERR(cipher)) |
---|
54 | | - return PTR_ERR(cipher); |
---|
55 | | - |
---|
56 | | - plain = kmalloc(8, GFP_NOFS); |
---|
57 | | - if (!plain) |
---|
58 | | - return -ENOMEM; |
---|
59 | | - |
---|
60 | | - plain[0] = (unsigned char) ((seqnum >> 24) & 0xff); |
---|
61 | | - plain[1] = (unsigned char) ((seqnum >> 16) & 0xff); |
---|
62 | | - plain[2] = (unsigned char) ((seqnum >> 8) & 0xff); |
---|
63 | | - plain[3] = (unsigned char) ((seqnum >> 0) & 0xff); |
---|
64 | | - plain[4] = direction; |
---|
65 | | - plain[5] = direction; |
---|
66 | | - plain[6] = direction; |
---|
67 | | - plain[7] = direction; |
---|
68 | | - |
---|
69 | | - code = krb5_rc4_setup_seq_key(kctx, cipher, cksum); |
---|
70 | | - if (code) |
---|
71 | | - goto out; |
---|
72 | | - |
---|
73 | | - code = krb5_encrypt(cipher, cksum, plain, buf, 8); |
---|
74 | | -out: |
---|
75 | | - crypto_free_skcipher(cipher); |
---|
76 | | - kfree(plain); |
---|
77 | | - return code; |
---|
78 | | -} |
---|
79 | 42 | s32 |
---|
80 | 43 | krb5_make_seq_num(struct krb5_ctx *kctx, |
---|
81 | | - struct crypto_skcipher *key, |
---|
| 44 | + struct crypto_sync_skcipher *key, |
---|
82 | 45 | int direction, |
---|
83 | 46 | u32 seqnum, |
---|
84 | 47 | unsigned char *cksum, unsigned char *buf) |
---|
85 | 48 | { |
---|
86 | 49 | unsigned char *plain; |
---|
87 | 50 | s32 code; |
---|
88 | | - |
---|
89 | | - if (kctx->enctype == ENCTYPE_ARCFOUR_HMAC) |
---|
90 | | - return krb5_make_rc4_seq_num(kctx, direction, seqnum, |
---|
91 | | - cksum, buf); |
---|
92 | 51 | |
---|
93 | 52 | plain = kmalloc(8, GFP_NOFS); |
---|
94 | 53 | if (!plain) |
---|
.. | .. |
---|
109 | 68 | return code; |
---|
110 | 69 | } |
---|
111 | 70 | |
---|
112 | | -static s32 |
---|
113 | | -krb5_get_rc4_seq_num(struct krb5_ctx *kctx, unsigned char *cksum, |
---|
114 | | - unsigned char *buf, int *direction, s32 *seqnum) |
---|
115 | | -{ |
---|
116 | | - struct crypto_skcipher *cipher; |
---|
117 | | - unsigned char *plain; |
---|
118 | | - s32 code; |
---|
119 | | - |
---|
120 | | - dprintk("RPC: %s:\n", __func__); |
---|
121 | | - cipher = crypto_alloc_skcipher(kctx->gk5e->encrypt_name, 0, |
---|
122 | | - CRYPTO_ALG_ASYNC); |
---|
123 | | - if (IS_ERR(cipher)) |
---|
124 | | - return PTR_ERR(cipher); |
---|
125 | | - |
---|
126 | | - code = krb5_rc4_setup_seq_key(kctx, cipher, cksum); |
---|
127 | | - if (code) |
---|
128 | | - goto out; |
---|
129 | | - |
---|
130 | | - plain = kmalloc(8, GFP_NOFS); |
---|
131 | | - if (!plain) { |
---|
132 | | - code = -ENOMEM; |
---|
133 | | - goto out; |
---|
134 | | - } |
---|
135 | | - |
---|
136 | | - code = krb5_decrypt(cipher, cksum, buf, plain, 8); |
---|
137 | | - if (code) |
---|
138 | | - goto out_plain; |
---|
139 | | - |
---|
140 | | - if ((plain[4] != plain[5]) || (plain[4] != plain[6]) |
---|
141 | | - || (plain[4] != plain[7])) { |
---|
142 | | - code = (s32)KG_BAD_SEQ; |
---|
143 | | - goto out_plain; |
---|
144 | | - } |
---|
145 | | - |
---|
146 | | - *direction = plain[4]; |
---|
147 | | - |
---|
148 | | - *seqnum = ((plain[0] << 24) | (plain[1] << 16) | |
---|
149 | | - (plain[2] << 8) | (plain[3])); |
---|
150 | | -out_plain: |
---|
151 | | - kfree(plain); |
---|
152 | | -out: |
---|
153 | | - crypto_free_skcipher(cipher); |
---|
154 | | - return code; |
---|
155 | | -} |
---|
156 | | - |
---|
157 | 71 | s32 |
---|
158 | 72 | krb5_get_seq_num(struct krb5_ctx *kctx, |
---|
159 | 73 | unsigned char *cksum, |
---|
.. | .. |
---|
161 | 75 | int *direction, u32 *seqnum) |
---|
162 | 76 | { |
---|
163 | 77 | s32 code; |
---|
164 | | - struct crypto_skcipher *key = kctx->seq; |
---|
165 | 78 | unsigned char *plain; |
---|
| 79 | + struct crypto_sync_skcipher *key = kctx->seq; |
---|
166 | 80 | |
---|
167 | 81 | dprintk("RPC: krb5_get_seq_num:\n"); |
---|
168 | 82 | |
---|
169 | | - if (kctx->enctype == ENCTYPE_ARCFOUR_HMAC) |
---|
170 | | - return krb5_get_rc4_seq_num(kctx, cksum, buf, |
---|
171 | | - direction, seqnum); |
---|
172 | 83 | plain = kmalloc(8, GFP_NOFS); |
---|
173 | 84 | if (!plain) |
---|
174 | 85 | return -ENOMEM; |
---|