xmlenc

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// XMLEncryptionNamespace is the XML Encryption namespace
	XMLEncryptionNamespace = "http://www.w3.org/2001/04/xmlenc#"
	// XMLEncryptionPrefix is the XML Encryption namespace prefix
	XMLEncryptionPrefix = "denc"
	// XMLSignatureNamespace is the XML Signature namespace
	XMLSignatureNamespace = "http://www.w3.org/2000/09/xmldsig#"
	// XMLSignaturePrefix is the XML Signature namespace prefix
	XMLSignaturePrefix = "ds"
	// XMLEncryption11Namespace is the XML Encryption 1.1 namespace
	XMLEncryption11Namespace = "http://www.w3.org/2009/xmlenc11#"
	// XMLEncryption11Prefix is the XML Encryption 1.1 namespace prefix
	XMLEncryption11Prefix = "xenc11"
	// XMLSignature11Namespace is the XML Signature 1.1 namespace
	XMLSignature11Namespace = "http://www.w3.org/2009/xmldsig11#"
	// XMLSignature11Prefix is the XML Signature 1.1 namespace prefix
	XMLSignature11Prefix = "dsig11"
)

XML namespace URIs

Variables

This section is empty.

Functions

This section is empty.

Types

type AgreementMethod

type AgreementMethod struct {
	XMLName             xml.Name             `xml:"http://www.w3.org/2001/04/xmlenc# AgreementMethod"`
	Algorithm           string               `xml:"Algorithm,attr"`
	KeyDerivationMethod *KeyDerivationMethod `xml:"http://www.w3.org/2009/xmlenc11# KeyDerivationMethod,omitempty"`
	OriginatorKeyInfo   *OriginatorKeyInfo   `xml:"http://www.w3.org/2001/04/xmlenc# OriginatorKeyInfo,omitempty"`
	RecipientKeyInfo    *RecipientKeyInfo    `xml:"http://www.w3.org/2001/04/xmlenc# RecipientKeyInfo,omitempty"`
}

AgreementMethod represents the AgreementMethod element for ECDH-ES (EC recipients)

type CipherData

type CipherData struct {
	XMLName     xml.Name `xml:"http://www.w3.org/2001/04/xmlenc# CipherData"`
	CipherValue string   `xml:"http://www.w3.org/2001/04/xmlenc# CipherValue"`
}

CipherData represents the CipherData element

type ConcatKDFParams

type ConcatKDFParams struct {
	XMLName      xml.Name     `xml:"http://www.w3.org/2009/xmlenc11# ConcatKDFParams"`
	AlgorithmID  string       `xml:"AlgorithmID,attr"`
	PartyUInfo   string       `xml:"PartyUInfo,attr"`
	PartyVInfo   string       `xml:"PartyVInfo,attr"`
	DigestMethod DigestMethod `xml:"http://www.w3.org/2000/09/xmldsig# DigestMethod"`
}

ConcatKDFParams represents ConcatKDF parameters

type DigestMethod

type DigestMethod struct {
	XMLName   xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# DigestMethod"`
	Algorithm string   `xml:"Algorithm,attr"`
}

DigestMethod represents the digest method (SHA-384)

type ECKeyValue

type ECKeyValue struct {
	XMLName    xml.Name    `xml:"http://www.w3.org/2009/xmldsig11# ECKeyValue"`
	NamedCurve *NamedCurve `xml:"http://www.w3.org/2009/xmldsig11# NamedCurve,omitempty"`
	PublicKey  string      `xml:"http://www.w3.org/2009/xmldsig11# PublicKey"`
}

ECKeyValue represents an EC key value

type ECRecipient

type ECRecipient struct {
	Certificate        *x509.Certificate
	CN                 string
	EphemeralPublicKey *ecdsa.PublicKey
	AlgorithmID        []byte
	PartyUInfo         []byte
	PartyVInfo         []byte
	DigestAlgorithm    string
	EncryptedKey       []byte // Base64-encoded wrapped transport key
}

ECRecipient represents an EC recipient

func (*ECRecipient) GetAlgorithmID

func (r *ECRecipient) GetAlgorithmID() []byte

GetAlgorithmID returns the AlgorithmID bytes

func (*ECRecipient) GetCN

func (r *ECRecipient) GetCN() string

GetCN returns the Common Name

func (*ECRecipient) GetCertificate

func (r *ECRecipient) GetCertificate() *x509.Certificate

GetCertificate returns the recipient's certificate

func (*ECRecipient) GetDigestAlgorithm added in v2.0.1

func (r *ECRecipient) GetDigestAlgorithm() string

GetDigestAlgorithm returns the digest algorithm URI used for ConcatKDF.

func (*ECRecipient) GetEncryptedKey

func (r *ECRecipient) GetEncryptedKey() ([]byte, error)

GetEncryptedKey returns the encrypted/wrapped key (decoded from base64)

func (*ECRecipient) GetEphemeralPublicKey

func (r *ECRecipient) GetEphemeralPublicKey() *ecdsa.PublicKey

GetEphemeralPublicKey returns the ephemeral EC public key

func (*ECRecipient) GetPartyUInfo

func (r *ECRecipient) GetPartyUInfo() []byte

GetPartyUInfo returns the PartyUInfo bytes

func (*ECRecipient) GetPartyVInfo

func (r *ECRecipient) GetPartyVInfo() []byte

GetPartyVInfo returns the PartyVInfo bytes

type EncryptedData

type EncryptedData struct {
	XMLName  xml.Name `xml:"http://www.w3.org/2001/04/xmlenc# EncryptedData"`
	ID       string   `xml:"Id,attr,omitempty"`
	Type     string   `xml:"Type,attr,omitempty"`
	MimeType string   `xml:"MimeType,attr"`

	EncryptionMethod     EncryptionMethod      `xml:"http://www.w3.org/2001/04/xmlenc# EncryptionMethod"`
	KeyInfo              KeyInfo               `xml:"http://www.w3.org/2000/09/xmldsig# KeyInfo"`
	CipherData           CipherData            `xml:"http://www.w3.org/2001/04/xmlenc# CipherData"`
	EncryptionProperties *EncryptionProperties `xml:"http://www.w3.org/2001/04/xmlenc# EncryptionProperties,omitempty"`
}

EncryptedData represents the root EncryptedData XML element

type EncryptedKey

type EncryptedKey struct {
	XMLName          xml.Name         `xml:"http://www.w3.org/2001/04/xmlenc# EncryptedKey"`
	ID               string           `xml:"Id,attr,omitempty"`
	Recipient        string           `xml:"Recipient,attr,omitempty"`
	EncryptionMethod EncryptionMethod `xml:"http://www.w3.org/2001/04/xmlenc# EncryptionMethod"`
	KeyInfo          KeyInfoElement   `xml:"http://www.w3.org/2000/09/xmldsig# KeyInfo"`
	CipherData       CipherData       `xml:"http://www.w3.org/2001/04/xmlenc# CipherData"`
}

EncryptedKey represents an EncryptedKey XML element (for RSA recipients)

type EncryptionMethod

type EncryptionMethod struct {
	XMLName   xml.Name `xml:"http://www.w3.org/2001/04/xmlenc# EncryptionMethod"`
	Algorithm string   `xml:"Algorithm,attr"`
}

EncryptionMethod represents the EncryptionMethod element

type EncryptionProperties

type EncryptionProperties struct {
	XMLName    xml.Name             `xml:"http://www.w3.org/2001/04/xmlenc# EncryptionProperties"`
	ID         string               `xml:"Id,attr,omitempty"`
	Properties []EncryptionProperty `xml:"http://www.w3.org/2001/04/xmlenc# EncryptionProperty"`
}

EncryptionProperties represents metadata about the encrypted document

type EncryptionProperty

type EncryptionProperty struct {
	XMLName xml.Name `xml:"http://www.w3.org/2001/04/xmlenc# EncryptionProperty"`
	ID      string   `xml:"Id,attr,omitempty"`
	Target  string   `xml:"Target,attr,omitempty"`
	Name    string   `xml:"Name,attr"`
	Content string   `xml:",chardata"`
}

EncryptionProperty represents a single metadata property

type KeyDerivationMethod

type KeyDerivationMethod struct {
	XMLName         xml.Name         `xml:"http://www.w3.org/2009/xmlenc11# KeyDerivationMethod"`
	Algorithm       string           `xml:"Algorithm,attr"`
	ConcatKDFParams *ConcatKDFParams `xml:"http://www.w3.org/2009/xmlenc11# ConcatKDFParams,omitempty"`
}

KeyDerivationMethod represents the KeyDerivationMethod element (ConcatKDF)

type KeyInfo

type KeyInfo struct {
	XMLName       xml.Name       `xml:"http://www.w3.org/2000/09/xmldsig# KeyInfo"`
	EncryptedKeys []EncryptedKey `xml:"http://www.w3.org/2001/04/xmlenc# EncryptedKey"`
}

KeyInfo represents the KeyInfo element containing recipients

type KeyInfoElement

type KeyInfoElement struct {
	XMLName         xml.Name         `xml:"http://www.w3.org/2000/09/xmldsig# KeyInfo"`
	KeyName         *string          `xml:"http://www.w3.org/2000/09/xmldsig# KeyName,omitempty"`
	X509Data        *X509Data        `xml:"http://www.w3.org/2000/09/xmldsig# X509Data,omitempty"`
	AgreementMethod *AgreementMethod `xml:"http://www.w3.org/2001/04/xmlenc# AgreementMethod,omitempty"`
	CarriedKeyName  *string          `xml:"http://www.w3.org/2000/09/xmldsig# CarriedKeyName,omitempty"`
}

KeyInfoElement represents a KeyInfo element within an EncryptedKey

type KeyValue

type KeyValue struct {
	XMLName    xml.Name    `xml:"http://www.w3.org/2000/09/xmldsig# KeyValue"`
	ECKeyValue *ECKeyValue `xml:"http://www.w3.org/2009/xmldsig11# ECKeyValue,omitempty"`
}

KeyValue represents the KeyValue element containing EC key

type NamedCurve

type NamedCurve struct {
	XMLName xml.Name `xml:"http://www.w3.org/2009/xmldsig11# NamedCurve"`
	URI     string   `xml:"URI,attr"`
}

NamedCurve represents the named curve specification

type OriginatorKeyInfo

type OriginatorKeyInfo struct {
	XMLName  xml.Name  `xml:"http://www.w3.org/2001/04/xmlenc# OriginatorKeyInfo"`
	KeyValue *KeyValue `xml:"http://www.w3.org/2000/09/xmldsig# KeyValue,omitempty"`
}

OriginatorKeyInfo represents the ephemeral public key info

type RSARecipient

type RSARecipient struct {
	Certificate  *x509.Certificate
	CN           string
	EncryptedKey []byte // Base64-encoded encrypted transport key
}

RSARecipient represents an RSA recipient

func (*RSARecipient) GetCN

func (r *RSARecipient) GetCN() string

GetCN returns the Common Name

func (*RSARecipient) GetCertificate

func (r *RSARecipient) GetCertificate() *x509.Certificate

GetCertificate returns the recipient's certificate

type Recipient

type Recipient interface {
	// GetCertificate returns the recipient's certificate
	GetCertificate() *x509.Certificate
	// GetCN returns the Common Name from the certificate
	GetCN() string
}

Recipient represents a recipient abstraction

type RecipientKeyInfo

type RecipientKeyInfo struct {
	XMLName  xml.Name  `xml:"http://www.w3.org/2001/04/xmlenc# RecipientKeyInfo"`
	X509Data *X509Data `xml:"http://www.w3.org/2000/09/xmldsig# X509Data,omitempty"`
}

RecipientKeyInfo represents the recipient certificate info

type X509Data

type X509Data struct {
	XMLName         xml.Name `xml:"http://www.w3.org/2000/09/xmldsig# X509Data"`
	X509Certificate string   `xml:"http://www.w3.org/2000/09/xmldsig# X509Certificate"`
}

X509Data represents X.509 certificate data

Jump to

Keyboard shortcuts

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