sslv2

package
v0.0.0-...-e4757b4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0, Apache-2.0, ISC Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_TWO_BYTE_RECORD_BYTES   = 32767
	MAX_THREE_BYTE_RECORD_BYTES = 16383
	MAX_RECORD_BYTES            = MAX_TWO_BYTE_RECORD_BYTES
)

Record sizes for two- and three-byte issues

View Source
const (
	MSG_TYPE_CLIENT_HELLO      byte = 1
	MSG_TYPE_SERVER_HELLO      byte = 4
	MSG_TYPE_CLIENT_MASTER_KEY byte = 2
)

Protocol message codes

View Source
const (
	SSL_VERSION_2 uint16 = 0x0002
)

Version codes

Variables

View Source
var ErrInvalidLength = errors.New("Invalid SSLv2 packet length")

ErrInvalidLength is returned when a byte slice to be Unmarshaled is too short, or when a single record length is greater than the max length of 32512 bytes.

View Source
var ErrUnexpectedMessage = errors.New("Unexpected message type")

Functions

This section is empty.

Types

type CipherKind

type CipherKind uint32

CipherKind holds a 3-byte ID for a cipher spec. It is invalid for a CipherKind to be greater than 0x00FFFFFF

const (
	SSL_CK_RC4_128_WITH_MD5              CipherKind = 0x010080
	SSL_CK_RC4_128_EXPORT40_WITH_MD5     CipherKind = 0x020080
	SSL_CK_RC2_128_CBC_WITH_MD5          CipherKind = 0x030080
	SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 CipherKind = 0x040080
	SSL_CK_IDEA_128_CBC_WITH_MD5         CipherKind = 0x050080
	SSL_CK_DES_64_CBC_WITH_MD5           CipherKind = 0x060040
	SSL_CK_DES_192_EDE3_CBC_WITH_MD5     CipherKind = 0x0700C0
)

Standard SSLv3 CipherKinds

func SSLv2CipherFromTLS

func SSLv2CipherFromTLS(newCipher uint32) CipherKind

SSLv2CipherFromTLS returns an SSLv2 object representing a cipher from SSLv3 or newer.

func (*CipherKind) MarshalJSON

func (ck *CipherKind) MarshalJSON() ([]byte, error)

func (*CipherKind) MarshalSSLv2

func (ck *CipherKind) MarshalSSLv2() ([]byte, error)

MarshalBinary implements the binary marshaler interface

func (*CipherKind) UnmarshalBinary

func (ck *CipherKind) UnmarshalBinary(b []byte) error

UnmarshalBinary implements the BinaryUnmarshler interface

type ClientHello

type ClientHello struct {
	Version   uint16       `json:"version"`
	Ciphers   []CipherKind `json:"ciphers,omitempty"`
	SessionID []byte       `json:"session_id,omitempty"`
	Challenge []byte       `json:"challenge,omitempty"`
}

func (*ClientHello) MarshalBinary

func (h *ClientHello) MarshalBinary() (b []byte, err error)

MarshalBinary implements the BinaryMarshaler interface

type ClientMasterKey

type ClientMasterKey struct {
	CipherKind   CipherKind
	ClearKey     []byte
	EncryptedKey []byte
	KeyArg       []byte
}

The ClientMasterKey struct represents the client-master-key message in the SSLv2 handshake protocol. The structure of the message is:

  client-master-key {
    char MSG-CLIENT-MASTER-KEY
    char CIPHER-KIND[3]
    char CLEAR-KEY-LENGTH-MSB
    char CLEAR-KEY-LENGTH-LSB
    char ENCRYPTED-KEY-LENGTH-MSB
    char ENCRYPTED-KEY-LENGTH-LSB
    char KEY-ARG-LENGTH-MSB
    char KEY-ARG-LENGTH-LSB
    char CLEAR-KEY-DATA[MSB<<8|LSB]
    char ENCRYPTED-KEY-DATA[MSB<<8|LSB]
    char KEY-ARG-DATA[MSB<<8|LSB]
}

See http://www-archive.mozilla.org/projects/security/pki/nss/ssl/draft02.html

func (*ClientMasterKey) MarshalSSLv2

func (cmk *ClientMasterKey) MarshalSSLv2() (b []byte, err error)

MarshalSSLv2 implments the marshaler interface

type Config

type Config struct {
	Ciphers    []CipherKind
	ExtraClear bool
}

type Conn

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

func Client

func Client(c net.Conn, config *Config) *Conn

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*Conn) Handshake

func (c *Conn) Handshake() (err error)

func (*Conn) HandshakeLog

func (c *Conn) HandshakeLog() *HandshakeData

func (*Conn) LocalAddr

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

LocalAddr returns the local network address.

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

Read reads data from the connection. Read can be made to time out and return a Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*Conn) RemoteAddr

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

RemoteAddr returns the remote network address.

func (*Conn) SetDeadline

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

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future I/O, not just the immediately following call to Read or Write.

An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.

A zero value for t means I/O operations will not time out.

func (*Conn) SetReadDeadline

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

SetReadDeadline sets the deadline for future Read calls. A zero value for t means Read will not time out.

func (*Conn) SetWriteDeadline

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

SetWriteDeadline sets the deadline for future Write calls. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write writes data to the connection. Write can be made to time out and return a Error with Timeout() == true after a fixed time limit; see SetDeadline and SetWriteDeadline.

type HandshakeData

type HandshakeData struct {
	ClientHello  *ClientHello  `json:"client_hello,omitempty"`
	ServerHello  *ServerHello  `json:"server_hello,omitempty"`
	ServerVerify *ServerVerify `json:"server_verify,omitempty"`
}
type Header struct {
	Length        uint16
	PaddingLength uint8
	// contains filtered or unexported fields
}

func (*Header) MarshalBinary

func (h *Header) MarshalBinary() (b []byte, err error)

MarshalBinary implements the BinaryMarshaler interface

func (*Header) UnmarshalBinary

func (h *Header) UnmarshalBinary(b []byte) (err error)

UnmarshalBinary implements the BinaryUnmarshaler interface

type ServerCertificate

type ServerCertificate struct {
	Raw         []byte            `json:"raw,omitempty"`
	Certificate *x509.Certificate `json:"parsed,omitempty"`
}

type ServerHello

type ServerHello struct {
	SessionIDHit    byte               `json:"session_id_hit"`
	CertificateType byte               `json:"certificate_type"`
	Version         uint16             `json:"version"`
	Certificate     *ServerCertificate `json:"certificate,omitempty"`
	Ciphers         []CipherKind       `json:"ciphers,omitempty"`
	ConnectionID    []byte             `json:"connection_id,omitempty"`
	// contains filtered or unexported fields
}

func (*ServerHello) MarshalBinary

func (h *ServerHello) MarshalBinary() (b []byte, err error)

MarshalBinary implements the BinaryMarshaler interface

func (*ServerHello) UnmarshalBinary

func (h *ServerHello) UnmarshalBinary(b []byte) (err error)

UnmarshalBinary implements the BinaryUnmarshaler interface

type ServerVerify

type ServerVerify struct {
	Raw         []byte `json:"-"`
	MessageType int    `json:"-"`
	Challenge   []byte `json:"-"`
	Valid       bool   `json:"valid"`
	ExtraClear  bool   `json:"extra_clear,omitempty"`
}

Directories

Path Synopsis
Package x509 parses X.509-encoded keys and certificates.
Package x509 parses X.509-encoded keys and certificates.
pkix
Package pkix contains shared, low level structures used for ASN.1 parsing and serialization of X.509 certificates, CRL and OCSP.
Package pkix contains shared, low level structures used for ASN.1 parsing and serialization of X.509 certificates, CRL and OCSP.

Jump to

Keyboard shortcuts

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