\doxysubsection{checksum.\+h File Reference}
\label{checksum_8h}\index{checksum.h@{checksum.h}}


Abstract wrappers around different weaksum and strongsum implementations.  


Include dependency graph for checksum.\+h\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{checksum_8h__incl}
\end{center}
\end{figure}
This graph shows which files directly or indirectly include this file\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{checksum_8h__dep__incl}
\end{center}
\end{figure}
\doxysubsubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{structweaksum}{weaksum}}
\begin{DoxyCompactList}\small\item\em Abstract wrapper around weaksum implementations. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef struct \mbox{\hyperlink{structweaksum}{weaksum}} \mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}}
\begin{DoxyCompactList}\small\item\em Abstract wrapper around weaksum implementations. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \mbox{\hyperlink{checksum_8h_a523b170a7d10ae0b00117c2761abaf8d}{weaksum\+\_\+kind\+\_\+t}} \{ {\bfseries RS\+\_\+\+ROLLSUM}
, {\bfseries RS\+\_\+\+RABINKARP}
 \}
\begin{DoxyCompactList}\small\item\em Weaksum implementations. \end{DoxyCompactList}\item 
enum \mbox{\hyperlink{checksum_8h_a358cb59b26ba2585bc2094b4da2a547d}{strongsum\+\_\+kind\+\_\+t}} \{ {\bfseries RS\+\_\+\+MD4}
, {\bfseries RS\+\_\+\+BLAKE2}
 \}
\begin{DoxyCompactList}\small\item\em Strongsum implementations. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static void \mbox{\hyperlink{checksum_8h_a4762992b0d062f082bb9619addd6da14}{weaksum\+\_\+reset}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum)
\item 
static void \mbox{\hyperlink{checksum_8h_a12db55745b883b7e117fb8f5519629d1}{weaksum\+\_\+init}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum, \mbox{\hyperlink{checksum_8h_a523b170a7d10ae0b00117c2761abaf8d}{weaksum\+\_\+kind\+\_\+t}} kind)
\item 
static size\+\_\+t \mbox{\hyperlink{checksum_8h_af5389595b1190670688cf904673cccc6}{weaksum\+\_\+count}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum)
\item 
static void \mbox{\hyperlink{checksum_8h_a97ddaee8fc505579b3015b985451aacf}{weaksum\+\_\+update}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum, const unsigned char $\ast$buf, size\+\_\+t len)
\item 
static void \mbox{\hyperlink{checksum_8h_ac01962ceae6b783e7580d2d7ef506cd8}{weaksum\+\_\+rotate}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum, unsigned char out, unsigned char in)
\item 
static void \mbox{\hyperlink{checksum_8h_a9aa0eeb5126f69d6416619d2d37b7bd3}{weaksum\+\_\+rollin}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum, unsigned char in)
\item 
static void \mbox{\hyperlink{checksum_8h_a55999c35253afe799ce1c5210a04f892}{weaksum\+\_\+rollout}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum, unsigned char out)
\item 
static rs\+\_\+weak\+\_\+sum\+\_\+t \mbox{\hyperlink{checksum_8h_a73ed806f1b3e9d11621a30cfb4a4efea}{weaksum\+\_\+digest}} (\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$sum)
\item 
rs\+\_\+weak\+\_\+sum\+\_\+t \mbox{\hyperlink{checksum_8h_a25c2d070f333e27ee30831f05bc77c65}{rs\+\_\+calc\+\_\+weak\+\_\+sum}} (\mbox{\hyperlink{checksum_8h_a523b170a7d10ae0b00117c2761abaf8d}{weaksum\+\_\+kind\+\_\+t}} kind, void const $\ast$buf, size\+\_\+t len)
\begin{DoxyCompactList}\small\item\em Calculate a weaksum. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{checksum_8h_aca0ef7069e47972313f74f66d9c29298}{rs\+\_\+calc\+\_\+strong\+\_\+sum}} (\mbox{\hyperlink{checksum_8h_a358cb59b26ba2585bc2094b4da2a547d}{strongsum\+\_\+kind\+\_\+t}} kind, void const $\ast$buf, size\+\_\+t len, rs\+\_\+strong\+\_\+sum\+\_\+t $\ast$sum)
\begin{DoxyCompactList}\small\item\em Calculate a strongsum. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsubsection{Detailed Description}
Abstract wrappers around different weaksum and strongsum implementations. 



Definition in file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.



\doxysubsubsection{Typedef Documentation}
\mbox{\label{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}} 
\index{checksum.h@{checksum.h}!weaksum\_t@{weaksum\_t}}
\index{weaksum\_t@{weaksum\_t}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_t}{weaksum\_t}}
{\footnotesize\ttfamily typedef struct \mbox{\hyperlink{structweaksum}{weaksum}} \mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}}}



Abstract wrapper around weaksum implementations. 

This is a polymorphic interface to the different rollsum implementations.

Historically rollsum methods were implemented as static inline functions because they were small and needed to be fast. Now that we need to call different methods for different rollsum implementations, they are getting more complicated. Is it better to delegate calls to the right implementation using static inline switch statements, or stop inlining them and use virtual method pointers? Tests suggest inlined switch statements is faster. 

\doxysubsubsection{Enumeration Type Documentation}
\mbox{\label{checksum_8h_a523b170a7d10ae0b00117c2761abaf8d}} 
\index{checksum.h@{checksum.h}!weaksum\_kind\_t@{weaksum\_kind\_t}}
\index{weaksum\_kind\_t@{weaksum\_kind\_t}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_kind\_t}{weaksum\_kind\_t}}
{\footnotesize\ttfamily enum \mbox{\hyperlink{checksum_8h_a523b170a7d10ae0b00117c2761abaf8d}{weaksum\+\_\+kind\+\_\+t}}}



Weaksum implementations. 



Definition at line \mbox{\hyperlink{checksum_8h_source_l00035}{35}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_a358cb59b26ba2585bc2094b4da2a547d}} 
\index{checksum.h@{checksum.h}!strongsum\_kind\_t@{strongsum\_kind\_t}}
\index{strongsum\_kind\_t@{strongsum\_kind\_t}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{strongsum\_kind\_t}{strongsum\_kind\_t}}
{\footnotesize\ttfamily enum \mbox{\hyperlink{checksum_8h_a358cb59b26ba2585bc2094b4da2a547d}{strongsum\+\_\+kind\+\_\+t}}}



Strongsum implementations. 



Definition at line \mbox{\hyperlink{checksum_8h_source_l00041}{41}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.



\doxysubsubsection{Function Documentation}
\mbox{\label{checksum_8h_a4762992b0d062f082bb9619addd6da14}} 
\index{checksum.h@{checksum.h}!weaksum\_reset@{weaksum\_reset}}
\index{weaksum\_reset@{weaksum\_reset}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_reset()}{weaksum\_reset()}}
{\footnotesize\ttfamily static void weaksum\+\_\+reset (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00064}{64}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_a12db55745b883b7e117fb8f5519629d1}} 
\index{checksum.h@{checksum.h}!weaksum\_init@{weaksum\_init}}
\index{weaksum\_init@{weaksum\_init}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_init()}{weaksum\_init()}}
{\footnotesize\ttfamily static void weaksum\+\_\+init (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum,  }\item[{\mbox{\hyperlink{checksum_8h_a523b170a7d10ae0b00117c2761abaf8d}{weaksum\+\_\+kind\+\_\+t}}}]{kind }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00072}{72}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_af5389595b1190670688cf904673cccc6}} 
\index{checksum.h@{checksum.h}!weaksum\_count@{weaksum\_count}}
\index{weaksum\_count@{weaksum\_count}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_count()}{weaksum\_count()}}
{\footnotesize\ttfamily static size\+\_\+t weaksum\+\_\+count (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00079}{79}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_a97ddaee8fc505579b3015b985451aacf}} 
\index{checksum.h@{checksum.h}!weaksum\_update@{weaksum\_update}}
\index{weaksum\_update@{weaksum\_update}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_update()}{weaksum\_update()}}
{\footnotesize\ttfamily static void weaksum\+\_\+update (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum,  }\item[{const unsigned char $\ast$}]{buf,  }\item[{size\+\_\+t}]{len }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00085}{85}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_ac01962ceae6b783e7580d2d7ef506cd8}} 
\index{checksum.h@{checksum.h}!weaksum\_rotate@{weaksum\_rotate}}
\index{weaksum\_rotate@{weaksum\_rotate}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_rotate()}{weaksum\_rotate()}}
{\footnotesize\ttfamily static void weaksum\+\_\+rotate (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum,  }\item[{unsigned char}]{out,  }\item[{unsigned char}]{in }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00094}{94}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_a9aa0eeb5126f69d6416619d2d37b7bd3}} 
\index{checksum.h@{checksum.h}!weaksum\_rollin@{weaksum\_rollin}}
\index{weaksum\_rollin@{weaksum\_rollin}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_rollin()}{weaksum\_rollin()}}
{\footnotesize\ttfamily static void weaksum\+\_\+rollin (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum,  }\item[{unsigned char}]{in }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00103}{103}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_a55999c35253afe799ce1c5210a04f892}} 
\index{checksum.h@{checksum.h}!weaksum\_rollout@{weaksum\_rollout}}
\index{weaksum\_rollout@{weaksum\_rollout}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_rollout()}{weaksum\_rollout()}}
{\footnotesize\ttfamily static void weaksum\+\_\+rollout (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum,  }\item[{unsigned char}]{out }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00111}{111}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_a73ed806f1b3e9d11621a30cfb4a4efea}} 
\index{checksum.h@{checksum.h}!weaksum\_digest@{weaksum\_digest}}
\index{weaksum\_digest@{weaksum\_digest}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{weaksum\_digest()}{weaksum\_digest()}}
{\footnotesize\ttfamily static rs\+\_\+weak\+\_\+sum\+\_\+t weaksum\+\_\+digest (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a6a8a4dd89feaf9852455fb96bdca8aba}{weaksum\+\_\+t}} $\ast$}]{sum }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Definition at line \mbox{\hyperlink{checksum_8h_source_l00119}{119}} of file \mbox{\hyperlink{checksum_8h_source}{checksum.\+h}}.

\mbox{\label{checksum_8h_a25c2d070f333e27ee30831f05bc77c65}} 
\index{checksum.h@{checksum.h}!rs\_calc\_weak\_sum@{rs\_calc\_weak\_sum}}
\index{rs\_calc\_weak\_sum@{rs\_calc\_weak\_sum}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{rs\_calc\_weak\_sum()}{rs\_calc\_weak\_sum()}}
{\footnotesize\ttfamily rs\+\_\+weak\+\_\+sum\+\_\+t rs\+\_\+calc\+\_\+weak\+\_\+sum (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a523b170a7d10ae0b00117c2761abaf8d}{weaksum\+\_\+kind\+\_\+t}}}]{kind,  }\item[{void const $\ast$}]{buf,  }\item[{size\+\_\+t}]{len }\end{DoxyParamCaption})}



Calculate a weaksum. 

Note this does not apply \mbox{\hyperlink{hashtable_8h_ac1bb2e17d20ca0fc08ab9e02ecaa698f}{mix32()}} to rollsum digests, unlike weaksum\+\_\+digest(). This is because rollsums are stored raw without \mbox{\hyperlink{hashtable_8h_ac1bb2e17d20ca0fc08ab9e02ecaa698f}{mix32()}} applied for backwards-\/compatibility, but we apply \mbox{\hyperlink{hashtable_8h_ac1bb2e17d20ca0fc08ab9e02ecaa698f}{mix32()}} when adding them into a signature and when getting the digest for calculating deltas.

Calculate a weaksum. 

Definition at line \mbox{\hyperlink{checksum_8c_source_l00034}{34}} of file \mbox{\hyperlink{checksum_8c_source}{checksum.\+c}}.

\mbox{\label{checksum_8h_aca0ef7069e47972313f74f66d9c29298}} 
\index{checksum.h@{checksum.h}!rs\_calc\_strong\_sum@{rs\_calc\_strong\_sum}}
\index{rs\_calc\_strong\_sum@{rs\_calc\_strong\_sum}!checksum.h@{checksum.h}}
\doxyparagraph{\texorpdfstring{rs\_calc\_strong\_sum()}{rs\_calc\_strong\_sum()}}
{\footnotesize\ttfamily void rs\+\_\+calc\+\_\+strong\+\_\+sum (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{checksum_8h_a358cb59b26ba2585bc2094b4da2a547d}{strongsum\+\_\+kind\+\_\+t}}}]{kind,  }\item[{void const $\ast$}]{buf,  }\item[{size\+\_\+t}]{len,  }\item[{rs\+\_\+strong\+\_\+sum\+\_\+t $\ast$}]{sum }\end{DoxyParamCaption})}



Calculate a strongsum. 

Calculate a strongsum.

In plain rsync, the checksum is perturbed by a seed value. This is used when retrying a failed transmission\+: we\textquotesingle{}ve discovered that the hashes collided at some point, so we\textquotesingle{}re going to try again with different hashes to see if we can get it right. (Check tridge\textquotesingle{}s thesis for details and to see if that\textquotesingle{}s correct.)

Since we can\textquotesingle{}t retry I\textquotesingle{}m not sure if it\textquotesingle{}s very useful for librsync, except perhaps as protection against hash collision attacks. 

Definition at line \mbox{\hyperlink{checksum_8c_source_l00059}{59}} of file \mbox{\hyperlink{checksum_8c_source}{checksum.\+c}}.

