<ahref="_s_s_l_client_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">/* Copyright 2019 OSU OPEnS Lab</span></div>
<divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment"> * Permission is hereby granted, free of charge, to any person obtaining a copy of this</span></div>
<divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment"> * software and associated documentation files (the "Software"), to deal in the Software</span></div>
<divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment"> * without restriction, including without limitation the rights to use, copy, modify,</span></div>
<divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment"> * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to</span></div>
<divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment"> * permit persons to whom the Software is furnished to do so, subject to the following</span></div>
<divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment"> * The above copyright notice and this permission notice shall be included in all</span></div>
<divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment"> * copies or substantial portions of the Software.</span></div>
<divclass="line"><aname="l00013"></a><spanclass="lineno"> 13</span> <spanclass="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,</span></div>
<divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="comment"> * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A</span></div>
<divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="comment"> * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT</span></div>
<divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="comment"> * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION</span></div>
<divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="comment"> * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE</span></div>
<divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="comment"> * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</span></div>
<divclass="line"><aname="l00418"></a><spanclass="lineno"> 418</span> <spanclass="comment">// check the current debug level and serial status</span></div>
<divclass="line"><aname="l00441"></a><spanclass="lineno"> 441</span> <spanclass="comment">// also store an array of SSLSessions, so we can resume communication with multiple websites</span></div>
<divclass="line"><aname="l00443"></a><spanclass="lineno"> 443</span> <spanclass="comment">// as well as the maximmum number of sessions we can store</span></div>
<divclass="line"><aname="l00449"></a><spanclass="lineno"> 449</span> <spanclass="comment">// store if we are connected in bearssl or not</span></div>
<divclass="line"><aname="l00453"></a><spanclass="lineno"> 453</span> <spanclass="comment">// store the context values required for SSL</span></div>
<divclass="line"><aname="l00456"></a><spanclass="lineno"> 456</span> <spanclass="comment">// use a mono-directional buffer by default to cut memory in half</span></div>
<divclass="line"><aname="l00457"></a><spanclass="lineno"> 457</span> <spanclass="comment">// can expand to a bi-directional buffer with maximum of BR_SSL_BUFSIZE_BIDI</span></div>
<divclass="line"><aname="l00458"></a><spanclass="lineno"> 458</span> <spanclass="comment">// or shrink to below BR_SSL_BUFSIZE_MONO, and bearSSL will adapt automatically</span></div>
<divclass="line"><aname="l00459"></a><spanclass="lineno"> 459</span> <spanclass="comment">// simply edit this value to change the buffer size to the desired value</span></div>
<divclass="line"><aname="l00460"></a><spanclass="lineno"> 460</span> <spanclass="comment">// additionally, we need to correct buffer size based off of how many sessions we decide to cache</span></div>
<divclass="line"><aname="l00461"></a><spanclass="lineno"> 461</span> <spanclass="comment">// since SSL takes so much memory if we don't it will cause the stack and heap to collide </span></div>
<divclass="line"><aname="l00470"></a><spanclass="lineno"> 470</span> <spanclass="comment">// store the index of where we are writing in the buffer</span></div>
<divclass="line"><aname="l00471"></a><spanclass="lineno"> 471</span> <spanclass="comment">// so we can send our records all at once to prevent</span></div>
<divclass="line"><aname="l00474"></a><spanclass="lineno"> 474</span> <spanclass="comment">// store the last BearSSL state so we can print changes to the console</span></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a8da354f30537c1064d554921937a73ae"><divclass="ttname"><ahref="class_s_s_l_client.html#a8da354f30537c1064d554921937a73ae">SSLClient::setTimeout</a></div><divclass="ttdeci">void setTimeout(unsigned int t)</div><divclass="ttdoc">Set the timeout when waiting for an SSL response.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:366</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html"><divclass="ttname"><ahref="class_s_s_l_client.html">SSLClient</a></div><divclass="ttdoc">The main SSLClient class. Check out README.md for more info.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:34</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_ad8ed697371748e31e01c3f697bc36cbe"><divclass="ttname"><ahref="class_s_s_l_client.html#ad8ed697371748e31e01c3f697bc36cbe">SSLClient::stop</a></div><divclass="ttdeci">void stop() override</div><divclass="ttdoc">Close the connection.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:196</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_aef1b52f4ad9633126cb68739175920eb"><divclass="ttname"><ahref="class_s_s_l_client.html#aef1b52f4ad9633126cb68739175920eb">SSLClient::read</a></div><divclass="ttdeci">int read() override</div><divclass="ttdoc">Read a single byte, or -1 if none is available.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:259</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_af632625f8d247f3885c81e1f05043ad1"><divclass="ttname"><ahref="class_s_s_l_client.html#af632625f8d247f3885c81e1f05043ad1">SSLClient::DebugLevel</a></div><divclass="ttdeci">DebugLevel</div><divclass="ttdoc">Level of verbosity used in logging for SSLClient.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:66</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a0e775669b4a040fbd3f281dcbcd2de78"><divclass="ttname"><ahref="class_s_s_l_client.html#a0e775669b4a040fbd3f281dcbcd2de78">SSLClient::available</a></div><divclass="ttdeci">int available() override</div><divclass="ttdoc">Returns the number of bytes available to read from the data that has been received and decrypted.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:134</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a7343a58457b4659f83b61cac1f442c3d"><divclass="ttname"><ahref="class_s_s_l_client.html#a7343a58457b4659f83b61cac1f442c3d">SSLClient::write</a></div><divclass="ttdeci">size_t write(uint8_t b) override</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:211</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a5488f01ccfddfd9e41f54dfbda48bcae"><divclass="ttname"><ahref="class_s_s_l_client.html#a5488f01ccfddfd9e41f54dfbda48bcae">SSLClient::connected</a></div><divclass="ttdeci">uint8_t connected() override</div><divclass="ttdoc">Check if the device is connected.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:223</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a2a178251978e0622f7e241da702ae498"><divclass="ttname"><ahref="class_s_s_l_client.html#a2a178251978e0622f7e241da702ae498">SSLClient::getTimeout</a></div><divclass="ttdeci">unsigned int getTimeout() const</div><divclass="ttdoc">Get the timeout when waiting for an SSL response.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:372</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a68f026a625ca1ccd1aba87bb6e670376"><divclass="ttname"><ahref="class_s_s_l_client.html#a68f026a625ca1ccd1aba87bb6e670376">SSLClient::SSLClient</a></div><divclass="ttdeci">SSLClient(Client &client, const br_x509_trust_anchor *trust_anchors, const size_t trust_anchors_num, const int analog_pin, const size_t max_sessions=1, const DebugLevel debug=SSL_WARN)</div><divclass="ttdoc">Initialize SSLClient with all of the prerequisites needed.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:24</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a9a4e9c9877ab73cf7e82d6942cc7db21"><divclass="ttname"><ahref="class_s_s_l_client.html#a9a4e9c9877ab73cf7e82d6942cc7db21">SSLClient::getClient</a></div><divclass="ttdeci">Client & getClient()</div><divclass="ttdoc">Returns a reference to the client object stored in this class. Take care not to break it.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:360</div></div>
<divclass="ttc"id="aclass_s_s_l_session_html"><divclass="ttname"><ahref="class_s_s_l_session.html">SSLSession</a></div><divclass="ttdoc">This class stores values which allow SSLClient to save and resume SSL sessions.</div><divclass="ttdef"><b>Definition:</b> SSLSession.h:51</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a48239f60f1b4318cc112706fc40c6cea"><divclass="ttname"><ahref="class_s_s_l_client.html#a48239f60f1b4318cc112706fc40c6cea">SSLClient::Error</a></div><divclass="ttdeci">Error</div><divclass="ttdoc">Static constants defining the possible errors encountered.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:44</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_ad5d9d8a4187a3f8918bf66af83e733c4"><divclass="ttname"><ahref="class_s_s_l_client.html#ad5d9d8a4187a3f8918bf66af83e733c4">SSLClient::removeSession</a></div><divclass="ttdeci">void removeSession(const char *host)</div><divclass="ttdoc">Clear the session corresponding to a host and IP.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:267</div></div>
<divclass="ttc"id="aclass_s_s_l_client_parameters_html"><divclass="ttname"><ahref="class_s_s_l_client_parameters.html">SSLClientParameters</a></div><divclass="ttdoc">This class stores data required for SSLClient to use mutual authentication.</div><divclass="ttdef"><b>Definition:</b> SSLClientParameters.h:52</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_ae3f9e6f8e8a50e520c936239abecfd22"><divclass="ttname"><ahref="class_s_s_l_client.html#ae3f9e6f8e8a50e520c936239abecfd22">SSLClient::getSessionCount</a></div><divclass="ttdeci">size_t getSessionCount() const</div><divclass="ttdoc">Get the maximum number of SSL sessions that can be stored at once.</div><divclass="ttdef"><b>Definition:</b> SSLClient.h:350</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a2bd012ef6f01df9694ba9fd0a3c227c3"><divclass="ttname"><ahref="class_s_s_l_client.html#a2bd012ef6f01df9694ba9fd0a3c227c3">SSLClient::getSession</a></div><divclass="ttdeci">SSLSession * getSession(const char *host)</div><divclass="ttdoc">Gets a session reference corresponding to a host and IP, or a reference to a empty session if none ex...</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:254</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a03c7926938acd57cfc3b982edf725a86"><divclass="ttname"><ahref="class_s_s_l_client.html#a03c7926938acd57cfc3b982edf725a86">SSLClient::write</a></div><divclass="ttdeci">size_t write(const uint8_t *buf, size_t size) override</div><divclass="ttdoc">Write some bytes to the SSL connection.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:93</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_aeee217b5558dfb0724f2319888a77256"><divclass="ttname"><ahref="class_s_s_l_client.html#aeee217b5558dfb0724f2319888a77256">SSLClient::setMutualAuthParams</a></div><divclass="ttdeci">void setMutualAuthParams(const SSLClientParameters &params)</div><divclass="ttdoc">Add a client certificate and enable support for mutual auth.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:278</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_ab285c2f5a03124558ef7f74b9f3d12ad"><divclass="ttname"><ahref="class_s_s_l_client.html#ab285c2f5a03124558ef7f74b9f3d12ad">SSLClient::setVerificationTime</a></div><divclass="ttdeci">void setVerificationTime(uint32_t days, uint32_t seconds)</div><divclass="ttdoc">Change the time used during x509 verification to a different value.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:300</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_aaf2192a6621fdf2f89cc26a9a1584f8c"><divclass="ttname"><ahref="class_s_s_l_client.html#aaf2192a6621fdf2f89cc26a9a1584f8c">SSLClient::flush</a></div><divclass="ttdeci">void flush() override</div><divclass="ttdoc">Force writing the buffered bytes from SSLClient::write to the network.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:182</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_ab97c0745f65a6c6009ac938b3b9912c3"><divclass="ttname"><ahref="class_s_s_l_client.html#ab97c0745f65a6c6009ac938b3b9912c3">SSLClient::connect</a></div><divclass="ttdeci">int connect(IPAddress ip, uint16_t port) override</div><divclass="ttdoc">Connect over SSL to a host specified by an IP address.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:52</div></div>
<divclass="ttc"id="aclass_s_s_l_client_html_a0c0b6f2ad25701d1e45adb613d072d86"><divclass="ttname"><ahref="class_s_s_l_client.html#a0c0b6f2ad25701d1e45adb613d072d86">SSLClient::peek</a></div><divclass="ttdeci">int peek() override</div><divclass="ttdoc">View the first byte of the buffer, without removing it from the SSLClient Buffer.</div><divclass="ttdef"><b>Definition:</b> SSLClient.cpp:170</div></div>
<liclass="footer">Generated by <ahref="http://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.8.20 </li>