Documentation
¶
Overview ¶
Copyright (c) Microsoft Corporation. Licensed under the MIT License.
Package openssl provides access to OpenSSL cryptographic functions.
Index ¶
- Constants
- func DecryptRSANoPadding(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error)
- func DecryptRSAOAEP(h hash.Hash, priv *PrivateKeyRSA, ciphertext, label []byte) ([]byte, error)
- func DecryptRSAOAEPWithMGF1Hash(h, mgfHash hash.Hash, priv *PrivateKeyRSA, ciphertext, label []byte) ([]byte, error)
- func DecryptRSAPKCS1(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error)
- func ECDH(priv *PrivateKeyECDH, pub *PublicKeyECDH) ([]byte, error)
- func EncryptRSANoPadding(pub *PublicKeyRSA, msg []byte) ([]byte, error)
- func EncryptRSAOAEP(h hash.Hash, pub *PublicKeyRSA, msg, label []byte) ([]byte, error)
- func EncryptRSAOAEPWithMGF1Hash(h, mgfHash hash.Hash, pub *PublicKeyRSA, msg, label []byte) ([]byte, error)
- func EncryptRSAPKCS1(pub *PublicKeyRSA, msg []byte) ([]byte, error)
- func FIPS() bool
- func Init() error
- func NewAESCipher(key []byte) (cipher.Block, error)
- func NewGCMTLS(c cipher.Block) (cipher.AEAD, error)
- func NewGCMTLS13(c cipher.Block) (cipher.AEAD, error)
- func NewHMAC(h func() hash.Hash, key []byte) hash.Hash
- func NewSHA1() hash.Hash
- func NewSHA224() hash.Hash
- func NewSHA256() hash.Hash
- func NewSHA384() hash.Hash
- func NewSHA512() hash.Hash
- func SHA1(p []byte) (sum [20]byte)
- func SHA224(p []byte) (sum [28]byte)
- func SHA256(p []byte) (sum [32]byte)
- func SHA384(p []byte) (sum [48]byte)
- func SHA512(p []byte) (sum [64]byte)
- func SetFIPS(enabled bool) error
- func SignMarshalECDSA(priv *PrivateKeyECDSA, hash []byte) ([]byte, error)
- func SignRSAPKCS1v15(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte) ([]byte, error)
- func SignRSAPSS(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte, saltLen int) ([]byte, error)
- func VerifyECDSA(pub *PublicKeyECDSA, hash []byte, sig []byte) bool
- func VerifyRSAPKCS1v15(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte) error
- func VerifyRSAPSS(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte, saltLen int) error
- func VersionText() string
- type BigInt
- type PrivateKeyECDH
- type PrivateKeyECDSA
- type PrivateKeyRSA
- type PublicKeyECDH
- type PublicKeyECDSA
- type PublicKeyRSA
Constants ¶
const RandReader = randReader(0)
Variables ¶
This section is empty.
Functions ¶
func DecryptRSANoPadding ¶
func DecryptRSANoPadding(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error)
func DecryptRSAOAEP ¶
func DecryptRSAOAEPWithMGF1Hash ¶ added in v0.2.2
func DecryptRSAPKCS1 ¶
func DecryptRSAPKCS1(priv *PrivateKeyRSA, ciphertext []byte) ([]byte, error)
func ECDH ¶ added in v0.2.3
func ECDH(priv *PrivateKeyECDH, pub *PublicKeyECDH) ([]byte, error)
func EncryptRSANoPadding ¶
func EncryptRSANoPadding(pub *PublicKeyRSA, msg []byte) ([]byte, error)
func EncryptRSAOAEP ¶
func EncryptRSAOAEPWithMGF1Hash ¶ added in v0.2.2
func EncryptRSAPKCS1 ¶
func EncryptRSAPKCS1(pub *PublicKeyRSA, msg []byte) ([]byte, error)
func FIPS ¶
func FIPS() bool
FIPS returns true if OpenSSL is running in FIPS mode, else returns false.
func Init ¶
func Init() error
Init loads and initializes OpenSSL. It must be called before any other OpenSSL call.
Only the first call to Init is effective, subsequent calls will return the same error result as the one from the first call.
If GO_OPENSSL_VERSION_OVERRIDE environment variable is not empty, its value will be appended to the OpenSSL shared library name as a version suffix when calling dlopen. For example, "GO_OPENSSL_VERSION_OVERRIDE=1.1.1k-fips" makes Init look for the shared library libcrypto.so.1.1.1k-fips. If GO_OPENSSL_VERSION_OVERRIDE environment variable is empty, Init will try to load the OpenSSL shared library using a list if supported and well-known version suffixes, going from higher to lower versions.
func NewGCMTLS ¶ added in v0.2.0
NewGCMTLS returns a GCM cipher specific to TLS and should not be used for non-TLS purposes.
func NewGCMTLS13 ¶ added in v0.2.9
NewGCMTLS13 returns a GCM cipher specific to TLS 1.3 and should not be used for non-TLS purposes.
func NewHMAC ¶
NewHMAC returns a new HMAC using OpenSSL. The function h must return a hash implemented by OpenSSL (for example, h could be openssl.NewSHA256). If h is not recognized, NewHMAC returns nil.
func SetFIPS ¶
SetFIPS enables or disables FIPS mode.
On OpenSSL 3, the `fips` provider is loaded if enabled is true, else the `default` provider is loaded.
func SignMarshalECDSA ¶
func SignMarshalECDSA(priv *PrivateKeyECDSA, hash []byte) ([]byte, error)
func SignRSAPKCS1v15 ¶
func SignRSAPSS ¶
func VerifyECDSA ¶
func VerifyECDSA(pub *PublicKeyECDSA, hash []byte, sig []byte) bool
func VerifyRSAPKCS1v15 ¶
func VerifyRSAPKCS1v15(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte) error
func VerifyRSAPSS ¶
func VersionText ¶
func VersionText() string
VersionText returns the version text of the OpenSSL currently loaded.
Types ¶
type BigInt ¶ added in v0.2.0
type BigInt []uint
A BigInt is the raw words from a BigInt. This definition allows us to avoid importing math/big. Conversion between BigInt and *big.Int is in openssl/bbig.
func GenerateKeyECDSA ¶
func GenerateKeyRSA ¶
type PrivateKeyECDH ¶ added in v0.2.3
type PrivateKeyECDH struct {
// contains filtered or unexported fields
}
func GenerateKeyECDH ¶ added in v0.2.3
func GenerateKeyECDH(curve string) (*PrivateKeyECDH, []byte, error)
func NewPrivateKeyECDH ¶ added in v0.2.3
func NewPrivateKeyECDH(curve string, bytes []byte) (*PrivateKeyECDH, error)
func (*PrivateKeyECDH) PublicKey ¶ added in v0.2.3
func (k *PrivateKeyECDH) PublicKey() (*PublicKeyECDH, error)
type PrivateKeyECDSA ¶
type PrivateKeyECDSA struct {
// contains filtered or unexported fields
}
func NewPrivateKeyECDSA ¶
func NewPrivateKeyECDSA(curve string, X, Y, D BigInt) (*PrivateKeyECDSA, error)
type PrivateKeyRSA ¶
type PrivateKeyRSA struct {
// contains filtered or unexported fields
}
func NewPrivateKeyRSA ¶
func NewPrivateKeyRSA(N, E, D, P, Q, Dp, Dq, Qinv BigInt) (*PrivateKeyRSA, error)
type PublicKeyECDH ¶ added in v0.2.3
type PublicKeyECDH struct {
// contains filtered or unexported fields
}
func NewPublicKeyECDH ¶ added in v0.2.3
func NewPublicKeyECDH(curve string, bytes []byte) (*PublicKeyECDH, error)
func (*PublicKeyECDH) Bytes ¶ added in v0.2.3
func (k *PublicKeyECDH) Bytes() []byte
type PublicKeyECDSA ¶
type PublicKeyECDSA struct {
// contains filtered or unexported fields
}
func NewPublicKeyECDSA ¶
func NewPublicKeyECDSA(curve string, X, Y BigInt) (*PublicKeyECDSA, error)
type PublicKeyRSA ¶
type PublicKeyRSA struct {
// contains filtered or unexported fields
}
func NewPublicKeyRSA ¶
func NewPublicKeyRSA(N, E BigInt) (*PublicKeyRSA, error)