Lines Matching refs:state

61 static void mppe_rekey(ppp_mppe_state * state, int initial_key)  in mppe_rekey()  argument
72 lwip_sha1_update(&sha1_ctx, state->master_key, state->keylen); in mppe_rekey()
74 lwip_sha1_update(&sha1_ctx, state->session_key, state->keylen); in mppe_rekey()
78 MEMCPY(state->session_key, sha1_digest, state->keylen); in mppe_rekey()
81 lwip_arc4_init(&state->arc4); in mppe_rekey()
82 lwip_arc4_setup(&state->arc4, sha1_digest, state->keylen); in mppe_rekey()
83 lwip_arc4_crypt(&state->arc4, state->session_key, state->keylen); in mppe_rekey()
84 lwip_arc4_free(&state->arc4); in mppe_rekey()
86 if (state->keylen == 8) { in mppe_rekey()
88 state->session_key[0] = 0xd1; in mppe_rekey()
89 state->session_key[1] = 0x26; in mppe_rekey()
90 state->session_key[2] = 0x9e; in mppe_rekey()
92 lwip_arc4_init(&state->arc4); in mppe_rekey()
93 lwip_arc4_setup(&state->arc4, state->session_key, state->keylen); in mppe_rekey()
100 void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key) { in mppe_set_key() argument
102 MEMCPY(state->master_key, key, MPPE_MAX_KEY_LEN); in mppe_set_key()
109 mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options) in mppe_init() argument
113 if (&pcb->mppe_decomp == state) { in mppe_init()
119 MEMCPY(state->session_key, state->master_key, sizeof(state->master_key)); in mppe_init()
122 state->keylen = 16; in mppe_init()
124 state->keylen = 8; in mppe_init()
132 state->stateful = 1; in mppe_init()
135 mppe_rekey(state, 1); in mppe_init()
140 char mkey[sizeof(state->master_key) * 2 + 1]; in mppe_init()
141 char skey[sizeof(state->session_key) * 2 + 1]; in mppe_init()
144 debugstr, pcb->netif->num, (state->keylen == 16) ? 128 : 40, in mppe_init()
145 (state->stateful) ? "stateful" : "stateless")); in mppe_init()
147 for (i = 0; i < (int)sizeof(state->master_key); i++) in mppe_init()
148 sprintf(mkey + i * 2, "%02x", state->master_key[i]); in mppe_init()
149 for (i = 0; i < (int)sizeof(state->session_key); i++) in mppe_init()
150 sprintf(skey + i * 2, "%02x", state->session_key[i]); in mppe_init()
163 state->ccount = MPPE_CCOUNT_SPACE - 1; in mppe_init()
169 state->bits = MPPE_BIT_ENCRYPTED; in mppe_init()
181 void mppe_comp_reset(ppp_pcb *pcb, ppp_mppe_state *state) in mppe_comp_reset() argument
184 state->bits |= MPPE_BIT_FLUSHED; in mppe_comp_reset()
193 mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t protocol) in mppe_compress() argument
223 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; in mppe_compress()
224 PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", pcb->netif->num, state->ccount)); in mppe_compress()
226 pl[0] = state->ccount>>8; in mppe_compress()
227 pl[1] = state->ccount; in mppe_compress()
229 if (!state->stateful || /* stateless mode */ in mppe_compress()
230 ((state->ccount & 0xff) == 0xff) || /* "flag" packet */ in mppe_compress()
231 (state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */ in mppe_compress()
233 if (state->stateful) { in mppe_compress()
236 mppe_rekey(state, 0); in mppe_compress()
237 state->bits |= MPPE_BIT_FLUSHED; in mppe_compress()
239 pl[0] |= state->bits; in mppe_compress()
240 state->bits &= ~MPPE_BIT_FLUSHED; /* reset for next xmit */ in mppe_compress()
253 lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); in mppe_compress()
268 void mppe_decomp_reset(ppp_pcb *pcb, ppp_mppe_state *state) in mppe_decomp_reset() argument
271 LWIP_UNUSED_ARG(state); in mppe_decomp_reset()
279 mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb) in mppe_decompress() argument
291 state->sanity_errors += 100; in mppe_decompress()
306 state->sanity_errors += 100; in mppe_decompress()
309 if (!state->stateful && !flushed) { in mppe_decompress()
312 state->sanity_errors += 100; in mppe_decompress()
315 if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { in mppe_decompress()
318 state->sanity_errors += 100; in mppe_decompress()
326 if (!state->stateful) { in mppe_decompress()
328 if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE > MPPE_CCOUNT_SPACE / 2) { in mppe_decompress()
329 state->sanity_errors++; in mppe_decompress()
334 while (state->ccount != ccount) { in mppe_decompress()
335 mppe_rekey(state, 0); in mppe_decompress()
336 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; in mppe_decompress()
340 if (!state->discard) { in mppe_decompress()
342 state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; in mppe_decompress()
343 if (ccount != state->ccount) { in mppe_decompress()
349 state->discard = 1; in mppe_decompress()
361 (state->ccount & ~0xff)) { in mppe_decompress()
362 mppe_rekey(state, 0); in mppe_decompress()
363 state->ccount = in mppe_decompress()
364 (state->ccount + in mppe_decompress()
369 state->discard = 0; in mppe_decompress()
370 state->ccount = ccount; in mppe_decompress()
381 mppe_rekey(state, 0); in mppe_decompress()
389 lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); in mppe_decompress()
396 state->sanity_errors >>= 1; in mppe_decompress()
401 if (state->sanity_errors >= SANITY_MAX) { in mppe_decompress()