clib

package
v0.0.0-...-5cc2439 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package clib holds all of the dirty C interaction for go-xmlsec.

Although this package is visible to the outside world, the API in this package is in NO WAY guaranteed to be stable. This package was initially meant to be placed in an internal package so that the API was not available to the outside world.

The only reason this is visible is so that the REALLY advanced users can abuse the quasi-direct-C-API to overcome shortcomings of the "public" API, if any (and of course, you WILL send me a pull request later... won't you?)

Please DO NOT rely on this API and expect that it will keep backcompat. When the need arises, it WILL be changed, and if you are not ready for it, your code WILL break in horrible horrible ways. You have been warned.

Index

Constants

View Source
const (
	KeyDataFormatUnknown  KeyDataFormat = C.xmlSecKeyDataFormatUnknown
	KeyDataFormatBinary                 = C.xmlSecKeyDataFormatBinary
	KeyDataFormatPem                    = C.xmlSecKeyDataFormatPem
	KeyDataFormatDer                    = C.xmlSecKeyDataFormatDer
	KeyDataFormatPkcs8Pem               = C.xmlSecKeyDataFormatPkcs8Pem
	KeyDataFormatPkcs8Der               = C.xmlSecKeyDataFormatPkcs8Der
	KeyDataFormatPkcs12                 = C.xmlSecKeyDataFormatPkcs12
	KeyDataFormatCertPem                = C.xmlSecKeyDataFormatCertPem
	KeyDataFormatCertDer                = C.xmlSecKeyDataFormatCertDer
)
View Source
const (
	DSigNs        = "http://www.w3.org/2000/09/xmldsig#"
	Prefix        = "ds"
	SignatureNode = "Signature"
)

Variables

View Source
var (
	ExclC14N  = TransformID{/* contains filtered or unexported fields */}
	Enveloped = TransformID{/* contains filtered or unexported fields */}
	InclC14N  = TransformID{/* contains filtered or unexported fields */}
	Sha1      = TransformID{/* contains filtered or unexported fields */}
	RsaSha1   = TransformID{/* contains filtered or unexported fields */}
)
View Source
var (
	// ErrInvalidDSigCtx is returned when a dsig.Ctx is invalid
	ErrInvalidDSigCtx = errors.New("invalid dsig context")
	// ErrInvalidKey is returned when a crypto.Key is invalid
	ErrInvalidKey = errors.New("invalid key")
	// ErrInvalidKeyType is returned when a the key type was invalid
	ErrInvalidKeyType = errors.New("invalid key type")
	// ErrInvalidKeysMngr is returned when a the key manager was invalid
	ErrInvalidKeysMngr = errors.New("invalid key manager")
)

Functions

func FindSignatureNode

func FindSignatureNode(n PtrSource) (types.Node, error)

func XMLSecCryptoAppKeyCertLoad

func XMLSecCryptoAppKeyCertLoad(key PtrSource, certFile string, format KeyDataFormat) error

func XMLSecCryptoAppKeyLoad

func XMLSecCryptoAppKeyLoad(file string, format KeyDataFormat) (uintptr, error)

XMLSecCryptoAppKeyLoad calls xmlSecCryptoAppKeyLoad to load a key from file

func XMLSecCryptoAppKeyLoadMemory

func XMLSecCryptoAppKeyLoadMemory(buf []byte, format KeyDataFormat) (uintptr, error)

XMLSecCryptoAppKeyLoadMemory calls xmlSecCryptoAppKeyLoadMemory to load a key from an in memory buffer. This function acceses the byte buffer directly, so make sure not to touch the buffer from some other goroutine

func XMLSecDSigCtxCreate

func XMLSecDSigCtxCreate(mngr PtrSource) (uintptr, error)

XMLSecDSigCtxCreate calls xmlSecDSigCtxCreate with a nil parameter and returns a pointer to the new struct

func XMLSecDSigCtxDestroy

func XMLSecDSigCtxDestroy(ctx PtrSource) error

XMLSecDSigCtxDestroy calls xmlSecDSigCtxDestroy on the underlying C pointer, if available.

func XMLSecDSigCtxSetKey

func XMLSecDSigCtxSetKey(ctx PtrSource, key PtrSource) error

XMLSecDSigCtxtSetKey sets the C pointer for key to the signKey slot of the C pointer for ctx.

func XMLSecDSigCtxSignDocument

func XMLSecDSigCtxSignDocument(ctx PtrSource, doc types.Document) error

func XMLSecDSigCtxSignNode

func XMLSecDSigCtxSignNode(ctx PtrSource, n types.Node) error

func XMLSecDSigCtxVerifyDocument

func XMLSecDSigCtxVerifyDocument(ctx PtrSource, doc types.Document) error

func XMLSecDSigCtxVerifyNode

func XMLSecDSigCtxVerifyNode(ctx PtrSource, n types.Node) error

func XMLSecDSigCtxVerifyRaw

func XMLSecDSigCtxVerifyRaw(ctxptr *C.xmlSecDSigCtx, nodeptr *C.xmlNode) error

func XMLSecInit

func XMLSecInit() error

XMLSecInit initializes xmlsec by calling the various initilizers. Currently it sets up libxslt to disable interaction with the filesystem and the network, and calls xmlSecInit, xmlSecCryptoAppInit, and xmlSecCryptoInit

func XMLSecKeyCreate

func XMLSecKeyCreate() (uintptr, error)

func XMLSecKeyDestroy

func XMLSecKeyDestroy(key PtrSource) error

func XMLSecKeyDuplicate

func XMLSecKeyDuplicate(key PtrSource) (uintptr, error)

func XMLSecKeyHasDsaKey

func XMLSecKeyHasDsaKey(key PtrSource) error

func XMLSecKeyHasEcdsaKey

func XMLSecKeyHasEcdsaKey(key PtrSource) error

func XMLSecKeyHasRsaKey

func XMLSecKeyHasRsaKey(key PtrSource) error

func XMLSecKeyHasX509

func XMLSecKeyHasX509(key PtrSource) error

func XMLSecKeysMngrAdoptKey

func XMLSecKeysMngrAdoptKey(mngr, key PtrSource) error

func XMLSecKeysMngrCertLoadMemory

func XMLSecKeysMngrCertLoadMemory(mngr PtrSource, buf []byte, format KeyDataFormat, typ KeyDataType) error

func XMLSecKeysMngrCreate

func XMLSecKeysMngrCreate() (uintptr, error)

Calls xmlSecKeysMngrCreate, then initializes using xmlSecCryptoAppDefaultKeysMngrInit

func XMLSecKeysMngrDestroy

func XMLSecKeysMngrDestroy(mngr PtrSource) error

func XMLSecKeysMngrGetKey

func XMLSecKeysMngrGetKey(mngr PtrSource, n PtrSource) (uintptr, error)

func XMLSecShutdown

func XMLSecShutdown() error

XMLSecShutdown cleans up xmlsec by calling the various shutdown functions.

func XMLSecTmplKeyInfoAddKeyValue

func XMLSecTmplKeyInfoAddKeyValue(n types.Node) (types.Node, error)

func XMLSecTmplKeyInfoAddX509Data

func XMLSecTmplKeyInfoAddX509Data(n types.Node) (types.Node, error)

func XMLSecTmplReferenceAddTransform

func XMLSecTmplReferenceAddTransform(n types.Node, transformID TransformID) (types.Node, error)

func XMLSecTmplSignatureAddReference

func XMLSecTmplSignatureAddReference(signode types.Node, digestMethod TransformID, id, uri, nodeType string) (types.Node, error)

func XMLSecTmplSignatureCreateNsPref

func XMLSecTmplSignatureCreateNsPref(doc types.Document, c14nMethod TransformID, signMethod TransformID, id string, prefix string) (types.Node, error)

func XMLSecTmplSignatureEnsureKeyInfo

func XMLSecTmplSignatureEnsureKeyInfo(n types.Node, id string) (types.Node, error)

Types

type KeyDataFormat

type KeyDataFormat int

type KeyDataType

type KeyDataType uint
const (
	KeyDataTypeUnknown   KeyDataType = 0x0000
	KeyDataTypeNone      KeyDataType = 0x0000
	KeyDataTypePublic    KeyDataType = 0x0001
	KeyDataTypePrivate   KeyDataType = 0x0002
	KeyDataTypeSymmetric KeyDataType = 0x0004
	KeyDataTypeSession   KeyDataType = 0x0008
	KeyDataTypePermanent KeyDataType = 0x0010
	KeyDataTypeTrusted   KeyDataType = 0x0100
	KeyDataTypeAny       KeyDataType = 0xFFFF
)

type PtrSource

type PtrSource interface {
	Pointer() uintptr
}

PtrSource defines the interface of things that wrap a C struct. Pointer method should return the underlying pointer in uintptr format.

type TransformID

type TransformID struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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