pki

package
v0.0.0-...-d687121 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashcashDifficulty int           = 18
	HashcashExpires    time.Duration = time.Second * 10
)
View Source
const (
	TokenSeparator string       = ":"
	TokenV1        TokenVersion = "v1" // CommonName: v1:clientID:oldToken 							before PKI is implemented, only the oldToken will be used
	TokenV2        TokenVersion = "v2" // CommonName: v2:clientID:base64url(sha256(public key)) 	initial implementation of PKI, the entire CommonName will be used
)

Variables

This section is empty.

Functions

func GenerateCertificate

func GenerateCertificate(logger *zap.Logger, ca tls.Certificate, req IdentityRequest) (derBytes []byte, err error)

func GeneratePrivKey

func GeneratePrivKey() (privKey ed25519.PublicKey, keyPem string)

func MakeSubjectV1

func MakeSubjectV1(id uint64, token string) pkix.Name

func MakeSubjectV2

func MakeSubjectV2(id uint64, hash []byte) pkix.Name

func MarshalCertificate

func MarshalCertificate(derBytes []byte) (pemBytes []byte)

func UnmarshalPrivateKey

func UnmarshalPrivateKey(pemBytes []byte) (ed25519.PrivateKey, error)

Types

type Identity

type Identity struct {
	Token []byte
	ID    uint64
}

func ExtractCertificateIdentity

func ExtractCertificateIdentity(cert *x509.Certificate) (*Identity, error)

func (*Identity) MarshalLogObject

func (n *Identity) MarshalLogObject(enc zapcore.ObjectEncoder) error

func (*Identity) NodeIdentity

func (n *Identity) NodeIdentity() *protocol.Node

type IdentityRequest

type IdentityRequest struct {
	PublicKey []byte
	Subject   pkix.Name
}

type TokenVersion

type TokenVersion string

Jump to

Keyboard shortcuts

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