Documentation ¶
Overview ¶
Small helpers for common crypto needs
Index ¶
- Constants
- func Identity(cert x509.Certificate) string
- func Issuer(cert x509.Certificate) string
- func MarshalPKCS8X25519PrivateKey(priv *X25519PrivateKey) ([]byte, error)
- func MarshalPemBytes(content []byte, pemType string) []byte
- func MarshalPemPKCS8X25519PrivateKey(priv *X25519PrivateKey) ([]byte, error)
- func MarshalPemPkcs1EncodedRsaPrivateKey(privKey *rsa.PrivateKey) []byte
- func MarshalPemPkcs1EncodedRsaPublicKey(pubKey *rsa.PublicKey) []byte
- func ParsePemBytes(pemBytes []byte, expectedType string) ([]byte, error)
- func ParsePemEncodedPrivateKey(serialized []byte) (crypto.PrivateKey, error)
- func ParsePemPkcs1EncodedRsaPrivateKey(pemBytes []byte) (*rsa.PrivateKey, error)
- func ParsePemPkcs1EncodedRsaPublicKey(pemBytes []byte) (*rsa.PublicKey, error)
- func ParsePemX509Certificate(pemBytes []byte) (*x509.Certificate, error)
- func PublicKeyFromPrivateKey(priv crypto.PrivateKey) (crypto.PublicKey, error)
- func PublicKeyHumanReadableDescription(pubkey crypto.PublicKey) (string, error)
- func RandBase64Url(bytesLen int) string
- func RandBase64UrlWithoutLeadingDash(bytesLen int) string
- func RandHex(bytesLen int) string
- func Sha256FingerprintForPublicKey(publicKey crypto.PublicKey) (string, error)
- type X25519PrivateKey
- type X25519PublicKey
Constants ¶
View Source
const ( PemTypePrivateKey = "PRIVATE KEY" // PKCS #8 (= supports different types via parametrization) PemTypePublicKey = "PUBLIC KEY" // PKCS #8 PemTypeRsaPrivateKey = "RSA PRIVATE KEY" PemTypeRsaPublicKey = "RSA PUBLIC KEY" PemTypeEcPrivateKey = "EC PRIVATE KEY" PemTypeEcPublicKey = "EC PUBLIC KEY" PemTypeCertificate = "CERTIFICATE" )
Variables ¶
This section is empty.
Functions ¶
func Identity ¶
func Identity(cert x509.Certificate) string
func Issuer ¶
func Issuer(cert x509.Certificate) string
func MarshalPKCS8X25519PrivateKey ¶
func MarshalPKCS8X25519PrivateKey(priv *X25519PrivateKey) ([]byte, error)
func MarshalPemBytes ¶
func MarshalPemPKCS8X25519PrivateKey ¶
func MarshalPemPKCS8X25519PrivateKey(priv *X25519PrivateKey) ([]byte, error)
func MarshalPemPkcs1EncodedRsaPrivateKey ¶
func MarshalPemPkcs1EncodedRsaPrivateKey(privKey *rsa.PrivateKey) []byte
func ParsePemEncodedPrivateKey ¶
func ParsePemEncodedPrivateKey(serialized []byte) (crypto.PrivateKey, error)
func ParsePemPkcs1EncodedRsaPrivateKey ¶
func ParsePemPkcs1EncodedRsaPrivateKey(pemBytes []byte) (*rsa.PrivateKey, error)
PEM(PKCS1(rsa.PrivateKey))
func ParsePemPkcs1EncodedRsaPublicKey ¶
PEM(PKCS1(rsa.PublicKey))
func ParsePemX509Certificate ¶
func ParsePemX509Certificate(pemBytes []byte) (*x509.Certificate, error)
PEM(cert)
func PublicKeyFromPrivateKey ¶
func PublicKeyFromPrivateKey(priv crypto.PrivateKey) (crypto.PublicKey, error)
func PublicKeyHumanReadableDescription ¶
"human readable" = don't ever try to parse the output format
func RandBase64Url ¶
func RandBase64UrlWithoutLeadingDash ¶
CLI arguments beginning with dash are problematic (which base64 URL variant can produce), so this variant is for nice guys to make life simpler (reduces entropy very little)
Types ¶
type X25519PrivateKey ¶
type X25519PrivateKey struct {
// contains filtered or unexported fields
}
func NewX25519PrivateKey ¶
func NewX25519PrivateKey(b []byte) (*X25519PrivateKey, error)
func ParsePKCS8X25519PrivateKey ¶
func ParsePKCS8X25519PrivateKey(der []byte) (*X25519PrivateKey, error)
func ParsePemPKCS8X25519PrivateKey ¶
func ParsePemPKCS8X25519PrivateKey(input []byte) (*X25519PrivateKey, error)
func (X25519PrivateKey) Bytes ¶
func (p X25519PrivateKey) Bytes() []byte
func (X25519PrivateKey) ECDH ¶
func (p X25519PrivateKey) ECDH(peer X25519PublicKey) ([]byte, error)
func (X25519PrivateKey) Public ¶
func (p X25519PrivateKey) Public() X25519PublicKey
type X25519PublicKey ¶
type X25519PublicKey struct {
// contains filtered or unexported fields
}
func NewX25519PublicKey ¶
func NewX25519PublicKey(key []byte) X25519PublicKey
func ParsePemPKCS8X25519PublicKey ¶
func ParsePemPKCS8X25519PublicKey(pemBytes []byte) (*X25519PublicKey, error)
func (X25519PublicKey) Bytes ¶
func (p X25519PublicKey) Bytes() []byte
Click to show internal directories.
Click to hide internal directories.