Documentation
¶
Index ¶
- Constants
- Variables
- func AddTrustedCert(vkey string, fp []byte)
- func AesEncrypt(origData, key []byte) ([]byte, error)
- func Blake2b(s string) string
- func BuildTotpUri(issuer, accountName, secret string) (string, error)
- func FNV1a64(parts ...string) string
- func GenerateTOTPSecret() (string, error)
- func GetCertContent(filePath, header string) (string, error)
- func GetCertFingerprint(certificate tls.Certificate) []byte
- func GetCertType(s string) string
- func GetFakeDomainName() string
- func GetRandomString(l int, id ...int) string
- func GetTOTPCode(secret string) (string, int64, error)
- func GetUUID() uuid.UUID
- func IsValidTOTPSecret(secret string) bool
- func LoadKeyPair(certFile, keyFile string) (tls.Certificate, error)
- func Md5(s string) string
- func NewPinnedTlsClientConfig(fingerprint []byte) *tls.Config
- func NewTlsClientConn(conn net.Conn) net.Conn
- func NewTlsServerConn(conn net.Conn, cert tls.Certificate) net.Conn
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PinFingerprint(fingerprint []byte) *tlsconn.PinSet
- func PrintTOTPCode(secret string)
- func PrintTOTPSecret()
- func SecretIndex(password string) string
- func SecretProof(password string, nonce []byte, node string) []byte
- func VerifyTOTP(secret, code string) bool
- type Identity
- type LoginPayload
Constants ¶
const TotpLen = otp.DefaultDigits
TotpLen is the length of a TOTP code.
Variables ¶
var (
SkipVerify = false
)
Functions ¶
func AddTrustedCert ¶ added in v0.28.1
AddTrustedCert trusts the bridge certificate with fingerprint fp for the client with vkey, in place of the one trusted for it before.
func AesEncrypt ¶
func BuildTotpUri ¶ added in v0.29.30
BuildTotpUri returns the otpauth URI of secret for authenticator apps.
func GenerateTOTPSecret ¶ added in v0.29.0
GenerateTOTPSecret returns a new random secret in base32.
func GetCertContent ¶ added in v0.35.0
GetCertContent returns filePath itself when it is PEM text containing header, or else the content of that file, relative to the run path.
func GetCertFingerprint ¶ added in v0.28.0
func GetCertFingerprint(certificate tls.Certificate) []byte
GetCertFingerprint returns the SHA-256 of certificate's leaf, as the bridge sends it to the client during the handshake, or nil if it has none.
func GetCertType ¶ added in v0.35.0
GetCertType reports whether s is "empty", PEM "text", an existing "file" or "invalid".
func GetFakeDomainName ¶ added in v0.30.4
func GetFakeDomainName() string
func GetRandomString ¶
GetRandomString 生成指定长度的随机密钥,支持可选传入id
func GetTOTPCode ¶ added in v0.29.0
GetTOTPCode returns the current code of secret and the seconds it stays current.
func IsValidTOTPSecret ¶ added in v0.29.30
IsValidTOTPSecret reports whether secret is a usable base32 secret.
func LoadKeyPair ¶ added in v0.35.0
func LoadKeyPair(certFile, keyFile string) (tls.Certificate, error)
LoadKeyPair loads a certificate and its key, each given as PEM text or as the path of a PEM file, relative to the run path.
func NewPinnedTlsClientConfig ¶ added in v0.34.8
NewPinnedTlsClientConfig returns a TLS client configuration that accepts only the server certificate with fingerprint (its SHA-256), as the server sent it, encrypted with the vkey, during the bridge handshake. It ignores SkipVerify: the fingerprint is authenticated by the vkey itself.
func NewTlsClientConn ¶
NewTlsClientConn returns a TLS client on conn that accepts only bridge certificates trusted by AddTrustedCert, or any if SkipVerify.
func NewTlsServerConn ¶
NewTlsServerConn returns a TLS server on conn that presents cert.
func PKCS5Padding ¶
PKCS5Padding Completion when the length is insufficient
func PinFingerprint ¶ added in v0.34.8
PinFingerprint returns the pin set holding the certificate with fingerprint, its SHA-256 (GetCertFingerprint), or an empty set, which trusts no certificate, if fingerprint is not a SHA-256.
func PrintTOTPCode ¶ added in v0.29.0
func PrintTOTPCode(secret string)
PrintTOTPCode prints the current code of secret.
func PrintTOTPSecret ¶ added in v0.29.0
func PrintTOTPSecret()
PrintTOTPSecret prints a new secret and its QR code.
func SecretIndex ¶ added in v0.35.0
SecretIndex names the secret tunnel of password in an attach request, so that nps finds the tunnel without a search; the password itself never travels. Like any hash of a password it is a verifier an observer could test guesses against, so it travels only inside the encrypted bridge connection.
func SecretProof ¶ added in v0.35.0
SecretProof is a visitor's proof that it knows password: an HMAC over the nonce nps sent for this attach and the visitor's node (npc uuid), so that a captured proof is good for no other attach.
func VerifyTOTP ¶ added in v0.35.0
VerifyTOTP reports whether code is a current code of secret that was not accepted before.
Types ¶
type Identity ¶ added in v0.35.0
type Identity struct {
Cert tls.Certificate
// contains filtered or unexported fields
}
Identity is the certificate a process presents in TLS, and the RSA key the web login encrypts credentials to.
func NewIdentity ¶ added in v0.35.0
func NewIdentity(custom tls.Certificate) (*Identity, error)
NewIdentity returns the identity of custom, or of a fresh self-signed certificate when custom holds none. The RSA key is the certificate's own when it is an RSA key, a fresh one otherwise.
func (*Identity) Fingerprint ¶ added in v0.35.0
Fingerprint returns the SHA-256 of the certificate's leaf (GetCertFingerprint).
func (*Identity) ParseLoginPayload ¶ added in v0.35.0
func (id *Identity) ParseLoginPayload(base64Cipher string) (*LoginPayload, error)
ParseLoginPayload decrypts the credentials a web login sent.
func (*Identity) RSAPublicKeyPEM ¶ added in v0.35.0
RSAPublicKeyPEM returns the public RSA key the web login encrypts to.
func (*Identity) TLSCert ¶ added in v0.35.0
func (id *Identity) TLSCert() tls.Certificate
TLSCert returns the certificate, none for a nil identity.