/** * starting mppe protocol. */ void mppe_start(mppe *_this) { char buf[256]; strlcpy(buf, mppe_bits_to_string(_this->ppp->ccp.mppe_o_bits), sizeof(buf)); mppe_log(_this, LOG_INFO, "logtype=Opened our=%s peer=%s", buf, mppe_bits_to_string(_this->ppp->ccp.mppe_p_bits)); _this->ppp->mppe_started = 1; _this->send.stateless = ((_this->ppp->ccp.mppe_o_bits & CCP_MPPE_STATELESS) != 0)? 1 : 0; if ((_this->ppp->ccp.mppe_o_bits & CCP_MPPE_NT_40bit) != 0) { _this->send.keylen = 8; _this->send.keybits = 40; } else if ((_this->ppp->ccp.mppe_o_bits & CCP_MPPE_NT_56bit) != 0) { _this->send.keylen = 8; _this->send.keybits = 56; } else if ((_this->ppp->ccp.mppe_o_bits & CCP_MPPE_NT_128bit) != 0) { _this->send.keylen = 16; _this->send.keybits = 128; } _this->recv.stateless = ((_this->ppp->ccp.mppe_p_bits & CCP_MPPE_STATELESS) != 0)? 1 : 0; if ((_this->ppp->ccp.mppe_p_bits & CCP_MPPE_NT_40bit) != 0) { _this->recv.keylen = 8; _this->recv.keybits = 40; } else if ((_this->ppp->ccp.mppe_p_bits & CCP_MPPE_NT_56bit) != 0) { _this->recv.keylen = 8; _this->recv.keybits = 56; } else if ((_this->ppp->ccp.mppe_p_bits & CCP_MPPE_NT_128bit) != 0) { _this->recv.keylen = 16; _this->recv.keybits = 128; } if (_this->send.keybits > 0) { mppe_rc4_init(_this, &_this->send, 0); GetNewKeyFromSHA(_this->send.master_key, _this->send.master_key, _this->send.keylen, _this->send.session_key); mppe_reduce_key(&_this->send); mppe_rc4_setkey(_this, &_this->send); } if (_this->recv.keybits > 0) { mppe_rc4_init(_this, &_this->recv, _this->recv.stateless); GetNewKeyFromSHA(_this->recv.master_key, _this->recv.master_key, _this->recv.keylen, _this->recv.session_key); mppe_reduce_key(&_this->recv); mppe_rc4_setkey(_this, &_this->recv); } }
static void MPPEKeyChange(struct mppe_state *mp) { char InterimKey[MPPE_KEY_LEN]; RC4_KEY RC4Key; GetNewKeyFromSHA(mp->mastkey, mp->sesskey, mp->keylen, InterimKey); RC4_set_key(&RC4Key, mp->keylen, InterimKey); RC4(&RC4Key, mp->keylen, InterimKey, mp->sesskey); MPPEReduceSessionKey(mp); }
static void mppe_key_change(mppe *_mppe, mppe_rc4_t *_this) { u_char interim[16]; void *keychg; keychg = rc4_create_ctx(); GetNewKeyFromSHA(_this->master_key, _this->session_key, _this->keylen, interim); rc4_key(keychg, _this->keylen, interim); rc4(keychg, _this->keylen, interim, _this->session_key); mppe_reduce_key(_this); if (_this->old_session_keys) { int idx = _this->coher_cnt % MPPE_NOLDKEY; memcpy(_this->old_session_keys[idx], _this->session_key, MPPE_KEYLEN); } free(keychg); }