Documentation
¶
Index ¶
- func Unmarshal(r io.Reader, target *Container) error
- func UnmarshalBytes(allBytes []byte, target *Container) error
- func UnmarshalFromFile(file string, target *Container) error
- type Container
- func (c *Container) DecryptCertificate(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptEmail(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptEverything(nonce []byte, key []byte) error
- func (c *Container) DecryptIdentifier(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptPrivateKey(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptRootCertificate(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptSerialNumber(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptSignature(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptToken(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) DecryptUsername(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) Dump(w io.Writer)
- func (c *Container) EncryptCertificate(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptEmail(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptEverything(nonce []byte, key []byte) error
- func (c *Container) EncryptIdentifier(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptPrivateKey(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptRootCertificate(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptSerialNumber(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptSignature(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptToken(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) EncryptUsername(nonce []byte, key []byte) ([]byte, error)
- func (c *Container) GetCertificate() []byte
- func (c *Container) GetEmail() []byte
- func (c *Container) GetIdentifier() []byte
- func (c *Container) GetNonce() []byte
- func (c *Container) GetPassword() []byte
- func (c *Container) GetPrivateKey() []byte
- func (c *Container) GetRootCertificate() []byte
- func (c *Container) GetSemVer() string
- func (c *Container) GetSerialNumber() []byte
- func (c *Container) GetSignature() []byte
- func (c *Container) GetTag() []byte
- func (c *Container) GetTlsCertificate() (*tls.Certificate, error)
- func (c *Container) GetToken() []byte
- func (c *Container) GetUsername() []byte
- func (c *Container) GetVersionMajor() byte
- func (c *Container) GetVersionMinor() byte
- func (c *Container) GetVersionPatch() byte
- func (c *Container) GetX509Certificate() (*x509.Certificate, error)
- func (c *Container) GetX509RootCertificate() (*x509.Certificate, error)
- func (c *Container) HeaderLen() int
- func (c *Container) Headers() [headerSize]byte
- func (c *Container) Len() int
- func (c *Container) Marshal(w io.Writer) error
- func (c *Container) MarshalBytes() []byte
- func (c *Container) MarshalToFile(file string, perms os.FileMode) error
- func (c *Container) Payload() []byte
- func (c *Container) PayloadLen() int
- func (c *Container) Read(s []byte) (int, error)
- func (c *Container) SetCertificate(cert []byte) *Container
- func (c *Container) SetEmail(e []byte) *Container
- func (c *Container) SetIdentifier(id []byte) *Container
- func (c *Container) SetNonce(n []byte) *Container
- func (c *Container) SetPassword(p []byte) *Container
- func (c *Container) SetPrivateKey(pk []byte) *Container
- func (c *Container) SetRandomNonce() error
- func (c *Container) SetRootCertificate(rc []byte) *Container
- func (c *Container) SetSerialNumber(sn []byte) *Container
- func (c *Container) SetSignature(sig []byte) *Container
- func (c *Container) SetTag(t []byte) *Container
- func (c *Container) SetToken(t []byte) *Container
- func (c *Container) SetUsername(u []byte) *Container
- func (c *Container) SetVersionMajor(v byte) *Container
- func (c *Container) SetVersionMinor(v byte) *Container
- func (c *Container) SetVersionPatch(v byte) *Container
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalBytes ¶
UnmarshalBytes takes a []byte and a pointer to a target container and deserializes the []byte into the container, e.g.:
var b []byte // some data source var c *eraf.Container = eraf.New() err := eraf.Unmarshal(b, c)
func UnmarshalFromFile ¶
UnmarshalFromFile deserializes a ERAF from the given file
Types ¶
type Container ¶
type Container struct {
// contains filtered or unexported fields
}
Container is the central struct to work with
func (*Container) DecryptCertificate ¶
DecryptCertificate decrypts and returns the certificate
func (*Container) DecryptEmail ¶
DecryptEmail decrypts and returns the email address
func (*Container) DecryptEverything ¶
DecryptEverything is the obvious counterpart to EncryptEverything. It performs the decryption in place, using either AES-128, AES-192 or AES-256, depending on key length.
func (*Container) DecryptIdentifier ¶
DecryptIdentifier decrypts and returns the identifier
func (*Container) DecryptPrivateKey ¶
DecryptPrivateKey decrypts and returns the private key
func (*Container) DecryptRootCertificate ¶
DecryptRootCertificate decrypts and returns the root certificate
func (*Container) DecryptSerialNumber ¶
DecryptSerialNumber decrypts and returns the serial number
func (*Container) DecryptSignature ¶
DecryptSignature decrypts and returns the signature
func (*Container) DecryptToken ¶
DecryptToken decrypts and returns the token
func (*Container) DecryptUsername ¶
DecryptUsername decrypts and returns the username
func (*Container) EncryptCertificate ¶
EncryptCertificate encrypts and returns the certificate
func (*Container) EncryptEmail ¶
EncryptEmail encrypts and returns the email address
func (*Container) EncryptEverything ¶
EncryptEverything take a nonce and a key to encrypt every data block using AES in place. All blocks will be encrypted and written back, no data is returned. Requires a key with a length of 16 bytes (AES-128), 24 bytes (AES-192) or 32 bytes (AES-256). The nonce requires a length of 12 bytes. You can use SetRandomNonce() to generate a cryptographically secure nonce.
func (*Container) EncryptIdentifier ¶
EncryptIdentifier encrypts and returns the identifier
func (*Container) EncryptPrivateKey ¶
EncryptPrivateKey encrypts and returns the private key
func (*Container) EncryptRootCertificate ¶
EncryptRootCertificate encrypts and returns the signature
func (*Container) EncryptSerialNumber ¶
EncryptSerialNumber encrypts and returns the serial number
func (*Container) EncryptSignature ¶
EncryptSignature encrypts and returns the signature
func (*Container) EncryptToken ¶
EncryptToken encrypts and returns the token
func (*Container) EncryptUsername ¶
EncryptUsername encrypts and returns the username
func (*Container) GetCertificate ¶
GetCertificate returns the certificate
func (*Container) GetIdentifier ¶
GetIdentifier returns the identifier
func (*Container) GetPassword ¶
GetPassword returns the password
func (*Container) GetPrivateKey ¶
GetPrivateKey returns the private key
func (*Container) GetRootCertificate ¶
GetRootCertificate returns the root certificate
func (*Container) GetSemVer ¶
GetSemVer returns the combination of all version elements as a semantic version string
func (*Container) GetSerialNumber ¶
GetSerialNumber returns the serial number
func (*Container) GetSignature ¶
GetSignature returns the signature
func (*Container) GetTlsCertificate ¶
func (c *Container) GetTlsCertificate() (*tls.Certificate, error)
GetTlsCertificate returns the certificate as *tls.Certificate
func (*Container) GetUsername ¶
GetUsername returns the username
func (*Container) GetVersionMajor ¶
GetVersionMajor returns the major version
func (*Container) GetVersionMinor ¶
GetVersionMinor returns the minor version
func (*Container) GetVersionPatch ¶
GetVersionPatch returns the patch version
func (*Container) GetX509Certificate ¶
func (c *Container) GetX509Certificate() (*x509.Certificate, error)
GetX509Certificate returns the certificate as *x509.Certificate
func (*Container) GetX509RootCertificate ¶
func (c *Container) GetX509RootCertificate() (*x509.Certificate, error)
GetX509RootCertificate returns the root certificate as *x509.Certificate
func (*Container) MarshalBytes ¶
MarshalBytes serializes the container into a []byte
func (*Container) MarshalToFile ¶
MarshalToFile serializes the ERAF file into the given file using the given file permissions
func (*Container) PayloadLen ¶
PayloadLen returns the amount of bytes the payload takes up
func (*Container) Read ¶
Read reads all bytes into s and returns the number of bytes read as well as an error
func (*Container) SetCertificate ¶
SetCertificate sets a certificate. For the convenience functions to work properly, the certificate expected to be in PEM format
func (*Container) SetIdentifier ¶
SetIdentifier sets an identifier
func (*Container) SetPassword ¶
SetPassword sets a password
func (*Container) SetPrivateKey ¶
SetPrivateKey sets a private key. For the convenience functions to work properly, the key is expected to be in PEM format
func (*Container) SetRandomNonce ¶
SetRandomNonce generates a 12-byte nonce (mainly for use with AES) and stores it into the nonce field
func (*Container) SetRootCertificate ¶
SetRootCertificate sets a root certificate
func (*Container) SetSerialNumber ¶
SetSerialNumber sets a serial number
func (*Container) SetSignature ¶
SetSignature sets a signature
func (*Container) SetUsername ¶
SetUsername sets a username
func (*Container) SetVersionMajor ¶
SetVersionMajor sets the major version
func (*Container) SetVersionMinor ¶
SetVersionMinor sets the minor version
func (*Container) SetVersionPatch ¶
SetVersionPatch sets the patch version