server

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixInfo      string = "/CA/INFO"
	PrefixNew              = "/CA/NEW"
	PrefixChallenge        = "/CA/CHALLENGE"
)
View Source
const (
	ApplicationStatusCodeBeforeChallenge ApplicationStatusCode = 0
	ApplicationStatusCodeChallenge                             = 1
	ApplicationStatusCodePending                               = 2
	ApplicationStatusCodeSuccess                               = 3
	ApplicationStatusCodeFailure                               = 4
)
View Source
const (
	ChallengeStatusCodeNeedCode     string = "need-code"
	ChallengeStatusCodeInvalidEmail        = "invalid-email"
	ChallengeStatusWrongCode               = "wrong-code"
	ChallengeStatusCodeSuccess             = "success"
)
View Source
const (
	ParameterKeyEmail string = "email"
	ParameterKeyCode         = "code"
)
View Source
const (
	ErrorCodeBadInterestFormat ErrorCode = 1
	ErrorCodeBadParameter                = 2
	ErrorCodeBadSignature                = 3
	ErrorCodeInvalidParameters           = 4
	ErrorCodeNameNotAllowed              = 5
	ErrorCodeBadValidityPeriod           = 6
	ErrorCodeRunOutOfTries               = 7
	ErrorCodeRunOutOfTime                = 8
)
View Source
const (
	ErrorReasonBadInterestFormat  string = "Bad Interest Format: the Interest format is incorrect, e.g., no ApplicationParameters."
	ErrorReasonBadParameterFormat        = "Bad Parameter Format: the ApplicationParameters field is not correctly formed."
	ErrorReasonBadSignature              = "Bad Signature or signature info: the Interest carries an invalid signature."
	ErrorReasonInvalidParameters         = "Invalid parameters: the input from the requester is not expected."
	ErrorReasonNameNotAllowed            = "Name not allowed: the requested certificate name cannot be assigned to the requester."
	ErrorReasonBadValidityPeriod         = "Bad ValidityPeriod: requested certificate has an erroneous validity period, e.g., too long time."
	ErrorReasonRunOutOfTries             = "Run out of tries: the requester failed to complete the challenge within allowed number of attempts."
	ErrorReasonRunOutOfTime              = "Run out of time: the requester failed to complete the challenge within time limit."
)
View Source
const RequestIdLength = 8
View Source
const SchemaJson = `` /* 740-byte string literal not displayed */
View Source
const (
	SecretCodeLength int = 6
)
View Source
const (
	SelectedChallengeEmail string = "email"
)

Variables

View Source
var AvailableChallenges = []string{SelectedChallengeEmail}

Functions

This section is empty.

Types

type ApplicationStatusCode

type ApplicationStatusCode uint64

type CaConfig

type CaConfig struct {
	Ca struct {
		Name                         string `yaml:"name"`
		Info                         string `yaml:"info"`
		NotAfterNow                  uint64 `yaml:"notAfterNow"`
		MaxCertificateValidityPeriod uint64 `yaml:"maxCertificateValidityPeriod"`
	}
}

type CaState

type CaState struct {
	CaCertName                   string
	CaCertBytes                  []byte // In the case of a non-root CA, the signed certificate served must be passed in.
	CaInfo                       string
	CaPrefix                     string
	ChallengeRequestStateMapping map[RequestId]*ChallengeRequestState
	IdentityKey                  *ecdsa.PrivateKey
	MaxValidityPeriod            time.Duration
	NotAfter                     time.Time
	NotBefore                    time.Time
	SmtpModule                   *email.SmtpModule
	Signer                       ndn.Signer
}

func NewCaState

func NewCaState(caCertName string, caCertBytes []byte, caInfo string, caPrefix string, identityKey *ecdsa.PrivateKey, maxValidPeriod uint64, notBefore time.Time, notAfter time.Time, smtpModule *email.SmtpModule) (*CaState, error)

func (*CaState) OnChallenge

func (caState *CaState) OnChallenge(interest ndn.Interest, rawInterest enc.Wire, sigCovered enc.Wire, reply ndn.ReplyFunc, deadline time.Time)

func (*CaState) OnNew

func (caState *CaState) OnNew(interest ndn.Interest, _ enc.Wire, sigCovered enc.Wire, reply ndn.ReplyFunc, _ time.Time)

func (*CaState) Serve

func (caState *CaState) Serve(ndnEngine ndn.Engine) error

type ChallengeRequestState

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

type ChallengeState

type ChallengeState struct {
	RemainingAttempts uint64
	Expiry            time.Time
}

func NewChallengeState

func NewChallengeState() *ChallengeState

type ChallengeStatus

type ChallengeStatus uint64
const (
	ChallengeStatusNewInterestReceived ChallengeStatus = iota
	ChallengeStatusChallengeIssued
)

type ChallengeType

type ChallengeType uint64
const (
	TbdChallengeType   ChallengeType = iota
	EmailChallengeType               // Unused because we only have a single challenge type available
)

type EmailChallengeState

type EmailChallengeState struct {
	Email      string
	SecretCode string
}

func NewEmailChallenge

func NewEmailChallenge(smtpModule *email.SmtpModule, emailAddress string) (*EmailChallengeState, email.Status)

type ErrorCode

type ErrorCode uint64

type ErrorReason

type ErrorReason []byte

type RequestId

type RequestId [RequestIdLength]byte

Jump to

Keyboard shortcuts

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