Lines Matching refs:state

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