%	es_dataflow.tikz
%	2020-06-25	Markku-Juhani O. Saarinen <mjos@pqshield.com>
%	CONTRIBUTED TO PUBLIC DOMAIN

\begin{tikzpicture}[scale=1.5]

\draw[thick,fill=red!10] (2.0, 0.0) ellipse (1.5 and 0.3) 
	node {\bf Noise Source};

\draw[-Stealth] (2.0,-0.3) -- ++(0.0, -0.6) 
        node[pos=0.5,anchor=east] {\small\em ``analog''}
        node[pos=0.5,anchor=west] {\small\em shot, quantum, ..};

\draw[rounded corners,fill=cyan!10] (2.0+1.2, -0.9) rectangle ++(-2.4,-0.5)
	node[pos=.5] {Sampling};

\draw[-Stealth] (2.0,-1.4) -- ++(0.0, -0.6)
        node[pos=0.5,anchor=east] {\small\em raw bits};

%\draw[rounded corners] (2.0+1.2, -2.0) rectangle ++(-2.4,-0.5)
%	node[pos=.5] {Conditioning};


\draw[thick,fill=cyan!10] (2.0+1.3,-2.0) -- ++(-2.6,-0.0) -- 
       ++(0.2,-0.5) -- ++(2.2,0.0) -- cycle;

\node at (2.0,-2.25) {Conditioning};

\draw[-Stealth, dashed] (2.0,-1.7) -- (4.5-0.8,-1.7);

\draw[-Stealth] (2.0,-2.5) -- ++(0.0, -0.6)
        node[pos=0.5,anchor=east] {\small\em pre-processed}
        node[pos=0.5,anchor=west] {\small {Entropy}$(X) > 12$ {bits}};

\draw[fill=blue!10] (4.4 - 0.7, -1.7 + 0.45) rectangle ++(1.4,-0.9) 
	node[align=center,pos=.5] {{Health}\\{Tests}};

\draw[-Stealth, dashed] (4.4, -2.15) -- (4.4, -3.35) -- (3.5, -3.35)
        node[pos=0.5,anchor=south] {\small\bf OK?};

\draw[thick,fill=green!10] (2.0 - 1.5, -3.1) 
	rectangle ++(3.0,-0.5)  node[pos=.5] {The {\bf ``seed''} CSR};

\node at (0.0, -3.35) {\bf ISA};

\draw[->, dotted] (0.0,-3.1) -- ++(0.0, 3.3);

\node[align=center,rotate=90] at (0.0,-1.7)
		{\small{\bf Hardware:}\\\small{\em Entropy Source (ES)}};

\draw[->, dotted] (0.0,-3.6) -- ++(0.0, -3.3);

\node[align=center,rotate=90] at (0.0,-5.0)
		{\small{\bf Software:}\\\small{\em Driver + DRBG(s)}};

\draw[-Stealth] (2.0,-3.6) -- ++(0.0, -0.6) 
        node[pos=0.5,anchor=east] {\small\em ( ES16 )}
        node[pos=0.5,anchor=west] {\small\em entropy};


\node[align=center] at (3.95,-3.6)
	{\small\textcolor{red!50!black}{\underline{\em Not OK:}}};
\node[align=center] at (3.95,-3.9)
	{\small\textcolor{red!50!black}{\em ( BIST / WAIT / DEAD )} };


%\draw[rounded corners] (2.0+1.2, -4.2) rectangle ++(-2.4,-0.5)
%	node[pos=.5] {Hash / Pool};


\draw[thick,dashed] (2.0+1.3,-4.2) -- ++(-2.6,-0.0) -- 
       ++(0.2,-0.5) -- ++(2.2,0.0) -- cycle;

\node at (2.0,-4.45) {Entropy Pool};

\draw[-Stealth] (2.0,-4.7) -- ++(0.0, -0.6) 
        node[pos=0.5,anchor=east] {\small\em processed}
        node[pos=0.5,anchor=west] {\small\em ``full entropy''};


%\draw[thick] (2.0+1.1,-5.3) -- ++(-2.2,-0.0) -- 
%       ++(-0.2,-0.5) -- ++(2.6,0.0) -- cycle;

\draw[thick,fill=brown!10] (2.0+1.2, -5.3) rectangle ++(-2.4,-0.5)
	node[pos=.5] {Crypto DRBG};

\draw[-Stealth] (2.0,-5.8) -- ++(0.0, -0.6) 
        node[pos=0.5,anchor=east] {\small\em Library API}
        node[pos=0.5,anchor=west] {\small\em Kernel syscall};


\draw[thick,fill=gray!20] (2.0, -6.7) ellipse (1.5 and 0.3) 
	node {\bf Application};

\end{tikzpicture}


