keys

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 19 Imported by: 3

Documentation

Overview

Package keys holds helper methods to generate/read/convert/write keys for Crypt4GH. Supported keys: OpenSSH (Ed25519), OpenSSL (Ed25519, X25519), Crypt4GH (X25519).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DerivePublicKey

func DerivePublicKey(privateKey [chacha20poly1305.KeySize]byte) (publicKey [chacha20poly1305.KeySize]byte)

DerivePublicKey derives public key from X25519 private key.

func GenerateKeyPair

func GenerateKeyPair() (publicKey, privateKey [chacha20poly1305.KeySize]byte, err error)

GenerateKeyPair method generates X25519 key pair.

func GenerateReaderSharedKey

func GenerateReaderSharedKey(privateKey, publicKey [chacha20poly1305.KeySize]byte) (*[]byte, error)

GenerateReaderSharedKey generates shared key for recipient, based on ECDH and BLAKE2 SHA-512.

func GenerateWriterSharedKey

func GenerateWriterSharedKey(privateKey, publicKey [chacha20poly1305.KeySize]byte) (*[]byte, error)

GenerateWriterSharedKey generates shared key for sender, based on ECDH and BLAKE2 SHA-512.

func PrivateKeyToCurve25519

func PrivateKeyToCurve25519(curve25519Private *[32]byte, privateKey ed25519.PrivateKey)

PrivateKeyToCurve25519 converts an ed25519 private key into a corresponding curve25519 private key such that the resulting curve25519 public key will equal the result from PublicKeyToCurve25519.

func PublicKeyToCurve25519

func PublicKeyToCurve25519(curveBytes *[32]byte, edBytes ed25519.PublicKey) bool

PublicKeyToCurve25519 converts an Ed25519 public key into the curve25519 public key that would be generated from the same private key.

func ReadPrivateKey

func ReadPrivateKey(reader io.Reader, passPhrase []byte) (privateKey [chacha20poly1305.KeySize]byte, err error)

ReadPrivateKey reads private key from io.Reader. Supported keys: OpenSSH (Ed25519, ECDH X25519), OpenSSL (Ed25519, X25519), Crypt4GH (X25519).

func ReadPublicKey

func ReadPublicKey(reader io.Reader) (publicKey [chacha20poly1305.KeySize]byte, err error)

ReadPublicKey reads public key from io.Reader. Supported keys: OpenSSH (Ed25519), OpenSSL (Ed25519, X25519), Crypt4GH (X25519).

func WriteCrypt4GHX25519PrivateKey

func WriteCrypt4GHX25519PrivateKey(writer io.Writer, privateKey [chacha20poly1305.KeySize]byte, password []byte) error

WriteCrypt4GHX25519PrivateKey writes X25519 public key to io.Writer in Crypt4GH format.

func WriteCrypt4GHX25519PublicKey

func WriteCrypt4GHX25519PublicKey(writer io.Writer, publicKey [chacha20poly1305.KeySize]byte) error

WriteCrypt4GHX25519PublicKey writes X25519 public key to io.Writer in Crypt4GH format.

func WriteOpenSSLX25519PrivateKey

func WriteOpenSSLX25519PrivateKey(writer io.Writer, privateKey [chacha20poly1305.KeySize]byte) error

WriteOpenSSLX25519PrivateKey writes X25519 public key to io.Writer in OpenSSL format.

func WriteOpenSSLX25519PublicKey

func WriteOpenSSLX25519PublicKey(writer io.Writer, publicKey [chacha20poly1305.KeySize]byte) error

WriteOpenSSLX25519PublicKey writes X25519 public key to io.Writer in OpenSSL format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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