crypto

package
v0.0.0-...-7a0c30e Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package crypto provides cryptographic primitives for the GOProto implementation.

Package crypto provides cryptographic primitives for the GOProto implementation.

Package crypto provides cryptographic primitives for the GOProto implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthKey

func AuthKey(sharedSecret []byte) []byte

AuthKey computes the authentication key from a shared secret. This is a simplified version - in practice, this would involve more steps.

func GenerateRandomIV

func GenerateRandomIV(blockSize int) ([]byte, error)

GenerateRandomIV generates a random IV for AES-IGE encryption.

func MessageKey

func MessageKey(data []byte) [16]byte

MessageKey calculates the message key as used in GOProto. It's the SHA-1 hash of a portion of the encrypted message.

func SHA1

func SHA1(data []byte) []byte

SHA1 computes the SHA-1 hash of the input data.

func SHA256

func SHA256(data []byte) []byte

SHA256 computes the SHA-256 hash of the input data.

Types

type DiffieHellman

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

DiffieHellman represents a Diffie-Hellman key exchange instance.

func NewDiffieHellman

func NewDiffieHellman() *DiffieHellman

NewDiffieHellman creates a new Diffie-Hellman instance with a predefined prime and generator. Uses a 2048-bit prime similar to RFC 3526 Group 14.

func (*DiffieHellman) ComputeSharedSecret

func (dh *DiffieHellman) ComputeSharedSecret(theirPublicKey *big.Int) *big.Int

ComputeSharedSecret computes the shared secret using our private key and their public key.

func (*DiffieHellman) GenerateKeys

func (dh *DiffieHellman) GenerateKeys() error

GenerateKeys generates a new private and public key pair.

func (*DiffieHellman) GetGenerator

func (dh *DiffieHellman) GetGenerator() int64

GetGenerator returns the generator used in the Diffie-Hellman exchange.

func (*DiffieHellman) GetPrime

func (dh *DiffieHellman) GetPrime() *big.Int

GetPrime returns the prime used in the Diffie-Hellman exchange.

func (*DiffieHellman) GetPublicKey

func (dh *DiffieHellman) GetPublicKey() *big.Int

GetPublicKey returns the public key.

type IGE

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

IGE (Infinite Garble Extension) implements the AES-IGE mode as used in GOProto.

func NewIGE

func NewIGE(key []byte) (*IGE, error)

NewIGE creates a new IGE instance with the given key.

func (*IGE) Decrypt

func (ige *IGE) Decrypt(ciphertext, iv []byte) ([]byte, error)

Decrypt decrypts the ciphertext using AES-IGE mode.

func (*IGE) Encrypt

func (ige *IGE) Encrypt(plaintext, iv []byte) ([]byte, error)

Encrypt encrypts the plaintext using AES-IGE mode.

Jump to

Keyboard shortcuts

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