api

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 21 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultBlockSize = 16

Variables

This section is empty.

Functions

func Base64UrlDecode

func Base64UrlDecode(text string) []byte

func Base64UrlEncode

func Base64UrlEncode(data []byte) string

func CreateAuthVerifier

func CreateAuthVerifier(password string, salt []byte, iterations uint32) string

func CreateBioAuthHash

func CreateBioAuthHash(bioKey []byte) []byte

func CreateEncryptionParams

func CreateEncryptionParams(password string, salt []byte, iterations uint32, dataKey []byte) (encryptionParams []byte, err error)

func DecryptAesV1

func DecryptAesV1(data []byte, key []byte) ([]byte, error)

func DecryptAesV1Full

func DecryptAesV1Full(data []byte, key []byte, usePadding bool) ([]byte, error)

func DecryptAesV2

func DecryptAesV2(data []byte, key []byte) ([]byte, error)

func DecryptEc

func DecryptEc(data []byte, private *ecdh.PrivateKey) (decrypted []byte, err error)

func DecryptEncryptionParams

func DecryptEncryptionParams(decodedParams []byte, password string) (params []byte, err error)

func DecryptRsa

func DecryptRsa(data []byte, privateKey *rsa.PrivateKey) (result []byte, err error)

func DeriveKeyHashV1

func DeriveKeyHashV1(password string, salt []byte, iterations uint32) []byte

func DeriveKeyHashV2

func DeriveKeyHashV2(domain string, password string, salt []byte, iterations uint32) []byte

func DeriveKeyV1

func DeriveKeyV1(password string, salt []byte, iterations uint32) []byte

func EcSharedKey

func EcSharedKey(public1 *ecdh.PublicKey, private2 *ecdh.PrivateKey) (key []byte, err error)

func EncryptAesV1

func EncryptAesV1(data []byte, key []byte) ([]byte, error)

func EncryptAesV1Full

func EncryptAesV1Full(data []byte, key []byte, iv []byte, usePadding bool) ([]byte, error)

func EncryptAesV2

func EncryptAesV2(data []byte, key []byte) ([]byte, error)

func EncryptAesV2Full

func EncryptAesV2Full(data []byte, key []byte, nonce []byte) ([]byte, error)

func EncryptEc

func EncryptEc(data []byte, public *ecdh.PublicKey) (encrypted []byte, err error)

func EncryptRsa

func EncryptRsa(data []byte, publicKey *rsa.PublicKey) ([]byte, error)

func GenerateAesKey

func GenerateAesKey() []byte

func GenerateEcKey

func GenerateEcKey() (private *ecdh.PrivateKey, public *ecdh.PublicKey, err error)

func GenerateRsaKey

func GenerateRsaKey() (private *rsa.PrivateKey, public *rsa.PublicKey, err error)

func GenerateUid

func GenerateUid() []byte

func GetEcPublicKey

func GetEcPublicKey(privateKey *ecdh.PrivateKey) *ecdh.PublicKey

func GetKeeperFileFullPath

func GetKeeperFileFullPath(filename string) string

func GetLogger

func GetLogger() *zap.Logger

func GetRandomBytes

func GetRandomBytes(size int) []byte

func GetRsaPublicKey

func GetRsaPublicKey(privateKey *rsa.PrivateKey) *rsa.PublicKey

func LoadEcPrivateKey

func LoadEcPrivateKey(data []byte) (*ecdh.PrivateKey, error)

func LoadEcPublicKey

func LoadEcPublicKey(data []byte) (publicKey *ecdh.PublicKey, err error)

func LoadRsaPrivateKey

func LoadRsaPrivateKey(privateKeyData []byte) (privateKey *rsa.PrivateKey, err error)

func LoadRsaPublicKey

func LoadRsaPublicKey(publicKey []byte) (*rsa.PublicKey, error)

func SetLogger

func SetLogger(logger *zap.Logger)

func SetNoLogger

func SetNoLogger()

func SliceForeach

func SliceForeach[T any](s []T, ef func(T))

func SliceReduce

func SliceReduce[T any, A any](s []T, ini A, rf func(T, A) A) (res A)

func SliceSelect

func SliceSelect[TI any, TO any](si []TI, sf func(TI) TO) (result []TO)

func SliceWhere

func SliceWhere[T any](s []T, wf func(T) bool) (result []T)

func UnloadEcPrivateKey

func UnloadEcPrivateKey(private *ecdh.PrivateKey) []byte

func UnloadEcPublicKey

func UnloadEcPublicKey(public *ecdh.PublicKey) []byte

func UnloadRsaPrivateKey

func UnloadRsaPrivateKey(privateKey *rsa.PrivateKey) []byte

func UnloadRsaPublicKey

func UnloadRsaPublicKey(publicKey *rsa.PublicKey) []byte

Types

type AuthorizedCommand

type AuthorizedCommand struct {
	KeeperApiCommand
	SessionToken string `json:"session_token"`
	Username     string `json:"username"`
}

func (*AuthorizedCommand) GetAuthorizedCommand

func (command *AuthorizedCommand) GetAuthorizedCommand() *AuthorizedCommand

type IKeeperCommand

type IKeeperCommand interface {
	CommandName() string
	GetAuthorizedCommand() *AuthorizedCommand
}

type IKeeperResponse

type IKeeperResponse interface {
	GetKeeperApiResponse() *KeeperApiResponse
}

type KeeperApiCommand

type KeeperApiCommand struct {
	Command       string `json:"command"`
	Locale        string `json:"locale"`
	ClientVersion string `json:"client_version"`
}

type KeeperApiError

type KeeperApiError struct {
	KeeperError
	// contains filtered or unexported fields
}

func NewKeeperApiError

func NewKeeperApiError(resultCode string, message string) *KeeperApiError

func (*KeeperApiError) Error

func (e *KeeperApiError) Error() string

func (*KeeperApiError) ResultCode

func (e *KeeperApiError) ResultCode() string

type KeeperApiErrorResponse

type KeeperApiErrorResponse struct {
	KeeperApiResponse
	Error          string `json:"error"`
	KeyId          int32  `json:"key_id"`
	RegionHost     string `json:"region_host"`
	AdditionalInfo string `json:"additional_info"`
}

type KeeperApiResponse

type KeeperApiResponse struct {
	Result     string `json:"result"`
	ResultCode string `json:"result_code"`
	Message    string `json:"message"`
	Command    string `json:"command"`
}

func (*KeeperApiResponse) GetKeeperApiResponse

func (rs *KeeperApiResponse) GetKeeperApiResponse() *KeeperApiResponse

func (*KeeperApiResponse) IsSuccess

func (rs *KeeperApiResponse) IsSuccess() bool

type KeeperError

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

func NewKeeperError

func NewKeeperError(message string) *KeeperError

func (*KeeperError) Error

func (e *KeeperError) Error() string

func (*KeeperError) Message

func (e *KeeperError) Message() string

type KeeperInvalidDeviceToken

type KeeperInvalidDeviceToken struct {
	KeeperError
}

func NewKeeperInvalidDeviceToken

func NewKeeperInvalidDeviceToken(additionalInfo string) *KeeperInvalidDeviceToken

func (*KeeperInvalidDeviceToken) Error

func (e *KeeperInvalidDeviceToken) Error() string

type RegionRedirectError

type RegionRedirectError struct {
	KeeperError
	// contains filtered or unexported fields
}

func NewKeeperRegionRedirect

func NewKeeperRegionRedirect(regionHost string, additionalInfo string) *RegionRedirectError

func (*RegionRedirectError) Error

func (e *RegionRedirectError) Error() string

func (*RegionRedirectError) RegionHost

func (e *RegionRedirectError) RegionHost() string

type Set

type Set[K comparable] map[K]struct{}

func MakeSet

func MakeSet[K comparable](keys []K) Set[K]

func NewSet

func NewSet[K comparable]() Set[K]

func (Set[K]) Add

func (s Set[K]) Add(key K)

func (Set[K]) Copy

func (s Set[K]) Copy() Set[K]

func (Set[K]) Delete

func (s Set[K]) Delete(key K)

func (Set[K]) Difference

func (s Set[K]) Difference(other []K)

func (Set[K]) Enumerate

func (s Set[K]) Enumerate(cb func(K) bool)

func (Set[K]) EqualTo

func (s Set[K]) EqualTo(other Set[K]) (result bool)

func (Set[K]) Has

func (s Set[K]) Has(key K) (ok bool)

func (Set[K]) Intersect

func (s Set[K]) Intersect(other []K)

func (Set[K]) ToArray

func (s Set[K]) ToArray() (result []K)

func (Set[K]) Union

func (s Set[K]) Union(other []K)

type StreamCryptor

type StreamCryptor interface {
	io.Reader
	GetTotal() int
}

func NewAesStreamDecryptor

func NewAesStreamDecryptor(reader io.Reader, key []byte) StreamCryptor

func NewAesStreamEncryptor

func NewAesStreamEncryptor(reader io.Reader, key []byte) StreamCryptor

Jump to

Keyboard shortcuts

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