Florob / suruga

TLS implementation in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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::net::tcp::TcpStream;

fn main() {
    let stream = TcpStream::connect("www.google.com", 443).unwrap();
    let mut client = suruga::TlsClient::from_tcp(stream).unwrap();
    client.write(b"GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n").unwrap();
    let mut msg = Vec::from_elem(100, 0u8);
    client.read(msg.as_mut_slice()).unwrap();
    let msg = String::from_utf8_lossy(msg.as_slice());
    println!("msg: {}", msg);
    client.close().unwrap();
}

About

TLS implementation in Rust

License:MIT License