dustls, a pure-rust DTLS implementation

Related tags

Miscellaneous dustls
Overview

dustls, a pure-rust DTLS implementation

A DTLSv1.2 implementation in Rust, reusing rustls for cryptographic primitives and most message payload formats.

Note: This library is a work in progress, and (possibly) not yet tuned to the ecosystem.

Note: This library directly works with TLS records, logic, and Cipher Suites, and hasn't had a security audit (yet), use at your own risk.

Comments
  • Published name

    Published name

    I'm still undecided as how to publish the crate on crates.io, I have already tried to get into contact with the crate owner of dtls, and if that comes through, I'll use that.

    However, if it doesn't come through, I'd like an alternative name that can be instantly used. I've thought of rustls-dtls, but that would pledge and use the rustls namespace, which I am not 100% sure on yet.

    Funny or clever names are appreciated though :D

    help wanted 
    opened by ShadowJonathan 5
  • License

    License

    I currently chose the EUPL-1.2 license because I believe it could gain some recognition and interest as a government-created and legalised document, which would give projects using it more assured standing.

    However, in the wider context of usability, compatibility, and other licensing, I don't know if this is the right choice, I'd like to see what some opinions are on licensing, and if I should change it to something like MIT or Apache-2.

    (Of course, before doing that, I'll get consensus from all authors up until that point, so it's easier to change earlier than to do it later.

    Also, I'm only interested if the current license is too restrictive for use, I am not going to change to a viral copyleft license like AGPLv3, as it would hinder library use, which is the primary motivation for this library for me.)

    help wanted 
    opened by ShadowJonathan 3
  • Buffer application data when expecting flight 5 or 6

    Buffer application data when expecting flight 5 or 6

    DTLS implementations are likely to send application data alongside flight 5 or 6, without waiting for confirmation, we should buffer this application data and give it to the connection object to then be immediately decrypted.

    opened by ShadowJonathan 0
  • Replay Protection

    Replay Protection

    Brainstormed some ideas for anti-replay, and they're as follows;

    • Have a VecDeque with epoch and sequence information on the packets, plus their arrival time.
    • Have a "max age" parameter by which all older packets are discarded.

    The first would be done with a 24-byte structure as;

    pub struct PacketToken {
      epoch_seq: u64, // epoch and sequence in one
      at: Instant, // u128 on linux, u64 on macos and windows
    }
    

    This would discard anything older than 2 minutes, or FIFO at a max amount (configurable).

    The oldest packet will update the "max age" sequence counter when it is popped from the stack, but only if it is younger than the age parameter.

    Searching the VecDeque for a match when a packet comes in would introduce a little overhead, but at the cost of replay protection.

    It would also cause a little memory overhead. (On linux, approximately 2.4MB for 100k packets indexed (150MB at max MTU, so 2 minutes of +10MBps download speeds))

    opened by ShadowJonathan 0
  • Server `Handshaker` will not transition to `Connection` until client sends data

    Server `Handshaker` will not transition to `Connection` until client sends data

    The DTLS 1.2 handshake looks like thus; image

    All of this is able to be encapsulated in Handshaker objects, which handle all of this (+ retransmission) for the clients.

    Because of this, handshakes have a special API which makes them able to alert the program to wait until a certain moment to retransmit the packets they'd want to send.

    However, the 6th flight could get lost, either the CCS or the Finished packet, which means the client can get in a deadlock, see the following passage from [RFC6347];

       In addition, for at least twice the default MSL defined for [TCP],
       when in the FINISHED state, the node that transmits the last flight
       (the server in an ordinary handshake or the client in a resumed
       handshake) MUST respond to a retransmit of the peer's last flight
       with a retransmit of the last flight.  This avoids deadlock
       conditions if the last flight gets lost.
    

    However, this would block the server handshaker from transitioning into a connection object until the client has sent any application data.

    It would be more "correct" to wait until a client sends data, but depending on the application, the server might want to immediately start to send data.

    This could be especially problematic with resuming sessions, or #9, which might require this kind of "last state" to be certain before either side starts sending buffered data again.

    For now, I think it's more clean to wait for application data, but in the future I could add a "server handshaker mode" which immediately transitions to a connection object after finishing the last flight, but keeps it sealed and keeps it ready to be sent if the client were to send flight 5 again, this would be a ton of extra logic to keep, though.

    opened by ShadowJonathan 3
  • `DIO` and `SelectiveDIO` traits, and `DeMux`

    `DIO` and `SelectiveDIO` traits, and `DeMux`

    #13 gave requirement for something like Connection objects to become fall-through, however, i don't think this works well with the black-box approach.

    Furthermore, together with #10, I'd like to make something reusable and generic, so i'll settle with a set of traits, and an object/trait;

    • DIO, "Datagram In Out", would also immediately standardise a Datagram IO. This'll only be on connection objects for now, but i could possibly look if i can implement this for things like UdpSocket. This is only currently meant to signal "upwards" IO, inputs to this will go up an abstraction layer, outputs will go down towards more physical layers.
    • SelectiveDIO, basically DIO, but can reject a packet.
    • DeMux, i'm not entirely sure if this'll be an object or a trait, but effectively this'll store many SelectiveDIO objects, and try each one in sequence until one of them accepts. This way, a connection object (wrapped in a dynamic selector), or a SRTP sink/buffer, can be multiplexed over the same "path" that a router would select such an object for.

    I don't know how well this would work/clash with #9, as partially this is also supposed to solve that bit, where multiple connections can exist over the same peering, but this could be a generic enough solution for now.

    For #13, this could be implemented by providing a selector which only checks on the following; 127 < B < 192: forward to RTP Checking the first byte, and moving on if it doesn't match.

    Possibly, in the future, this could allow for a QUIC+DTLS dual endpoint and router.

    batteries 
    opened by ShadowJonathan 0
  • Requirements for use with WebRTC

    Requirements for use with WebRTC

    The WebRTC spec defines some requirements for the used DTLS implementation:

    At least the TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 cipher suite needs to be supported with support for the P-256. Both of these requirements are met in rustls (TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 & P-256).

    Firefox additionally has support for P-384 and x25519 as well as TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, and TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256. Chrome adds TLS_RSA_WITH_AES_128_GCM_SHA256 on top. Except the added one of chrome all are supported by rustls, so this is fine. Both Chrome and Firefox also have support for CBC ones, but I guess we can ignore them (at least for now).

    Furthermore, "Implementations MUST NOT implement DTLS renegotiation and MUST reject it with a "no_renegotiation" alert if offered." So I guess It would be nice if dtls-rs could allow to configure in which cases an alert should be created in addition to allow configuring stuff like renegotiation.

    The spec has some more API requirements I will not copy here. Could you have a look at them too?

    request 
    opened by valkum 1
Owner
Jonathan de Jong
amateur sysadmin, programs only sometime, likes coffee with sugar and milk
Jonathan de Jong
Risc-V assembly interpreter built with pure Rust

Risc-V Interpreter Interpreter for Risc-V assembly built with Rust Report bug · Request feature Table of contents Quick start Exemple Program Instruct

null 2 Aug 24, 2022
A pure-Rust serverless discord chatbot hosted on Cloudflare Workers.

About A pure-Rust serverless discord chatbot hosted on Cloudflare Workers. With a free account you have up to 100k requests per day. For storing state

Mike Dallas 31 Nov 21, 2022
A fast llama2 decoder in pure Rust.

llama2.rs ?? This is a Rust implementation of Llama2 inference on CPU The goal is to be as fast as possible. It has the following features: Support fo

Sasha Rush 771 Oct 30, 2023
The official rust implementation of the SpamProtectionBot API

SpamProtection-rs Table of contents About Supported Rust version Features How to use Credits License About SpamProtection-Rust is a Rust wrapper for I

Intellivoid 0 Feb 26, 2022
RusTiny -- A Rust implementation of Tiny+ language

RusTiny -- A Rust implementation of Tiny+ language 编译器实践 基本要求: 参考《编译原理及实践》的TINY语言编译器(已上传到群中)完成TINY+ 语言(见附录 A)的解释器:即给定满足 TINY+语言的源代码输入,你的解 释器可以给出对其的解释执

M4tsuri 2 May 22, 2022
kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

kindly is a simple Rust implementation of a set-user-ID-root program, similar to sudo but in a much reduced way.

Vinícius Miguel 26 Dec 5, 2022
An implementation of Joker Calculus in Rust

Joker Calculus An implementation of Joker Calculus in Rust Based on paper Joker Calculus, by Daniel Fischer, William Alexander Morris and Sven Nilsen

AdvancedResearch 4 Jan 17, 2022
Mild RSA implementation written in Rust for a class.

rust_rsa About this repo This is my Rust implementation of the RSA encryption standard, based on this book. This is for my CS 3000 - Advanced Algorith

Star 0 May 6, 2022
A clean implementation of Reso using Rust.

A clean implementation of Reso using Rust. The principle of Reso Rust is almost identical to Reso, only missing some functionality

Matas Minelga 12 Nov 26, 2022
An experimental implementation of gitbom in Rust

gitbom-rs "An experimental implementation of GitBOM in Rust" NOTICE: This project is still a work in progress and is not ready for any use beyond expe

GitBOM 9 Sep 1, 2022
Rust implementation for parsing StarCraft .chk files.

bwmap Rust implementation for parsing StarCraft .chk files. bounding.net uses this library to parse StarCraft and StarCraft: Brood War maps and store

null 8 Dec 19, 2022
rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust.

rlox-interpreter rlox-interpreter is an AST-walking implementation of Bob Nystrom's Lox language in Rust. Disclaimer: This is my first Rust project, d

Paul Fedorow 3 Oct 5, 2022
Rust implementation for Wlroots (Sway, Wayfire, Hikari, River, etc.) of Gnome Screenshot and Idle DBUS Server, which Upwork uses to capture the screen as proof of work.

?? upwork-wlroots-bridge ?? Rust Implementation for Wlroots (Sway, Wayfire, Hikari, River, etc.) of Gnome Screenshot and Idle DBUS Server (with extra

Daniel Moretti V. 4 Jan 2, 2023
Rust implementation of ESP32 NVS partition generator.

Simple ESP32 NVS writer library for Rust Overview A library for Rust to generate NVS partitions for ESP32. How to use See examples/write_simple.rs. Ma

Kenta IDA 4 Dec 29, 2022
LSR - A Rust Implementation of LS for Windows

LSR - A Rust Implementation of LS for Windows(and possibly other platforms) This is underdevelopment Quick Start For now, I only tested this code on t

Christopher Schneider 4 Jan 31, 2023
The most primitive and the fastest implementation of a fixed-size last-in-first-out stack on stack in Rust, for Copy-implementing types

This is the simplest and the fastest (faster than Vec!) implementation of a last-in-first-out stack data structure, on stack, when stack elements are

Yegor Bugayenko 10 Jun 18, 2023
A mimimal Rust implementation of Llama.c

llama2.rs Rust meets llama. A mimimal Rust implementation of karpathy's llama.c. Currently the code uses the 15M parameter model provided by Karpathy

null 6 Aug 8, 2023
A rust and SageMath implementation of (2,2)-isogenies in the theta model

An Algorithmic Approach to (2, 2)-isogenies in the Theta Model Code accompanying the research paper: An Algorithmic Approach to (2, 2)-isogenies in th

null 7 Dec 4, 2023
unFlow is a Design as Code implementation, a DSL for UX & backend modeling. DSL to Sketch file, Sketch to DSL, DSL to code.

unflow 是一个低代码、无代码设计语言。unFlow is a Design as Code implementation, a DSL for UX & backend modeling. DSL to Sketch file, Sketch to DSL, DSL to code.

Inherd OS Team (硬核开源小组) 70 Nov 27, 2022