Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type XBin25Config ¶
type XBin25Config struct {
// EncryptCertFile is the path to the certificate file containing the public key used for encryption.
EncryptCertFile string
// EncryptKeyFile is the path to the private key file used for decryption.
EncryptKeyFile string
// SignCertFile is the path to the certificate file containing the public key used for signature verification.
SignCertFile string
// SignKeyFile is the path to the private key file used for signing.
SignKeyFile string
// BlockSize specifies the block size for parallel compression algorithms.
// Larger values can improve compression speed on multi-core systems at the cost of memory usage.
BlockSize int
// Label is a context parameter for RSA-OAEP encryption.
// This is automatically derived from the labelStr parameter in NewConfig.
Label string
// Duration specifies the maximum allowed age for messages.
// Messages older than this duration will be rejected, protecting against replay attacks.
Duration time.Duration
}
XBin25Config holds all configuration parameters for encryption and decryption. A single configuration can be used for multiple Marshall/Unmarshall operations.
func NewConfig ¶
func NewConfig( encryptCertFile, encryptKeyFile, signCertFile, signKeyFile, labelStr string, duration time.Duration, blockSize int, ) *XBin25Config
NewConfig creates a new XBin25Config with the provided parameters.
Parameters:
- encryptCertFile: Path to the certificate file containing the public key used for encryption
- encryptKeyFile: Path to the private key file used for decryption
- signCertFile: Path to the certificate file containing the public key used for signature verification
- signKeyFile: Path to the private key file used for signing
- labelStr: A string label that is hashed and used as context for RSA-OAEP encryption
- duration: Maximum allowed age for messages (for replay protection)
- blockSize: Block size for parallel compression algorithms
The function initializes memguard to protect sensitive cryptographic material in memory.
func (*XBin25Config) Marshall ¶
func (config *XBin25Config) Marshall(data interface{}) ([]byte, error)
Marshall converts any serializable Go data structure into a secure binary format.
The process involves:
- MessagePack encoding of the input data
- AES-256-GCM encryption with a random key
- RSA-OAEP encryption of the AES key
- zstd compression of the encrypted package
- RSA-PSS signature of the compressed data
- Timestamping for replay protection
- Final compression with parallel gzip
Parameters:
- data: Any Go value that can be serialized by MessagePack
Returns:
- []byte: The marshalled, encrypted, signed, and compressed data
- error: An error if any step in the process fails
func (*XBin25Config) Unmarshall ¶
func (config *XBin25Config) Unmarshall(data []byte) (interface{}, error)
Unmarshall decrypts, verifies, and deserializes binary data produced by the Marshall function.
The process involves:
- Decompression of the outer pgzip layer
- Deserialization of the envelope structure
- Timestamp verification for replay protection
- RSA-PSS signature verification
- Decompression of the zstd layer
- RSA-OAEP decryption of the AES key
- AES-GCM decryption of the data
- MessagePack deserialization of the plaintext
Parameters:
- data: Binary data previously produced by Marshall
Returns:
- interface{}: The unmarshalled Go value
- error: An error if any step in the process fails
Click to show internal directories.
Click to hide internal directories.