зеркало из https://github.com/microsoft/ivy.git
merging quic16_temp1
This commit is contained in:
Коммит
65eef34e20
|
@ -95,31 +95,36 @@ module quic_protection(tls_id,tls) = {
|
|||
var h := get_header_info(pkt);
|
||||
var level := get_level(pkt);
|
||||
var sample_size := tls.iv_size(c,level);
|
||||
var pnum_pos := h.pkt_num_pos;
|
||||
if sample_size = 0 {
|
||||
res.ok := false;
|
||||
}
|
||||
else {
|
||||
var pnum_pos := h.pkt_num_pos;
|
||||
|
||||
var sample_pos := pnum_pos + 4;
|
||||
if sample_pos + sample_size > pkt.end {
|
||||
sample_pos := pkt.end - sample_size
|
||||
};
|
||||
var sample := pkt.segment(sample_pos,sample_pos+sample_size);
|
||||
var pnum := pkt.segment(pnum_pos,pnum_pos+4);
|
||||
pnum := tls.decrypt_cipher(c,level,pnum,sample);
|
||||
|
||||
var pnum_len := get_pnum_len(pnum,0);
|
||||
var hdr := pkt.segment(0,pnum_pos);
|
||||
hdr := hdr.extend(pnum.segment(0,pnum_len));
|
||||
var new_seq := get_pnum(pnum,0,pnum_len);
|
||||
new_seq := correct_pnum(seq,new_seq,pnum_len);
|
||||
var pyld := pkt.segment(pnum_pos + pnum_len,pkt.end);
|
||||
res := tls.decrypt_aead(c,level,pyld,new_seq,hdr);
|
||||
if res.ok {
|
||||
# fix up the length field to account for removal of checksum
|
||||
if h.hdr_long {
|
||||
var new_len := to_var_int_16(h.payload_length-16);
|
||||
hdr := hdr.set(pnum_pos-2,new_len.value(0));
|
||||
hdr := hdr.set(pnum_pos-1,new_len.value(1));
|
||||
var sample_pos := pnum_pos + 4;
|
||||
if sample_pos + sample_size > pkt.end {
|
||||
sample_pos := pkt.end - sample_size
|
||||
};
|
||||
res.data := hdr.extend(res.data);
|
||||
var sample := pkt.segment(sample_pos,sample_pos+sample_size);
|
||||
var pnum := pkt.segment(pnum_pos,pnum_pos+4);
|
||||
pnum := tls.decrypt_cipher(c,level,pnum,sample);
|
||||
|
||||
var pnum_len := get_pnum_len(pnum,0);
|
||||
var hdr := pkt.segment(0,pnum_pos);
|
||||
hdr := hdr.extend(pnum.segment(0,pnum_len));
|
||||
var new_seq := get_pnum(pnum,0,pnum_len);
|
||||
new_seq := correct_pnum(seq,new_seq,pnum_len);
|
||||
var pyld := pkt.segment(pnum_pos + pnum_len,pkt.end);
|
||||
res := tls.decrypt_aead(c,level,pyld,new_seq,hdr);
|
||||
if res.ok {
|
||||
# fix up the length field to account for removal of checksum
|
||||
if h.hdr_long {
|
||||
var new_len := to_var_int_16(h.payload_length-16);
|
||||
hdr := hdr.set(pnum_pos-2,new_len.value(0));
|
||||
hdr := hdr.set(pnum_pos-1,new_len.value(1));
|
||||
};
|
||||
res.data := hdr.extend(res.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ include file
|
|||
# Parameters are:
|
||||
#
|
||||
# the_cid:int cid to be used by the client (default 0xd)
|
||||
# client_addr:int the client IP address (default 0xff000001, i.e., the loopback interface)
|
||||
# server_addr:int the server IP address (default 0xff000001, i.e., the loopback interface)
|
||||
# client_addr:int the client IP address (default 0x7f000001, i.e., the loopback interface)
|
||||
# server_addr:int the server IP address (default 0x7f000001, i.e., the loopback interface)
|
||||
# server_port:int the server port number (default 4443)
|
||||
# send_fin:bool indicates the server waits for FIN in stream to respond
|
||||
#
|
||||
|
@ -64,8 +64,8 @@ object endpoint_id = {
|
|||
# The parameters
|
||||
|
||||
parameter the_cid : cid = 0xd
|
||||
parameter client_addr : ip.addr = 0xff000001
|
||||
parameter server_addr : ip.addr = 0xff000001
|
||||
parameter client_addr : ip.addr = 0x7f000001
|
||||
parameter server_addr : ip.addr = 0x7f000001
|
||||
parameter server_port : ip.port = 4443
|
||||
parameter server_cid : cid = 0xb
|
||||
parameter client_port : ip.port = 4987
|
||||
|
@ -122,7 +122,7 @@ instance net : udp_impl(endpoint_id,prot.arr,quic_prot_ser,quic_prot_deser)
|
|||
|
||||
action endpoint_id_addr(ep_id : endpoint_id) returns (ep:ip.endpoint) = {
|
||||
ep.protocol := ip.udp;
|
||||
ep.addr := server_addr if ep_id = endpoint_id.server else 0xc0a80102; # the loop-back addr
|
||||
ep.addr := server_addr if ep_id = endpoint_id.server else client_addr; # the loop-back addr
|
||||
ep.port := client_port if ep_id = endpoint_id.client
|
||||
else (client_port_alt if ep_id = endpoint_id.client_alt
|
||||
else server_port);
|
||||
|
@ -349,7 +349,7 @@ implement net.recv(host:endpoint_id, s:net.socket, src:ip.endpoint, pkts:prot.ar
|
|||
}
|
||||
else {
|
||||
call undecryptable_packet_event(src,dst,ppkt);
|
||||
assert false;
|
||||
# assert false;
|
||||
};
|
||||
idx := idx.next;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import os
|
|||
import sys
|
||||
import imp
|
||||
import subprocess
|
||||
import stats
|
||||
import re
|
||||
import time
|
||||
|
||||
|
@ -30,15 +29,62 @@ tests = [
|
|||
|
||||
import sys
|
||||
def usage():
|
||||
print "usage: \n {} <dir> <iters> <server> [pat]".format(sys.argv[0])
|
||||
print """usage:
|
||||
{} [option...]
|
||||
options:
|
||||
dir=<output directory to create>
|
||||
iters=<number of iterations>
|
||||
server={{picoquic,quant,winquic}}
|
||||
test=<test name pattern>
|
||||
stats={{true,false}}
|
||||
""".format(sys.argv[0])
|
||||
sys.exit(1)
|
||||
if len(sys.argv) < 4 or len(sys.argv) > 5 :
|
||||
usage()
|
||||
exit(1)
|
||||
dirpath = sys.argv[1]
|
||||
iters = int(sys.argv[2])
|
||||
server_name = sys.argv[3]
|
||||
pat = sys.argv[4] if len(sys.argv) >= 5 else '*'
|
||||
|
||||
dirpath = None
|
||||
iters = 100
|
||||
server_name = 'winquic'
|
||||
getstats = False
|
||||
pat = '*'
|
||||
|
||||
# server_addr=0xc0a80101 client_addr=0xc0a80102
|
||||
ivy_options = {'server_addr':None,'client_addr':None}
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
vals = arg.split('=')
|
||||
if len(vals) != 2:
|
||||
usage()
|
||||
name,val = vals
|
||||
if name == 'dir':
|
||||
dirpath = val
|
||||
elif name == 'iters':
|
||||
try:
|
||||
iters = int(val)
|
||||
except:
|
||||
usage()
|
||||
elif name == 'server':
|
||||
server_name = val
|
||||
elif name == 'stats':
|
||||
if val not in ['true','false']:
|
||||
usage()
|
||||
getstats = val == 'true'
|
||||
elif name == 'test':
|
||||
pat = val
|
||||
elif name in ivy_options:
|
||||
ivy_options[name] = val
|
||||
else:
|
||||
usage()
|
||||
|
||||
if dirpath is None:
|
||||
idx = 0
|
||||
while True:
|
||||
path = os.path.join('temp',str(idx))
|
||||
if not os.path.exists(path):
|
||||
dirpath = path
|
||||
break
|
||||
idx = idx + 1
|
||||
|
||||
print 'output directory: {}'.format(dirpath)
|
||||
|
||||
try:
|
||||
patre = re.compile(pat)
|
||||
except:
|
||||
|
@ -51,7 +97,8 @@ except OSError:
|
|||
sys.stderr.write('cannot create directory "{}"\n'.format(dirpath))
|
||||
exit(1)
|
||||
|
||||
extra_args = ['server_addr=0xc0a80101','client_addr=0xc0a80102'] if server_name == 'winquic' else []
|
||||
# extra_args = ['server_addr=0xc0a80101','client_addr=0xc0a80102'] if server_name == 'winquic' else []
|
||||
extra_args = [oname+'='+oval for oname,oval in ivy_options.iteritems() if oval is not None]
|
||||
|
||||
svrd = dict(servers)
|
||||
if server_name not in svrd:
|
||||
|
@ -178,11 +225,13 @@ try:
|
|||
status = test.run(seq)
|
||||
if not status:
|
||||
num_failures += 1
|
||||
with open_out(test.name+'.dat') as out:
|
||||
save = os.getcwd()
|
||||
os.chdir(dirpath)
|
||||
stats.doit(test.name,out)
|
||||
os.chdir(save)
|
||||
if getstats:
|
||||
import stats
|
||||
with open_out(test.name+'.dat') as out:
|
||||
save = os.getcwd()
|
||||
os.chdir(dirpath)
|
||||
stats.doit(test.name,out)
|
||||
os.chdir(save)
|
||||
if num_failures:
|
||||
print 'error: {} tests(s) failed'.format(num_failures)
|
||||
else:
|
||||
|
|
|
@ -249,7 +249,7 @@ module tls_gnutls(cid,index,bytes,extens,exten_ser,lower,upper) = {
|
|||
ptls_buffer_init(&sendbuf, (void *)"", 0);
|
||||
int ret = ptls_handle_message(s->gs, &sendbuf, epoch_offsets, in_epoch, input, inlen, s->hsp);
|
||||
if (ret == PTLS_ERROR_IN_PROGRESS) {
|
||||
std::cerr << "PICOTLS RETURNED PTLS_ERROR_IN_PROGRESS\n";
|
||||
// std::cerr << "PICOTLS RETURNED PTLS_ERROR_IN_PROGRESS\n";
|
||||
} else if (ret != 0) {
|
||||
std::cerr << "PICOTLS RETURNED ERROR: " << ret << "\n";
|
||||
}
|
||||
|
@ -408,9 +408,9 @@ module tls_gnutls(cid,index,bytes,extens,exten_ser,lower,upper) = {
|
|||
pn_enc = (ptls_cipher_context_t *)(s->crypto_context[l].pn_dec);
|
||||
if (!pn_enc) {
|
||||
std::cerr << "cipher for level " << l << " is not set\n";
|
||||
exit(1);
|
||||
sz = 0;
|
||||
}
|
||||
sz = pn_enc->algo->iv_size;
|
||||
else sz = pn_enc->algo->iv_size;
|
||||
|
||||
>>>
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ object impl(me:host) = {
|
|||
myaddr.sin_addr.s_addr = htonl(addr.addr);
|
||||
// myaddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
myaddr.sin_port = htons(addr.port);
|
||||
// std::cout << "binding id: " << `me` << " port: " << ntohs(myaddr.sin_port) << std::endl;
|
||||
std::cout << "binding id: " << `me` << " addr: " << ntohl(myaddr.sin_addr.s_addr) << " port: " << ntohs(myaddr.sin_port) << std::endl;
|
||||
if (::bind(s, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0)
|
||||
{ perror("bind failed"); exit(1); }
|
||||
install_reader(new udp_reader(`me`,s, *`cb`, this));
|
||||
|
|
Загрузка…
Ссылка в новой задаче