fix signature
This commit is contained in:
parent
28bc6819a6
commit
420c689644
2 changed files with 7 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
use std::rc::Rc;
|
use std::{io::Write, rc::Rc};
|
||||||
|
|
||||||
use hmac::Mac;
|
use hmac::Mac;
|
||||||
|
use md5::{Digest, Md5};
|
||||||
use rc4::{KeyInit, Rc4, StreamCipher};
|
use rc4::{KeyInit, Rc4, StreamCipher};
|
||||||
use rnex_core::prudp::{
|
use rnex_core::prudp::{
|
||||||
encryption::{DEFAULT_KEY, EncryptionPair},
|
encryption::{DEFAULT_KEY, EncryptionPair},
|
||||||
|
|
@ -35,7 +36,9 @@ impl CryptoInstance for InsecureInstance {
|
||||||
if data.len() == 0 {
|
if data.len() == 0 {
|
||||||
[0x78, 0x56, 0x34, 0x12]
|
[0x78, 0x56, 0x34, 0x12]
|
||||||
} else {
|
} 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");
|
.expect("unable to create hmac md5");
|
||||||
hmac.update(data);
|
hmac.update(data);
|
||||||
hmac.finalize().into_bytes()[0..4].try_into().unwrap()
|
hmac.finalize().into_bytes()[0..4].try_into().unwrap()
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ impl<C: Crypto> Server<C> {
|
||||||
let mut inner = conn.inner.lock().await;
|
let mut inner = conn.inner.lock().await;
|
||||||
let seq = inner.server_packet_counter;
|
let seq = inner.server_packet_counter;
|
||||||
let packet = new_data_packet(
|
let packet = new_data_packet(
|
||||||
HAS_SIZE | NEED_ACK | RELIABLE,
|
NEED_ACK | RELIABLE,
|
||||||
self.param.virtual_port,
|
self.param.virtual_port,
|
||||||
conn.addr.virtual_port,
|
conn.addr.virtual_port,
|
||||||
data,
|
data,
|
||||||
|
|
@ -268,7 +268,7 @@ impl<C: Crypto> Server<C> {
|
||||||
});
|
});
|
||||||
|
|
||||||
let packet = new_connect_packet(
|
let packet = new_connect_packet(
|
||||||
ACK | HAS_SIZE,
|
ACK,
|
||||||
header.destination,
|
header.destination,
|
||||||
header.source,
|
header.source,
|
||||||
self_signat,
|
self_signat,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue