crypto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultKeyBitSize        = 4096
	DefaultDsaParameterSize  = dsa.L2048N256
	DefaultEllipticCurveType = EllipticCurveTypeP521
)

Variables

View Source
var (
	DefaultDsaRestriction = DsaRestrictionNone
)
View Source
var (
	DefaultEcdsaRestriction = EcdsaRestrictionAtLeast384Bits
)
View Source
var (
	DefaultEd25519Restriction = Ed25519RestrictionAll
)
View Source
var (
	DefaultRsaRestriction = RsaRestrictionAtLeast4096Bits
)

Functions

func DoWithEachAuthorizedKey

func DoWithEachAuthorizedKey[R any](requireExistence bool, callback func(gssh.PublicKey) (result R, canContinue bool, err error), files ...string) (result R, err error)

func EnsureKeyFile

func EnsureKeyFile(fn string, reqOnAbsence *KeyRequirement, rand io.Reader) (crypto.Signer, error)

func WriteSshPrivateKey

func WriteSshPrivateKey(pk crypto.Signer, to io.Writer) error

Types

type DsaRestriction

type DsaRestriction uint8
const (
	DsaRestrictionNone DsaRestriction = iota
	DsaRestrictionAll
	DsaRestrictionAtLeast1024Bits
	DsaRestrictionAtLeast2048Bits
	DsaRestrictionAtLeast3072Bits
)

func (DsaRestriction) BitsAllowed

func (this DsaRestriction) BitsAllowed(in int) bool

func (DsaRestriction) IsEqualTo

func (this DsaRestriction) IsEqualTo(other any) bool

func (DsaRestriction) IsZero

func (this DsaRestriction) IsZero() bool

func (DsaRestriction) KeyAllowed

func (this DsaRestriction) KeyAllowed(in any) (bool, error)

func (DsaRestriction) MarshalText

func (this DsaRestriction) MarshalText() (text []byte, err error)

func (*DsaRestriction) Set

func (this *DsaRestriction) Set(text string) error

func (DsaRestriction) String

func (this DsaRestriction) String() string

func (*DsaRestriction) UnmarshalText

func (this *DsaRestriction) UnmarshalText(text []byte) error

func (DsaRestriction) Validate

func (this DsaRestriction) Validate() error

type EcdsaRestriction

type EcdsaRestriction uint8
const (
	EcdsaRestrictionNone EcdsaRestriction = iota
	EcdsaRestrictionAll
	EcdsaRestrictionAtLeast256Bits
	EcdsaRestrictionAtLeast384Bits
	EcdsaRestrictionAtLeast521Bits
)

func (EcdsaRestriction) BitsAllowed

func (this EcdsaRestriction) BitsAllowed(in int) bool

func (EcdsaRestriction) IsEqualTo

func (this EcdsaRestriction) IsEqualTo(other any) bool

func (EcdsaRestriction) IsZero

func (this EcdsaRestriction) IsZero() bool

func (EcdsaRestriction) KeyAllowed

func (this EcdsaRestriction) KeyAllowed(in any) (bool, error)

func (EcdsaRestriction) MarshalText

func (this EcdsaRestriction) MarshalText() (text []byte, err error)

func (*EcdsaRestriction) Set

func (this *EcdsaRestriction) Set(text string) error

func (EcdsaRestriction) String

func (this EcdsaRestriction) String() string

func (*EcdsaRestriction) UnmarshalText

func (this *EcdsaRestriction) UnmarshalText(text []byte) error

func (EcdsaRestriction) Validate

func (this EcdsaRestriction) Validate() error

type Ed25519Restriction

type Ed25519Restriction uint8
const (
	Ed25519RestrictionNone Ed25519Restriction = iota
	Ed25519RestrictionAll
	Ed25519RestrictionAtLeast256Bits
)

func (Ed25519Restriction) BitsAllowed

func (this Ed25519Restriction) BitsAllowed(in int) bool

func (Ed25519Restriction) IsEqualTo

func (this Ed25519Restriction) IsEqualTo(other any) bool

func (Ed25519Restriction) IsZero

func (this Ed25519Restriction) IsZero() bool

func (Ed25519Restriction) KeyAllowed

func (this Ed25519Restriction) KeyAllowed(in any) (bool, error)

func (Ed25519Restriction) MarshalText

func (this Ed25519Restriction) MarshalText() (text []byte, err error)

func (*Ed25519Restriction) Set

func (this *Ed25519Restriction) Set(text string) error

func (Ed25519Restriction) String

func (this Ed25519Restriction) String() string

func (*Ed25519Restriction) UnmarshalText

func (this *Ed25519Restriction) UnmarshalText(text []byte) error

func (Ed25519Restriction) Validate

func (this Ed25519Restriction) Validate() error

type EllipticCurveType

type EllipticCurveType uint8
const (
	EllipticCurveTypeP224 EllipticCurveType = iota
	EllipticCurveTypeP256
	EllipticCurveTypeP384
	EllipticCurveTypeP521
)

func (EllipticCurveType) Curve

func (this EllipticCurveType) Curve() (elliptic.Curve, error)

func (EllipticCurveType) String

func (this EllipticCurveType) String() string

type KeyRequirement

type KeyRequirement struct {
	Type KeyType

	// BitSize is used for RSA keys. Default is DefaultKeyBitSize
	BitSize *int

	// DsaParameterSize is used for KeyTypeDsa. Default is DefaultDsaParameterSize
	DsaParameterSize *dsa.ParameterSizes

	// EllipticCurveType is used for KeyTypeEcdsa. Default is DefaultEllipticCurveType
	EllipticCurveType *EllipticCurveType
}

func (KeyRequirement) CreateFile

func (this KeyRequirement) CreateFile(rand io.Reader, fn string) (crypto.Signer, error)

func (KeyRequirement) GenerateKey

func (this KeyRequirement) GenerateKey(rand io.Reader) (crypto.Signer, error)

type KeyType

type KeyType uint8
const (
	KeyTypeRsa KeyType = iota
	KeyTypeDsa
	KeyTypeEcdsa
	KeyTypeEd25519
)

func (KeyType) String

func (this KeyType) String() string

type Restriction

type Restriction interface {
	KeyAllowed(crypto.Signer) (bool, error)
}

type RsaRestriction

type RsaRestriction uint8
const (
	RsaRestrictionNone RsaRestriction = iota
	RsaRestrictionAll
	RsaRestrictionAtLeast1024Bits
	RsaRestrictionAtLeast2048Bits
	RsaRestrictionAtLeast3072Bits
	RsaRestrictionAtLeast4096Bits
)

func (RsaRestriction) BitsAllowed

func (this RsaRestriction) BitsAllowed(in int) bool

func (RsaRestriction) IsEqualTo

func (this RsaRestriction) IsEqualTo(other any) bool

func (RsaRestriction) IsZero

func (this RsaRestriction) IsZero() bool

func (RsaRestriction) KeyAllowed

func (this RsaRestriction) KeyAllowed(in any) (bool, error)

func (RsaRestriction) MarshalText

func (this RsaRestriction) MarshalText() (text []byte, err error)

func (*RsaRestriction) Set

func (this *RsaRestriction) Set(text string) error

func (RsaRestriction) String

func (this RsaRestriction) String() string

func (*RsaRestriction) UnmarshalText

func (this *RsaRestriction) UnmarshalText(text []byte) error

func (RsaRestriction) Validate

func (this RsaRestriction) Validate() error

Directories

Path Synopsis
unix

Jump to

Keyboard shortcuts

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