xmlenc.h

Name

xmlenc.h -- The XML Encrypiton standard implementation.

Synopsis



struct      xmlSecEncCtx;
xmlSecEncCtxPtr xmlSecEncCtxCreate          (xmlSecKeysMngrPtr keysMngr);
void        xmlSecEncCtxDestroy             (xmlSecEncCtxPtr ctx);
int         xmlSecEncryptMemory             (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             unsigned char *buf,
                                             size_t size,
                                             xmlSecEncResultPtr *result);
int         xmlSecEncryptUri                (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             const char *uri,
                                             xmlSecEncResultPtr *result);
int         xmlSecEncryptXmlNode            (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             xmlNodePtr src,
                                             xmlSecEncResultPtr *result);
int         xmlSecDecrypt                   (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             xmlSecEncResultPtr *result);
struct      xmlSecEncResult;
xmlSecEncResultPtr xmlSecEncResultCreate    (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             int encrypt,
                                             xmlNodePtr node);
void        xmlSecEncResultDestroy          (xmlSecEncResultPtr result);
void        xmlSecEncResultDebugDump        (xmlSecEncResultPtr result,
                                             FILE *output);
xmlNodePtr  xmlSecEncDataCreate             (const xmlChar *id,
                                             const xmlChar *type,
                                             const xmlChar *mimeType,
                                             const xmlChar *encoding);
void        xmlSecEncDataDestroy            (xmlNodePtr encNode);
xmlNodePtr  xmlSecEncDataAddEncMethod       (xmlNodePtr encNode,
                                             xmlSecTransformId encMethod);
xmlNodePtr  xmlSecEncDataAddKeyInfo         (xmlNodePtr encNode);
xmlNodePtr  xmlSecEncDataAddEncProperties   (xmlNodePtr encNode,
                                             const xmlChar *id);
xmlNodePtr  xmlSecEncDataAddEncProperty     (xmlNodePtr encNode,
                                             const xmlChar *id,
                                             const xmlChar *target);
xmlNodePtr  xmlSecEncDataAddCipherValue     (xmlNodePtr encNode);
xmlNodePtr  xmlSecEncDataAddCipherReference (xmlNodePtr encNode,
                                             const xmlChar *uri);
xmlNodePtr  xmlSecCipherReferenceAddTransform
                                            (xmlNodePtr encNode,
                                             xmlSecTransformId transform);

Description

Details

struct xmlSecEncCtx

struct xmlSecEncCtx {
    xmlSecKeysMngrPtr		keysMngr;
    xmlSecTransformId		encryptionMethod;
    int				ignoreType;
    time_t			certsVerificationTime;
};

XML Encrypiton context.

xmlSecKeysMngrPtr keysMngr the pointer to keys manager xmlSecKeysMngr.
xmlSecTransformId encryptionMethod the default encryption algorithm id.
int ignoreType the flag to ignore Type attribute in the <enc:EncryptedData> node
time_t certsVerificationTime 


xmlSecEncCtxCreate ()

xmlSecEncCtxPtr xmlSecEncCtxCreate          (xmlSecKeysMngrPtr keysMngr);

Creates new encryption context.

keysMngr : the pointer to xmlSecKeysMngr structure.
Returns :newly allocated xmlSecEncCtx structure or NULL if an error occurs.


xmlSecEncCtxDestroy ()

void        xmlSecEncCtxDestroy             (xmlSecEncCtxPtr ctx);

Destroys the xmlSecEncCtx structure.

ctx : the pointer to xmlSecEncCtx structure.


xmlSecEncryptMemory ()

int         xmlSecEncryptMemory             (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             unsigned char *buf,
                                             size_t size,
                                             xmlSecEncResultPtr *result);

Encrypts binary data from the buf according to the template in the <enc:EncryptionData> node. After the encrytion the result XML is in the encNode node.

ctx : the pointer to xmlSecEncCtx structure.
context : the pointer to application specific data that will be passed to all callback functions.
key : the key to use (if NULL then the key specified in <dsig:KeyInfo> will be used).
encNode : the pointer to encryption template (<enc:EncryptionData> node).
buf : the pointer to data to encrypt.
size : the size of the data in buf.
result : the pointer where to store encryption results.
Returns :0 on success or a negative value otherwise.


xmlSecEncryptUri ()

int         xmlSecEncryptUri                (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             const char *uri,
                                             xmlSecEncResultPtr *result);

Encrypts binary data from the uri according to the template in the <enc:EncryptionData> node. After the encrytion the result XML is in the encNode node.

ctx : the pointer to xmlSecEncCtx structure.
context : the pointer to application specific data that will be passed to all callback functions.
key : the key to use (if NULL then the key specified in <dsig:KeyInfo> will be used).
encNode : the pointer to encryption template (<enc:EncryptionData> node).
uri : the URI to data to encrypt.
result : the pointer where to store encryption results.
Returns :0 on success or a negative value otherwise.


xmlSecEncryptXmlNode ()

int         xmlSecEncryptXmlNode            (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             xmlNodePtr src,
                                             xmlSecEncResultPtr *result);

Encrypts XML data from the encNode according to the template in the <enc:EncryptionData> node. After the encrytion the result XML is in the src node.

ctx : the pointer to xmlSecEncCtx structure.
context : the pointer to application specific data that will be passed to all callback functions.
key : the key to use (if NULL then the key specified in <dsig:KeyInfo> will be used).
encNode : the pointer to encryption template (<enc:EncryptionData> node).
src : the pointer to XML node to encrypt.
result : the pointer where to store encryption results.
Returns :0 on success or a negative value otherwise.


xmlSecDecrypt ()

int         xmlSecDecrypt                   (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             xmlSecKeyPtr key,
                                             xmlNodePtr encNode,
                                             xmlSecEncResultPtr *result);

Decrypts data from the <enc:EncryptionData> node.

ctx : the pointer to xmlSecEncCtx structure.
context : the pointer to application specific data that will be passed to all callback functions.
key : the key to use (if NULL then the key specified in <dsig:KeyInfo> will be used).
encNode : the pointer to encryption template (<enc:EncryptionData> node).
result : the pointer where to store encryption results.
Returns :0 on success or a negative value otherwise.


struct xmlSecEncResult

struct xmlSecEncResult {
    xmlSecEncCtxPtr		ctx;
    void			*context;
    xmlNodePtr			self;
    int				encrypt;
    xmlChar			*id;
    xmlChar			*type;
    xmlChar			*mimeType;
    xmlChar			*encoding;
    xmlSecTransformId		encryptionMethod;
    xmlSecKeyPtr		key;
    xmlBufferPtr		buffer;
    int				replaced;
};

The XML Encrypiton results.

xmlSecEncCtxPtr ctx the pointer to xmlSecEncCtx structure.
void *context the pointer to application specific data.
xmlNodePtr self the pointer to <enc:EncryptedData> node.
int encrypt the encrypt/decrypt flag.
xmlChar *id the Id attribute of the <enc:EncryptedData> node.
xmlChar *type the Type attribute of the <enc:EncryptedData> node.
xmlChar *mimeType the MimeType attribute of the <enc:EncryptedData> node.
xmlChar *encoding the Encoding attribute of the <enc:EncryptedData> node.
xmlSecTransformId encryptionMethod the used encryption algorithm id.
xmlSecKeyPtr key the used encryption key.
xmlBufferPtr buffer the decrypted data.
int replaced if set then the decrypted data were put back into the original document.


xmlSecEncResultCreate ()

xmlSecEncResultPtr xmlSecEncResultCreate    (xmlSecEncCtxPtr ctx,
                                             void *context,
                                             int encrypt,
                                             xmlNodePtr node);

Creates new xmlSecEncResult structure.

ctx : the pointer to xmlSecEncCtx structure.
context : the pointer to application specific data that will be passed to all callback functions.
encrypt : the encrypt/decrypt flag.
node : the pointer to <enc:EncryptedData> node.
Returns :newly created xmlSecEncResult structure or NULL if an error occurs.


xmlSecEncResultDestroy ()

void        xmlSecEncResultDestroy          (xmlSecEncResultPtr result);

Destroys xmlSecEncResult structure result.

result : the pointer to xmlSecEncResult structure.


xmlSecEncResultDebugDump ()

void        xmlSecEncResultDebugDump        (xmlSecEncResultPtr result,
                                             FILE *output);

Prints the xmlSecEncResult structure result to file output.

result : the pointer to xmlSecEncResult structure.
output : the pointer to destination FILE.


xmlSecEncDataCreate ()

xmlNodePtr  xmlSecEncDataCreate             (const xmlChar *id,
                                             const xmlChar *type,
                                             const xmlChar *mimeType,
                                             const xmlChar *encoding);

Creates new <enc:EncryptedData> node for encryption template.

id : the Id attribute (optional).
type : the Type attribute (optional)
mimeType : the MimeType attribute (optional)
encoding : the Encoding attribute (optional)
Returns :the pointer newly created <enc:EncryptedData> node or NULL if an error occurs.


xmlSecEncDataDestroy ()

void        xmlSecEncDataDestroy            (xmlNodePtr encNode);

Destroys the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.


xmlSecEncDataAddEncMethod ()

xmlNodePtr  xmlSecEncDataAddEncMethod       (xmlNodePtr encNode,
                                             xmlSecTransformId encMethod);

Adds <enc:EncryptionMethod> node with specified encryption algorithm (encMethodId) to the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.
encMethod : the encryption method id.
Returns :the pointer to newly created <enc:EncryptionMethod> node or NULL if an error occurs.


xmlSecEncDataAddKeyInfo ()

xmlNodePtr  xmlSecEncDataAddKeyInfo         (xmlNodePtr encNode);

Adds <dsig:KeyInfo> to the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.
Returns :the pointer to newly created <dsig:KeyInfo> node or NULL if an error occurs.


xmlSecEncDataAddEncProperties ()

xmlNodePtr  xmlSecEncDataAddEncProperties   (xmlNodePtr encNode,
                                             const xmlChar *id);

Adds <enc:EncryptionProperties> node to the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.
id : the Id attribute (optional).
Returns :the pointer to newly created <enc:EncryptionProperties> node or NULL if an error occurs.


xmlSecEncDataAddEncProperty ()

xmlNodePtr  xmlSecEncDataAddEncProperty     (xmlNodePtr encNode,
                                             const xmlChar *id,
                                             const xmlChar *target);

Adds <enc:EncryptionProperty> node (and the parent <enc:EncryptionProperties> node if required) to the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.
id : the Id attribute (optional).
target : the Target attribute (optional).
Returns :the pointer to newly created <enc:EncryptionProperty> node or NULL if an error occurs.


xmlSecEncDataAddCipherValue ()

xmlNodePtr  xmlSecEncDataAddCipherValue     (xmlNodePtr encNode);

Adds <enc:CipherValue> to the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.
Returns :the pointer to newly created <enc:CipherValue> node or NULL if an error occurs.


xmlSecEncDataAddCipherReference ()

xmlNodePtr  xmlSecEncDataAddCipherReference (xmlNodePtr encNode,
                                             const xmlChar *uri);

Adds <enc:CipherReference> node with specified URI attribute uri to the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.
uri : the URI attribute (may be NULL).
Returns :the pointer to newly created <enc:CipherReference> node or NULL if an error occurs.


xmlSecCipherReferenceAddTransform ()

xmlNodePtr  xmlSecCipherReferenceAddTransform
                                            (xmlNodePtr encNode,
                                             xmlSecTransformId transform);

Adds <dsig:Transform> node (and the parent <dsig:Transforms> node) with specified transform methods transform to the <enc:CipherReference> child node of the <enc:EncryptedData> node encNode.

encNode : the pointer to <enc:EncryptedData> node.
transform : the transform id.
Returns :the pointer to newly created <dsig:Transform> node or NULL if an error occurs.