Documentation ¶
Index ¶
- Constants
- func AesDecrypt(input io.Reader, passphrase []byte) (io.Reader, error)
- func AesEncrypt(input io.Reader, output io.Writer, passphrase []byte) error
- func CreateServerTLSConfiguration() *tls.Config
- func CreateTLSConfigurationFromBytes(caCert, cert, key []byte, skipClientVerification, skipServerVerification bool) (*tls.Config, error)
- func CreateTLSConfigurationFromDisk(caCertPath, certPath, keyPath string, skipServerVerification bool) (*tls.Config, error)
- type ECDSAService
- func (service *ECDSAService) CreateSignature(message string) (string, error)
- func (service *ECDSAService) EncodedPublicKey() string
- func (service *ECDSAService) GenerateKeyPair() ([]byte, []byte, error)
- func (service *ECDSAService) PEMHeaders() (string, string)
- func (service *ECDSAService) ParseKeyPair(private, public []byte) error
- type Service
Constants ¶
const ( // PrivateKeyPemHeader represents the header that is appended to the PEM file when // storing the private key. PrivateKeyPemHeader = "EC PRIVATE KEY" // PublicKeyPemHeader represents the header that is appended to the PEM file when // storing the public key. PublicKeyPemHeader = "ECDSA PUBLIC KEY" )
Variables ¶
This section is empty.
Functions ¶
func AesDecrypt ¶
AesDecrypt reads from input, decrypts with AES-256 and returns the reader to a read decrypted content from. passphrase is used to generate an encryption key.
func AesEncrypt ¶
AesEncrypt reads from input, encrypts with AES-256 and writes to the output. passphrase is used to generate an encryption key.
func CreateServerTLSConfiguration ¶
CreateServerTLSConfiguration creates a basic tls.Config to be used by servers with recommended TLS settings
func CreateTLSConfigurationFromBytes ¶
func CreateTLSConfigurationFromBytes(caCert, cert, key []byte, skipClientVerification, skipServerVerification bool) (*tls.Config, error)
CreateTLSConfigurationFromBytes initializes a tls.Config using a CA certificate, a certificate and a key loaded from memory.
Types ¶
type ECDSAService ¶
type ECDSAService struct {
// contains filtered or unexported fields
}
ECDSAService is a service used to create digital signatures when communicating with an agent based environment(endpoint). It will automatically generates a key pair using ECDSA or can also reuse an existing ECDSA key pair.
func NewECDSAService ¶
func NewECDSAService(secret string) *ECDSAService
NewECDSAService returns a pointer to a ECDSAService. An optional secret can be specified
func (*ECDSAService) CreateSignature ¶
func (service *ECDSAService) CreateSignature(message string) (string, error)
CreateSignature creates a digital signature. It automatically hash a specific message using MD5 and creates a signature from that hash. If a secret is associated to the service, it will be used instead of the specified message. It then encodes the generated signature in base64.
func (*ECDSAService) EncodedPublicKey ¶
func (service *ECDSAService) EncodedPublicKey() string
EncodedPublicKey returns the encoded version of the public that can be used to be shared with other services. It's the hexadecimal encoding of the public key content.
func (*ECDSAService) GenerateKeyPair ¶
func (service *ECDSAService) GenerateKeyPair() ([]byte, []byte, error)
GenerateKeyPair will create a new key pair using ECDSA.
func (*ECDSAService) PEMHeaders ¶
func (service *ECDSAService) PEMHeaders() (string, string)
PEMHeaders returns the ECDSA PEM headers.
func (*ECDSAService) ParseKeyPair ¶
func (service *ECDSAService) ParseKeyPair(private, public []byte) error
ParseKeyPair parses existing private/public key pair content and associate the parsed keys to the service.
type Service ¶
type Service struct{}
Service represents a service for encrypting/hashing data.
func (*Service) CompareHashAndData ¶
CompareHashAndData compares a hash to clear data and returns an error if the comparison fails.