utils

package
v0.0.0-...-2fc7595 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AEStoEncryptedPEM

func AEStoEncryptedPEM(raw []byte, pwd []byte) ([]byte, error)

AEStoEncryptedPEM encapsulates an AES key in the encrypted PEM format

func AEStoPEM

func AEStoPEM(raw []byte) []byte

AEStoPEM encapsulates an AES key in the PEM format

func Clone

func Clone(src []byte) []byte

Clone clones the passed slice

func DERToPrivateKey

func DERToPrivateKey(der []byte) (key interface{}, err error)

DERToPrivateKey unmarshals a der to private key

func DERToPublicKey

func DERToPublicKey(raw []byte) (pub interface{}, err error)

DERToPublicKey unmarshals a der to public key

func DERToSM2Certificate

func DERToSM2Certificate(asn1Data []byte) (*sm2.Certificate, error)

DERToSM2Certificate converts der to sm2

func DERToX509Certificate

func DERToX509Certificate(asn1Data []byte) (*x509.Certificate, error)

DERToX509Certificate converts der to x509

func DirEmpty

func DirEmpty(path string) (bool, error)

DirEmpty checks if a directory is empty

func DirExists

func DirExists(path string) (bool, error)

DirExists checks if a directory exists

func DirMissingOrEmpty

func DirMissingOrEmpty(path string) (bool, error)

DirMissingOrEmpty checks is a directory is missing or empty

func ErrToString

func ErrToString(err error) string

ErrToString converts and error to a string. If the error is nil, it returns the string "<clean>"

func GetCurveHalfOrdersAt

func GetCurveHalfOrdersAt(c elliptic.Curve) *big.Int

func IsLowS

func IsLowS(k *ecdsa.PublicKey, s *big.Int) (bool, error)

IsLow checks that s is a low-S

func MarshalECDSASignature

func MarshalECDSASignature(r, s *big.Int) ([]byte, error)

func PEMtoAES

func PEMtoAES(raw []byte, pwd []byte) ([]byte, error)

PEMtoAES extracts from the PEM an AES key

func PEMtoPrivateKey

func PEMtoPrivateKey(raw []byte, pwd []byte) (interface{}, error)

PEMtoPrivateKey unmarshals a pem to private key

func PEMtoPublicKey

func PEMtoPublicKey(raw []byte, pwd []byte) (interface{}, error)

PEMtoPublicKey unmarshals a pem to public key

func PrivateKeyToDER

func PrivateKeyToDER(privateKey *ecdsa.PrivateKey) ([]byte, error)

PrivateKeyToDER marshals a private key to der

func PrivateKeyToEncryptedPEM

func PrivateKeyToEncryptedPEM(privateKey interface{}, pwd []byte) ([]byte, error)

PrivateKeyToEncryptedPEM converts a private key to an encrypted PEM

func PrivateKeyToPEM

func PrivateKeyToPEM(privateKey interface{}, pwd []byte) ([]byte, error)

PrivateKeyToPEM converts the private key to PEM format. EC private keys are converted to PKCS#8 format. RSA private keys are converted to PKCS#1 format.

func PublicKeyToDER

func PublicKeyToDER(publicKey interface{}) ([]byte, error)

PublicKeyToDER marshals a public key to the der format

func PublicKeyToEncryptedPEM

func PublicKeyToEncryptedPEM(publicKey interface{}, pwd []byte) ([]byte, error)

PublicKeyToEncryptedPEM converts a public key to encrypted pem

func PublicKeyToPEM

func PublicKeyToPEM(publicKey interface{}, pwd []byte) ([]byte, error)

PublicKeyToPEM marshals a public key to the pem format

func SignatureToLowS

func SignatureToLowS(k *ecdsa.PublicKey, signature []byte) ([]byte, error)

func ToLowS

func ToLowS(k *ecdsa.PublicKey, s *big.Int) (*big.Int, bool, error)

func UnmarshalECDSASignature

func UnmarshalECDSASignature(raw []byte) (*big.Int, *big.Int, error)

Types

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

Jump to

Keyboard shortcuts

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