Documentation
¶
Index ¶
- func Decrypt(gcm cipher.AEAD, encoded string) ([]byte, error)
- func DeriveSharedKey(privateKey *ecdh.PrivateKey, peerPublicKeyB64 string) (cipher.AEAD, error)
- func Encrypt(gcm cipher.AEAD, plaintext []byte) (string, error)
- func EnsureKeyPair(dir string) (string, error)
- func LoadPrivateKey(dir string) (*ecdh.PrivateKey, error)
- type DeviceCodeResponse
- type DeviceToken
- type TokenResponse
- type TokenStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeriveSharedKey ¶
DeriveSharedKey performs X25519 ECDH + HKDF to produce an AES-256-GCM key.
func Encrypt ¶
Encrypt encrypts plaintext with AES-256-GCM and returns base64(iv || ciphertext || tag).
func EnsureKeyPair ¶
EnsureKeyPair loads or generates an X25519 keypair. Returns the base64-encoded public key. Private key is stored in dir/wing_key.
func LoadPrivateKey ¶
func LoadPrivateKey(dir string) (*ecdh.PrivateKey, error)
LoadPrivateKey loads the X25519 private key from disk.
Types ¶
type DeviceCodeResponse ¶
type DeviceCodeResponse struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURL string `json:"verification_url"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
func RequestDeviceCode ¶
func RequestDeviceCode(baseURL, machineID string, publicKey ...string) (*DeviceCodeResponse, error)
type DeviceToken ¶
type DeviceToken struct {
Token string `json:"token" yaml:"device_token"`
ExpiresAt int64 `json:"expires_at" yaml:"expires_at"`
IssuedAt int64 `json:"issued_at" yaml:"issued_at"`
DeviceID string `json:"device_id" yaml:"device_id"`
PublicKey string `json:"public_key,omitempty" yaml:"public_key,omitempty"`
}
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
ExpiresAt int64 `json:"expires_at"`
Error string `json:"error,omitempty"`
}
func PollForToken ¶
func RefreshToken ¶
func RefreshToken(baseURL string, token DeviceToken) (*TokenResponse, error)
type TokenStore ¶
type TokenStore struct {
Dir string
}
func NewTokenStore ¶
func NewTokenStore(dir string) *TokenStore
func (*TokenStore) Delete ¶
func (s *TokenStore) Delete() error
func (*TokenStore) IsValid ¶
func (s *TokenStore) IsValid(token *DeviceToken) bool
func (*TokenStore) Load ¶
func (s *TokenStore) Load() (*DeviceToken, error)
func (*TokenStore) Save ¶
func (s *TokenStore) Save(token *DeviceToken) error
Click to show internal directories.
Click to hide internal directories.