Details
XMLSEC_TRANSFORM_BINARY_CHUNK
#define XMLSEC_TRANSFORM_BINARY_CHUNK 64
The binary data chunks size. XMLSec processes binary data one chunk
at a time. Changing this impacts xmlsec memory usage and performance.
xmlSecTransformIdsGet ()
xmlSecPtrListPtr xmlSecTransformIdsGet (void);
Gets global registered transform klasses list.
| Returns : |
the pointer to list of all registered transform klasses. |
xmlSecTransformIdsInit ()
int xmlSecTransformIdsInit (void);
Initializes the transform klasses. This function is called from the
xmlSecInit function and the application should not call it directly.
| Returns : |
0 on success or a negative value if an error occurs. |
xmlSecTransformIdsShutdown ()
void xmlSecTransformIdsShutdown (void);
Shuts down the keys data klasses. This function is called from the
xmlSecShutdown function and the application should not call it directly.
xmlSecTransformIdsRegisterDefault ()
int xmlSecTransformIdsRegisterDefault
(void);
Registers default (implemented by XML Security Library)
transform klasses: XPath transform, Base64 transform, ...
| Returns : |
0 on success or a negative value if an error occurs. |
xmlSecTransformIdsRegister ()
int xmlSecTransformIdsRegister (xmlSecTransformId id);
Registers id in the global list of transform klasses.
| id: |
the transform klass. |
| Returns : |
0 on success or a negative value if an error occurs. |
enum xmlSecTransformStatus
typedef enum {
xmlSecTransformStatusNone = 0,
xmlSecTransformStatusWorking,
xmlSecTransformStatusFinished,
xmlSecTransformStatusOk,
xmlSecTransformStatusFail
} xmlSecTransformStatus;
The transform execution status.
enum xmlSecTransformMode
typedef enum {
xmlSecTransformModeNone = 0,
xmlSecTransformModePush,
xmlSecTransformModePop
} xmlSecTransformMode;
The transform operation mode
enum xmlSecTransformOperation
typedef enum {
xmlSecTransformOperationNone = 0,
xmlSecTransformOperationEncode,
xmlSecTransformOperationDecode,
xmlSecTransformOperationSign,
xmlSecTransformOperationVerify,
xmlSecTransformOperationEncrypt,
xmlSecTransformOperationDecrypt
} xmlSecTransformOperation;
The transform operation.
xmlSecTransformUriType
typedef unsigned int xmlSecTransformUriType;
URI transform type bit mask.
xmlSecTransformUriTypeNone
#define xmlSecTransformUriTypeNone 0x0000
The URI type is unknown or not set.
xmlSecTransformUriTypeEmpty
#define xmlSecTransformUriTypeEmpty 0x0001
The empty URI ("") type.
xmlSecTransformUriTypeSameDocument
#define xmlSecTransformUriTypeSameDocument 0x0002
The smae document ("#...") but not empty ("") URI type.
xmlSecTransformUriTypeLocal
#define xmlSecTransformUriTypeLocal 0x0004
The local URI ("file:///....") type.
xmlSecTransformUriTypeRemote
#define xmlSecTransformUriTypeRemote 0x0008
The remote URI type.
xmlSecTransformUriTypeAny
#define xmlSecTransformUriTypeAny 0xFFFF
Any URI type.
xmlSecTransformUriTypeCheck ()
int xmlSecTransformUriTypeCheck (xmlSecTransformUriType type,
const xmlChar *uri);
Checks if uri matches expected type type.
| type: |
the expected URI type. |
| uri: |
the uri for checking. |
| Returns : |
1 if uri matches type, 0 if not or a negative value
if an error occurs. |
xmlSecTransformDataType
typedef xmlSecByte xmlSecTransformDataType;
Transform data type bit mask.
xmlSecTransformDataTypeUnknown
#define xmlSecTransformDataTypeUnknown 0x0000
The transform data type is unknown or nor data expected.
xmlSecTransformDataTypeBin
#define xmlSecTransformDataTypeBin 0x0001
The binary transform data.
xmlSecTransformDataTypeXml
#define xmlSecTransformDataTypeXml 0x0002
The xml transform data.
xmlSecTransformUsage
typedef unsigned int xmlSecTransformUsage;
The transform usage bit mask.
xmlSecTransformUsageUnknown
#define xmlSecTransformUsageUnknown 0x0000
Transforms usage is unknown or undefined.
xmlSecTransformUsageDSigTransform
#define xmlSecTransformUsageDSigTransform 0x0001
Transform could be used in <dsig:Transform>.
xmlSecTransformUsageC14NMethod
#define xmlSecTransformUsageC14NMethod 0x0002
Transform could be used in <dsig:CanonicalizationMethod>.
xmlSecTransformUsageDigestMethod
#define xmlSecTransformUsageDigestMethod 0x0004
Transform could be used in <dsig:DigestMethod>.
xmlSecTransformUsageSignatureMethod
#define xmlSecTransformUsageSignatureMethod 0x0008
Transform could be used in <dsig:SignatureMethod>.
xmlSecTransformUsageEncryptionMethod
#define xmlSecTransformUsageEncryptionMethod 0x0010
Transform could be used in <enc:EncryptionMethod>.
xmlSecTransformUsageAny
#define xmlSecTransformUsageAny 0xFFFF
Transform could be used for operation.
xmlSecTransformCtxPreExecuteCallback ()
int (*xmlSecTransformCtxPreExecuteCallback)
(xmlSecTransformCtxPtr transformCtx);
The callback called after creating transforms chain but before
starting data processing. Application can use this callback to
do additional transforms chain verification or modification and
aborting transforms execution (if necessary).
| transformCtx: |
the pointer to transform's context. |
| Returns : |
0 on success and a negative value otherwise (in this case,
transforms chain will not be executed and xmlsec processing stops). |
XMLSEC_TRANSFORMCTX_FLAGS_USE_VISA3D_HACK
#define XMLSEC_TRANSFORMCTX_FLAGS_USE_VISA3D_HACK 0x00000001
If this flag is set then URI ID references are resolved directly
without using XPointers. This allows one to sign/verify Visa3D
documents that don't follow XML, XPointer and XML DSig specifications.
struct xmlSecTransformCtx
struct xmlSecTransformCtx {
/* user settings */
void* userData;
unsigned int flags;
unsigned int flags2;
xmlSecTransformUriType enabledUris;
xmlSecPtrList enabledTransforms;
xmlSecTransformCtxPreExecuteCallback preExecCallback;
/* results */
xmlSecBufferPtr result;
xmlSecTransformStatus status;
xmlChar* uri;
xmlChar* xptrExpr;
xmlSecTransformPtr first;
xmlSecTransformPtr last;
/* for the future */
void* reserved0;
void* reserved1;
};
The transform execution context.
xmlSecTransformCtxCreate ()
xmlSecTransformCtxPtr xmlSecTransformCtxCreate
(void);
Creates transforms chain processing context.
The caller is responsible for destroying returend object by calling
xmlSecTransformCtxDestroy function.
| Returns : |
pointer to newly allocated context object or NULL if an error
occurs. |
xmlSecTransformCtxInitialize ()
int xmlSecTransformCtxInitialize (xmlSecTransformCtxPtr ctx);
Initializes transforms chain processing context.
The caller is responsible for cleaing up returend object by calling
xmlSecTransformCtxFinalize function.
| ctx: |
the pointer to transforms chain processing context. |
| Returns : |
0 on success or a negative value if an error occurs. |
xmlSecTransformCtxReset ()
void xmlSecTransformCtxReset (xmlSecTransformCtxPtr ctx);
Resets transfroms context for new processing.
| ctx: |
the pointer to transforms chain processing context. |
xmlSecTransformCtxCopyUserPref ()
int xmlSecTransformCtxCopyUserPref (xmlSecTransformCtxPtr dst,
xmlSecTransformCtxPtr src);
Copies user settings from src context to dst.
| dst: |
the pointer to destination transforms chain processing context. |
| src: |
the pointer to source transforms chain processing context. |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformCtxSetUri ()
int xmlSecTransformCtxSetUri (xmlSecTransformCtxPtr ctx,
const xmlChar *uri,
xmlNodePtr hereNode);
Parses uri and adds xpointer transforms if required.
The following examples demonstrate what the URI attribute identifies and
how it is dereferenced
(http://www.w3.org/TR/xmldsig-core/sec-ReferenceProcessingModel):
- URI="http://example.com/bar.xml"
identifies the octets that represent the external resource
'http://example.com/bar.xml', that is probably an XML document given
its file extension.
- URI="http://example.com/bar.xmlchapter1"
identifies the element with ID attribute value 'chapter1' of the
external XML resource 'http://example.com/bar.xml', provided as an
octet stream. Again, for the sake of interoperability, the element
identified as 'chapter1' should be obtained using an XPath transform
rather than a URI fragment (barename XPointer resolution in external
resources is not REQUIRED in this specification).
- URI=""
identifies the node-set (minus any comment nodes) of the XML resource
containing the signature
- URI="chapter1"
identifies a node-set containing the element with ID attribute value
'chapter1' of the XML resource containing the signature. XML Signature
(and its applications) modify this node-set to include the element plus
all descendents including namespaces and attributes -- but not comments.
| ctx: |
the pointer to transforms chain processing context. |
| uri: |
the URI. |
| hereNode: |
the pointer to "here" node required by some
XML transforms (may be NULL). |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformCtxCreateAndAppend ()
xmlSecTransformPtr xmlSecTransformCtxCreateAndAppend
(xmlSecTransformCtxPtr ctx,
xmlSecTransformId id);
Creaeates new transform and connects it to the end of the chain of
transforms in the ctx (see xmlSecTransformConnect function for details).
| ctx: |
the pointer to transforms chain processing context. |
| id: |
the new transform klass. |
| Returns : |
pointer to newly created transform or NULL if an error occurs. |
xmlSecTransformCtxCreateAndPrepend ()
xmlSecTransformPtr xmlSecTransformCtxCreateAndPrepend
(xmlSecTransformCtxPtr ctx,
xmlSecTransformId id);
Creaeates new transform and connects it to the end of the chain of
transforms in the ctx (see xmlSecTransformConnect function for details).
| ctx: |
the pointer to transforms chain processing context. |
| id: |
the new transform klass. |
| Returns : |
pointer to newly created transform or NULL if an error occurs. |
xmlSecTransformCtxNodeRead ()
xmlSecTransformPtr xmlSecTransformCtxNodeRead
(xmlSecTransformCtxPtr ctx,
xmlNodePtr node,
xmlSecTransformUsage usage);
Reads the transform from the node and appends it to the current chain
of transforms in ctx.
| ctx: |
the pointer to transforms chain processing context. |
| node: |
the pointer to transform's node. |
| usage: |
the transform's usage (signature, encryption, etc.). |
| Returns : |
pointer to newly created transform or NULL if an error occurs. |
xmlSecTransformCtxNodesListRead ()
int xmlSecTransformCtxNodesListRead (xmlSecTransformCtxPtr ctx,
xmlNodePtr node,
xmlSecTransformUsage usage);
Reads transforms from the <dsig:Transform/> children of the node and
appends them to the current transforms chain in ctx object.
| ctx: |
the pointer to transforms chain processing context. |
| node: |
the pointer to <dsig:Transform/> nodes parent node. |
| usage: |
the transform's usage (signature, encryption, etc.). |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformCtxBinaryExecute ()
int xmlSecTransformCtxBinaryExecute (xmlSecTransformCtxPtr ctx,
const xmlSecByte *data,
xmlSecSize dataSize);
Processes binary data using transforms chain in the ctx.
| ctx: |
the pointer to transforms chain processing context. |
| data: |
the input binary data buffer. |
| dataSize: |
the input data size. |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformCtxUriExecute ()
int xmlSecTransformCtxUriExecute (xmlSecTransformCtxPtr ctx,
const xmlChar *uri);
Process binary data from the URI using transforms chain in ctx.
| ctx: |
the pointer to transforms chain processing context. |
| uri: |
the URI. |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformCtxXmlExecute ()
int xmlSecTransformCtxXmlExecute (xmlSecTransformCtxPtr ctx,
xmlSecNodeSetPtr nodes);
Process nodes using transforms in the transforms chain in ctx.
| ctx: |
the pointer to transforms chain processing context. |
| nodes: |
the input node set. |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformCtxExecute ()
int xmlSecTransformCtxExecute (xmlSecTransformCtxPtr ctx,
xmlDocPtr doc);
Executes transforms chain in ctx.
| ctx: |
the pointer to transforms chain processing context. |
| doc: |
the pointer to input document. |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformCtxDebugDump ()
void xmlSecTransformCtxDebugDump (xmlSecTransformCtxPtr ctx,
FILE *output);
Prints transforms context debug information to output.
| ctx: |
the pointer to transforms chain processing context. |
| output: |
the pointer to output FILE. |
xmlSecTransformCtxDebugXmlDump ()
void xmlSecTransformCtxDebugXmlDump (xmlSecTransformCtxPtr ctx,
FILE *output);
Prints transforms context debug information to output in XML format.
| ctx: |
the pointer to transforms chain processing context. |
| output: |
the pointer to output FILE. |
struct xmlSecTransform
struct xmlSecTransform {
xmlSecTransformId id;
xmlSecTransformOperation operation;
xmlSecTransformStatus status;
xmlNodePtr hereNode;
/* transforms chain */
xmlSecTransformPtr next;
xmlSecTransformPtr prev;
/* binary data */
xmlSecBuffer inBuf;
xmlSecBuffer outBuf;
/* xml data */
xmlSecNodeSetPtr inNodes;
xmlSecNodeSetPtr outNodes;
/* reserved for the future */
void* reserved0;
void* reserved1;
};
The transform structure.
xmlSecTransformCreate ()
xmlSecTransformPtr xmlSecTransformCreate (xmlSecTransformId id);
Creates new transform of the id klass. The caller is responsible for
destroying returned tansform using xmlSecTransformDestroy function.
| id: |
the transform id to create. |
| Returns : |
pointer to newly created transform or NULL if an error occurs. |
xmlSecTransformNodeRead ()
xmlSecTransformPtr xmlSecTransformNodeRead (xmlNodePtr node,
xmlSecTransformUsage usage,
xmlSecTransformCtxPtr transformCtx);
Reads transform from the node as follows:
1) reads "Algorithm" attribute;
2) checks the lists of known and allowed transforms;
3) calls transform's create method;
4) calls transform's read transform node method.
| node: |
the pointer to the transform's node. |
| usage: |
the transform usage (signature, encryption, ...). |
| transformCtx: |
the transform's chaing processing context. |
| Returns : |
pointer to newly created transform or NULL if an error occurs. |
xmlSecTransformSetKeyReq ()
int xmlSecTransformSetKeyReq (xmlSecTransformPtr transform,
xmlSecKeyReqPtr keyReq);
Sets the key requirements for transform in the keyReq.
| transform: |
the pointer to transform. |
| keyReq: |
the pointer to keys requirements object. |
| Returns : |
0 on success or a negative value otherwise. |
xmlSecTransformExecute ()
int xmlSecTransformExecute (xmlSecTransformPtr transform,
int last,
xmlSecTransformCtxPtr transformCtx);
Executes transform (used by default popBin/pushBin/popXml/pushXml methods).
| transform: |
the pointer to transform. |
| last: |
the flag: if set to 1 then it's the last data chunk. |
| transformCtx: |
the transform's chaing processing context. |
| Returns : |
0 on success or a negative value if an error occurs. |
xmlSecTransformDebugDump ()
void xmlSecTransformDebugDump (xmlSecTransformPtr transform,
FILE *output);
Prints transform's debug information to output.
xmlSecTransformDebugXmlDump ()
void xmlSecTransformDebugXmlDump (xmlSecTransformPtr transform,
FILE *output);
Prints transform's debug information to output in XML format.
xmlSecTransformGetName()
#define xmlSecTransformGetName(transform)
Macro. Returns transform name.
xmlSecTransformIsValid()
#define xmlSecTransformIsValid(transform)
Macro. Returns 1 if the transform is valid or 0 otherwise.
xmlSecTransformCheckType()
#define xmlSecTransformCheckType(transform, t)
Macro. Returns 1 if the transform is valid and has specified type t
or 0 otherwise.
xmlSecTransformCheckId()
#define xmlSecTransformCheckId(transform, i)
Macro. Returns 1 if the transform is valid and has specified id i
or 0 otherwise.
xmlSecTransformCheckSize()
#define xmlSecTransformCheckSize(transform, size)
Macro. Returns 1 if the transform is valid and has at least size
bytes or 0 otherwise.
xmlSecTransformConnect ()
int xmlSecTransformConnect (xmlSecTransformPtr left,
xmlSecTransformPtr right,
xmlSecTransformCtxPtr transformCtx);
If the data object is a node-set and the next transform requires octets,
the signature application MUST attempt to convert the node-set to an octet
stream using Canonical XML [XML-C14N].
The story is different if the right transform is base64 decode
(http://www.w3.org/TR/xmldsig-core/sec-Base-64):
This transform requires an octet stream for input. If an XPath node-set
(or sufficiently functional alternative) is given as input, then it is
converted to an octet stream by performing operations logically equivalent
to 1) applying an XPath transform with expression self::text(), then 2)
taking the string-value of the node-set. Thus, if an XML element is
identified by a barename XPointer in the Reference URI, and its content
consists solely of base64 encoded character data, then this transform
automatically strips away the start and end tags of the identified element
and any of its descendant elements as well as any descendant comments and
processing instructions. The output of this transform is an octet stream.
| left: |
the pointer to left (prev) transform. |
| right: |
the pointer to right (next) transform. |
| transformCtx: |
the transform's chaing processing context. |
| Returns : |
0 on success or a negative value if an error occurs. |
xmlSecTransformRemove ()
void xmlSecTransformRemove (xmlSecTransformPtr transform);
Removes transform from the chain.
xmlSecTransformDefaultPushBin ()
int xmlSecTransformDefaultPushBin (xmlSecTransformPtr transform,