fix signature

This commit is contained in:
Maple 2026-01-31 20:41:37 +01:00
commit 420c689644
2 changed files with 7 additions and 4 deletions

View file

@ -1,6 +1,7 @@
use std::rc::Rc;
use std::{io::Write, rc::Rc};
use hmac::Mac;
use md5::{Digest, Md5};
use rc4::{KeyInit, Rc4, StreamCipher};
use rnex_core::prudp::{
encryption::{DEFAULT_KEY, EncryptionPair},
@ -35,7 +36,9 @@ impl CryptoInstance for InsecureInstance {
if data.len() == 0 {
[0x78, 0x56, 0x34, 0x12]
} else {
let mut hmac = <HmacMd5 as Mac>::new_from_slice(ACCESS_KEY.as_bytes())
let mut hash = Md5::new();
hash.write(ACCESS_KEY.as_bytes()).unwrap();
let mut hmac = <HmacMd5 as Mac>::new_from_slice(&hash.finalize().as_slice())
.expect("unable to create hmac md5");
hmac.update(data);
hmac.finalize().into_bytes()[0..4].try_into().unwrap()

View file

@ -109,7 +109,7 @@ impl<C: Crypto> Server<C> {
let mut inner = conn.inner.lock().await;
let seq = inner.server_packet_counter;
let packet = new_data_packet(
HAS_SIZE | NEED_ACK | RELIABLE,
NEED_ACK | RELIABLE,
self.param.virtual_port,
conn.addr.virtual_port,
data,
@ -268,7 +268,7 @@ impl<C: Crypto> Server<C> {
});
let packet = new_connect_packet(
ACK | HAS_SIZE,
ACK,
header.destination,
header.source,
self_signat,