crypto

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanSetHolder added in v0.19.1

func CanSetHolder(key IdentifiedKey) bool

CanSetHolder returns true if the holder of the key can be updated.

func Equal

func Equal(a, b IdentifiedKey) bool

Equal checks whether a and b are equal.

func SetHolder added in v0.19.1

func SetHolder(key IdentifiedKey, holder uuid.UUID) bool

SetHolder sets the holder uuid for a key or returns false if incorrect.

func WritePlayerKey added in v0.19.1

func WritePlayerKey(wr io.Writer, playerKey IdentifiedKey) error

Types

type IdentifiedKey

type IdentifiedKey interface {
	KeySigned
	// SignedPublicKey returns RSA public key.
	// Note: this key is at least 2048 bits but may be larger.
	SignedPublicKey() *rsa.PublicKey
	SignedPublicKeyBytes() []byte
	// VerifyDataSignature validates a signature against this public key.
	VerifyDataSignature(signature []byte, toVerify ...[]byte) bool
	// SignatureHolder retrieves the signature holders UUID.
	// Returns null before the LoginEvent.
	SignatureHolder() uuid.UUID
	// KeyRevision retrieves the key revision.
	KeyRevision() keyrevision.Revision
}

IdentifiedKey represents session-server cross-signed dated RSA public key.

func NewIdentifiedKey

func NewIdentifiedKey(revision keyrevision.Revision, key []byte, expiry int64, signature []byte) (IdentifiedKey, error)

func ReadPlayerKey added in v0.19.1

func ReadPlayerKey(protocol proto.Protocol, rd io.Reader) (IdentifiedKey, error)

type KeyIdentifiable

type KeyIdentifiable interface {
	// IdentifiedKey returns the timed identified key of the object context.
	// Only available in 1.19 and newer.
	IdentifiedKey() IdentifiedKey
}

KeyIdentifiable identifies a type with a public RSA signature.

type KeySigned

type KeySigned interface {
	Signer() *rsa.PublicKey

	// ExpiryTemporal returns the expiry time point of the key.
	// Note: this limit is arbitrary. RSA keys don't expire,
	// but the signature of this key as provided by the session
	// server will expire.
	ExpiryTemporal() time.Time

	// Expired checks if the signature has expired.
	Expired() bool

	// Signature retrieves the RSA signature of the signed object.
	Signature() []byte

	// SignatureValid validates the signature, expiry temporal and key against the signer public key.
	//
	// Note: This will not check for expiry.
	//
	// DOES NOT WORK YET FOR MESSAGES AND COMMANDS!
	//
	// Does not work for 1.19.1 until the user has authenticated.
	SignatureValid() bool

	// Salt returns the signature salt or empty if not salted.
	Salt() []byte
}

type SignaturePair added in v0.19.1

type SignaturePair struct {
	Signer    uuid.UUID
	Signature []byte
}

func (*SignaturePair) Decode added in v0.19.1

func (p *SignaturePair) Decode(c *proto.PacketContext, rd io.Reader) (err error)

func (*SignaturePair) Encode added in v0.19.1

func (p *SignaturePair) Encode(c *proto.PacketContext, wr io.Writer) error

type SignedChatCommand

type SignedChatCommand struct {
	Command            string
	Signer             *rsa.PublicKey
	Expiry             time.Time
	Salt               []byte
	Sender             uuid.UUID
	SignedPreview      bool
	Signatures         map[string][]byte
	PreviousSignatures []*SignaturePair
	LastSignature      *SignaturePair
}

type SignedChatMessage

type SignedChatMessage struct {
	Message            string
	Signer             *rsa.PublicKey
	Signature          []byte
	Expiry             time.Time
	Salt               []byte
	Sender             uuid.UUID
	SignedPreview      bool
	PreviousSignatures []*SignaturePair
	LastSignature      *SignaturePair
}

type SignedMessage

type SignedMessage interface {
	KeySigned
	Message() string       // Returns the signed message.
	SignerUUID() uuid.UUID // Returns the signers UUID.
	PreviewSigned() bool   // If true the signature of this message applies to a stylized component instead.
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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