\hypertarget{session__cipher_8h}{}\section{src/session\+\_\+cipher.h File Reference}
\label{session__cipher_8h}\index{src/session\+\_\+cipher.\+h@{src/session\+\_\+cipher.\+h}}
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$stddef.\+h$>$}\newline
{\ttfamily \#include \char`\"{}signal\+\_\+protocol\+\_\+types.\+h\char`\"{}}\newline
Include dependency graph for session\+\_\+cipher.\+h\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=297pt]{session__cipher_8h__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{session__cipher_8h_a48e09bee3587f661ffca3d4ac37970fa}{session\+\_\+cipher\+\_\+create} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$$\ast$cipher, \hyperlink{signal__protocol__types_8h_a407899f11766a172ae880601b8c3b4df}{signal\+\_\+protocol\+\_\+store\+\_\+context} $\ast$store, const \hyperlink{structsignal__protocol__address}{signal\+\_\+protocol\+\_\+address} $\ast$remote\+\_\+address, \hyperlink{structsignal__context}{signal\+\_\+context} $\ast$global\+\_\+context)
\item 
void \hyperlink{session__cipher_8h_a42efdf09c7a13dcda38150cbcb391c27}{session\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, void $\ast$user\+\_\+data)
\item 
void $\ast$ \hyperlink{session__cipher_8h_a46c2619915b3e5fddba2a7f356ded3c7}{session\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher)
\item 
void \hyperlink{session__cipher_8h_a63ebc446a79b016e9a46df795bd1c42d}{session\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, int($\ast$callback)(\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, \hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$plaintext, void $\ast$decrypt\+\_\+context))
\item 
int \hyperlink{session__cipher_8h_a6ae0c5876ea846029b26617f0a4e9ec1}{session\+\_\+cipher\+\_\+encrypt} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, const \hyperlink{uthash_8h_aba7bc1797add20fe3efdf37ced1182c5}{uint8\+\_\+t} $\ast$padded\+\_\+message, size\+\_\+t padded\+\_\+message\+\_\+len, \hyperlink{signal__protocol__types_8h_abd86bf8290e33b6f12e5b7122085aab0}{ciphertext\+\_\+message} $\ast$$\ast$encrypted\+\_\+message)
\item 
int \hyperlink{session__cipher_8h_a66c405d5099d2f07c48d377f597c2b1f}{session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, \hyperlink{signal__protocol__types_8h_a8469b9f45a4e727fb35f36a053f0ffe5}{pre\+\_\+key\+\_\+signal\+\_\+message} $\ast$ciphertext, void $\ast$decrypt\+\_\+context, \hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$$\ast$plaintext)
\item 
int \hyperlink{session__cipher_8h_a235909f9fabf5fc3124cdded94b62ba9}{session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, \hyperlink{signal__protocol__types_8h_a99a243404a335c930047b749c75fc75a}{signal\+\_\+message} $\ast$ciphertext, void $\ast$decrypt\+\_\+context, \hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$$\ast$plaintext)
\item 
int \hyperlink{session__cipher_8h_a72c80dbcb452e6fb4f8db2243529d512}{session\+\_\+cipher\+\_\+get\+\_\+remote\+\_\+registration\+\_\+id} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, \hyperlink{uthash_8h_a435d1572bf3f880d55459d9805097f62}{uint32\+\_\+t} $\ast$remote\+\_\+id)
\item 
int \hyperlink{session__cipher_8h_a88c1a7e03a0ac03dec817d53e7adc97b}{session\+\_\+cipher\+\_\+get\+\_\+session\+\_\+version} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, \hyperlink{uthash_8h_a435d1572bf3f880d55459d9805097f62}{uint32\+\_\+t} $\ast$version)
\item 
void \hyperlink{session__cipher_8h_ac25e6b707eeccd2fb4e4639c8c9e2b31}{session\+\_\+cipher\+\_\+free} (\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher)
\end{DoxyCompactItemize}


\subsection{Function Documentation}
\mbox{\Hypertarget{session__cipher_8h_a48e09bee3587f661ffca3d4ac37970fa}\label{session__cipher_8h_a48e09bee3587f661ffca3d4ac37970fa}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+create@{session\+\_\+cipher\+\_\+create}}
\index{session\+\_\+cipher\+\_\+create@{session\+\_\+cipher\+\_\+create}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+create()}{session\_cipher\_create()}}
{\footnotesize\ttfamily int session\+\_\+cipher\+\_\+create (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$$\ast$}]{cipher,  }\item[{\hyperlink{signal__protocol__types_8h_a407899f11766a172ae880601b8c3b4df}{signal\+\_\+protocol\+\_\+store\+\_\+context} $\ast$}]{store,  }\item[{const \hyperlink{structsignal__protocol__address}{signal\+\_\+protocol\+\_\+address} $\ast$}]{remote\+\_\+address,  }\item[{\hyperlink{structsignal__context}{signal\+\_\+context} $\ast$}]{global\+\_\+context }\end{DoxyParamCaption})}

The main entry point for Signal Protocol encrypt/decrypt operations.

Once a session has been established with session\+\_\+builder, this class can be used for all encrypt/decrypt operations within that session. Construct a session cipher for encrypt/decrypt operations on a session. In order to use session\+\_\+cipher, a session must have already been created and stored using session\+\_\+builder.

The store and global contexts must remain valid for the lifetime of the session cipher.

When finished, free the returned instance by calling \hyperlink{session__cipher_8h_ac25e6b707eeccd2fb4e4639c8c9e2b31}{session\+\_\+cipher\+\_\+free()}.


\begin{DoxyParams}{Parameters}
{\em cipher} & set to a freshly allocated session cipher instance \\
\hline
{\em store} & the signal\+\_\+protocol\+\_\+store\+\_\+context to store all state information in \\
\hline
{\em remote\+\_\+address} & the remote address that messages will be encrypted to or decrypted from. \\
\hline
{\em global\+\_\+context} & the global library context \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, or negative on failure 
\end{DoxyReturn}
\mbox{\Hypertarget{session__cipher_8h_a66c405d5099d2f07c48d377f597c2b1f}\label{session__cipher_8h_a66c405d5099d2f07c48d377f597c2b1f}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message@{session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message}}
\index{session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message@{session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message()}{session\_cipher\_decrypt\_pre\_key\_signal\_message()}}
{\footnotesize\ttfamily int session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher,  }\item[{\hyperlink{signal__protocol__types_8h_a8469b9f45a4e727fb35f36a053f0ffe5}{pre\+\_\+key\+\_\+signal\+\_\+message} $\ast$}]{ciphertext,  }\item[{void $\ast$}]{decrypt\+\_\+context,  }\item[{\hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$$\ast$}]{plaintext }\end{DoxyParamCaption})}

Decrypt a message.


\begin{DoxyParams}{Parameters}
{\em ciphertext} & The pre\+\_\+key\+\_\+signal\+\_\+message to decrypt. \\
\hline
{\em decrypt\+\_\+context} & Optional context pointer associated with the ciphertext, which is passed to the decryption callback function \\
\hline
{\em plaintext} & Set to a newly allocated buffer containing the plaintext.\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em S\+G\+\_\+\+S\+U\+C\+C\+E\+SS} & Success \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+M\+E\+S\+S\+A\+GE} & if the input is not valid ciphertext. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+D\+U\+P\+L\+I\+C\+A\+T\+E\+\_\+\+M\+E\+S\+S\+A\+GE} & if the input is a message that has already been received. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+L\+E\+G\+A\+C\+Y\+\_\+\+M\+E\+S\+S\+A\+GE} & if the input is a message formatted by a protocol version that is no longer supported. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+K\+E\+Y\+\_\+\+ID} & when there is no local pre\+\_\+key\+\_\+record that corresponds to the pre key ID in the message. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+K\+EY} & when the message is formatted incorrectly. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+U\+N\+T\+R\+U\+S\+T\+E\+D\+\_\+\+I\+D\+E\+N\+T\+I\+TY} & when the identity key of the sender is untrusted. \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{session__cipher_8h_a235909f9fabf5fc3124cdded94b62ba9}\label{session__cipher_8h_a235909f9fabf5fc3124cdded94b62ba9}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message@{session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message}}
\index{session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message@{session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message()}{session\_cipher\_decrypt\_signal\_message()}}
{\footnotesize\ttfamily int session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher,  }\item[{\hyperlink{signal__protocol__types_8h_a99a243404a335c930047b749c75fc75a}{signal\+\_\+message} $\ast$}]{ciphertext,  }\item[{void $\ast$}]{decrypt\+\_\+context,  }\item[{\hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$$\ast$}]{plaintext }\end{DoxyParamCaption})}

Decrypt a message.


\begin{DoxyParams}{Parameters}
{\em ciphertext} & The signal\+\_\+message to decrypt. \\
\hline
{\em decrypt\+\_\+context} & Optional context pointer associated with the ciphertext, which is passed to the decryption callback function \\
\hline
{\em plaintext} & Set to a newly allocated buffer containing the plaintext.\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em S\+G\+\_\+\+S\+U\+C\+C\+E\+SS} & Success \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+M\+E\+S\+S\+A\+GE} & if the input is not valid ciphertext. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+D\+U\+P\+L\+I\+C\+A\+T\+E\+\_\+\+M\+E\+S\+S\+A\+GE} & if the input is a message that has already been received. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+L\+E\+G\+A\+C\+Y\+\_\+\+M\+E\+S\+S\+A\+GE} & if the input is a message formatted by a protocol version that is no longer supported. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+N\+O\+\_\+\+S\+E\+S\+S\+I\+ON} & if there is no established session for this contact. \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{session__cipher_8h_a6ae0c5876ea846029b26617f0a4e9ec1}\label{session__cipher_8h_a6ae0c5876ea846029b26617f0a4e9ec1}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+encrypt@{session\+\_\+cipher\+\_\+encrypt}}
\index{session\+\_\+cipher\+\_\+encrypt@{session\+\_\+cipher\+\_\+encrypt}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+encrypt()}{session\_cipher\_encrypt()}}
{\footnotesize\ttfamily int session\+\_\+cipher\+\_\+encrypt (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher,  }\item[{const \hyperlink{uthash_8h_aba7bc1797add20fe3efdf37ced1182c5}{uint8\+\_\+t} $\ast$}]{padded\+\_\+message,  }\item[{size\+\_\+t}]{padded\+\_\+message\+\_\+len,  }\item[{\hyperlink{signal__protocol__types_8h_abd86bf8290e33b6f12e5b7122085aab0}{ciphertext\+\_\+message} $\ast$$\ast$}]{encrypted\+\_\+message }\end{DoxyParamCaption})}

Encrypt a message.


\begin{DoxyParams}{Parameters}
{\em padded\+\_\+message} & The plaintext message bytes, optionally padded to a constant multiple. \\
\hline
{\em padded\+\_\+message\+\_\+len} & The length of the data pointed to by padded\+\_\+message \\
\hline
{\em encrypted\+\_\+message} & Set to a ciphertext message encrypted to the recipient+device tuple.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
S\+G\+\_\+\+S\+U\+C\+C\+E\+SS on success, negative on error 
\end{DoxyReturn}
\mbox{\Hypertarget{session__cipher_8h_ac25e6b707eeccd2fb4e4639c8c9e2b31}\label{session__cipher_8h_ac25e6b707eeccd2fb4e4639c8c9e2b31}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+free@{session\+\_\+cipher\+\_\+free}}
\index{session\+\_\+cipher\+\_\+free@{session\+\_\+cipher\+\_\+free}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+free()}{session\_cipher\_free()}}
{\footnotesize\ttfamily void session\+\_\+cipher\+\_\+free (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher }\end{DoxyParamCaption})}

\mbox{\Hypertarget{session__cipher_8h_a72c80dbcb452e6fb4f8db2243529d512}\label{session__cipher_8h_a72c80dbcb452e6fb4f8db2243529d512}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+get\+\_\+remote\+\_\+registration\+\_\+id@{session\+\_\+cipher\+\_\+get\+\_\+remote\+\_\+registration\+\_\+id}}
\index{session\+\_\+cipher\+\_\+get\+\_\+remote\+\_\+registration\+\_\+id@{session\+\_\+cipher\+\_\+get\+\_\+remote\+\_\+registration\+\_\+id}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+get\+\_\+remote\+\_\+registration\+\_\+id()}{session\_cipher\_get\_remote\_registration\_id()}}
{\footnotesize\ttfamily int session\+\_\+cipher\+\_\+get\+\_\+remote\+\_\+registration\+\_\+id (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher,  }\item[{\hyperlink{uthash_8h_a435d1572bf3f880d55459d9805097f62}{uint32\+\_\+t} $\ast$}]{remote\+\_\+id }\end{DoxyParamCaption})}

Gets the remote registration ID for this session cipher.


\begin{DoxyParams}{Parameters}
{\em remote\+\_\+id} & Set to the value of the remote registration ID\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
S\+G\+\_\+\+S\+U\+C\+C\+E\+SS on success, negative on error 
\end{DoxyReturn}
\mbox{\Hypertarget{session__cipher_8h_a88c1a7e03a0ac03dec817d53e7adc97b}\label{session__cipher_8h_a88c1a7e03a0ac03dec817d53e7adc97b}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+get\+\_\+session\+\_\+version@{session\+\_\+cipher\+\_\+get\+\_\+session\+\_\+version}}
\index{session\+\_\+cipher\+\_\+get\+\_\+session\+\_\+version@{session\+\_\+cipher\+\_\+get\+\_\+session\+\_\+version}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+get\+\_\+session\+\_\+version()}{session\_cipher\_get\_session\_version()}}
{\footnotesize\ttfamily int session\+\_\+cipher\+\_\+get\+\_\+session\+\_\+version (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher,  }\item[{\hyperlink{uthash_8h_a435d1572bf3f880d55459d9805097f62}{uint32\+\_\+t} $\ast$}]{version }\end{DoxyParamCaption})}

Gets the version of the session associated with this session cipher.


\begin{DoxyParams}{Parameters}
{\em version} & Set to the value of the session version\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em S\+G\+\_\+\+S\+U\+C\+C\+E\+SS} & Success \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+N\+O\+\_\+\+S\+E\+S\+S\+I\+ON} & if no session could be found \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{session__cipher_8h_a46c2619915b3e5fddba2a7f356ded3c7}\label{session__cipher_8h_a46c2619915b3e5fddba2a7f356ded3c7}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data@{session\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data}}
\index{session\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data@{session\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data()}{session\_cipher\_get\_user\_data()}}
{\footnotesize\ttfamily void$\ast$ session\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher }\end{DoxyParamCaption})}

Get the optional user data pointer for the session cipher.

This is to give callback functions a way of accessing app specific context information for this cipher. \mbox{\Hypertarget{session__cipher_8h_a63ebc446a79b016e9a46df795bd1c42d}\label{session__cipher_8h_a63ebc446a79b016e9a46df795bd1c42d}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback@{session\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback}}
\index{session\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback@{session\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback()}{session\_cipher\_set\_decryption\_callback()}}
{\footnotesize\ttfamily void session\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher,  }\item[{int($\ast$)(\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$cipher, \hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$plaintext, void $\ast$decrypt\+\_\+context)}]{callback }\end{DoxyParamCaption})}

Set the callback function that is called during the decrypt process.

The callback function is called from within \hyperlink{session__cipher_8h_a66c405d5099d2f07c48d377f597c2b1f}{session\+\_\+cipher\+\_\+decrypt\+\_\+pre\+\_\+key\+\_\+signal\+\_\+message()} and \hyperlink{session__cipher_8h_a235909f9fabf5fc3124cdded94b62ba9}{session\+\_\+cipher\+\_\+decrypt\+\_\+signal\+\_\+message()} after decryption is complete but before the updated session state has been committed to the session store. If the callback function returns a negative value, then the decrypt function will immediately fail with an error.

This a callback allows some implementations to store the committed plaintext to their local message store first, in case they are concerned with a crash or write error happening between the time the session state is updated but before they\textquotesingle{}re able to successfully store the plaintext to disk.


\begin{DoxyParams}{Parameters}
{\em callback} & the callback function to set \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{session__cipher_8h_a42efdf09c7a13dcda38150cbcb391c27}\label{session__cipher_8h_a42efdf09c7a13dcda38150cbcb391c27}} 
\index{session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}!session\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data@{session\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data}}
\index{session\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data@{session\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data}!session\+\_\+cipher.\+h@{session\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{session\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data()}{session\_cipher\_set\_user\_data()}}
{\footnotesize\ttfamily void session\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a4a208c3e8a59fe1c41527b757e52f8b5}{session\+\_\+cipher} $\ast$}]{cipher,  }\item[{void $\ast$}]{user\+\_\+data }\end{DoxyParamCaption})}

Set the optional user data pointer for the session cipher.

This is to give callback functions a way of accessing app specific context information for this cipher. 