spipe

package module
v0.0.0-...-3e93270 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2014 License: BSD-2-Clause Imports: 15 Imported by: 13

README

Alpha version.

Documentation

Overview

Package spipe implements Colin Percival's spiped protocol (http://www.tarsnap.com/spiped.html) for creating symmetrically encrypted and authenticated connections.

Communication between client and server requires a pre-shared symmetric key with at least 256 bits of entropy. The initial key negotiation is performed using HMAC-SHA256 and an authenticated Diffie-Hellman key exchange over the standard 2048-bit "group 14". Packets are transmitted encrypted with AES-256 in CTR mode and authenticated using HMAC-SHA256.

The Dial function connects to a server and performs handshake:

conn, err := spipe.Dial(sharedKey, "tcp", "127.0.0.1:8080")
if err != nil {
	// handle error
}
fmt.Fprintf(conn, "Hello\n")

The Listen function creates servers:

ln, err := spipe.Listen(sharedKey, "tcp", ":8080")
if err != nil {
	// handle error
}
for {
	conn, err := ln.Accept()
	if err != nil {
		// handle error
		continue
	}
	go handleConnection(conn)
}

Shared key can be of any length, as it is compressed with SHA256 before using.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(key []byte, network, laddr string) (net.Listener, error)

Listen announces on the local network address laddr, which will accept spipe client connections with the given shared secret key.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func Client

func Client(key []byte, nc net.Conn) *Conn

Client returns a new spipe client connection using nc as the underlying connection.

func Dial

func Dial(key []byte, network, raddr string) (*Conn, error)

Dial connects to remote address raddr on the given network, which must be running spipe server with the same shared secret key. It then performs handshake to authenticate itself, and returns the connection on success.

func Server

func Server(key []byte, nc net.Conn) *Conn

Server returns a new spipe server connection using nc as the underlying connection.

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Flush

func (c *Conn) Flush() error

func (*Conn) Handshake

func (c *Conn) Handshake() error

Handshake runs handshake if it has not yet been run. Most users of this package need not call Handshake explicitly: the first Read or Write will call it automatically.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (c *Conn) Read(p []byte) (nn int, err error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

func (c *Conn) Write(p []byte) (nn int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL