# XML Encryption
[OMXMLSecurity]

## Functions
AXIS2_EXTERN axis2_status_t | oxs_xml_enc_encrypt_node (const axutil_env_t *env, oxs_ctx_t *enc_ctx, axiom_node_t *node, axiom_node_t **enc_type_node, axiom_node_t *key_reference_node)
AXIS2_EXTERN axis2_status_t | oxs_xml_enc_decrypt_node (const axutil_env_t *env, oxs_ctx_t *enc_ctx, axiom_node_t *enc_type_node, axiom_node_t **decrypted_node)
AXIS2_EXTERN axis2_status_t | oxs_xml_enc_encrypt_data (const axutil_env_t *env, oxs_ctx_t *enc_ctx, oxs_buffer_t *content_buf, axiom_node_t **enc_type_node, axiom_node_t *key_reference_node)
AXIS2_EXTERN axis2_status_t | oxs_xml_enc_decrypt_data (const axutil_env_t *env, oxs_ctx_t *enc_ctx, axiom_node_t *enc_type_node, oxs_buffer_t *result_buf)
AXIS2_EXTERN axis2_status_t | oxs_xml_enc_encrypt_key (const axutil_env_t *env, oxs_asym_ctx_t *asym_ctx, axiom_node_t *parent, oxs_key_t *sym_key, axutil_array_list_t *id_list)
AXIS2_EXTERN axis2_status_t | oxs_xml_enc_decrypt_key (const axutil_env_t *env, oxs_asym_ctx_t *asym_ctx, axiom_node_t *parent, axiom_node_t *encrypted_key_node, oxs_key_t *key)

## Function Documentation

AXIS2_EXTERN axis2_status_t oxs_xml_enc_decrypt_data | ( | const axutil_env_t * | env,
|  | oxs_ctx_t * | enc_ctx,
|  | axiom_node_t * | enc_type_node,
|  | oxs_buffer_t * | result_buf |
| ) |  |  |

Decrypts and places the data inside the The name of the method is bit tricky as it doesn't exactly decrypts a data buffer.

Parameters:

  | env | pointer to environment struct
  | enc_ctx | encryption context
  | enc_type_node | the EncryptedData node which needs to be decrypted
  | result_buf | the buffer to keep the decrypted content

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE

AXIS2_EXTERN axis2_status_t oxs_xml_enc_decrypt_key | ( | const axutil_env_t * | env,
|  | oxs_asym_ctx_t * | asym_ctx,
|  | axiom_node_t * | parent,
|  | axiom_node_t * | encrypted_key_node,
|  | oxs_key_t * | key |
| ) |  |  |

Decrypts a key/data in asymmetric way as specified in . This method is specifically written to support the key decryption in WS-Secruity

Parameters:

  | env | pointer to environment struct
  | enc_ctx | encryption context
  | parent | parent of the EncryptedKey node
  | encrypted_key_node | the EncryptedKey node
  | key,the | key which holds the decrypted key data

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE

AXIS2_EXTERN axis2_status_t oxs_xml_enc_decrypt_node | ( | const axutil_env_t * | env,
|  | oxs_ctx_t * | enc_ctx,
|  | axiom_node_t * | enc_type_node,
|  | axiom_node_t ** | decrypted_node |
| ) |  |  |

Decrypts a node as specified in the . A reference is taken to assign the address of the decrypted node

Parameters:

  | env | pointer to environment struct
  | enc_ctx | encryption context
  | enc_type_node | the EncryptedData node which needs to be decrypted
  | decrypted_node | reference to the decrypted node

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE

AXIS2_EXTERN axis2_status_t oxs_xml_enc_encrypt_data | ( | const axutil_env_t * | env,
|  | oxs_ctx_t * | enc_ctx,
|  | oxs_buffer_t * | content_buf,
|  | axiom_node_t ** | enc_type_node,
|  | axiom_node_t * | key_reference_node |
| ) |  |  |

Encrypts data or the content of the as specified in the . A reference is taken for the EncryptedData to place the encrypted data

Parameters:

  | env | pointer to environment struct
  | enc_ctx | encryption context
  | content_buf | the content to be encrypted.
  | enc_type_node | reference to the EncryptedData node
  | key_reference_node | key reference provided by STS generated tokens.

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE

AXIS2_EXTERN axis2_status_t oxs_xml_enc_encrypt_key | ( | const axutil_env_t * | env,
|  | oxs_asym_ctx_t * | asym_ctx,
|  | axiom_node_t * | parent,
|  | oxs_key_t * | sym_key,
|  | axutil_array_list_t * | id_list |
| ) |  |  |

Encrypts a key/data in asymmetric way as specified in . This method is specifically written to support the key encryption in WS-Secruity

Parameters:

  | env | pointer to environment struct
  | enc_ctx | encryption context
  | parent | parent of the EncryptedKey node
  | sym_key,the | symmetric key that needs to be encrypted
  | id_list | the list of nodes that are encrypted by this particular key

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE

AXIS2_EXTERN axis2_status_t oxs_xml_enc_encrypt_node | ( | const axutil_env_t * | env,
|  | oxs_ctx_t * | enc_ctx,
|  | axiom_node_t * | node,
|  | axiom_node_t ** | enc_type_node,
|  | axiom_node_t * | key_reference_node |
| ) |  |  |

Encrypts a given node as specified in the . A reference is taken for the EncryptedData to place the encrypted data.

Parameters:

  | env | pointer to environment struct
  | enc_ctx | encryption context
  | node | the node tobe encrypted
  | enc_type_node | reference to the EncryptedData node
  | key_reference_node | key reference provided by STS generated tokens.

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE