crypto

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 7 Imported by: 1,106

Documentation

Overview

Deprecated: This package has moved into go-libp2p as a sub-package: github.com/libp2p/go-libp2p/core/crypto.

Package crypto implements various cryptographic utilities used by libp2p. This includes a Public and Private key interface and key implementations for supported key algorithms.

Index

Constants

View Source
const (
	// RSA is an enum for the supported RSA key type
	RSA = iota
	// Ed25519 is an enum for the supported Ed25519 key type
	Ed25519
	// Secp256k1 is an enum for the supported Secp256k1 key type
	Secp256k1
	// ECDSA is an enum for the supported ECDSA key type
	ECDSA
)
View Source
const WeakRsaKeyEnv = crypto.WeakRsaKeyEnv

WeakRsaKeyEnv is an environment variable which, when set, lowers the minimum required bits of RSA keys to 512. This should be used exclusively in test situations. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.WeakRsaKeyEnv instead

Variables

View Source
var (
	// ErrNotECDSAPubKey is returned when the public key passed is not an ecdsa public key
	// Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNotECDSAPubKey instead
	ErrNotECDSAPubKey = crypto.ErrNotECDSAPubKey
	// ErrNilSig is returned when the signature is nil
	// Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNilSig instead
	ErrNilSig = crypto.ErrNilSig
	// ErrNilPrivateKey is returned when a nil private key is provided
	// Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNilPrivateKey instead
	ErrNilPrivateKey = crypto.ErrNilPrivateKey
	// ErrNilPublicKey is returned when a nil public key is provided
	// Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrNilPublicKey instead
	ErrNilPublicKey = crypto.ErrNilPublicKey
	// ECDSACurve is the default ecdsa curve used
	// Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSACurve instead
	ECDSACurve = elliptic.P256()
)
View Source
var (
	// ErrBadKeyType is returned when a key is not supported
	ErrBadKeyType = errors.New("invalid or unsupported key type")
	// KeyTypes is a list of supported keys
	KeyTypes = []int{
		RSA,
		Ed25519,
		Secp256k1,
		ECDSA,
	}
)
View Source
var ErrRsaKeyTooSmall error

ErrRsaKeyTooSmall is returned when trying to generate or parse an RSA key that's smaller than MinRsaKeyBits bits. In test Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ErrRsaKeyTooSmall instead

View Source
var MinRsaKeyBits = crypto.MinRsaKeyBits

Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MinRsaKeyBits instead

View Source
var PrivKeyUnmarshallers = crypto.PrivKeyUnmarshallers

PrivKeyUnmarshallers is a map of unmarshallers by key type Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKeyUnmarshallers instead

View Source
var PubKeyUnmarshallers = crypto.PubKeyUnmarshallers

PubKeyUnmarshallers is a map of unmarshallers by key type Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKeyUnmarshallers instead

Functions

func ConfigDecodeKey

func ConfigDecodeKey(b string) ([]byte, error)

ConfigDecodeKey decodes from b64 (for config file) to a byte array that can be unmarshalled. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ConfigDecodeKey instead

func ConfigEncodeKey

func ConfigEncodeKey(b []byte) string

ConfigEncodeKey encodes a marshalled key to b64 (for config file). Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ConfigEncodeKey instead

func ECDSAKeyPairFromKey

func ECDSAKeyPairFromKey(priv *ecdsa.PrivateKey) (PrivKey, PubKey, error)

ECDSAKeyPairFromKey generates a new ecdsa private and public key from an input private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAKeyPairFromKey instead

func GenerateECDSAKeyPair

func GenerateECDSAKeyPair(src io.Reader) (PrivKey, PubKey, error)

GenerateECDSAKeyPair generates a new ecdsa private and public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateECDSAKeyPair instead

func GenerateECDSAKeyPairWithCurve

func GenerateECDSAKeyPairWithCurve(curve elliptic.Curve, src io.Reader) (PrivKey, PubKey, error)

GenerateECDSAKeyPairWithCurve generates a new ecdsa private and public key with a speicified curve Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateECDSAKeyPairWithCurve instead

func GenerateEd25519Key

func GenerateEd25519Key(src io.Reader) (PrivKey, PubKey, error)

GenerateEd25519Key generates a new ed25519 private and public key pair. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateEd25519Key instead

func GenerateKeyPair

func GenerateKeyPair(typ, bits int) (PrivKey, PubKey, error)

GenerateKeyPair generates a private and public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateKeyPair instead

func GenerateKeyPairWithReader

func GenerateKeyPairWithReader(typ, bits int, src io.Reader) (PrivKey, PubKey, error)

GenerateKeyPairWithReader returns a keypair of the given type and bitsize Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateKeyPairWithReader instead

func GenerateRSAKeyPair

func GenerateRSAKeyPair(bits int, src io.Reader) (PrivKey, PubKey, error)

GenerateRSAKeyPair generates a new rsa private and public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateRSAKeyPair

func GenerateSecp256k1Key

func GenerateSecp256k1Key(src io.Reader) (PrivKey, PubKey, error)

GenerateSecp256k1Key generates a new Secp256k1 private and public key pair Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateSecp256k1Key instead

func KeyEqual

func KeyEqual(k1, k2 Key) bool

KeyEqual checks whether two Keys are equivalent (have identical byte representations). Deprecated: use github.com/libp2p/go-libp2p/core/crypto.KeyEqual instead

func KeyPairFromStdKey added in v0.2.4

func KeyPairFromStdKey(priv stdcrypto.PrivateKey) (PrivKey, PubKey, error)

KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p-core/crypto keys Deprecated: use github.com/libp2p/go-libp2p/core/crypto.KeyPairFromStdKey instead

func MarshalECDSAPrivateKey

func MarshalECDSAPrivateKey(ePriv ECDSAPrivateKey) (res []byte, err error)

MarshalECDSAPrivateKey returns x509 bytes from a private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalECDSAPrivateKey instead

func MarshalECDSAPublicKey

func MarshalECDSAPublicKey(ePub ECDSAPublicKey) (res []byte, err error)

MarshalECDSAPublicKey returns x509 bytes from a public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalECDSAPublicKey instead

func MarshalPrivateKey

func MarshalPrivateKey(k PrivKey) ([]byte, error)

MarshalPrivateKey converts a key object into its protobuf serialized form. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalPrivateKey instead

func MarshalPublicKey

func MarshalPublicKey(k PubKey) ([]byte, error)

MarshalPublicKey converts a public key object into a protobuf serialized public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalPublicKey instead

func PrivKeyToStdKey added in v0.4.0

func PrivKeyToStdKey(priv PrivKey) (stdcrypto.PrivateKey, error)

PrivKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) private keys Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKeyToStdKey instead

func PubKeyToStdKey added in v0.4.0

func PubKeyToStdKey(pub PubKey) (stdcrypto.PublicKey, error)

PubKeyToStdKey converts libp2p/go-libp2p-core/crypto private keys to standard library (and secp256k1) public keys Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKeyToStdKey instead

func PublicKeyToProto

func PublicKeyToProto(k PubKey) (*pb.PublicKey, error)

PublicKeyToProto converts a public key object into an unserialized protobuf PublicKey message. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PublicKeyToProto instead

Types

type ECDSAPrivateKey

type ECDSAPrivateKey = crypto.ECDSAPrivateKey

ECDSAPrivateKey is an implementation of an ECDSA private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAPrivateKey instead

type ECDSAPublicKey

type ECDSAPublicKey = crypto.ECDSAPublicKey

ECDSAPublicKey is an implementation of an ECDSA public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAPublicKey instead

type ECDSASig

type ECDSASig = crypto.ECDSASig

ECDSASig holds the r and s values of an ECDSA signature Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSASig instead

type Ed25519PrivateKey

type Ed25519PrivateKey = crypto.Ed25519PrivateKey

Ed25519PrivateKey is an ed25519 private key. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Ed25519PrivateKey instead

type Ed25519PublicKey

type Ed25519PublicKey = crypto.Ed25519PublicKey

Ed25519PublicKey is an ed25519 public key. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Ed25519PublicKey instead

type GenSharedKey

type GenSharedKey = crypto.GenSharedKey

GenSharedKey generates the shared key from a given private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenSharedKey instead

func GenerateEKeyPair

func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error)

GenerateEKeyPair returns an ephemeral public key and returns a function that will compute the shared secret key. Used in the identify module.

Focuses only on ECDH now, but can be made more general in the future. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.GenerateEKeyPair instead

type Key

type Key = crypto.Key

Key represents a crypto key that can be compared to another key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Key instead

type PrivKey

type PrivKey = crypto.PrivKey

PrivKey represents a private key that can be used to generate a public key and sign data Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKey instead

func UnmarshalECDSAPrivateKey

func UnmarshalECDSAPrivateKey(data []byte) (res PrivKey, err error)

UnmarshalECDSAPrivateKey returns a private key from x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.MarshalECDSAPrivateKey instead

func UnmarshalEd25519PrivateKey

func UnmarshalEd25519PrivateKey(data []byte) (PrivKey, error)

UnmarshalEd25519PrivateKey returns a private key from input bytes. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalEd25519PrivateKey instead

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (PrivKey, error)

UnmarshalPrivateKey converts a protobuf serialized private key into its representative object Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalPrivateKey instead

func UnmarshalRsaPrivateKey

func UnmarshalRsaPrivateKey(b []byte) (key PrivKey, err error)

UnmarshalRsaPrivateKey returns a private key from the input x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalRsaPrivateKey

func UnmarshalSecp256k1PrivateKey

func UnmarshalSecp256k1PrivateKey(data []byte) (k PrivKey, err error)

UnmarshalSecp256k1PrivateKey returns a private key from bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalSecp256k1PrivateKey instead

type PrivKeyUnmarshaller

type PrivKeyUnmarshaller = crypto.PrivKeyUnmarshaller

PrivKeyUnmarshaller is a func that creates a PrivKey from a given slice of bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PrivKeyUnmarshaller instead

type PubKey

type PubKey = crypto.PubKey

PubKey is a public key that can be used to verifiy data signed with the corresponding private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKey instead

func ECDSAPublicKeyFromPubKey added in v0.12.0

func ECDSAPublicKeyFromPubKey(pub ecdsa.PublicKey) (PubKey, error)

ECDSAPublicKeyFromPubKey generates a new ecdsa public key from an input public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.ECDSAPublicKeyFromPubKey instead

func PublicKeyFromProto

func PublicKeyFromProto(pmes *pb.PublicKey) (PubKey, error)

PublicKeyFromProto converts an unserialized protobuf PublicKey message into its representative object. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PublicKeyFromProto instead

func UnmarshalECDSAPublicKey

func UnmarshalECDSAPublicKey(data []byte) (key PubKey, err error)

UnmarshalECDSAPublicKey returns the public key from x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalECDSAPublicKey instead

func UnmarshalEd25519PublicKey

func UnmarshalEd25519PublicKey(data []byte) (PubKey, error)

UnmarshalEd25519PublicKey returns a public key from input bytes. Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalEd25519PublicKey instead

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte) (PubKey, error)

UnmarshalPublicKey converts a protobuf serialized public key into its representative object Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalPublicKey instead

func UnmarshalRsaPublicKey

func UnmarshalRsaPublicKey(b []byte) (key PubKey, err error)

UnmarshalRsaPublicKey returns a public key from the input x509 bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalRsaPublicKey

func UnmarshalSecp256k1PublicKey

func UnmarshalSecp256k1PublicKey(data []byte) (_k PubKey, err error)

UnmarshalSecp256k1PublicKey returns a public key from bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.UnmarshalSecp256k1PublicKey instead

type PubKeyUnmarshaller

type PubKeyUnmarshaller = crypto.PubKeyUnmarshaller

PubKeyUnmarshaller is a func that creates a PubKey from a given slice of bytes Deprecated: use github.com/libp2p/go-libp2p/core/crypto.PubKeyUnmarshaller instead

type RsaPrivateKey

type RsaPrivateKey = crypto.RsaPrivateKey

RsaPrivateKey is an rsa private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.RsaPrivateKey instead

type RsaPublicKey

type RsaPublicKey = crypto.RsaPublicKey

RsaPublicKey is an rsa public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.RsaPublicKey instead

type Secp256k1PrivateKey

type Secp256k1PrivateKey = crypto.Secp256k1PrivateKey

Secp256k1PrivateKey is an Secp256k1 private key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Secp256k1PrivateKey instead

type Secp256k1PublicKey

type Secp256k1PublicKey = crypto.Secp256k1PublicKey

Secp256k1PublicKey is an Secp256k1 public key Deprecated: use github.com/libp2p/go-libp2p/core/crypto.Secp256k1PublicKey instead

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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