crypt_bridge

package
v0.0.0-...-c3cf44d Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 7 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

Package crypt_bridge loads libhatnfileencryptor at runtime via purego (no cgo) and exposes Encrypt and Decrypt functions wrapping hatn CryptContainer.

The shared library is located via:

  1. Env var WHITEM_FILE_ENCRYPTOR_LIB (absolute path, takes precedence).
  2. <exe-dir>/native/libhatnfileencryptor.<ext> (ext = dylib on darwin, so on linux).

Contexts (hatn App + cipher suites) are created lazily per (configFile, sectionPath) pair and cached for the process lifetime.

Concurrency: a package-level mutex serialises calls to each C function. These are low-frequency admin operations, so a global lock is acceptable and eliminates any OpenSSL/plugin reentrancy risk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(configFile, sectionPath string, ciphertext []byte, passphrase string) ([]byte, error)

Decrypt decrypts a CryptContainer blob produced by Encrypt (or hatn-file-encryptor) using the cipher suites from (configFile, sectionPath) and the provided passphrase.

func Encrypt

func Encrypt(configFile, sectionPath string, plain []byte, passphrase string) ([]byte, error)

Encrypt encrypts plain using the default cipher suite from the hatn App config at (configFile, sectionPath) and the provided passphrase.

The returned ciphertext is a CryptContainer blob byte-compatible with hatn's CryptContainer::unpack / parseAccountConfig on the C++ client side.

func Load

func Load() error

Load explicitly loads the shared library. Call this at server startup to detect a missing or broken library early rather than on the first call. Safe to call multiple times; the library is loaded at most once.

Types

This section is empty.

Jump to

Keyboard shortcuts

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