aesrsa

package
v1.84.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeHybridAESRSAEncryptedPayload

func DecodeHybridAESRSAEncryptedPayload(p *HybridAESRSAEncryptedPayload) (cipher, key, nonce []byte, err error)

func DecryptHybridAESRSAEncryptedPayloadFromBytes

func DecryptHybridAESRSAEncryptedPayloadFromBytes(block []byte, payload *HybridAESRSAEncryptedPayload) (decrypted []byte, err error)

DecryptHybridAESRSAEncryptedPayloadFromPrivateKeyPath takes a path to an RSA private key PEM file and uses it to decode the AES key in a hybrid encoded payload. This AES key is then used to decode the actual payload contents. Information of the use of hybrid AES RSA encryption can be found here https://www.ijrar.org/papers/IJRAR23B1852.pdf

func DecryptHybridAESRSAEncryptedPayloadFromPrivateKey

func DecryptHybridAESRSAEncryptedPayloadFromPrivateKey(privateKeyPath string, payload *HybridAESRSAEncryptedPayload) (decrypted []byte, err error)

DecryptHybridAESRSAEncryptedPayloadFromPrivateKey takes a path to an RSA private key and uses it to decode the AES key in a hybrid encoded payload. This AES key is then used to decode the actual payload contents. Information of the use of hybrid AES RSA encryption can be found here https://www.ijrar.org/papers/IJRAR23B1852.pdf

func ParsePEMBlock

func ParsePEMBlock(path string) (block *pem.Block, err error)

ParsePEMBlock will parse the first PEM block found within path

Types

type HybridAESRSAEncryptedPayload

type HybridAESRSAEncryptedPayload struct {
	// Ciphertext contains the encrypted contents
	CipherText string `json:"cipher_text" yaml:"cipher_text" mapstructure:"cipher_text"`
	// EncryptedKey contains the encryped AES key used to encrypt the data
	EncryptedKey string `json:"encrypted_key" yaml:"encrypted_key" mapstructure:"encrypted_key"`
	// Nonce used for encryption is required during decryption
	Nonce string `json:"nonce" yaml:"nonce" mapstructure:"nonce"`
}

func EncodeHybridAESRSAEncryptedPayload

func EncodeHybridAESRSAEncryptedPayload(cipher, key, nonce []byte) (p *HybridAESRSAEncryptedPayload)

func EncryptHybridAESRSAEncryptedPayloadFromBytes

func EncryptHybridAESRSAEncryptedPayloadFromBytes(block []byte, payload []byte) (encrypted *HybridAESRSAEncryptedPayload, err error)

EncryptHybridAESRSAEncryptedPayloadFromBytes takes an x509 certificate for key encypherment and uses it to encode a payload using hybrid RSA AES encryption where an AES key is used to encrypt the content in payload and the AES key is encrypted using RSA encryption. AES encryption is used to encode the payload itself as it is faster than RSA for larger payloads. RSA is used to encrypt the relatively small AES key and allows asymmetric encryption whilst also being fast. More information can be found at https://www.ijrar.org/papers/IJRAR23B1852.pdf

func EncryptHybridAESRSAEncryptedPayloadFromCertificate

func EncryptHybridAESRSAEncryptedPayloadFromCertificate(certPath string, payload []byte) (encrypted *HybridAESRSAEncryptedPayload, err error)

EncryptHybridAESRSAEncryptedPayloadFromCertificate takes a path to a valid x509 certificate for key encypherment and uses it to encode a payload using hybrid RSA AES encryption where an AES key is used to encrypt the content in payload and the AES key is encrypted using RSA encryption. AES encryption is used to encode the payload itself as it is faster than RSA for larger payloads. RSA is used to encrypt the relatively small AES key and allows asymmetric encryption whilst also being fast. More information can be found at https://www.ijrar.org/papers/IJRAR23B1852.pdf

func (*HybridAESRSAEncryptedPayload) Validate

func (p *HybridAESRSAEncryptedPayload) Validate() (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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