\hypertarget{group__cipher_8h}{}\section{src/group\+\_\+cipher.h File Reference}
\label{group__cipher_8h}\index{src/group\+\_\+cipher.\+h@{src/group\+\_\+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 group\+\_\+cipher.\+h\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=292pt]{group__cipher_8h__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{group__cipher_8h_add3993e968b67025bf8cf8aaa95983a8}{group\+\_\+cipher\+\_\+create} (\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$$\ast$cipher, \hyperlink{signal__protocol__types_8h_a407899f11766a172ae880601b8c3b4df}{signal\+\_\+protocol\+\_\+store\+\_\+context} $\ast$store, const \hyperlink{structsignal__protocol__sender__key__name}{signal\+\_\+protocol\+\_\+sender\+\_\+key\+\_\+name} $\ast$sender\+\_\+key\+\_\+id, \hyperlink{structsignal__context}{signal\+\_\+context} $\ast$global\+\_\+context)
\item 
void \hyperlink{group__cipher_8h_afc616e97cf5e8419eaa52c3a1951ce59}{group\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data} (\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$cipher, void $\ast$user\+\_\+data)
\item 
void $\ast$ \hyperlink{group__cipher_8h_a5647849b977db272fc886d62e5cd8693}{group\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data} (\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$cipher)
\item 
void \hyperlink{group__cipher_8h_aaf21e7bec1ecccb7e80742c28cb0137a}{group\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback} (\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$cipher, int($\ast$callback)(\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$cipher, \hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$plaintext, void $\ast$decrypt\+\_\+context))
\item 
int \hyperlink{group__cipher_8h_ad7e4870693179a01e59636369d307265}{group\+\_\+cipher\+\_\+encrypt} (\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$cipher, const \hyperlink{uthash_8h_aba7bc1797add20fe3efdf37ced1182c5}{uint8\+\_\+t} $\ast$padded\+\_\+plaintext, size\+\_\+t padded\+\_\+plaintext\+\_\+len, \hyperlink{signal__protocol__types_8h_abd86bf8290e33b6f12e5b7122085aab0}{ciphertext\+\_\+message} $\ast$$\ast$encrypted\+\_\+message)
\item 
int \hyperlink{group__cipher_8h_a72273719dc6e306536665e86d046c500}{group\+\_\+cipher\+\_\+decrypt} (\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$cipher, \hyperlink{signal__protocol__types_8h_a46b224236473e63e6ed6788d4a2e820c}{sender\+\_\+key\+\_\+message} $\ast$ciphertext, void $\ast$decrypt\+\_\+context, \hyperlink{structsignal__buffer}{signal\+\_\+buffer} $\ast$$\ast$plaintext)
\item 
void \hyperlink{group__cipher_8h_a466b7e78fb0b2e23b0e47a87e2a20b20}{group\+\_\+cipher\+\_\+free} (\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$cipher)
\end{DoxyCompactItemize}


\subsection{Function Documentation}
\mbox{\Hypertarget{group__cipher_8h_add3993e968b67025bf8cf8aaa95983a8}\label{group__cipher_8h_add3993e968b67025bf8cf8aaa95983a8}} 
\index{group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}!group\+\_\+cipher\+\_\+create@{group\+\_\+cipher\+\_\+create}}
\index{group\+\_\+cipher\+\_\+create@{group\+\_\+cipher\+\_\+create}!group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{group\+\_\+cipher\+\_\+create()}{group\_cipher\_create()}}
{\footnotesize\ttfamily int group\+\_\+cipher\+\_\+create (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$$\ast$}]{cipher,  }\item[{\hyperlink{signal__protocol__types_8h_a407899f11766a172ae880601b8c3b4df}{signal\+\_\+protocol\+\_\+store\+\_\+context} $\ast$}]{store,  }\item[{const \hyperlink{structsignal__protocol__sender__key__name}{signal\+\_\+protocol\+\_\+sender\+\_\+key\+\_\+name} $\ast$}]{sender\+\_\+key\+\_\+id,  }\item[{\hyperlink{structsignal__context}{signal\+\_\+context} $\ast$}]{global\+\_\+context }\end{DoxyParamCaption})}

Construct a group cipher for encrypt/decrypt operations.

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

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


\begin{DoxyParams}{Parameters}
{\em cipher} & set to a freshly allocated group cipher instance \\
\hline
{\em store} & the signal\+\_\+protocol\+\_\+store\+\_\+context to store all state information in \\
\hline
{\em sender\+\_\+key\+\_\+id} & the sender 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{group__cipher_8h_a72273719dc6e306536665e86d046c500}\label{group__cipher_8h_a72273719dc6e306536665e86d046c500}} 
\index{group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}!group\+\_\+cipher\+\_\+decrypt@{group\+\_\+cipher\+\_\+decrypt}}
\index{group\+\_\+cipher\+\_\+decrypt@{group\+\_\+cipher\+\_\+decrypt}!group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{group\+\_\+cipher\+\_\+decrypt()}{group\_cipher\_decrypt()}}
{\footnotesize\ttfamily int group\+\_\+cipher\+\_\+decrypt (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$}]{cipher,  }\item[{\hyperlink{signal__protocol__types_8h_a46b224236473e63e6ed6788d4a2e820c}{sender\+\_\+key\+\_\+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 sender\+\_\+key\+\_\+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{group__cipher_8h_ad7e4870693179a01e59636369d307265}\label{group__cipher_8h_ad7e4870693179a01e59636369d307265}} 
\index{group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}!group\+\_\+cipher\+\_\+encrypt@{group\+\_\+cipher\+\_\+encrypt}}
\index{group\+\_\+cipher\+\_\+encrypt@{group\+\_\+cipher\+\_\+encrypt}!group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{group\+\_\+cipher\+\_\+encrypt()}{group\_cipher\_encrypt()}}
{\footnotesize\ttfamily int group\+\_\+cipher\+\_\+encrypt (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$}]{cipher,  }\item[{const \hyperlink{uthash_8h_aba7bc1797add20fe3efdf37ced1182c5}{uint8\+\_\+t} $\ast$}]{padded\+\_\+plaintext,  }\item[{size\+\_\+t}]{padded\+\_\+plaintext\+\_\+len,  }\item[{\hyperlink{signal__protocol__types_8h_abd86bf8290e33b6f12e5b7122085aab0}{ciphertext\+\_\+message} $\ast$$\ast$}]{encrypted\+\_\+message }\end{DoxyParamCaption})}

Encrypt a message.


\begin{DoxyParams}{Parameters}
{\em padded\+\_\+plaintext} & The plaintext message bytes, optionally padded to a constant multiple. \\
\hline
{\em padded\+\_\+plaintext\+\_\+len} & The length of the data pointed to by padded\+\_\+message \\
\hline
{\em encrypted\+\_\+message} & Set to a ciphertext message encrypted to the group+sender+device tuple.\\
\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 there is no established session for this contact. \\
\hline
{\em S\+G\+\_\+\+E\+R\+R\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+K\+EY} & if there is no valid private key for this session. \\
\hline
\end{DoxyRetVals}
\mbox{\Hypertarget{group__cipher_8h_a466b7e78fb0b2e23b0e47a87e2a20b20}\label{group__cipher_8h_a466b7e78fb0b2e23b0e47a87e2a20b20}} 
\index{group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}!group\+\_\+cipher\+\_\+free@{group\+\_\+cipher\+\_\+free}}
\index{group\+\_\+cipher\+\_\+free@{group\+\_\+cipher\+\_\+free}!group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{group\+\_\+cipher\+\_\+free()}{group\_cipher\_free()}}
{\footnotesize\ttfamily void group\+\_\+cipher\+\_\+free (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$}]{cipher }\end{DoxyParamCaption})}

\mbox{\Hypertarget{group__cipher_8h_a5647849b977db272fc886d62e5cd8693}\label{group__cipher_8h_a5647849b977db272fc886d62e5cd8693}} 
\index{group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}!group\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data@{group\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data}}
\index{group\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data@{group\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data}!group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{group\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data()}{group\_cipher\_get\_user\_data()}}
{\footnotesize\ttfamily void$\ast$ group\+\_\+cipher\+\_\+get\+\_\+user\+\_\+data (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$}]{cipher }\end{DoxyParamCaption})}

Get the optional user data pointer for the group cipher.

This is to give callback functions a way of accessing app specific context information for this cipher. \mbox{\Hypertarget{group__cipher_8h_aaf21e7bec1ecccb7e80742c28cb0137a}\label{group__cipher_8h_aaf21e7bec1ecccb7e80742c28cb0137a}} 
\index{group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}!group\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback@{group\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback}}
\index{group\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback@{group\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback}!group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{group\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback()}{group\_cipher\_set\_decryption\_callback()}}
{\footnotesize\ttfamily void group\+\_\+cipher\+\_\+set\+\_\+decryption\+\_\+callback (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$}]{cipher,  }\item[{int($\ast$)(\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+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{group__cipher_8h_a72273719dc6e306536665e86d046c500}{group\+\_\+cipher\+\_\+decrypt()} 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{group__cipher_8h_afc616e97cf5e8419eaa52c3a1951ce59}\label{group__cipher_8h_afc616e97cf5e8419eaa52c3a1951ce59}} 
\index{group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}!group\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data@{group\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data}}
\index{group\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data@{group\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data}!group\+\_\+cipher.\+h@{group\+\_\+cipher.\+h}}
\subsubsection{\texorpdfstring{group\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data()}{group\_cipher\_set\_user\_data()}}
{\footnotesize\ttfamily void group\+\_\+cipher\+\_\+set\+\_\+user\+\_\+data (\begin{DoxyParamCaption}\item[{\hyperlink{signal__protocol__types_8h_a6a6aeba57ba54ccc371313e03e710c26}{group\+\_\+cipher} $\ast$}]{cipher,  }\item[{void $\ast$}]{user\+\_\+data }\end{DoxyParamCaption})}

Set the optional user data pointer for the group cipher.

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