[INACTIVE] TLS 1.2 implementation in Rust

Related tags

Cryptography suruga
Overview

suruga is Rust implementation of TLS 1.2.

It currently implements some core parts of TLS 1.2, NIST P-256 ECDHE and chacha20-poly1305.

Usage

extern crate suruga;

use std::io::prelude::*;
use std::net::TcpStream;

fn main() {
    test().unwrap();
}

fn test() -> suruga::tls_result::TlsResult<()> {
    let stream = try!(TcpStream::connect("www.google.com:443"));
    let mut client = try!(suruga::TlsClient::from_tcp(stream));
    let _len = try!(client.write(b"GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n"));

    let mut msg = vec![0u8; 100];
    try!(client.read(&mut msg));
    let msg = String::from_utf8_lossy(&msg);
    println!("msg: {}", msg);

    try!(client.close());

    Ok(())
}
Comments
  • Use Sized trait for Self

    Use Sized trait for Self

    Use Sized trait for Self, to remove this kind of warning:

    λ cargo build
       Compiling suruga v0.1.0
    src\tls_item.rs:21:5: 21:64 warning: the trait `core::marker::Sized` is not implemented for the type `Self` [E0277]
    src\tls_item.rs:21     fn tls_read<R: ReadExt>(reader: &mut R) -> TlsResult<Self>;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src\tls_item.rs:21:5: 21:64 help: run `rustc --explain E0277` to see a detailed explanation
    src\tls_item.rs:21:5: 21:64 note: `Self` does not have a constant size known at compile-time
    src\tls_item.rs:21:5: 21:64 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
    src\tls_item.rs:21     fn tls_read<R: ReadExt>(reader: &mut R) -> TlsResult<Self>;
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src\tls_item.rs:21:5: 21:64 note: required by `core::result::Result`
    
    

    Because it would be a hard error in the next Rust version.

    opened by luthfianto 1
  • Rust nightly

    Rust nightly

    This will probably be an ongoing issue seeing how Rust changes all the time. Currently doesn't work with nightly rustc 1.0.0-nightly (c5961ad06 2015-01-28 21:49:38 +0000).

    src/cipher/ecdhe.rs:2:5: 2:23 error: unresolved import `std::io::BufReader`. Could not find `io` in `std`
    src/cipher/ecdhe.rs:2 use std::io::BufReader;
                              ^~~~~~~~~~~~~~~~~~
    src/handshake.rs:1:5: 1:23 error: unresolved import `std::io::MemReader`. Could not find `io` in `std`
    src/handshake.rs:1 use std::io::MemReader;
                           ^~~~~~~~~~~~~~~~~~
    src/client.rs:1:5: 1:33 error: unresolved import `std::io::net::tcp::TcpStream`. Could not find `io` in `std`
    src/client.rs:1 use std::io::net::tcp::TcpStream;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/client.rs:4:15: 4:23 error: unresolved import `std::io::IoResult`. Could not find `io` in `std`
    src/client.rs:4 use std::io::{IoResult, IoError, OtherIoError};
                                  ^~~~~~~~
    src/client.rs:4:25: 4:32 error: unresolved import `std::io::IoError`. Could not find `io` in `std`
    src/client.rs:4 use std::io::{IoResult, IoError, OtherIoError};
                                            ^~~~~~~
    src/client.rs:4:34: 4:46 error: unresolved import `std::io::OtherIoError`. Could not find `io` in `std`
    src/client.rs:4 use std::io::{IoResult, IoError, OtherIoError};
                                                     ^~~~~~~~~~~~
    src/tls_result.rs:2:5: 2:21 error: unresolved import `std::io::IoError`. Could not find `io` in `std`
    src/tls_result.rs:2 use std::io::IoError;
    

    Fixed somewhat in #4 but needs more work (cargo test in particular).

    opened by soulseekah 1
  • Make it work with rustc 1.0.0-nightly

    Make it work with rustc 1.0.0-nightly

    at rustc 1.0.0-nightly (c5961ad06 2015-01-28 21:49:38 +0000)

    Renamed std::io to std::old_io since io is moving somewhere. Added a couple of missing new trait requirements.

    cargo test is still failing:

    src/crypto/p256.rs:615:26: 615:32 error: type `[u32]` does not implement any method in scope named `fmt`
    src/crypto/p256.rs:615                 self.v[].fmt(a)
                                                    ^~~~~~
    src/crypto/p256.rs:615:32: 615:32 help: methods from traits can only be called if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
    src/crypto/p256.rs:615:32: 615:32 help: candidate #1: use `core::fmt::Debug`
    src/crypto/poly1305.rs:348:24: 348:30 error: type `[u32]` does not implement any method in scope named `fmt`
    src/crypto/poly1305.rs:348             (self.v[]).fmt(a)
                                                      ^~~~~~
    src/crypto/poly1305.rs:348:30: 348:30 help: methods from traits can only be called if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
    src/crypto/poly1305.rs:348:30: 348:30 help: candidate #1: use `core::fmt::Debug`
    
    opened by soulseekah 1
  • Add copy_memory replacement function, because it's deprecated

    Add copy_memory replacement function, because it's deprecated

    copy_memory is already deprecated, as per rust-lang/rust#27740 and removed from Rust 1.5

    After applying #14 and this PR, suruga can be built and passes cargo test on Rust 1.5

    opened by luthfianto 0
  • Fix E0034 ambiguity errors with Universal Funtion Call syntax

    Fix E0034 ambiguity errors with Universal Funtion Call syntax

    It won't compile in Rust 1.5 without the UFC

    (Actually it still won't compile in Rust 1.5 because of a different error. The error is the use of deprecated std::slice::bytes::copy_memory in src/client.rs:4. See #15)

    opened by luthfianto 0
  • Update for upstream changes

    Update for upstream changes

    This patchset fixes:

    • obsolete syntax issues
    • crypto algorithms due to overflow semantic changes
    • std::io changes

    rustc version: nightly 30e1f9a1c 2015-03-14

    opened by klutzy 0
  • (WIP) X.509 certificate parser

    (WIP) X.509 certificate parser

    WIP of #2. not intended to merge yet.

    der todos:

    • from_tlv refactor
    • reduce clone: slices rather than owning vectors
    • re-re-review chrono routine (datetime depends on it, so cert validation may rely on it)

    x509 todos:

    • prepare proper testsuite (currently using nist pkix. use other suites too), test integration
    • more validation impl & test
    • rsa.. boring
    opened by klutzy 0
  • Implement certificate parser / validation

    Implement certificate parser / validation

    opened by klutzy 7
Owner
klutzy/defunct
klutzy/defunct
A Rust implementation of Trojan with QUIC tunnel, Lite-TLS and more.

Trojan-Oxide A Rust implementation of Trojan with QUIC tunnel, Lite-TLS and more. Overview Full support for the original Trojan Protocol, including TC

null 13 Oct 17, 2022
A modern TLS library in Rust

Rustls is a modern TLS library written in Rust. It's pronounced 'rustles'. It uses ring for cryptography and libwebpki for certificate verification. S

ctz 4k Jan 9, 2023
OpenSSL compatibility layer for the Rust SSL/TLS stack

An OpenSSL compatibility layer for the Rust SSL/TLS stack. MesaLink is an OpenSSL compatibility layer for the Rust SSL/TLS stack, namely rustls, webpk

MesaLock Linux 1.5k Dec 23, 2022
A modern TLS library in Rust

Rustls is a modern TLS library written in Rust. It uses ring for cryptography and libwebpki for certificate verification. Status Rustls is ready for u

null 4k Jan 9, 2023
A no-std / no-alloc TLS 1.3 client

puny-tls - no-std/no-alloc TLS 1.3 client This is an improvement over tiny-tls-rs to make it more useable. However the only reason this exists is to r

Björn Quentin 2 Aug 22, 2022
Marvin-Blockchain-Rust: A Rust-based blockchain implementation, part of the Marvin blockchain project.

Marvin Blockchain - Rust Implementation Welcome to the Rust implementation of the Marvin Blockchain. This project is part of a comparative study on bu

João Henrique Machado Silva 3 Sep 6, 2024
IBC modules and relayer - Formal specifications and Rust implementation

ibc-rs Rust implementation of the Inter-Blockchain Communication (IBC) protocol. This project comprises primarily four crates: The ibc crate defines t

Informal Systems 296 Dec 31, 2022
A Rust implementation of BIP-0039

bip39-rs A Rust implementation of BIP0039 Changes See the changelog file, or the Github releases for specific tags. Documentation Add bip39 to your Ca

Infincia LLC 49 Dec 9, 2022
Official Rust implementation of the Nimiq protocol

Nimiq Core implementation in Rust (core-rs) Rust implementation of the Nimiq Blockchain Core Nimiq is a frictionless payment protocol for the web. Thi

Nimiq 72 Sep 23, 2022
Rust implementation of Zcash protocol

The Parity Zcash client. Gitter Blog: Parity teams up with Zcash Foundation for Parity Zcash client Installing from source Installing the snap Running

Parity Technologies 183 Sep 8, 2022
A (mostly) pure-Rust implementation of various cryptographic algorithms.

Rust-Crypto A (mostly) pure-Rust implementation of various common cryptographic algorithms. Rust-Crypto seeks to create practical, auditable, pure-Rus

null 1.2k Dec 27, 2022
A pure-Rust implementation of group operations on Ristretto and Curve25519

curve25519-dalek A pure-Rust implementation of group operations on Ristretto and Curve25519. curve25519-dalek is a library providing group operations

dalek cryptography 611 Dec 25, 2022
A prototype implementation of the Host Identity Protocol v2 for bare-metal systems, written in pure-rust.

Host Identity Protocol for bare-metal systems, using Rust I've been evaluating TLS replacements in constrained environments for a while now. Embedded

null 31 Dec 12, 2022
An implementation of the FP-Growth algorithm in pure Rust.

fp-growth-rs An implementation of the FP-Growth algorithm in pure Rust, which is inspired by enaeseth/python-fp-growth. Usage Add this to your Cargo.t

JmPotato 13 Dec 20, 2022
A pure-Rust implementation of various threshold secret sharing schemes

Threshold Secret Sharing Efficient pure-Rust library for secret sharing, offering efficient share generation and reconstruction for both traditional S

Snips 137 Dec 29, 2022
A Rust implementation of the Message Layer Security group messaging protocol

Molasses An extremely early implementation of the Message Layer Security group messaging protocol. This repo is based on draft 4 of the MLS protocol s

Trail of Bits 109 Dec 13, 2022
Pure Rust implementation of the RNCryptor cryptographic format by Rob Napier

rncryptor Rust Implementation of the RNCryptor spec This library implements the specification for the RNCryptor encrypted file format by Rob Napier. d

null 7 Jun 29, 2022
Implementation of the Web Cryptography specification in Rust.

[wip] webcrypto Implementation of the Web Cryptography specification in Rust. This crate hopes to ease interoperability between WASM and native target

Divy Srivastava 5 Mar 7, 2022
Implementation of Plonk by Hand in rust

plonk-by-fingers This is a toy implementation of the excellent Joshua Fitzgerald Plonk by hand (part2) (part3) tutorial all written from scratch, do n

adria0.eth 34 Dec 19, 2022