<refentry id="xmlsec-ciphers">
<refmeta>
<refentrytitle>ciphers.h</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>XMLSEC Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>ciphers.h</refname><refpurpose>The ciphers transform.</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>
<synopsis>



struct      <link linkend="xmlSecCipherTransform">xmlSecCipherTransform</link>;
typedef     <link linkend="xmlSecCipherTransformId">xmlSecCipherTransformId</link>;
int         (<link linkend="xmlSecCipherUpdateMethod">*xmlSecCipherUpdateMethod</link>)     (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> transform,
                                             unsigned char *buffer,
                                             <link linkend="size-t">size_t</link> size);
int         (<link linkend="xmlSecCipherFinalMethod">*xmlSecCipherFinalMethod</link>)      (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> transform);
int         <link linkend="xmlSecCipherTransformRead">xmlSecCipherTransformRead</link>       (<link linkend="xmlSecBinTransformPtr">xmlSecBinTransformPtr</link> transform,
                                             unsigned char *buf,
                                             <link linkend="size-t">size_t</link> size);
int         <link linkend="xmlSecCipherTransformWrite">xmlSecCipherTransformWrite</link>      (<link linkend="xmlSecBinTransformPtr">xmlSecBinTransformPtr</link> transform,
                                             unsigned char *buf,
                                             <link linkend="size-t">size_t</link> size);
int         <link linkend="xmlSecCipherTransformFlush">xmlSecCipherTransformFlush</link>      (<link linkend="xmlSecBinTransformPtr">xmlSecBinTransformPtr</link> transform);
int         <link linkend="xmlSecEvpCipherUpdate">xmlSecEvpCipherUpdate</link>           (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> cipher,
                                             unsigned char *buffer,
                                             <link linkend="size-t">size_t</link> size);
int         <link linkend="xmlSecEvpCipherFinal">xmlSecEvpCipherFinal</link>            (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> cipher);
int         <link linkend="xmlSecCipherUpdate">xmlSecCipherUpdate</link>              (<link linkend="xmlSecTransformPtr">xmlSecTransformPtr</link> transform,
                                             unsigned char *buffer,
                                             <link linkend="size-t">size_t</link> size);
int         <link linkend="xmlSecCipherFinal">xmlSecCipherFinal</link>               (<link linkend="xmlSecTransformPtr">xmlSecTransformPtr</link> transform);
</synopsis>
</refsynopsisdiv>





<refsect1>
<title>Description</title>
<para>

</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="xmlSecCipherTransform">struct xmlSecCipherTransform</title>
<programlisting>struct xmlSecCipherTransform {	
    /* same as for xmlSecTransform but id type changed */
    xmlSecCipherTransformId		id;    
    xmlSecTransformStatus		status;
    int					dontDestroy;
    void				*data;
    
    /* xmlSecBinTransform specific */
    int					encode;
    xmlSecCipherTransformPtr		next;
    xmlSecCipherTransformPtr		prev;   
    void				*binData;
    
    /* xmlSecCipherTransform specific */
    unsigned char			*bufIn;
    unsigned char			*bufOut;
    EVP_CIPHER_CTX 			cipherCtx;
    unsigned char			*iv;
    size_t				ivPos;
    void				*cipherData;
};
</programlisting>
<para>
The cipher (encrypt/decrypt) transform.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="struct">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row>
<entry><link linkend="xmlSecCipherTransformId">xmlSecCipherTransformId</link> <structfield>id</structfield></entry>
<entry> the transform id (pointer to <link linkend="xmlSecBinTransformId">xmlSecBinTransformId</link>).
</entry>
</row>
<row>
<entry><link linkend="xmlSecTransformStatus">xmlSecTransformStatus</link> <structfield>status</structfield></entry>
<entry> the transform status (ok/fail/unknown).
</entry>
</row>
<row>
<entry>int <structfield>dontDestroy</structfield></entry>
<entry> the don't automatically destroy flag.
</entry>
</row>
<row>
<entry>void *<structfield>data</structfield></entry>
<entry> the pointer to transform specific data.
</entry>
</row>
<row>
<entry>int <structfield>encode</structfield></entry>
<entry> encode/decode (encrypt/decrypt) flag.
</entry>
</row>
<row>
<entry><link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> <structfield>next</structfield></entry>
<entry> next binary transform in the chain.
</entry>
</row>
<row>
<entry><link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> <structfield>prev</structfield></entry>
<entry> previous binary transform in the chain.
</entry>
</row>
<row>
<entry>void *<structfield>binData</structfield></entry>
<entry> the pointer to binary transform speific data.
</entry>
</row>
<row>
<entry>unsigned char *<structfield>bufIn</structfield></entry>
<entry> the pointer to input buffer.
</entry>
</row>
<row>
<entry>unsigned char *<structfield>bufOut</structfield></entry>
<entry> the pointer to output buffer.
</entry>
</row>
<row>
<entry><link linkend="EVP-CIPHER-CTX-CAPS">EVP_CIPHER_CTX</link> <structfield>cipherCtx</structfield></entry>
<entry> the EVP chiper context.
</entry>
</row>
<row>
<entry>unsigned char *<structfield>iv</structfield></entry>
<entry> the pointer to IV.
</entry>
</row>
<row>
<entry><link linkend="size-t">size_t</link> <structfield>ivPos</structfield></entry>
<entry>the position in IV (what was written out).
</entry>
</row>
<row>
<entry>void *<structfield>cipherData</structfield></entry>
<entry> the chipher specific data.
</entry>
</row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherTransformId">xmlSecCipherTransformId</title>
<programlisting>typedef const struct _xmlSecCipherTransformIdStruct	*xmlSecCipherTransformId;
</programlisting>
<para>
The cipher (encrypt/decrypt) transform id.</para>
<para>

</para></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherUpdateMethod">xmlSecCipherUpdateMethod ()</title>
<programlisting>int         (*xmlSecCipherUpdateMethod)     (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> transform,
                                             unsigned char *buffer,
                                             <link linkend="size-t">size_t</link> size);</programlisting>
<para>
Encrypts/decrypts new chunk of data.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>transform</parameter>&nbsp;:</entry>
<entry> the pointer to cipher transform.
</entry></row>
<row><entry align="right"><parameter>buffer</parameter>&nbsp;:</entry>
<entry> the pointer to data.
</entry></row>
<row><entry align="right"><parameter>size</parameter>&nbsp;:</entry>
<entry> the data size.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>0 on success or a negative value otherwise.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherFinalMethod">xmlSecCipherFinalMethod ()</title>
<programlisting>int         (*xmlSecCipherFinalMethod)      (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> transform);</programlisting>
<para>
Finalizes encryption/decryption.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>transform</parameter>&nbsp;:</entry>
<entry> the pointer to cipher transform.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>0 on success or a negative value otherwise.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherTransformRead">xmlSecCipherTransformRead ()</title>
<programlisting>int         xmlSecCipherTransformRead       (<link linkend="xmlSecBinTransformPtr">xmlSecBinTransformPtr</link> transform,
                                             unsigned char *buf,
                                             <link linkend="size-t">size_t</link> size);</programlisting>
<para>
Reads data from previous transform, encrypts or decrypts them 
and returns in the output buffer.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>transform</parameter>&nbsp;:</entry>
<entry> the pointer to a cipher transform.
</entry></row>
<row><entry align="right"><parameter>buf</parameter>&nbsp;:</entry>
<entry> the output buffer.
</entry></row>
<row><entry align="right"><parameter>size</parameter>&nbsp;:</entry>
<entry> tje output buffer size.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of bytes in the buffer or negative value
if an error occurs.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherTransformWrite">xmlSecCipherTransformWrite ()</title>
<programlisting>int         xmlSecCipherTransformWrite      (<link linkend="xmlSecBinTransformPtr">xmlSecBinTransformPtr</link> transform,
                                             unsigned char *buf,
                                             <link linkend="size-t">size_t</link> size);</programlisting>
<para>
Encrypts or decrypts the input data and writes them 
to the next transform.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>transform</parameter>&nbsp;:</entry>
<entry> the poiter to a cipher transform.
</entry></row>
<row><entry align="right"><parameter>buf</parameter>&nbsp;:</entry>
<entry> the input data buffer.
</entry></row>
<row><entry align="right"><parameter>size</parameter>&nbsp;:</entry>
<entry> the input data size.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>0 if success or a negative value otherwise.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherTransformFlush">xmlSecCipherTransformFlush ()</title>
<programlisting>int         xmlSecCipherTransformFlush      (<link linkend="xmlSecBinTransformPtr">xmlSecBinTransformPtr</link> transform);</programlisting>
<para>
Writes the rest of data to previous transform.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>transform</parameter>&nbsp;:</entry>
<entry> the pointer to a cipher transform.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>0 if success or negative value otherwise.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecEvpCipherUpdate">xmlSecEvpCipherUpdate ()</title>
<programlisting>int         xmlSecEvpCipherUpdate           (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> cipher,
                                             unsigned char *buffer,
                                             <link linkend="size-t">size_t</link> size);</programlisting>
<para>
Encrypts/decrypts new piece of data.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>cipher</parameter>&nbsp;:</entry>
<entry> the pointer to EVP_* cipher transform. 
</entry></row>
<row><entry align="right"><parameter>buffer</parameter>&nbsp;:</entry>
<entry> the input buffer.
</entry></row>
<row><entry align="right"><parameter>size</parameter>&nbsp;:</entry>
<entry> the input buffer size.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of bytes processed or a negative value
if an error occurs.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecEvpCipherFinal">xmlSecEvpCipherFinal ()</title>
<programlisting>int         xmlSecEvpCipherFinal            (<link linkend="xmlSecCipherTransformPtr">xmlSecCipherTransformPtr</link> cipher);</programlisting>
<para>
Finalize encryption/decryption.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>cipher</parameter>&nbsp;:</entry>
<entry> the pointer to EVP_* cipher transform. 
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of bytes processed or a negative value
if an error occurs.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherUpdate">xmlSecCipherUpdate ()</title>
<programlisting>int         xmlSecCipherUpdate              (<link linkend="xmlSecTransformPtr">xmlSecTransformPtr</link> transform,
                                             unsigned char *buffer,
                                             <link linkend="size-t">size_t</link> size);</programlisting>
<para>
Encrypts/decrypts new piece of data.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>transform</parameter>&nbsp;:</entry>
<entry> the pointer to cipher transform. 
</entry></row>
<row><entry align="right"><parameter>buffer</parameter>&nbsp;:</entry>
<entry> the input buffer.
</entry></row>
<row><entry align="right"><parameter>size</parameter>&nbsp;:</entry>
<entry> the input buffer size.
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of bytes processed or a negative value
if an error occurs.
</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="xmlSecCipherFinal">xmlSecCipherFinal ()</title>
<programlisting>int         xmlSecCipherFinal               (<link linkend="xmlSecTransformPtr">xmlSecTransformPtr</link> transform);</programlisting>
<para>
Finalize encryption/decryption.</para>
<para>

</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>transform</parameter>&nbsp;:</entry>
<entry> the pointer to cipher transform. 
</entry></row>
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry>the number of bytes processed or a negative value
if an error occurs.
</entry></row>
</tbody></tgroup></informaltable></refsect2>

</refsect1>




</refentry>
