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
- Variables
- func FindSignatureNode(n PtrSource) (types.Node, error)
- func XMLSecCryptoAppKeyCertLoad(key PtrSource, certFile string, format KeyDataFormat) error
- func XMLSecCryptoAppKeyLoad(file string, format KeyDataFormat) (uintptr, error)
- func XMLSecCryptoAppKeyLoadMemory(buf []byte, format KeyDataFormat) (uintptr, error)
- func XMLSecDSigCtxCreate(mngr PtrSource) (uintptr, error)
- func XMLSecDSigCtxDestroy(ctx PtrSource) error
- func XMLSecDSigCtxSetKey(ctx PtrSource, key PtrSource) error
- func XMLSecDSigCtxSignDocument(ctx PtrSource, doc types.Document) error
- func XMLSecDSigCtxSignNode(ctx PtrSource, n types.Node) error
- func XMLSecDSigCtxVerifyDocument(ctx PtrSource, doc types.Document) error
- func XMLSecDSigCtxVerifyNode(ctx PtrSource, n types.Node) error
- func XMLSecDSigCtxVerifyRaw(ctxptr *C.xmlSecDSigCtx, nodeptr *C.xmlNode) error
- func XMLSecInit() error
- func XMLSecKeyCreate() (uintptr, error)
- func XMLSecKeyDestroy(key PtrSource) error
- func XMLSecKeyDuplicate(key PtrSource) (uintptr, error)
- func XMLSecKeyHasDsaKey(key PtrSource) error
- func XMLSecKeyHasEcdsaKey(key PtrSource) error
- func XMLSecKeyHasRsaKey(key PtrSource) error
- func XMLSecKeyHasX509(key PtrSource) error
- func XMLSecKeysMngrAdoptKey(mngr, key PtrSource) error
- func XMLSecKeysMngrCertLoadMemory(mngr PtrSource, buf []byte, format KeyDataFormat, typ KeyDataType) error
- func XMLSecKeysMngrCreate() (uintptr, error)
- func XMLSecKeysMngrDestroy(mngr PtrSource) error
- func XMLSecKeysMngrGetKey(mngr PtrSource, n PtrSource) (uintptr, error)
- func XMLSecShutdown() error
- func XMLSecTmplKeyInfoAddKeyValue(n types.Node) (types.Node, error)
- func XMLSecTmplKeyInfoAddX509Data(n types.Node) (types.Node, error)
- func XMLSecTmplReferenceAddTransform(n types.Node, transformID TransformID) (types.Node, error)
- func XMLSecTmplSignatureAddReference(signode types.Node, digestMethod TransformID, id, uri, nodeType string) (types.Node, error)
- func XMLSecTmplSignatureCreateNsPref(doc types.Document, c14nMethod TransformID, signMethod TransformID, id string, ...) (types.Node, error)
- func XMLSecTmplSignatureEnsureKeyInfo(n types.Node, id string) (types.Node, error)
- type KeyDataFormat
- type KeyDataType
- type PtrSource
- type TransformID
Constants ¶
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 )
const ( DSigNs = "http://www.w3.org/2000/09/xmldsig#" Prefix = "ds" SignatureNode = "Signature" )
Variables ¶
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 */} Gost2012_256 = TransformID{/* contains filtered or unexported fields */} Gost2012_512 = TransformID{/* contains filtered or unexported fields */} )
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 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 ¶
XMLSecDSigCtxCreate calls xmlSecDSigCtxCreate with a nil parameter and returns a pointer to the new struct
func XMLSecDSigCtxDestroy ¶
XMLSecDSigCtxDestroy calls xmlSecDSigCtxDestroy on the underlying C pointer, if available.
func XMLSecDSigCtxSetKey ¶
XMLSecDSigCtxtSetKey sets the C pointer for key to the signKey slot of the C pointer for ctx.
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 XMLSecKeyDestroy ¶
func XMLSecKeyDuplicate ¶
func XMLSecKeyHasDsaKey ¶
func XMLSecKeyHasEcdsaKey ¶
func XMLSecKeyHasRsaKey ¶
func XMLSecKeyHasX509 ¶
func XMLSecKeysMngrAdoptKey ¶
func XMLSecKeysMngrCertLoadMemory ¶
func XMLSecKeysMngrCertLoadMemory(mngr PtrSource, buf []byte, format KeyDataFormat, typ KeyDataType) error
func XMLSecKeysMngrCreate ¶
Calls xmlSecKeysMngrCreate, then initializes using xmlSecCryptoAppDefaultKeysMngrInit
func XMLSecKeysMngrDestroy ¶
func XMLSecShutdown ¶
func XMLSecShutdown() error
XMLSecShutdown cleans up xmlsec by calling the various shutdown functions.
func XMLSecTmplSignatureCreateNsPref ¶
func XMLSecTmplSignatureCreateNsPref(doc types.Document, c14nMethod TransformID, signMethod TransformID, id string, prefix 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
}