bitwarden

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

bitwarden implements an API client for bitwarden

References:

https://github.com/jcs/rubywarden/blob/master/API.md
https://github.com/mvdan/bitw/blob/master/auth.go
https://github.com/philhug/bitwarden-client-go

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMacError = fmt.Errorf("MAC error")
)

Functions

func HashedPassword

func HashedPassword(salt, password string, iterations int) string

func MakeInternalKey

func MakeInternalKey(salt, password string, iterations int) []byte

Types

type Client

type Client struct {
	*client.Client
}

func New

func New(opts ...client.ClientOpt) (*Client, error)

func (*Client) Login

func (c *Client) Login(session *Session) error

Login returns a token for a session, or a challenge for two-factor authentication

func (*Client) Prelogin

func (c *Client) Prelogin(email, password string) (*Session, error)

Prelogin returns a session for logging in for a given email and password

func (*Client) Register

func (c *Client) Register(name, email, password string)

type CryptoKey

type CryptoKey struct {
	Key []byte
	Mac []byte
}

func NewKey

func NewKey(key, mac []byte) *CryptoKey

NewKey returns a new CryptoKey for AES-256-CBC

func (*CryptoKey) Check

func (k *CryptoKey) Check(data *Encrypted) bool

Check the integrity of the data using HMAC, if the key has a MAC

func (*CryptoKey) Decrypt

func (k *CryptoKey) Decrypt(data *Encrypted) ([]byte, error)

Decrypt data using AES-256-CBC

func (*CryptoKey) Encrypt

func (k *CryptoKey) Encrypt(data []byte) (*Encrypted, error)

Encrypt data using AES-256-CBC

type Encrypted

type Encrypted struct {
	Type  uint   `json:"type"`          // Cypher type
	Value string `json:"value"`         // Encrypted value in base64
	Iv    string `json:"iv,omitempty"`  // Initialization Vector in base64 (for decryption)
	Mac   string `json:"mac,omitempty"` // Message Authentication Hash (HMAC) in base64
}

func MakeEncKey

func MakeEncKey(key []byte) (*Encrypted, error)

func (*Encrypted) String

func (k *Encrypted) String() string

Return the encrypted value as a string

type Register

type Register struct {
	Name               string `json:"name"`
	Email              string `json:"email"`
	MasterPasswordHash string `json:"masterPasswordHash"`
	MasterPasswordHint string `json:"masterPasswordHint"`
	Key                string `json:"key"`
	Kdf                uint   `json:"kdf"`
	KdfIterations      uint   `json:"kdfIterations"`
}

type Session

type Session struct {
	Kdf struct {
		Iterations int `json:"kdfIterations"`
	} `json:"kdf"`
	Key      []byte `json:"key"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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