Lines Matching refs:state

131 static void get_new_key_from_sha(struct ppp_mppe_state * state)  in get_new_key_from_sha()  argument
133 crypto_shash_init(state->sha1); in get_new_key_from_sha()
134 crypto_shash_update(state->sha1, state->master_key, in get_new_key_from_sha()
135 state->keylen); in get_new_key_from_sha()
136 crypto_shash_update(state->sha1, sha_pad->sha_pad1, in get_new_key_from_sha()
138 crypto_shash_update(state->sha1, state->session_key, in get_new_key_from_sha()
139 state->keylen); in get_new_key_from_sha()
140 crypto_shash_update(state->sha1, sha_pad->sha_pad2, in get_new_key_from_sha()
142 crypto_shash_final(state->sha1, state->sha1_digest); in get_new_key_from_sha()
149 static void mppe_rekey(struct ppp_mppe_state * state, int initial_key) in mppe_rekey() argument
151 get_new_key_from_sha(state); in mppe_rekey()
153 arc4_setkey(&state->arc4, state->sha1_digest, state->keylen); in mppe_rekey()
154 arc4_crypt(&state->arc4, state->session_key, state->sha1_digest, in mppe_rekey()
155 state->keylen); in mppe_rekey()
157 memcpy(state->session_key, state->sha1_digest, state->keylen); in mppe_rekey()
159 if (state->keylen == 8) { in mppe_rekey()
161 state->session_key[0] = 0xd1; in mppe_rekey()
162 state->session_key[1] = 0x26; in mppe_rekey()
163 state->session_key[2] = 0x9e; in mppe_rekey()
165 arc4_setkey(&state->arc4, state->session_key, state->keylen); in mppe_rekey()
173 struct ppp_mppe_state *state; in mppe_alloc() local
177 if (optlen != CILEN_MPPE + sizeof(state->master_key) || in mppe_alloc()
182 state = kzalloc(sizeof(*state), GFP_KERNEL); in mppe_alloc()
183 if (state == NULL) in mppe_alloc()
191 state->sha1 = kmalloc(sizeof(*state->sha1) + in mppe_alloc()
194 if (!state->sha1) { in mppe_alloc()
198 state->sha1->tfm = shash; in mppe_alloc()
204 state->sha1_digest = kmalloc(digestsize, GFP_KERNEL); in mppe_alloc()
205 if (!state->sha1_digest) in mppe_alloc()
209 memcpy(state->master_key, &options[CILEN_MPPE], in mppe_alloc()
210 sizeof(state->master_key)); in mppe_alloc()
211 memcpy(state->session_key, state->master_key, in mppe_alloc()
212 sizeof(state->master_key)); in mppe_alloc()
219 return (void *)state; in mppe_alloc()
222 kfree(state->sha1_digest); in mppe_alloc()
223 if (state->sha1) { in mppe_alloc()
224 crypto_free_shash(state->sha1->tfm); in mppe_alloc()
225 kfree_sensitive(state->sha1); in mppe_alloc()
227 kfree(state); in mppe_alloc()
237 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; in mppe_free() local
238 if (state) { in mppe_free()
239 kfree(state->sha1_digest); in mppe_free()
240 crypto_free_shash(state->sha1->tfm); in mppe_free()
241 kfree_sensitive(state->sha1); in mppe_free()
242 kfree_sensitive(state); in mppe_free()
253 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; in mppe_init() local
262 state->keylen = 16; in mppe_init()
264 state->keylen = 8; in mppe_init()
271 state->stateful = 1; in mppe_init()
274 mppe_rekey(state, 1); in mppe_init()
278 debugstr, unit, (state->keylen == 16) ? 128 : 40, in mppe_init()
279 (state->stateful) ? "stateful" : "stateless"); in mppe_init()
283 (int)sizeof(state->master_key), state->master_key, in mppe_init()
284 (int)sizeof(state->session_key), state->session_key); in mppe_init()
293 state->ccount = MPPE_CCOUNT_SPACE - 1; in mppe_init()
299 state->bits = MPPE_BIT_ENCRYPTED; in mppe_init()
301 state->unit = unit; in mppe_init()
302 state->debug = debug; in mppe_init()
326 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; in mppe_comp_reset() local
328 state->bits |= MPPE_BIT_FLUSHED; in mppe_comp_reset()
340 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; in mppe_compress() local
354 "(have: %d need: %d)\n", state->unit, in mppe_compress()
369 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; in mppe_compress()
370 if (state->debug >= 7) in mppe_compress()
371 printk(KERN_DEBUG "mppe_compress[%d]: ccount %d\n", state->unit, in mppe_compress()
372 state->ccount); in mppe_compress()
373 put_unaligned_be16(state->ccount, obuf); in mppe_compress()
375 if (!state->stateful || /* stateless mode */ in mppe_compress()
376 ((state->ccount & 0xff) == 0xff) || /* "flag" packet */ in mppe_compress()
377 (state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */ in mppe_compress()
379 if (state->debug && state->stateful) in mppe_compress()
381 state->unit); in mppe_compress()
382 mppe_rekey(state, 0); in mppe_compress()
383 state->bits |= MPPE_BIT_FLUSHED; in mppe_compress()
385 obuf[0] |= state->bits; in mppe_compress()
386 state->bits &= ~MPPE_BIT_FLUSHED; /* reset for next xmit */ in mppe_compress()
392 arc4_crypt(&state->arc4, obuf, ibuf, isize); in mppe_compress()
394 state->stats.unc_bytes += isize; in mppe_compress()
395 state->stats.unc_packets++; in mppe_compress()
396 state->stats.comp_bytes += osize; in mppe_compress()
397 state->stats.comp_packets++; in mppe_compress()
408 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; in mppe_comp_stats() local
410 *stats = state->stats; in mppe_comp_stats()
437 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; in mppe_decompress() local
442 if (state->debug) in mppe_decompress()
445 state->unit, isize); in mppe_decompress()
457 "(have: %d need: %d)\n", state->unit, in mppe_decompress()
464 if (state->debug >= 7) in mppe_decompress()
466 state->unit, ccount); in mppe_decompress()
472 state->unit); in mppe_decompress()
473 state->sanity_errors += 100; in mppe_decompress()
476 if (!state->stateful && !flushed) { in mppe_decompress()
478 "stateless mode!\n", state->unit); in mppe_decompress()
479 state->sanity_errors += 100; in mppe_decompress()
482 if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { in mppe_decompress()
484 "flag packet!\n", state->unit); in mppe_decompress()
485 state->sanity_errors += 100; in mppe_decompress()
493 if (!state->stateful) { in mppe_decompress()
495 if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE in mppe_decompress()
497 state->sanity_errors++; in mppe_decompress()
502 while (state->ccount != ccount) { in mppe_decompress()
503 mppe_rekey(state, 0); in mppe_decompress()
504 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; in mppe_decompress()
508 if (!state->discard) { in mppe_decompress()
510 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; in mppe_decompress()
511 if (ccount != state->ccount) { in mppe_decompress()
517 state->discard = 1; in mppe_decompress()
528 (state->ccount & ~0xff)) { in mppe_decompress()
529 mppe_rekey(state, 0); in mppe_decompress()
530 state->ccount = in mppe_decompress()
531 (state->ccount + in mppe_decompress()
536 state->discard = 0; in mppe_decompress()
537 state->ccount = ccount; in mppe_decompress()
548 mppe_rekey(state, 0); in mppe_decompress()
566 arc4_crypt(&state->arc4, obuf, ibuf, 1); in mppe_decompress()
581 arc4_crypt(&state->arc4, obuf + 1, ibuf + 1, isize - 1); in mppe_decompress()
583 state->stats.unc_bytes += osize; in mppe_decompress()
584 state->stats.unc_packets++; in mppe_decompress()
585 state->stats.comp_bytes += isize; in mppe_decompress()
586 state->stats.comp_packets++; in mppe_decompress()
589 state->sanity_errors >>= 1; in mppe_decompress()
594 if (state->sanity_errors < SANITY_MAX) in mppe_decompress()
612 struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; in mppe_incomp() local
614 if (state->debug && in mppe_incomp()
618 "(proto %04x)\n", state->unit, PPP_PROTOCOL(ibuf)); in mppe_incomp()
620 state->stats.inc_bytes += icnt; in mppe_incomp()
621 state->stats.inc_packets++; in mppe_incomp()
622 state->stats.unc_bytes += icnt; in mppe_incomp()
623 state->stats.unc_packets++; in mppe_incomp()