\doxysection{src/core/base64.c File Reference}
\label{base64_8c}\index{src/core/base64.c@{src/core/base64.c}}
{\ttfamily \#include $<$osmocom/core/base64.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \textbf{ osmo\+\_\+base64\+\_\+encode} (unsigned char $\ast$dst, size\+\_\+t dlen, size\+\_\+t $\ast$olen, const unsigned char $\ast$src, size\+\_\+t slen)
\begin{DoxyCompactList}\small\item\em Encode a buffer into base64 format. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+base64\+\_\+decode} (unsigned char $\ast$dst, size\+\_\+t dlen, size\+\_\+t $\ast$olen, const unsigned char $\ast$src, size\+\_\+t slen)
\begin{DoxyCompactList}\small\item\em Decode a base64-\/formatted buffer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
static const unsigned char \textbf{ base64\+\_\+enc\+\_\+map} [64]
\item 
static const unsigned char \textbf{ base64\+\_\+dec\+\_\+map} [128]
\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\label{base64_8c_a1674f5075736ca10c24f00ff6b2f0009}} 
\index{base64.c@{base64.c}!osmo\_base64\_decode@{osmo\_base64\_decode}}
\index{osmo\_base64\_decode@{osmo\_base64\_decode}!base64.c@{base64.c}}
\doxysubsubsection{osmo\_base64\_decode()}
{\footnotesize\ttfamily int osmo\+\_\+base64\+\_\+decode (\begin{DoxyParamCaption}\item[{unsigned char $\ast$}]{dst,  }\item[{size\+\_\+t}]{dlen,  }\item[{size\+\_\+t $\ast$}]{olen,  }\item[{const unsigned char $\ast$}]{src,  }\item[{size\+\_\+t}]{slen }\end{DoxyParamCaption})}



Decode a base64-\/formatted buffer. 


\begin{DoxyParams}{Parameters}
{\em dst} & destination buffer (can be NULL for checking size) \\
\hline
{\em dlen} & size of the destination buffer \\
\hline
{\em olen} & number of bytes written \\
\hline
{\em src} & source buffer \\
\hline
{\em slen} & amount of data to be decoded\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, MBEDTLS\+\_\+\+ERR\+\_\+\+BASE64\+\_\+\+BUFFER\+\_\+\+TOO\+\_\+\+SMALL, or MBEDTLS\+\_\+\+ERR\+\_\+\+BASE64\+\_\+\+INVALID\+\_\+\+CHARACTER if the input data is not correct. $\ast$olen is always updated to reflect the amount of data that has (or would have) been written.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
Call this function with $\ast$dst = NULL or dlen = 0 to obtain the required buffer size in $\ast$olen 
\end{DoxyNote}


References \textbf{ base64\+\_\+dec\+\_\+map}, and \textbf{ n}.

\mbox{\label{base64_8c_a1808831840f22ba9774b6f108754dea9}} 
\index{base64.c@{base64.c}!osmo\_base64\_encode@{osmo\_base64\_encode}}
\index{osmo\_base64\_encode@{osmo\_base64\_encode}!base64.c@{base64.c}}
\doxysubsubsection{osmo\_base64\_encode()}
{\footnotesize\ttfamily int osmo\+\_\+base64\+\_\+encode (\begin{DoxyParamCaption}\item[{unsigned char $\ast$}]{dst,  }\item[{size\+\_\+t}]{dlen,  }\item[{size\+\_\+t $\ast$}]{olen,  }\item[{const unsigned char $\ast$}]{src,  }\item[{size\+\_\+t}]{slen }\end{DoxyParamCaption})}



Encode a buffer into base64 format. 


\begin{DoxyParams}{Parameters}
{\em dst} & destination buffer \\
\hline
{\em dlen} & size of the destination buffer \\
\hline
{\em olen} & number of bytes written \\
\hline
{\em src} & source buffer \\
\hline
{\em slen} & amount of data to be encoded\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, or MBEDTLS\+\_\+\+ERR\+\_\+\+BASE64\+\_\+\+BUFFER\+\_\+\+TOO\+\_\+\+SMALL. $\ast$olen is always updated to reflect the amount of data that has (or would have) been written.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
Call this function with dlen = 0 to obtain the required buffer size in $\ast$olen 
\end{DoxyNote}


References \textbf{ base64\+\_\+enc\+\_\+map}, and \textbf{ n}.



\doxysubsection{Variable Documentation}
\mbox{\label{base64_8c_a05aa2b28511eac04bd7d83ad744e9340}} 
\index{base64.c@{base64.c}!base64\_dec\_map@{base64\_dec\_map}}
\index{base64\_dec\_map@{base64\_dec\_map}!base64.c@{base64.c}}
\doxysubsubsection{base64\_dec\_map}
{\footnotesize\ttfamily const unsigned char base64\+\_\+dec\+\_\+map[128]\hspace{0.3cm}{\ttfamily [static]}}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{        127, 127, 127, 127, 127, 127, 127, 127, 127, 127,}
\DoxyCodeLine{        127, 127, 127, 127, 127, 127, 127, 127, 127, 127,}
\DoxyCodeLine{        127, 127, 127, 127, 127, 127, 127, 127, 127, 127,}
\DoxyCodeLine{        127, 127, 127, 127, 127, 127, 127, 127, 127, 127,}
\DoxyCodeLine{        127, 127, 127, 62, 127, 127, 127, 63, 52, 53,}
\DoxyCodeLine{        54, 55, 56, 57, 58, 59, 60, 61, 127, 127,}
\DoxyCodeLine{        127, 64, 127, 127, 127, 0, 1, 2, 3, 4,}
\DoxyCodeLine{        5, 6, 7, 8, 9, 10, 11, 12, 13, 14,}
\DoxyCodeLine{        15, 16, 17, 18, 19, 20, 21, 22, 23, 24,}
\DoxyCodeLine{        25, 127, 127, 127, 127, 127, 127, 26, 27, 28,}
\DoxyCodeLine{        29, 30, 31, 32, 33, 34, 35, 36, 37, 38,}
\DoxyCodeLine{        39, 40, 41, 42, 43, 44, 45, 46, 47, 48,}
\DoxyCodeLine{        49, 50, 51, 127, 127, 127, 127, 127}
\DoxyCodeLine{\}}

\end{DoxyCode}


Referenced by \textbf{ osmo\+\_\+base64\+\_\+decode()}.

\mbox{\label{base64_8c_ac2cbe10aa2936a9fce4c0f9bd9e7e01d}} 
\index{base64.c@{base64.c}!base64\_enc\_map@{base64\_enc\_map}}
\index{base64\_enc\_map@{base64\_enc\_map}!base64.c@{base64.c}}
\doxysubsubsection{base64\_enc\_map}
{\footnotesize\ttfamily const unsigned char base64\+\_\+enc\+\_\+map[64]\hspace{0.3cm}{\ttfamily [static]}}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{        \textcolor{charliteral}{'A'}, \textcolor{charliteral}{'B'}, \textcolor{charliteral}{'C'}, \textcolor{charliteral}{'D'}, \textcolor{charliteral}{'E'}, \textcolor{charliteral}{'F'}, \textcolor{charliteral}{'G'}, \textcolor{charliteral}{'H'}, \textcolor{charliteral}{'I'}, \textcolor{charliteral}{'J'},}
\DoxyCodeLine{        \textcolor{charliteral}{'K'}, \textcolor{charliteral}{'L'}, \textcolor{charliteral}{'M'}, \textcolor{charliteral}{'N'}, \textcolor{charliteral}{'O'}, \textcolor{charliteral}{'P'}, \textcolor{charliteral}{'Q'}, \textcolor{charliteral}{'R'}, \textcolor{charliteral}{'S'}, \textcolor{charliteral}{'T'},}
\DoxyCodeLine{        \textcolor{charliteral}{'U'}, \textcolor{charliteral}{'V'}, \textcolor{charliteral}{'W'}, \textcolor{charliteral}{'X'}, \textcolor{charliteral}{'Y'}, \textcolor{charliteral}{'Z'}, \textcolor{charliteral}{'a'}, \textcolor{charliteral}{'b'}, \textcolor{charliteral}{'c'}, \textcolor{charliteral}{'d'},}
\DoxyCodeLine{        \textcolor{charliteral}{'e'}, \textcolor{charliteral}{'f'}, \textcolor{charliteral}{'g'}, \textcolor{charliteral}{'h'}, \textcolor{charliteral}{'i'}, \textcolor{charliteral}{'j'}, \textcolor{charliteral}{'k'}, \textcolor{charliteral}{'l'}, \textcolor{charliteral}{'m'}, \textcolor{charliteral}{'n'},}
\DoxyCodeLine{        \textcolor{charliteral}{'o'}, \textcolor{charliteral}{'p'}, \textcolor{charliteral}{'q'}, \textcolor{charliteral}{'r'}, \textcolor{charliteral}{'s'}, \textcolor{charliteral}{'t'}, \textcolor{charliteral}{'u'}, \textcolor{charliteral}{'v'}, \textcolor{charliteral}{'w'}, \textcolor{charliteral}{'x'},}
\DoxyCodeLine{        \textcolor{charliteral}{'y'}, \textcolor{charliteral}{'z'}, \textcolor{charliteral}{'0'}, \textcolor{charliteral}{'1'}, \textcolor{charliteral}{'2'}, \textcolor{charliteral}{'3'}, \textcolor{charliteral}{'4'}, \textcolor{charliteral}{'5'}, \textcolor{charliteral}{'6'}, \textcolor{charliteral}{'7'},}
\DoxyCodeLine{        \textcolor{charliteral}{'8'}, \textcolor{charliteral}{'9'}, \textcolor{charliteral}{'+'}, \textcolor{charliteral}{'/'}}
\DoxyCodeLine{\}}

\end{DoxyCode}


Referenced by \textbf{ osmo\+\_\+base64\+\_\+encode()}.

