totp

package module
v0.0.0-...-e09d910 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

README

TOTP

Project status: alpha

Not all planned features are completed. The API, spec, status and other user facing objects are subject to change. We do not support backward-compatibility for the alpha releases.

A simple utility command line program to handle TOTP Accounts

See docs for usage details.

Documentation

Index

Constants

View Source
const (
	Period = 30
)

Variables

View Source
var (
	Algorithm_name = map[int32]string{
		0: "ALGORITHM_TYPE_UNSPECIFIED",
		1: "SHA1",
		2: "SHA256",
		3: "SHA512",
		4: "MD5",
	}
	Algorithm_value = map[string]int32{
		"ALGORITHM_TYPE_UNSPECIFIED": 0,
		"SHA1":                       1,
		"SHA256":                     2,
		"SHA512":                     3,
		"MD5":                        4,
	}
)

Enum value maps for Algorithm.

View Source
var (
	Digit_name = map[int32]string{
		0: "DIGIT_COUNT_UNSPECIFIED",
		1: "SIX",
		2: "EIGHT",
	}
	Digit_value = map[string]int32{
		"DIGIT_COUNT_UNSPECIFIED": 0,
		"SIX":                     1,
		"EIGHT":                   2,
	}
)

Enum value maps for DigitCount.

View Source
var (
	OTPType_name = map[int32]string{
		0: "OTP_TYPE_UNSPECIFIED",
		1: "HOTP",
		2: "TOTP",
	}
	OTPType_value = map[string]int32{
		"OTP_TYPE_UNSPECIFIED": 0,
		"HOTP":                 1,
		"TOTP":                 2,
	}
)

Enum value maps for OtpType.

Functions

This section is empty.

Types

type Algorithm

type Algorithm int32
const (
	AlgorithmUnspecified Algorithm = 0
	AlgorithmSHA1        Algorithm = 1
	AlgorithmSHA256      Algorithm = 2
	AlgorithmSHA512      Algorithm = 3
	AlgorithmMD5         Algorithm = 4
)

func (Algorithm) Descriptor

func (Algorithm) Descriptor() protoreflect.EnumDescriptor

func (Algorithm) Enum

func (x Algorithm) Enum() *Algorithm

func (Algorithm) EnumDescriptor deprecated

func (Algorithm) EnumDescriptor() ([]byte, []int)

Deprecated: Use Algorithm.Descriptor instead.

func (Algorithm) Number

func (x Algorithm) Number() protoreflect.EnumNumber

func (Algorithm) String

func (x Algorithm) String() string

func (Algorithm) Type

type Digit

type Digit int32
const (
	DigitUnspecified Digit = 0
	DigitSix         Digit = 1
	DigitEight       Digit = 2
)

func (Digit) Descriptor

func (Digit) Descriptor() protoreflect.EnumDescriptor

func (Digit) Enum

func (x Digit) Enum() *Digit

func (Digit) EnumDescriptor deprecated

func (Digit) EnumDescriptor() ([]byte, []int)

Deprecated: Use DigitCount.Descriptor instead.

func (Digit) Number

func (x Digit) Number() protoreflect.EnumNumber

func (Digit) String

func (x Digit) String() string

func (Digit) Type

func (Digit) Type() protoreflect.EnumType

type OTPAccount

type OTPAccount struct {
	Secret    []byte     `protobuf:"bytes,1,opt,name=secret,proto3,oneof" json:"secret,omitempty"`
	Name      *string    `protobuf:"bytes,2,opt,name=name,proto3,oneof" json:"name,omitempty"`
	Issuer    *string    `protobuf:"bytes,3,opt,name=issuer,proto3,oneof" json:"issuer,omitempty"`
	Algorithm *Algorithm `protobuf:"varint,4,opt,name=algorithm,proto3,enum=Algorithm,oneof" json:"algorithm,omitempty"`
	Digits    *Digit     `protobuf:"varint,5,opt,name=digits,proto3,enum=DigitCount,oneof" json:"digits,omitempty"`
	Type      *OTPType   `protobuf:"varint,6,opt,name=type,proto3,enum=OtpType,oneof" json:"type,omitempty"`
	Counter   *int64     `protobuf:"varint,7,opt,name=counter,proto3,oneof" json:"counter,omitempty"`
	// contains filtered or unexported fields
}

func NewOTPAccount

func NewOTPAccount(issuer, name string, opts ...Option) (*OTPAccount, error)

func (*OTPAccount) Default

func (x *OTPAccount) Default()

func (*OTPAccount) Descriptor deprecated

func (*OTPAccount) Descriptor() ([]byte, []int)

Deprecated: Use OtpAccount.ProtoReflect.Descriptor instead.

func (*OTPAccount) Generate

func (x *OTPAccount) Generate() (string, error)

func (*OTPAccount) GetAlgorithm

func (x *OTPAccount) GetAlgorithm() Algorithm

func (*OTPAccount) GetCounter

func (x *OTPAccount) GetCounter() int64

func (*OTPAccount) GetDigits

func (x *OTPAccount) GetDigits() Digit

func (*OTPAccount) GetIssuer

func (x *OTPAccount) GetIssuer() string

func (*OTPAccount) GetName

func (x *OTPAccount) GetName() string

func (*OTPAccount) GetSecret

func (x *OTPAccount) GetSecret() []byte

func (*OTPAccount) GetType

func (x *OTPAccount) GetType() OTPType

func (*OTPAccount) Image

func (x *OTPAccount) Image(width int, height int) (image.Image, error)

func (*OTPAccount) ProtoMessage

func (*OTPAccount) ProtoMessage()

func (*OTPAccount) ProtoReflect

func (x *OTPAccount) ProtoReflect() protoreflect.Message

func (*OTPAccount) Reset

func (x *OTPAccount) Reset()

func (*OTPAccount) String

func (x *OTPAccount) String() string

func (*OTPAccount) URL

func (x *OTPAccount) URL() string

func (*OTPAccount) ValidFor

func (x *OTPAccount) ValidFor() time.Duration

func (*OTPAccount) Validate

func (x *OTPAccount) Validate(code string) bool

func (*OTPAccount) ValidateConfig

func (x *OTPAccount) ValidateConfig() error

type OTPData

type OTPData struct {
	OTPAccounts []*OTPAccount `protobuf:"bytes,1,rep,name=otp_accounts,json=otpAccounts,proto3" json:"otp_accounts,omitempty"`
	Version     *int32        `protobuf:"varint,2,opt,name=version,proto3,oneof" json:"version,omitempty"`
	BatchSize   *int32        `protobuf:"varint,3,opt,name=batch_size,json=batchSize,proto3,oneof" json:"batch_size,omitempty"`
	BatchIndex  *int32        `protobuf:"varint,4,opt,name=batch_index,json=batchIndex,proto3,oneof" json:"batch_index,omitempty"`
	BatchID     *int32        `protobuf:"varint,5,opt,name=batch_id,json=batchId,proto3,oneof" json:"batch_id,omitempty"`
	// contains filtered or unexported fields
}

func (*OTPData) Default

func (x *OTPData) Default()

func (*OTPData) Descriptor deprecated

func (*OTPData) Descriptor() ([]byte, []int)

Deprecated: Use OtpData.ProtoReflect.Descriptor instead.

func (*OTPData) GetBatchID

func (x *OTPData) GetBatchID() int32

func (*OTPData) GetBatchIndex

func (x *OTPData) GetBatchIndex() int32

func (*OTPData) GetBatchSize

func (x *OTPData) GetBatchSize() int32

func (*OTPData) GetOTPAccounts

func (x *OTPData) GetOTPAccounts() []*OTPAccount

func (*OTPData) GetVersion

func (x *OTPData) GetVersion() int32

func (*OTPData) ProtoMessage

func (*OTPData) ProtoMessage()

func (*OTPData) ProtoReflect

func (x *OTPData) ProtoReflect() protoreflect.Message

func (*OTPData) Reset

func (x *OTPData) Reset()

func (*OTPData) String

func (x *OTPData) String() string

type OTPType

type OTPType int32
const (
	OTPTypeUnspecified OTPType = 0
	OTPTypeHOTP        OTPType = 1
	OTPTypeTOTP        OTPType = 2
)

func (OTPType) Descriptor

func (OTPType) Descriptor() protoreflect.EnumDescriptor

func (OTPType) Enum

func (x OTPType) Enum() *OTPType

func (OTPType) EnumDescriptor deprecated

func (OTPType) EnumDescriptor() ([]byte, []int)

Deprecated: Use OtpType.Descriptor instead.

func (OTPType) Number

func (x OTPType) Number() protoreflect.EnumNumber

func (OTPType) String

func (x OTPType) String() string

func (OTPType) Type

func (OTPType) Type() protoreflect.EnumType

type Option

type Option func(o *options)

func WithAlgorithm

func WithAlgorithm(al Algorithm) Option

func WithDigits

func WithDigits(d Digit) Option

func WithSecretSize

func WithSecretSize(size uint) Option

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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