seclib2

package
v0.3.11-8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 30 Imported by: 32

Documentation

Index

Constants

View Source
const (
	SYM_ENC_ALG_AES_256 = TSymEncAlg("aes-256")
	SYM_ENC_ALG_SM4_128 = TSymEncAlg("sm4")
)

Variables

View Source
var (
	AES_256 = SSymEncAlg{
			// contains filtered or unexported fields
	}
	SM4_128 = SSymEncAlg{
			// contains filtered or unexported fields
	}
)
View Source
var CERT_SEP = []byte("-END CERTIFICATE-")

Functions

func AnalyzePasswordStrenth

func AnalyzePasswordStrenth(passwd string) seclib.PasswordStrength

func BcryptPassword

func BcryptPassword(passwd string) (string, error)

func BcryptVerifyPassword

func BcryptVerifyPassword(passwd string, hash string) error

func CleanCertificate

func CleanCertificate(cert string) string

func DecodePrivateKey

func DecodePrivateKey(keyString []byte) (*rsa.PrivateKey, error)

func Decrypt

func Decrypt(privateKey, secret []byte) ([]byte, error)

func DecryptBase64

func DecryptBase64(privateKey string, secret string) (string, error)

func Encrypt

func Encrypt(publicKey, origData []byte) ([]byte, error)

func EncryptBase64

func EncryptBase64(publicKey string, message string) (string, error)

func GenerateDSASSHKeypair

func GenerateDSASSHKeypair() (string, string, error)

func GeneratePassword

func GeneratePassword(passwd string) (string, error)

func GenerateRSASSHKeypair

func GenerateRSASSHKeypair() (string, string, error)

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

func GetPublicKeyScheme

func GetPublicKeyScheme(pubkey ssh.PublicKey) string

func HashId

func HashId(seed string, idx byte, width int) string

func InitTLSConfig

func InitTLSConfig(certFile, keyFile string) (*tls.Config, error)

func InitTLSConfigByData

func InitTLSConfigByData(caCertBlock, certPEMBlock, keyPEMBlock []byte) (*tls.Config, error)

func InitTLSConfigWithCA

func InitTLSConfigWithCA(certFile, keyFile, caCertFile string) (*tls.Config, error)

func MeetComplxity

func MeetComplxity(passwd string) bool

func MergeCaCertFiles

func MergeCaCertFiles(cafile string, certfile string) (string, error)

MergeCaCertFiles concatenates cert and ca file to form a chain, write it to a tmpfile then return the path

Callers are responsible for removing the returned tmpfile

func NewCert

func NewCert(certfile, keyfile string, parseFunc func([]byte, []byte) (tls.Certificate, error)) (*tls.Certificate, error)

NewCert generates TLS cert by using the given cert,key and parse function.

func NewCertPool

func NewCertPool(CAFiles []string) (*x509.CertPool, error)

NewCertPool creates x509 certPool with provided CA files.

func RandomPassword2

func RandomPassword2(width int) string

func ValidatePassword

func ValidatePassword(passwd string) error

func VerifyPassword

func VerifyPassword(passwd string, hash string) error

Types

type SSymEncAlg

type SSymEncAlg struct {
	// contains filtered or unexported fields
}

func Alg

func Alg(alg TSymEncAlg) SSymEncAlg

func (SSymEncAlg) CbcDecode

func (alg SSymEncAlg) CbcDecode(cipherText []byte, encryptionKey []byte) ([]byte, error)

func (SSymEncAlg) CbcDecodeBase64

func (alg SSymEncAlg) CbcDecodeBase64(cipherText string, encryptionKey []byte) ([]byte, error)

func (SSymEncAlg) CbcEncode

func (alg SSymEncAlg) CbcEncode(content []byte, encryptionKey []byte) ([]byte, error)

func (SSymEncAlg) CbcEncodeBase64

func (alg SSymEncAlg) CbcEncodeBase64(content []byte, encryptionKey []byte) (string, error)

func (SSymEncAlg) CbcEncodeIV

func (alg SSymEncAlg) CbcEncodeIV(content []byte, encryptionKey []byte, IV []byte) ([]byte, error)

AES-256-CBC key: 32bytes=256bites

func (SSymEncAlg) GenerateKey

func (alg SSymEncAlg) GenerateKey() string

func (SSymEncAlg) Name

func (alg SSymEncAlg) Name() TSymEncAlg

type TSymEncAlg

type TSymEncAlg string

Jump to

Keyboard shortcuts

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