\hypertarget{ktls__ocf_8c_source}{}\doxysection{ktls\+\_\+ocf.\+c}
\label{ktls__ocf_8c_source}\index{opencrypto/ktls\_ocf.c@{opencrypto/ktls\_ocf.c}}
\mbox{\hyperlink{ktls__ocf_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2019 Netflix Inc.}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00005}00005 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00006}00006 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00007}00007 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00008}00008 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00009}00009 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00010}00010 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00011}00011 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00012}00012 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00013}00013 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00014}00014 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00015}00015 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00016}00016 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00017}00017 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00018}00018 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00019}00019 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00020}00020 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00021}00021 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00022}00022 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00023}00023 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00024}00024 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00025}00025 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00026}00026 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00027}00027 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00028}00028 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00029}\mbox{\hyperlink{ktls__ocf_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00029}} \mbox{\hyperlink{ktls__ocf_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00030}00030 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00031}00031 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/counter.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/endian.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <sys/ktls.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/mbuf.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/module.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/mutex.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/sysctl.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/uio.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <vm/vm.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00045}00045 \textcolor{preprocessor}{\#include <vm/pmap.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00046}00046 \textcolor{preprocessor}{\#include <vm/vm\_param.h>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{cryptodev_8h}{opencrypto/cryptodev.h}}>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00048}00048 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{ktls_8h}{opencrypto/ktls.h}}>}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00049}00049 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00050}\mbox{\hyperlink{structktls__ocf__session}{00050}} \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00051}\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{00051}}         \mbox{\hyperlink{structcrypto__session}{crypto\_session\_t}} \mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00052}\mbox{\hyperlink{structktls__ocf__session_a8d19c8b2c220aa8207c4ae7ca7ecf1cf}{00052}}         \mbox{\hyperlink{structcrypto__session}{crypto\_session\_t}} \mbox{\hyperlink{structktls__ocf__session_a8d19c8b2c220aa8207c4ae7ca7ecf1cf}{mac\_sid}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00053}\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{00053}}         \textcolor{keyword}{struct }mtx \mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00054}\mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{00054}}         \textcolor{keywordtype}{int} \mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00055}\mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{00055}}         \textcolor{keywordtype}{bool} \mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{implicit\_iv}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00056}00056 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00057}00057         \textcolor{comment}{/* Only used for TLS 1.0 with the implicit IV. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00058}00058 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00059}00059         \textcolor{keywordtype}{bool} in\_progress;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00060}00060         uint64\_t next\_seqno;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00061}00061 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00062}\mbox{\hyperlink{structktls__ocf__session_adec2f9991d37683a2ca6dfa2fdab28e5}{00062}}         \textcolor{keywordtype}{char} \mbox{\hyperlink{structktls__ocf__session_adec2f9991d37683a2ca6dfa2fdab28e5}{iv}}[\mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}}];}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00063}00063 \};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00064}00064 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00065}\mbox{\hyperlink{structocf__operation}{00065}} \textcolor{keyword}{struct }\mbox{\hyperlink{structocf__operation}{ocf\_operation}} \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00066}\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{00066}}         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00067}\mbox{\hyperlink{structocf__operation_a521d6c539a1cab31b48a5ec467caae6e}{00067}}         \textcolor{keywordtype}{bool} \mbox{\hyperlink{structocf__operation_a521d6c539a1cab31b48a5ec467caae6e}{done}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00068}00068 \};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00069}00069 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00070}\mbox{\hyperlink{ktls__ocf_8c_a421b6129a9846aec915b4d63a6b8e177}{00070}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a421b6129a9846aec915b4d63a6b8e177}{MALLOC\_DEFINE}}(M\_KTLS\_OCF, \textcolor{stringliteral}{"{}ktls\_ocf"{}}, \textcolor{stringliteral}{"{}OCF KTLS"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00071}00071 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00072}\mbox{\hyperlink{ktls__ocf_8c_a8d430948d85f8237c0ab0db74c4fb138}{00072}} \mbox{\hyperlink{ktls__ocf_8c_a8d430948d85f8237c0ab0db74c4fb138}{SYSCTL\_DECL}}(\_kern\_ipc\_tls);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00073}\mbox{\hyperlink{ktls__ocf_8c_a1c9a6e8a2fa7b37d723ee6e4e1c4ca3d}{00073}} \mbox{\hyperlink{ktls__ocf_8c_a8d430948d85f8237c0ab0db74c4fb138}{SYSCTL\_DECL}}(\_kern\_ipc\_tls\_stats);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00074}00074 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00075}\mbox{\hyperlink{ktls__ocf_8c_afc0732c96f31e7791242866044a757eb}{00075}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_afc0732c96f31e7791242866044a757eb}{SYSCTL\_NODE}}(\_kern\_ipc\_tls\_stats, OID\_AUTO, ocf,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00076}00076     CTLFLAG\_RD | CTLFLAG\_MPSAFE, 0,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00077}00077     \textcolor{stringliteral}{"{}Kernel TLS offload via OCF stats"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00078}00078 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00079}\mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{00079}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls10\_cbc\_encrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00080}\mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{00080}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls10\_cbc\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00081}00081     CTLFLAG\_RD, \&ocf\_tls10\_cbc\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00082}00082     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.0 CBC encryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00083}00083 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00084}\mbox{\hyperlink{ktls__ocf_8c_aabcd1e5be1dcfe70767da5f308992c16}{00084}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls11\_cbc\_encrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00085}\mbox{\hyperlink{ktls__ocf_8c_a5456789502dd40f90827c52b3ea6066c}{00085}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls11\_cbc\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00086}00086     CTLFLAG\_RD, \&ocf\_tls11\_cbc\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00087}00087     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.1/1.2 CBC encryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00088}00088 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00089}\mbox{\hyperlink{ktls__ocf_8c_ad84c443c1afdaaf181e029070ae0a98c}{00089}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls12\_gcm\_decrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00090}\mbox{\hyperlink{ktls__ocf_8c_a1e06ee82b208e03c3644cd8b64473e93}{00090}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls12\_gcm\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00091}00091     CTLFLAG\_RD, \&ocf\_tls12\_gcm\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00092}00092     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.2 GCM decryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00093}00093 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00094}\mbox{\hyperlink{ktls__ocf_8c_aa57c75a75bb79c70a90d6878df0d2bd2}{00094}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls12\_gcm\_encrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00095}\mbox{\hyperlink{ktls__ocf_8c_ada2c92951f597eaf3cc2b0a4613da5bf}{00095}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls12\_gcm\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00096}00096     CTLFLAG\_RD, \&ocf\_tls12\_gcm\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00097}00097     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.2 GCM encryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00099}\mbox{\hyperlink{ktls__ocf_8c_a980d93f1420b6bdef21a9f6c9b22f276}{00099}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls12\_chacha20\_decrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00100}\mbox{\hyperlink{ktls__ocf_8c_a3fee03811f028fcf7a3ca1b6681da6b6}{00100}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls12\_chacha20\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00101}00101     CTLFLAG\_RD, \&ocf\_tls12\_chacha20\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00102}00102     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.2 Chacha20-\/Poly1305 decryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00103}00103 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00104}\mbox{\hyperlink{ktls__ocf_8c_a719cd299a75042971ee36e07b22d5bf6}{00104}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls12\_chacha20\_encrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00105}\mbox{\hyperlink{ktls__ocf_8c_ac29782afca10a7ac70d5f0b9be49aa4f}{00105}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls12\_chacha20\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00106}00106     CTLFLAG\_RD, \&ocf\_tls12\_chacha20\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00107}00107     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.2 Chacha20-\/Poly1305 encryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00108}00108 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00109}\mbox{\hyperlink{ktls__ocf_8c_a245bdc92f293779f07c8b1c73550896a}{00109}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls13\_gcm\_decrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00110}\mbox{\hyperlink{ktls__ocf_8c_a3284fbbc6e39e96017c6713d4e960fb5}{00110}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls13\_gcm\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00111}00111     CTLFLAG\_RD, \&ocf\_tls13\_gcm\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00112}00112     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.3 GCM decryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00113}00113 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00114}\mbox{\hyperlink{ktls__ocf_8c_a3f5fdf46aa1259a426012efc8432fe4c}{00114}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls13\_gcm\_encrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00115}\mbox{\hyperlink{ktls__ocf_8c_a2dbc9a166e9f4d93fcaa49b3724b3f91}{00115}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls13\_gcm\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00116}00116     CTLFLAG\_RD, \&ocf\_tls13\_gcm\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00117}00117     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.3 GCM encryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00118}00118 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00119}\mbox{\hyperlink{ktls__ocf_8c_ae56c55ba73ca7f7cf4eaf5625b3b4e3a}{00119}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls13\_chacha20\_decrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00120}\mbox{\hyperlink{ktls__ocf_8c_afe39fd047bdc76458b1f4f70309fde4b}{00120}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls13\_chacha20\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00121}00121     CTLFLAG\_RD, \&ocf\_tls13\_chacha20\_decrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00122}00122     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.3 Chacha20-\/Poly1305 decryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00123}00123 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00124}\mbox{\hyperlink{ktls__ocf_8c_ab337157e4da053dc0ca55f9bc9110728}{00124}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_tls13\_chacha20\_encrypts);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00125}\mbox{\hyperlink{ktls__ocf_8c_a53b2630b67855aa00fc26839e6054fb5}{00125}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, tls13\_chacha20\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00126}00126     CTLFLAG\_RD, \&ocf\_tls13\_chacha20\_encrypts,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00127}00127     \textcolor{stringliteral}{"{}Total number of OCF TLS 1.3 Chacha20-\/Poly1305 encryption operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00128}00128 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00129}\mbox{\hyperlink{ktls__ocf_8c_a00932d313eeafee298752f039c4ae73e}{00129}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_inplace);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00130}\mbox{\hyperlink{ktls__ocf_8c_af16aa88435deae9f8725abf21700b284}{00130}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, inplace,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00131}00131     CTLFLAG\_RD, \&ocf\_inplace,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00132}00132     \textcolor{stringliteral}{"{}Total number of OCF in-\/place operations"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00133}00133 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00134}\mbox{\hyperlink{ktls__ocf_8c_a20f7220ae0f0c31a0969d947d98abc80}{00134}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_separate\_output);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00135}\mbox{\hyperlink{ktls__ocf_8c_a43ced1bcb41384418190c474b964ffc9}{00135}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, separate\_output,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00136}00136     CTLFLAG\_RD, \&ocf\_separate\_output,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00137}00137     \textcolor{stringliteral}{"{}Total number of OCF operations with a separate output buffer"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00139}\mbox{\hyperlink{ktls__ocf_8c_a418cedd917f3a978e5e78071e6431ee0}{00139}} \textcolor{keyword}{static} \mbox{\hyperlink{ktls__ocf_8c_a02b63ec61101b5695510543d812babb3}{COUNTER\_U64\_DEFINE\_EARLY}}(ocf\_retries);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00140}\mbox{\hyperlink{ktls__ocf_8c_afd2cd2522ebf0d8ddfd0913a86d38e45}{00140}} \mbox{\hyperlink{ktls__ocf_8c_a1085fad80806b6c307c7feee351ee5d7}{SYSCTL\_COUNTER\_U64}}(\_kern\_ipc\_tls\_stats\_ocf, OID\_AUTO, retries, CTLFLAG\_RD,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00141}00141     \&ocf\_retries,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00142}00142     \textcolor{stringliteral}{"{}Number of OCF encryption operation retries"{}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00143}00143 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00144}00144 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00145}\mbox{\hyperlink{ktls__ocf_8c_afce0975bb22a636b44d33b89daadecff}{00145}} \mbox{\hyperlink{ktls__ocf_8c_afce0975bb22a636b44d33b89daadecff}{ktls\_ocf\_callback\_sync}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcryptop}{cryptop}} *crp \_\_unused)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00146}00146 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00147}00147         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00148}00148 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00149}00149 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00150}00150 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00151}\mbox{\hyperlink{ktls__ocf_8c_a9eec86c97503e9e25ba72129551401ec}{00151}} \mbox{\hyperlink{ktls__ocf_8c_a9eec86c97503e9e25ba72129551401ec}{ktls\_ocf\_callback\_async}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcryptop}{cryptop}} *crp)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00152}00152 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00153}00153         \textcolor{keyword}{struct }\mbox{\hyperlink{structocf__operation}{ocf\_operation}} *oo;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00154}00154 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00155}00155         oo = crp-\/>\mbox{\hyperlink{structcryptop_ac6ec4c1169a454775d530401c7572788}{crp\_opaque}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00156}00156         mtx\_lock(\&oo-\/>\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}}-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00157}00157         oo-\/>\mbox{\hyperlink{structocf__operation_a521d6c539a1cab31b48a5ec467caae6e}{done}} = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00158}00158         mtx\_unlock(\&oo-\/>\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}}-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00159}00159         wakeup(oo);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00160}00160         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00161}00161 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00162}00162 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00163}00163 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00164}\mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{00164}} \mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{ktls\_ocf\_dispatch}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}}, \textcolor{keyword}{struct} \mbox{\hyperlink{structcryptop}{cryptop}} *crp)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00165}00165 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00166}00166         \textcolor{keyword}{struct }\mbox{\hyperlink{structocf__operation}{ocf\_operation}} oo;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00167}00167         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00168}00168         \textcolor{keywordtype}{bool} async;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00169}00169 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00170}00170         oo.\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}} = \mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00171}00171         oo.\mbox{\hyperlink{structocf__operation_a521d6c539a1cab31b48a5ec467caae6e}{done}} = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00172}00172 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00173}00173         crp-\/>\mbox{\hyperlink{structcryptop_ac6ec4c1169a454775d530401c7572788}{crp\_opaque}} = \&oo;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00174}00174         \textcolor{keywordflow}{for} (;;) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00175}00175                 async = !\mbox{\hyperlink{cryptodev_8h_ae6bc2e493daed5397d5b9f8549f5c960}{CRYPTO\_SESS\_SYNC}}(crp-\/>\mbox{\hyperlink{structcryptop_aa6e9681f39c803322322ece0f7739053}{crp\_session}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00176}00176                 crp-\/>\mbox{\hyperlink{structcryptop_a01148b0a418c8a40bed58e74fa7d46c8}{crp\_callback}} = async ? \mbox{\hyperlink{ktls__ocf_8c_a9eec86c97503e9e25ba72129551401ec}{ktls\_ocf\_callback\_async}} :}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00177}00177                     \mbox{\hyperlink{ktls__ocf_8c_afce0975bb22a636b44d33b89daadecff}{ktls\_ocf\_callback\_sync}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00178}00178 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00179}00179                 error = \mbox{\hyperlink{crypto_8c_ad3792d285ef5db2f1538381aed3b031a}{crypto\_dispatch}}(crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00180}00180                 \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00181}00181                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00182}00182                 \textcolor{keywordflow}{if} (async) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00183}00183                         mtx\_lock(\&\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}}-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00184}00184                         \textcolor{keywordflow}{while} (!oo.\mbox{\hyperlink{structocf__operation_a521d6c539a1cab31b48a5ec467caae6e}{done}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00185}00185                                 mtx\_sleep(\&oo, \&\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}}-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}}, 0, \textcolor{stringliteral}{"{}ocfktls"{}}, 0);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00186}00186                         mtx\_unlock(\&\mbox{\hyperlink{structocf__operation_ab56704ed89c854990a802304d94b9b58}{os}}-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00187}00187                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00188}00188 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00189}00189                 \textcolor{keywordflow}{if} (crp-\/>\mbox{\hyperlink{structcryptop_ae1d16088047f3e6b4592f5aa8e8d8279}{crp\_etype}} != EAGAIN) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00190}00190                         error = crp-\/>\mbox{\hyperlink{structcryptop_ae1d16088047f3e6b4592f5aa8e8d8279}{crp\_etype}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00191}00191                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00192}00192                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00193}00193 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00194}00194                 crp-\/>\mbox{\hyperlink{structcryptop_ae1d16088047f3e6b4592f5aa8e8d8279}{crp\_etype}} = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00195}00195                 crp-\/>\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} \&= \string~CRYPTO\_F\_DONE;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00196}00196                 oo.\mbox{\hyperlink{structocf__operation_a521d6c539a1cab31b48a5ec467caae6e}{done}} = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00197}00197                 counter\_u64\_add(ocf\_retries, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00198}00198         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00199}00199         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00200}00200 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00201}00201 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00202}00202 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00203}\mbox{\hyperlink{ktls__ocf_8c_a4a59d06a8fad8c7458b9d7cb061b8b18}{00203}} \mbox{\hyperlink{ktls__ocf_8c_a4a59d06a8fad8c7458b9d7cb061b8b18}{ktls\_ocf\_dispatch\_async\_cb}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structcryptop}{cryptop}} *crp)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00204}00204 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00205}00205         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__encrypt__state}{ktls\_ocf\_encrypt\_state}} *state;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00206}00206         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00207}00207 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00208}00208         state = \mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}}-\/>\mbox{\hyperlink{structcryptop_ac6ec4c1169a454775d530401c7572788}{crp\_opaque}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00209}00209         \textcolor{keywordflow}{if} (\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}}-\/>\mbox{\hyperlink{structcryptop_ae1d16088047f3e6b4592f5aa8e8d8279}{crp\_etype}} == EAGAIN) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00210}00210                 \mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}}-\/>\mbox{\hyperlink{structcryptop_ae1d16088047f3e6b4592f5aa8e8d8279}{crp\_etype}} = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00211}00211                 \mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}}-\/>\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} \&= \string~CRYPTO\_F\_DONE;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00212}00212                 counter\_u64\_add(ocf\_retries, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00213}00213                 error = \mbox{\hyperlink{crypto_8c_ad3792d285ef5db2f1538381aed3b031a}{crypto\_dispatch}}(\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00214}00214                 \textcolor{keywordflow}{if} (error != 0) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00215}00215                         \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00216}00216                         \mbox{\hyperlink{ktls_8h_a255b2419a71233d2c9d02d29382ef458}{ktls\_encrypt\_cb}}(state, error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00217}00217                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00218}00218                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00219}00219         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00220}00220 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00221}00221         error = \mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}}-\/>\mbox{\hyperlink{structcryptop_ae1d16088047f3e6b4592f5aa8e8d8279}{crp\_etype}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00222}00222         \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00223}00223         \mbox{\hyperlink{ktls_8h_a255b2419a71233d2c9d02d29382ef458}{ktls\_encrypt\_cb}}(state, error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00224}00224         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00225}00225 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00226}00226 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00227}00227 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00228}\mbox{\hyperlink{ktls__ocf_8c_a8649104385a46f3c7192152cbc8865f9}{00228}} \mbox{\hyperlink{ktls__ocf_8c_a8649104385a46f3c7192152cbc8865f9}{ktls\_ocf\_dispatch\_async}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structktls__ocf__encrypt__state}{ktls\_ocf\_encrypt\_state}} *state,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00229}00229     \textcolor{keyword}{struct} \mbox{\hyperlink{structcryptop}{cryptop}} *\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00230}00230 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00231}00231         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00232}00232 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00233}00233         \mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}}-\/>\mbox{\hyperlink{structcryptop_ac6ec4c1169a454775d530401c7572788}{crp\_opaque}} = state;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00234}00234         \mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}}-\/>\mbox{\hyperlink{structcryptop_a01148b0a418c8a40bed58e74fa7d46c8}{crp\_callback}} = \mbox{\hyperlink{ktls__ocf_8c_a4a59d06a8fad8c7458b9d7cb061b8b18}{ktls\_ocf\_dispatch\_async\_cb}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00235}00235         error = \mbox{\hyperlink{crypto_8c_ad3792d285ef5db2f1538381aed3b031a}{crypto\_dispatch}}(\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00236}00236         \textcolor{keywordflow}{if} (error != 0)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00237}00237                 \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00238}00238         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00239}00239 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00240}00240 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00241}00241 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00242}\mbox{\hyperlink{ktls__ocf_8c_aab3b4a8d61ab4b7a5ba9721a57456d15}{00242}} \mbox{\hyperlink{ktls__ocf_8c_aab3b4a8d61ab4b7a5ba9721a57456d15}{ktls\_ocf\_tls\_cbc\_encrypt}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structktls__ocf__encrypt__state}{ktls\_ocf\_encrypt\_state}} *state,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00243}00243     \textcolor{keyword}{struct} ktls\_session *tls, \textcolor{keyword}{struct} mbuf *\mbox{\hyperlink{structktls__ocf__encrypt__state_a67c88647198855de439ab5942b632baa}{m}}, \textcolor{keyword}{struct} iovec *outiov,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00244}00244     \textcolor{keywordtype}{int} outiovcnt)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00245}00245 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00246}00246         \textcolor{keyword}{const} \textcolor{keyword}{struct }tls\_record\_layer *hdr;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00247}00247         \textcolor{keyword}{struct }uio *uio;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00248}00248         \textcolor{keyword}{struct }tls\_mac\_data *ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00249}00249         \textcolor{keyword}{struct }\mbox{\hyperlink{structcryptop}{cryptop}} *crp;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00250}00250         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00251}00251         \textcolor{keyword}{struct }iovec iov[m-\/>m\_epg\_npgs + 2];}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00252}00252         u\_int pgoff;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00253}00253         \textcolor{keywordtype}{int} i, error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00254}00254         uint16\_t tls\_comp\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00255}00255         uint8\_t pad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00256}00256 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00257}00257         MPASS(outiovcnt + 1 <= nitems(iov));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00258}00258 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00259}00259         os = tls-\/>ocf\_session;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00260}00260         hdr = (\textcolor{keyword}{const} \textcolor{keyword}{struct }tls\_record\_layer *)m-\/>m\_epg\_hdr;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00261}00261         crp = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00262}00262         uio = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_ac33685772fc914891dc8f02ba59a1800}{uio}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00263}00263         MPASS(tls-\/>sync\_dispatch);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00264}00264 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00265}00265 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00266}00266         \textcolor{keywordflow}{if} (os-\/>\mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{implicit\_iv}}) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00267}00267                 mtx\_lock(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00268}00268                 KASSERT(!os-\/>in\_progress,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00269}00269                     (\textcolor{stringliteral}{"{}concurrent implicit IV encryptions"{}}));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00270}00270                 \textcolor{keywordflow}{if} (os-\/>next\_seqno != m-\/>m\_epg\_seqno) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00271}00271                         printf(\textcolor{stringliteral}{"{}KTLS CBC: TLS records out of order.  "{}}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00272}00272                             \textcolor{stringliteral}{"{}Expected \%ju, got \%ju\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00273}00273                             (uintmax\_t)os-\/>next\_seqno,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00274}00274                             (uintmax\_t)m-\/>m\_epg\_seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00275}00275                         mtx\_unlock(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00276}00276                         \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00277}00277                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00278}00278                 os-\/>in\_progress = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00279}00279                 mtx\_unlock(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00280}00280         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00281}00281 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00282}00282 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00283}00283         \textcolor{comment}{/* Payload length. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00284}00284         tls\_comp\_len = m-\/>m\_len -\/ (m-\/>m\_epg\_hdrlen + m-\/>m\_epg\_trllen);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00285}00285 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00286}00286         \textcolor{comment}{/* Initialize the AAD. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00287}00287         ad = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_a271f901843280b5b58a4dabef0d4f94f}{mac}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00288}00288         ad-\/>seq = htobe64(m-\/>m\_epg\_seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00289}00289         ad-\/>type = hdr-\/>tls\_type;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00290}00290         ad-\/>tls\_vmajor = hdr-\/>tls\_vmajor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00291}00291         ad-\/>tls\_vminor = hdr-\/>tls\_vminor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00292}00292         ad-\/>tls\_length = htons(tls\_comp\_len);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00293}00293 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00294}00294         \textcolor{comment}{/* First, compute the MAC. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00295}00295         iov[0].iov\_base = ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00296}00296         iov[0].iov\_len = \textcolor{keyword}{sizeof}(*ad);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00297}00297         pgoff = m-\/>m\_epg\_1st\_off;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00298}00298         \textcolor{keywordflow}{for} (i = 0; i < m-\/>m\_epg\_npgs; i++, pgoff = 0) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00299}00299                 iov[i + 1].iov\_base = (\textcolor{keywordtype}{void} *)PHYS\_TO\_DMAP(m-\/>m\_epg\_pa[i] +}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00300}00300                     pgoff);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00301}00301                 iov[i + 1].iov\_len = m\_epg\_pagelen(m, i, pgoff);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00302}00302         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00303}00303         iov[m-\/>m\_epg\_npgs + 1].iov\_base = m-\/>m\_epg\_trail;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00304}00304         iov[m-\/>m\_epg\_npgs + 1].iov\_len = os-\/>\mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00305}00305         uio-\/>uio\_iov = iov;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00306}00306         uio-\/>uio\_iovcnt = m-\/>m\_epg\_npgs + 2;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00307}00307         uio-\/>uio\_offset = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00308}00308         uio-\/>uio\_segflg = UIO\_SYSSPACE;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00309}00309         uio-\/>uio\_td = curthread;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00310}00310         uio-\/>uio\_resid = \textcolor{keyword}{sizeof}(*ad) + tls\_comp\_len + os-\/>\mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00311}00311 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00312}00312         \mbox{\hyperlink{crypto_8c_ae3902a698a5f6f82412f2d01fb61b55b}{crypto\_initreq}}(crp, os-\/>\mbox{\hyperlink{structktls__ocf__session_a8d19c8b2c220aa8207c4ae7ca7ecf1cf}{mac\_sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00313}00313         crp-\/>\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00314}00314         crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} = \textcolor{keyword}{sizeof}(*ad) + tls\_comp\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00315}00315         crp-\/>\mbox{\hyperlink{structcryptop_ab21b34eea16b6607737a7e506af1605a}{crp\_digest\_start}} = crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00316}00316         crp-\/>\mbox{\hyperlink{structcryptop_afbee27b48615d717b2dd44252f5661ef}{crp\_op}} = \mbox{\hyperlink{cryptodev_8h_aab8bb68c196639f4b152663825c689b6}{CRYPTO\_OP\_COMPUTE\_DIGEST}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00317}00317         crp-\/>\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} = \mbox{\hyperlink{cryptodev_8h_a2736b0220d0b0dc9243f4bb88aa6349c}{CRYPTO\_F\_CBIMM}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00318}00318         \mbox{\hyperlink{cryptodev_8h_acb924a28d64c4633e5b3a79a01377d63}{crypto\_use\_uio}}(crp, uio);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00319}00319         error = \mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{ktls\_ocf\_dispatch}}(os, crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00320}00320 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00321}00321         \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00322}00322         \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00323}00323 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00324}00324                 \textcolor{keywordflow}{if} (os-\/>\mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{implicit\_iv}}) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00325}00325                         mtx\_lock(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00326}00326                         os-\/>in\_progress = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00327}00327                         mtx\_unlock(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00328}00328                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00329}00329 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00330}00330                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00331}00331         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00332}00332 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00333}00333         \textcolor{comment}{/* Second, add the padding. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00334}00334         pad = m-\/>m\_epg\_trllen -\/ os-\/>\mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} -\/ 1;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00335}00335         \textcolor{keywordflow}{for} (i = 0; i < pad + 1; i++)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00336}00336                 m-\/>m\_epg\_trail[os-\/>\mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} + i] = pad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00337}00337 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00338}00338         \textcolor{comment}{/* Finally, encrypt the record. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00339}00339         \mbox{\hyperlink{crypto_8c_ae3902a698a5f6f82412f2d01fb61b55b}{crypto\_initreq}}(crp, os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00340}00340         crp-\/>\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} = m-\/>m\_epg\_hdrlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00341}00341         crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} = tls\_comp\_len + m-\/>m\_epg\_trllen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00342}00342         KASSERT(crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} \% \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}} == 0,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00343}00343             (\textcolor{stringliteral}{"{}invalid encryption size"{}}));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00344}00344         \mbox{\hyperlink{cryptodev_8h_af5a89c7f148a439fe61edf83c81434ff}{crypto\_use\_single\_mbuf}}(crp, m);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00345}00345         crp-\/>\mbox{\hyperlink{structcryptop_afbee27b48615d717b2dd44252f5661ef}{crp\_op}} = \mbox{\hyperlink{cryptodev_8h_a308ebc4fcf06c890e1fa7803eca03649}{CRYPTO\_OP\_ENCRYPT}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00346}00346         crp-\/>\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} = \mbox{\hyperlink{cryptodev_8h_a2736b0220d0b0dc9243f4bb88aa6349c}{CRYPTO\_F\_CBIMM}} | \mbox{\hyperlink{cryptodev_8h_a7d342342af088db7586c133d8ec27f28}{CRYPTO\_F\_IV\_SEPARATE}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00347}00347         \textcolor{keywordflow}{if} (os-\/>\mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{implicit\_iv}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00348}00348                 memcpy(crp-\/>\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, os-\/>\mbox{\hyperlink{structktls__ocf__session_adec2f9991d37683a2ca6dfa2fdab28e5}{iv}}, \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00349}00349         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00350}00350                 memcpy(crp-\/>\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, hdr + 1, \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00351}00351 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00352}00352         \textcolor{keywordflow}{if} (outiov != NULL) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00353}00353                 uio-\/>uio\_iov = outiov;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00354}00354                 uio-\/>uio\_iovcnt = outiovcnt;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00355}00355                 uio-\/>uio\_offset = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00356}00356                 uio-\/>uio\_segflg = UIO\_SYSSPACE;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00357}00357                 uio-\/>uio\_td = curthread;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00358}00358                 uio-\/>uio\_resid = crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00359}00359                 \mbox{\hyperlink{cryptodev_8h_aa788a7a3c46d67cfd0226017ed28191c}{crypto\_use\_output\_uio}}(crp, uio);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00360}00360         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00361}00361 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00362}00362         \textcolor{keywordflow}{if} (os-\/>\mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{implicit\_iv}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00363}00363                 counter\_u64\_add(ocf\_tls10\_cbc\_encrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00364}00364         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00365}00365                 counter\_u64\_add(ocf\_tls11\_cbc\_encrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00366}00366         \textcolor{keywordflow}{if} (outiov != NULL)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00367}00367                 counter\_u64\_add(ocf\_separate\_output, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00368}00368         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00369}00369                 counter\_u64\_add(ocf\_inplace, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00370}00370         error = \mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{ktls\_ocf\_dispatch}}(os, crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00371}00371 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00372}00372         \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00373}00373 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00374}00374         \textcolor{keywordflow}{if} (os-\/>\mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{implicit\_iv}}) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00375}00375                 KASSERT(os-\/>\mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} + pad + 1 >= \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}},}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00376}00376                     (\textcolor{stringliteral}{"{}trailer too short to read IV"{}}));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00377}00377                 memcpy(os-\/>\mbox{\hyperlink{structktls__ocf__session_adec2f9991d37683a2ca6dfa2fdab28e5}{iv}}, m-\/>m\_epg\_trail + m-\/>m\_epg\_trllen -\/ \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}},}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00378}00378                     \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00379}00379 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00380}00380                 mtx\_lock(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00381}00381                 os-\/>next\_seqno = m-\/>m\_epg\_seqno + 1;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00382}00382                 os-\/>in\_progress = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00383}00383                 mtx\_unlock(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00384}00384 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00385}00385         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00386}00386         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00387}00387 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00388}00388 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00389}00389 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00390}\mbox{\hyperlink{ktls__ocf_8c_abc66f8c39c3a09ad85eac9556f7cbe43}{00390}} \mbox{\hyperlink{ktls__ocf_8c_abc66f8c39c3a09ad85eac9556f7cbe43}{ktls\_ocf\_tls12\_aead\_encrypt}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structktls__ocf__encrypt__state}{ktls\_ocf\_encrypt\_state}} *state,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00391}00391     \textcolor{keyword}{struct} ktls\_session *tls, \textcolor{keyword}{struct} mbuf *m, \textcolor{keyword}{struct} iovec *outiov,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00392}00392     \textcolor{keywordtype}{int} outiovcnt)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00393}00393 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00394}00394         \textcolor{keyword}{const} \textcolor{keyword}{struct }tls\_record\_layer *hdr;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00395}00395         \textcolor{keyword}{struct }uio *uio;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00396}00396         \textcolor{keyword}{struct }tls\_aead\_data *ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00397}00397         \textcolor{keyword}{struct }\mbox{\hyperlink{structcryptop}{cryptop}} *crp;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00398}00398         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00399}00399         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00400}00400         uint16\_t tls\_comp\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00401}00401 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00402}00402         os = tls-\/>ocf\_session;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00403}00403         hdr = (\textcolor{keyword}{const} \textcolor{keyword}{struct }tls\_record\_layer *)m-\/>m\_epg\_hdr;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00404}00404         crp = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00405}00405         uio = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_ac33685772fc914891dc8f02ba59a1800}{uio}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00406}00406 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00407}00407         \mbox{\hyperlink{crypto_8c_ae3902a698a5f6f82412f2d01fb61b55b}{crypto\_initreq}}(crp, os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00408}00408 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00409}00409         \textcolor{comment}{/* Setup the IV. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00410}00410         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}}) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00411}00411                 memcpy(crp-\/>\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, tls-\/>params.iv, TLS\_AEAD\_GCM\_LEN);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00412}00412                 memcpy(crp-\/>\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}} + TLS\_AEAD\_GCM\_LEN, hdr + 1,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00413}00413                     \textcolor{keyword}{sizeof}(uint64\_t));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00414}00414         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00415}00415                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00416}00416 \textcolor{comment}{                 * Chacha20-\/Poly1305 constructs the IV for TLS 1.2}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00417}00417 \textcolor{comment}{                 * identically to constructing the IV for AEAD in TLS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00418}00418 \textcolor{comment}{                 * 1.3.}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00419}00419 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00420}00420                 memcpy(crp-\/>\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, tls-\/>params.iv, tls-\/>params.iv\_len);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00421}00421                 *(uint64\_t *)(crp-\/>\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}} + 4) \string^= htobe64(m-\/>m\_epg\_seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00422}00422         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00423}00423 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00424}00424         \textcolor{comment}{/* Setup the AAD. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00425}00425         ad = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_a0137042149ee72df82f849d0fcd0d0f8}{aead}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00426}00426         tls\_comp\_len = m-\/>m\_len -\/ (m-\/>m\_epg\_hdrlen + m-\/>m\_epg\_trllen);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00427}00427         ad-\/>seq = htobe64(m-\/>m\_epg\_seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00428}00428         ad-\/>type = hdr-\/>tls\_type;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00429}00429         ad-\/>tls\_vmajor = hdr-\/>tls\_vmajor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00430}00430         ad-\/>tls\_vminor = hdr-\/>tls\_vminor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00431}00431         ad-\/>tls\_length = htons(tls\_comp\_len);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00432}00432         crp-\/>\mbox{\hyperlink{structcryptop_a06af2a2f2bf8b27dd93f0703c8ccabec}{crp\_aad}} = ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00433}00433         crp-\/>\mbox{\hyperlink{structcryptop_ace579565d024d6be985951d78da0b42d}{crp\_aad\_length}} = \textcolor{keyword}{sizeof}(*ad);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00434}00434 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00435}00435         \textcolor{comment}{/* Set fields for input payload. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00436}00436         \mbox{\hyperlink{cryptodev_8h_af5a89c7f148a439fe61edf83c81434ff}{crypto\_use\_single\_mbuf}}(crp, m);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00437}00437         crp-\/>\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} = m-\/>m\_epg\_hdrlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00438}00438         crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} = tls\_comp\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00439}00439 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00440}00440         \textcolor{keywordflow}{if} (outiov != NULL) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00441}00441                 crp-\/>\mbox{\hyperlink{structcryptop_ab21b34eea16b6607737a7e506af1605a}{crp\_digest\_start}} = crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00442}00442 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00443}00443                 uio-\/>uio\_iov = outiov;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00444}00444                 uio-\/>uio\_iovcnt = outiovcnt;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00445}00445                 uio-\/>uio\_offset = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00446}00446                 uio-\/>uio\_segflg = UIO\_SYSSPACE;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00447}00447                 uio-\/>uio\_td = curthread;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00448}00448                 uio-\/>uio\_resid = crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} + tls-\/>params.tls\_tlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00449}00449                 \mbox{\hyperlink{cryptodev_8h_aa788a7a3c46d67cfd0226017ed28191c}{crypto\_use\_output\_uio}}(crp, uio);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00450}00450         \} \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00451}00451                 crp-\/>\mbox{\hyperlink{structcryptop_ab21b34eea16b6607737a7e506af1605a}{crp\_digest\_start}} = crp-\/>\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} +}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00452}00452                     crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00453}00453 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00454}00454         crp-\/>\mbox{\hyperlink{structcryptop_afbee27b48615d717b2dd44252f5661ef}{crp\_op}} = \mbox{\hyperlink{cryptodev_8h_a308ebc4fcf06c890e1fa7803eca03649}{CRYPTO\_OP\_ENCRYPT}} | \mbox{\hyperlink{cryptodev_8h_aab8bb68c196639f4b152663825c689b6}{CRYPTO\_OP\_COMPUTE\_DIGEST}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00455}00455         crp-\/>\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} = \mbox{\hyperlink{cryptodev_8h_a2736b0220d0b0dc9243f4bb88aa6349c}{CRYPTO\_F\_CBIMM}} | \mbox{\hyperlink{cryptodev_8h_a7d342342af088db7586c133d8ec27f28}{CRYPTO\_F\_IV\_SEPARATE}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00456}00456         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00457}00457                 counter\_u64\_add(ocf\_tls12\_gcm\_encrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00458}00458         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00459}00459                 counter\_u64\_add(ocf\_tls12\_chacha20\_encrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00460}00460         \textcolor{keywordflow}{if} (outiov != NULL)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00461}00461                 counter\_u64\_add(ocf\_separate\_output, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00462}00462         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00463}00463                 counter\_u64\_add(ocf\_inplace, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00464}00464         \textcolor{keywordflow}{if} (tls-\/>sync\_dispatch) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00465}00465                 error = \mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{ktls\_ocf\_dispatch}}(os, crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00466}00466                 \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00467}00467         \} \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00468}00468                 error = \mbox{\hyperlink{ktls__ocf_8c_a8649104385a46f3c7192152cbc8865f9}{ktls\_ocf\_dispatch\_async}}(state, crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00469}00469         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00470}00470 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00471}00471 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00472}00472 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00473}\mbox{\hyperlink{ktls__ocf_8c_a9e4334496d6f5d2a1aa61b4371a8c6c2}{00473}} \mbox{\hyperlink{ktls__ocf_8c_a9e4334496d6f5d2a1aa61b4371a8c6c2}{ktls\_ocf\_tls12\_aead\_decrypt}}(\textcolor{keyword}{struct} ktls\_session *tls,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00474}00474     \textcolor{keyword}{const} \textcolor{keyword}{struct} tls\_record\_layer *hdr, \textcolor{keyword}{struct} mbuf *m, uint64\_t seqno,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00475}00475     \textcolor{keywordtype}{int} *trailer\_len)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00476}00476 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00477}00477         \textcolor{keyword}{struct }tls\_aead\_data ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00478}00478         \textcolor{keyword}{struct }\mbox{\hyperlink{structcryptop}{cryptop}} crp;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00479}00479         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00480}00480         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00481}00481         uint16\_t tls\_comp\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00482}00482 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00483}00483         os = tls-\/>ocf\_session;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00484}00484 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00485}00485         \mbox{\hyperlink{crypto_8c_ae3902a698a5f6f82412f2d01fb61b55b}{crypto\_initreq}}(\&crp, os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00486}00486 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00487}00487         \textcolor{comment}{/* Setup the IV. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00488}00488         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}}) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00489}00489                 memcpy(crp.\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, tls-\/>params.iv, TLS\_AEAD\_GCM\_LEN);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00490}00490                 memcpy(crp.\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}} + TLS\_AEAD\_GCM\_LEN, hdr + 1,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00491}00491                     \textcolor{keyword}{sizeof}(uint64\_t));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00492}00492         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00493}00493                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00494}00494 \textcolor{comment}{                 * Chacha20-\/Poly1305 constructs the IV for TLS 1.2}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00495}00495 \textcolor{comment}{                 * identically to constructing the IV for AEAD in TLS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00496}00496 \textcolor{comment}{                 * 1.3.}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00497}00497 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00498}00498                 memcpy(crp.\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, tls-\/>params.iv, tls-\/>params.iv\_len);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00499}00499                 *(uint64\_t *)(crp.\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}} + 4) \string^= htobe64(seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00500}00500         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00501}00501 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00502}00502         \textcolor{comment}{/* Setup the AAD. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00503}00503         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00504}00504                 tls\_comp\_len = ntohs(hdr-\/>tls\_length) -\/}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00505}00505                     (\mbox{\hyperlink{cryptodev_8h_a95bcdcbda80aacecdac6d55a25c79893}{AES\_GMAC\_HASH\_LEN}} + \textcolor{keyword}{sizeof}(uint64\_t));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00506}00506         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00507}00507                 tls\_comp\_len = ntohs(hdr-\/>tls\_length) -\/ \mbox{\hyperlink{cryptodev_8h_aea4eabbeeb4ef6aa2f4b6dd53c0c5add}{POLY1305\_HASH\_LEN}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00508}00508         ad.seq = htobe64(seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00509}00509         ad.type = hdr-\/>tls\_type;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00510}00510         ad.tls\_vmajor = hdr-\/>tls\_vmajor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00511}00511         ad.tls\_vminor = hdr-\/>tls\_vminor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00512}00512         ad.tls\_length = htons(tls\_comp\_len);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00513}00513         crp.\mbox{\hyperlink{structcryptop_a06af2a2f2bf8b27dd93f0703c8ccabec}{crp\_aad}} = \&ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00514}00514         crp.\mbox{\hyperlink{structcryptop_ace579565d024d6be985951d78da0b42d}{crp\_aad\_length}} = \textcolor{keyword}{sizeof}(ad);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00515}00515 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00516}00516         crp.\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} = tls-\/>params.tls\_hlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00517}00517         crp.\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} = tls\_comp\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00518}00518         crp.\mbox{\hyperlink{structcryptop_ab21b34eea16b6607737a7e506af1605a}{crp\_digest\_start}} = crp.\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} + crp.\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00519}00519 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00520}00520         crp.\mbox{\hyperlink{structcryptop_afbee27b48615d717b2dd44252f5661ef}{crp\_op}} = \mbox{\hyperlink{cryptodev_8h_a492115d357c83ed96d939c1f9cf96a4d}{CRYPTO\_OP\_DECRYPT}} | \mbox{\hyperlink{cryptodev_8h_ac0fa98eb80caecba8e0468b6756a2d93}{CRYPTO\_OP\_VERIFY\_DIGEST}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00521}00521         crp.\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} = \mbox{\hyperlink{cryptodev_8h_a2736b0220d0b0dc9243f4bb88aa6349c}{CRYPTO\_F\_CBIMM}} | \mbox{\hyperlink{cryptodev_8h_a7d342342af088db7586c133d8ec27f28}{CRYPTO\_F\_IV\_SEPARATE}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00522}00522         \mbox{\hyperlink{cryptodev_8h_a6d92510388352ff97ff77857e093e354}{crypto\_use\_mbuf}}(\&crp, m);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00523}00523 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00524}00524         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00525}00525                 counter\_u64\_add(ocf\_tls12\_gcm\_decrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00526}00526         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00527}00527                 counter\_u64\_add(ocf\_tls12\_chacha20\_decrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00528}00528         error = \mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{ktls\_ocf\_dispatch}}(os, \&crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00529}00529 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00530}00530         \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(\&crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00531}00531         *trailer\_len = tls-\/>params.tls\_tlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00532}00532         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00533}00533 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00534}00534 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00535}00535 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00536}\mbox{\hyperlink{ktls__ocf_8c_a4a18e0c6766e0f6a4fcd22f7baf615a9}{00536}} \mbox{\hyperlink{ktls__ocf_8c_a4a18e0c6766e0f6a4fcd22f7baf615a9}{ktls\_ocf\_tls13\_aead\_encrypt}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structktls__ocf__encrypt__state}{ktls\_ocf\_encrypt\_state}} *state,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00537}00537     \textcolor{keyword}{struct} ktls\_session *tls, \textcolor{keyword}{struct} mbuf *m, \textcolor{keyword}{struct} iovec *outiov,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00538}00538     \textcolor{keywordtype}{int} outiovcnt)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00539}00539 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00540}00540         \textcolor{keyword}{const} \textcolor{keyword}{struct }tls\_record\_layer *hdr;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00541}00541         \textcolor{keyword}{struct }uio *uio;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00542}00542         \textcolor{keyword}{struct }tls\_aead\_data\_13 *ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00543}00543         \textcolor{keyword}{struct }\mbox{\hyperlink{structcryptop}{cryptop}} *crp;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00544}00544         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00545}00545         \textcolor{keywordtype}{char} nonce[12];}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00546}00546         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00547}00547 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00548}00548         os = tls-\/>ocf\_session;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00549}00549         hdr = (\textcolor{keyword}{const} \textcolor{keyword}{struct }tls\_record\_layer *)m-\/>m\_epg\_hdr;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00550}00550         crp = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_acc88ee24485ecdb3b769c078e2a46a9d}{crp}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00551}00551         uio = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_ac33685772fc914891dc8f02ba59a1800}{uio}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00552}00552 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00553}00553         \mbox{\hyperlink{crypto_8c_ae3902a698a5f6f82412f2d01fb61b55b}{crypto\_initreq}}(crp, os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00554}00554 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00555}00555         \textcolor{comment}{/* Setup the nonce. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00556}00556         memcpy(nonce, tls-\/>params.iv, tls-\/>params.iv\_len);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00557}00557         *(uint64\_t *)(nonce + 4) \string^= htobe64(m-\/>m\_epg\_seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00558}00558 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00559}00559         \textcolor{comment}{/* Setup the AAD. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00560}00560         ad = \&state-\/>\mbox{\hyperlink{structktls__ocf__encrypt__state_a3c7813704eb241e07113fda773456a96}{aead13}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00561}00561         ad-\/>type = hdr-\/>tls\_type;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00562}00562         ad-\/>tls\_vmajor = hdr-\/>tls\_vmajor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00563}00563         ad-\/>tls\_vminor = hdr-\/>tls\_vminor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00564}00564         ad-\/>tls\_length = hdr-\/>tls\_length;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00565}00565         crp-\/>\mbox{\hyperlink{structcryptop_a06af2a2f2bf8b27dd93f0703c8ccabec}{crp\_aad}} = ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00566}00566         crp-\/>\mbox{\hyperlink{structcryptop_ace579565d024d6be985951d78da0b42d}{crp\_aad\_length}} = \textcolor{keyword}{sizeof}(*ad);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00567}00567 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00568}00568         \textcolor{comment}{/* Set fields for input payload. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00569}00569         \mbox{\hyperlink{cryptodev_8h_af5a89c7f148a439fe61edf83c81434ff}{crypto\_use\_single\_mbuf}}(crp, m);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00570}00570         crp-\/>\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} = m-\/>m\_epg\_hdrlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00571}00571         crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} = m-\/>m\_len -\/}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00572}00572             (m-\/>m\_epg\_hdrlen + m-\/>m\_epg\_trllen);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00573}00573 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00574}00574         \textcolor{comment}{/* Store the record type as the first byte of the trailer. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00575}00575         m-\/>m\_epg\_trail[0] = m-\/>m\_epg\_record\_type;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00576}00576         crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}}++;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00577}00577 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00578}00578         \textcolor{keywordflow}{if} (outiov != NULL) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00579}00579                 crp-\/>\mbox{\hyperlink{structcryptop_ab21b34eea16b6607737a7e506af1605a}{crp\_digest\_start}} = crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00580}00580 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00581}00581                 uio-\/>uio\_iov = outiov;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00582}00582                 uio-\/>uio\_iovcnt = outiovcnt;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00583}00583                 uio-\/>uio\_offset = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00584}00584                 uio-\/>uio\_segflg = UIO\_SYSSPACE;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00585}00585                 uio-\/>uio\_td = curthread;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00586}00586                 uio-\/>uio\_resid = m-\/>m\_len -\/ m-\/>m\_epg\_hdrlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00587}00587                 \mbox{\hyperlink{cryptodev_8h_aa788a7a3c46d67cfd0226017ed28191c}{crypto\_use\_output\_uio}}(crp, uio);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00588}00588         \} \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00589}00589                 crp-\/>\mbox{\hyperlink{structcryptop_ab21b34eea16b6607737a7e506af1605a}{crp\_digest\_start}} = crp-\/>\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} +}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00590}00590                     crp-\/>\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00591}00591 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00592}00592         crp-\/>\mbox{\hyperlink{structcryptop_afbee27b48615d717b2dd44252f5661ef}{crp\_op}} = \mbox{\hyperlink{cryptodev_8h_a308ebc4fcf06c890e1fa7803eca03649}{CRYPTO\_OP\_ENCRYPT}} | \mbox{\hyperlink{cryptodev_8h_aab8bb68c196639f4b152663825c689b6}{CRYPTO\_OP\_COMPUTE\_DIGEST}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00593}00593         crp-\/>\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} = \mbox{\hyperlink{cryptodev_8h_a2736b0220d0b0dc9243f4bb88aa6349c}{CRYPTO\_F\_CBIMM}} | \mbox{\hyperlink{cryptodev_8h_a7d342342af088db7586c133d8ec27f28}{CRYPTO\_F\_IV\_SEPARATE}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00594}00594 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00595}00595         memcpy(crp-\/>\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, nonce, \textcolor{keyword}{sizeof}(nonce));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00596}00596 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00597}00597         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00598}00598                 counter\_u64\_add(ocf\_tls13\_gcm\_encrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00599}00599         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00600}00600                 counter\_u64\_add(ocf\_tls13\_chacha20\_encrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00601}00601         \textcolor{keywordflow}{if} (outiov != NULL)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00602}00602                 counter\_u64\_add(ocf\_separate\_output, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00603}00603         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00604}00604                 counter\_u64\_add(ocf\_inplace, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00605}00605         \textcolor{keywordflow}{if} (tls-\/>sync\_dispatch) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00606}00606                 error = \mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{ktls\_ocf\_dispatch}}(os, crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00607}00607                 \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00608}00608         \} \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00609}00609                 error = \mbox{\hyperlink{ktls__ocf_8c_a8649104385a46f3c7192152cbc8865f9}{ktls\_ocf\_dispatch\_async}}(state, crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00610}00610         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00611}00611 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00612}00612 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00613}00613 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00614}\mbox{\hyperlink{ktls__ocf_8c_a128decb3d47f79f8e2c722588d097094}{00614}} \mbox{\hyperlink{ktls__ocf_8c_a128decb3d47f79f8e2c722588d097094}{ktls\_ocf\_tls13\_aead\_decrypt}}(\textcolor{keyword}{struct} ktls\_session *tls,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00615}00615     \textcolor{keyword}{const} \textcolor{keyword}{struct} tls\_record\_layer *hdr, \textcolor{keyword}{struct} mbuf *m, uint64\_t seqno,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00616}00616     \textcolor{keywordtype}{int} *trailer\_len)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00617}00617 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00618}00618         \textcolor{keyword}{struct }tls\_aead\_data\_13 ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00619}00619         \textcolor{keyword}{struct }\mbox{\hyperlink{structcryptop}{cryptop}} crp;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00620}00620         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00621}00621         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00622}00622         u\_int tag\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00623}00623 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00624}00624         os = tls-\/>ocf\_session;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00625}00625 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00626}00626         tag\_len = tls-\/>params.tls\_tlen -\/ 1;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00627}00627 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00628}00628         \textcolor{comment}{/* Payload must contain at least one byte for the record type. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00629}00629         \textcolor{keywordflow}{if} (ntohs(hdr-\/>tls\_length) < tag\_len + 1)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00630}00630                 \textcolor{keywordflow}{return} (EBADMSG);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00631}00631 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00632}00632         \mbox{\hyperlink{crypto_8c_ae3902a698a5f6f82412f2d01fb61b55b}{crypto\_initreq}}(\&crp, os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00633}00633 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00634}00634         \textcolor{comment}{/* Setup the nonce. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00635}00635         memcpy(crp.\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}}, tls-\/>params.iv, tls-\/>params.iv\_len);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00636}00636         *(uint64\_t *)(crp.\mbox{\hyperlink{structcryptop_a11aeb40d186d2b67cd35c60e78d6795e}{crp\_iv}} + 4) \string^= htobe64(seqno);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00637}00637 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00638}00638         \textcolor{comment}{/* Setup the AAD. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00639}00639         ad.type = hdr-\/>tls\_type;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00640}00640         ad.tls\_vmajor = hdr-\/>tls\_vmajor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00641}00641         ad.tls\_vminor = hdr-\/>tls\_vminor;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00642}00642         ad.tls\_length = hdr-\/>tls\_length;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00643}00643         crp.\mbox{\hyperlink{structcryptop_a06af2a2f2bf8b27dd93f0703c8ccabec}{crp\_aad}} = \&ad;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00644}00644         crp.\mbox{\hyperlink{structcryptop_ace579565d024d6be985951d78da0b42d}{crp\_aad\_length}} = \textcolor{keyword}{sizeof}(ad);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00645}00645 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00646}00646         crp.\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} = tls-\/>params.tls\_hlen;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00647}00647         crp.\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}} = ntohs(hdr-\/>tls\_length) -\/ tag\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00648}00648         crp.\mbox{\hyperlink{structcryptop_ab21b34eea16b6607737a7e506af1605a}{crp\_digest\_start}} = crp.\mbox{\hyperlink{structcryptop_a3a943098cd2d72c21d2b06ce4113b6ac}{crp\_payload\_start}} + crp.\mbox{\hyperlink{structcryptop_a3ded5aae79556d1fabcb71843b5d55ec}{crp\_payload\_length}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00649}00649 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00650}00650         crp.\mbox{\hyperlink{structcryptop_afbee27b48615d717b2dd44252f5661ef}{crp\_op}} = \mbox{\hyperlink{cryptodev_8h_a492115d357c83ed96d939c1f9cf96a4d}{CRYPTO\_OP\_DECRYPT}} | \mbox{\hyperlink{cryptodev_8h_ac0fa98eb80caecba8e0468b6756a2d93}{CRYPTO\_OP\_VERIFY\_DIGEST}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00651}00651         crp.\mbox{\hyperlink{structcryptop_a920dac304b7724622e0e87f1c38f058f}{crp\_flags}} = \mbox{\hyperlink{cryptodev_8h_a2736b0220d0b0dc9243f4bb88aa6349c}{CRYPTO\_F\_CBIMM}} | \mbox{\hyperlink{cryptodev_8h_a7d342342af088db7586c133d8ec27f28}{CRYPTO\_F\_IV\_SEPARATE}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00652}00652         \mbox{\hyperlink{cryptodev_8h_a6d92510388352ff97ff77857e093e354}{crypto\_use\_mbuf}}(\&crp, m);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00653}00653 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00654}00654         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}})}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00655}00655                 counter\_u64\_add(ocf\_tls13\_gcm\_decrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00656}00656         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00657}00657                 counter\_u64\_add(ocf\_tls13\_chacha20\_decrypts, 1);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00658}00658         error = \mbox{\hyperlink{ktls__ocf_8c_a9c039ace1581db01afaebe396e90ffa9}{ktls\_ocf\_dispatch}}(os, \&crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00659}00659 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00660}00660         \mbox{\hyperlink{crypto_8c_aedb38a47b4abc6224d53867846b463bb}{crypto\_destroyreq}}(\&crp);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00661}00661         *trailer\_len = tag\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00662}00662         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00663}00663 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00664}00664 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00665}00665 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00666}\mbox{\hyperlink{ktls_8h_af0292d6062ad1c0f14769b2565bd9bc7}{00666}} \mbox{\hyperlink{ktls__ocf_8c_af0292d6062ad1c0f14769b2565bd9bc7}{ktls\_ocf\_free}}(\textcolor{keyword}{struct} ktls\_session *tls)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00667}00667 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00668}00668         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00669}00669 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00670}00670         os = tls-\/>ocf\_session;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00671}00671         \mbox{\hyperlink{crypto_8c_a1e5b9ab6a05e445d9e87f3efb49add06}{crypto\_freesession}}(os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00672}00672         mtx\_destroy(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00673}00673         zfree(os, M\_KTLS\_OCF);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00674}00674 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00675}00675 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00676}00676 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00677}\mbox{\hyperlink{ktls_8h_a9414f5736e1a6d96ee0b4e2051afdbe8}{00677}} \mbox{\hyperlink{ktls__ocf_8c_a9414f5736e1a6d96ee0b4e2051afdbe8}{ktls\_ocf\_try}}(\textcolor{keyword}{struct} socket *so, \textcolor{keyword}{struct} ktls\_session *tls, \textcolor{keywordtype}{int} direction)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00678}00678 \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00679}00679         \textcolor{keyword}{struct }\mbox{\hyperlink{structcrypto__session__params}{crypto\_session\_params}} \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}, mac\_csp;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00680}00680         \textcolor{keyword}{struct }\mbox{\hyperlink{structktls__ocf__session}{ktls\_ocf\_session}} *os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00681}00681         \textcolor{keywordtype}{int} error, \mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00682}00682 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00683}00683         memset(\&\mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}, 0, \textcolor{keyword}{sizeof}(\mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00684}00684         memset(\&mac\_csp, 0, \textcolor{keyword}{sizeof}(mac\_csp));}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00685}00685         mac\_csp.\mbox{\hyperlink{structcrypto__session__params_acfa0c09adfa2af792584f68c4e791ea0}{csp\_mode}} = \mbox{\hyperlink{cryptodev_8h_a54a2aabc68a896c51a007a50aa947bae}{CSP\_MODE\_NONE}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00686}00686         \mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} = 0;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00687}00687 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00688}00688         \textcolor{keywordflow}{switch} (tls-\/>params.cipher\_algorithm) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00689}00689         \textcolor{keywordflow}{case} \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00690}00690                 \textcolor{keywordflow}{switch} (tls-\/>params.cipher\_key\_len) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00691}00691                 \textcolor{keywordflow}{case} 128 / 8:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00692}00692                 \textcolor{keywordflow}{case} 256 / 8:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00693}00693                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00694}00694                 \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00695}00695                         \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00696}00696                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00697}00697 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00698}00698                 \textcolor{comment}{/* Only TLS 1.2 and 1.3 are supported. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00699}00699                 \textcolor{keywordflow}{if} (tls-\/>params.tls\_vmajor != TLS\_MAJOR\_VER\_ONE ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00700}00700                     tls-\/>params.tls\_vminor < TLS\_MINOR\_VER\_TWO ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00701}00701                     tls-\/>params.tls\_vminor > TLS\_MINOR\_VER\_THREE)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00702}00702                         \textcolor{keywordflow}{return} (EPROTONOSUPPORT);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00703}00703 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00704}00704                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_ac889cab24a8e813b238b40d5408590d7}{csp\_flags}} |= \mbox{\hyperlink{cryptodev_8h_af47b09e6bd73edca92a70088b074963f}{CSP\_F\_SEPARATE\_OUTPUT}} | \mbox{\hyperlink{cryptodev_8h_a07e30917d64f229cf8d0be6bb9dd18b6}{CSP\_F\_SEPARATE\_AAD}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00705}00705                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_acfa0c09adfa2af792584f68c4e791ea0}{csp\_mode}} = \mbox{\hyperlink{cryptodev_8h_a192b14004af3e22e95f59aef515453ca}{CSP\_MODE\_AEAD}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00706}00706                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_aedcb92e9d97b3936065dd5d2f3e35795}{csp\_cipher\_alg}} = \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00707}00707                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_acb03603f2d528f63db6f04697d4f35fd}{csp\_cipher\_key}} = tls-\/>params.cipher\_key;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00708}00708                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_a2d1bde3549ba4427155118663392b568}{csp\_cipher\_klen}} = tls-\/>params.cipher\_key\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00709}00709                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_a2842a4cc524d39f9a68e4bce28fcd429}{csp\_ivlen}} = \mbox{\hyperlink{cryptodev_8h_ab56cf0e4c330a877c149eb5d41a4fa8f}{AES\_GCM\_IV\_LEN}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00710}00710                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00711}00711         \textcolor{keywordflow}{case} \mbox{\hyperlink{cryptodev_8h_a28e9f7ce2ceb8ae28fc19c18c65f97f6}{CRYPTO\_AES\_CBC}}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00712}00712                 \textcolor{keywordflow}{switch} (tls-\/>params.cipher\_key\_len) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00713}00713                 \textcolor{keywordflow}{case} 128 / 8:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00714}00714                 \textcolor{keywordflow}{case} 256 / 8:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00715}00715                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00716}00716                 \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00717}00717                         \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00718}00718                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00719}00719 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00720}00720                 \textcolor{keywordflow}{switch} (tls-\/>params.auth\_algorithm) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00721}00721                 \textcolor{keywordflow}{case} \mbox{\hyperlink{cryptodev_8h_a3e1d6229f4614428d2f10c58fbc5a807}{CRYPTO\_SHA1\_HMAC}}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00722}00722                         \mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} = \mbox{\hyperlink{cryptodev_8h_abc253430c98bab25e98aa93483fd6ce7}{SHA1\_HASH\_LEN}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00723}00723                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00724}00724                 \textcolor{keywordflow}{case} \mbox{\hyperlink{cryptodev_8h_ac358ddc2cec141463613a1be15ea8dc5}{CRYPTO\_SHA2\_256\_HMAC}}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00725}00725                         \mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} = \mbox{\hyperlink{cryptodev_8h_afbd4febd20a225f5503ad4162ea74251}{SHA2\_256\_HASH\_LEN}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00726}00726                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00727}00727                 \textcolor{keywordflow}{case} \mbox{\hyperlink{cryptodev_8h_a8b54ddf724dd5b486d955a0a3f4abcd3}{CRYPTO\_SHA2\_384\_HMAC}}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00728}00728                         \mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} = \mbox{\hyperlink{cryptodev_8h_a65adb708ef4c0abd4722885ec8740e60}{SHA2\_384\_HASH\_LEN}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00729}00729                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00730}00730                 \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00731}00731                         \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00732}00732                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00733}00733 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00734}00734                 \textcolor{comment}{/* Only TLS 1.0-\/1.2 are supported. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00735}00735                 \textcolor{keywordflow}{if} (tls-\/>params.tls\_vmajor != TLS\_MAJOR\_VER\_ONE ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00736}00736                     tls-\/>params.tls\_vminor < TLS\_MINOR\_VER\_ZERO ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00737}00737                     tls-\/>params.tls\_vminor > TLS\_MINOR\_VER\_TWO)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00738}00738                         \textcolor{keywordflow}{return} (EPROTONOSUPPORT);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00739}00739 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00740}00740                 \textcolor{comment}{/* AES-\/CBC is not supported for receive. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00741}00741                 \textcolor{keywordflow}{if} (direction == KTLS\_RX)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00742}00742                         \textcolor{keywordflow}{return} (EPROTONOSUPPORT);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00743}00743 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00744}00744                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_ac889cab24a8e813b238b40d5408590d7}{csp\_flags}} |= \mbox{\hyperlink{cryptodev_8h_af47b09e6bd73edca92a70088b074963f}{CSP\_F\_SEPARATE\_OUTPUT}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00745}00745                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_acfa0c09adfa2af792584f68c4e791ea0}{csp\_mode}} = \mbox{\hyperlink{cryptodev_8h_a75f7617514227e0eef21b50fe1809f1c}{CSP\_MODE\_CIPHER}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00746}00746                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_aedcb92e9d97b3936065dd5d2f3e35795}{csp\_cipher\_alg}} = \mbox{\hyperlink{cryptodev_8h_a28e9f7ce2ceb8ae28fc19c18c65f97f6}{CRYPTO\_AES\_CBC}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00747}00747                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_acb03603f2d528f63db6f04697d4f35fd}{csp\_cipher\_key}} = tls-\/>params.cipher\_key;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00748}00748                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_a2d1bde3549ba4427155118663392b568}{csp\_cipher\_klen}} = tls-\/>params.cipher\_key\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00749}00749                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_a2842a4cc524d39f9a68e4bce28fcd429}{csp\_ivlen}} = \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00750}00750 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00751}00751                 mac\_csp.\mbox{\hyperlink{structcrypto__session__params_ac889cab24a8e813b238b40d5408590d7}{csp\_flags}} |= \mbox{\hyperlink{cryptodev_8h_af47b09e6bd73edca92a70088b074963f}{CSP\_F\_SEPARATE\_OUTPUT}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00752}00752                 mac\_csp.\mbox{\hyperlink{structcrypto__session__params_acfa0c09adfa2af792584f68c4e791ea0}{csp\_mode}} = \mbox{\hyperlink{cryptodev_8h_a1786cb220ec95419fca65e0a1116cae3}{CSP\_MODE\_DIGEST}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00753}00753                 mac\_csp.\mbox{\hyperlink{structcrypto__session__params_a90c375669bd96c3f9b423788a469a413}{csp\_auth\_alg}} = tls-\/>params.auth\_algorithm;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00754}00754                 mac\_csp.\mbox{\hyperlink{structcrypto__session__params_a2f67f04893c6ef7ddab12a5aca346a97}{csp\_auth\_key}} = tls-\/>params.auth\_key;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00755}00755                 mac\_csp.\mbox{\hyperlink{structcrypto__session__params_a699c3e19c0c0ea86bcca5da38d7c8675}{csp\_auth\_klen}} = tls-\/>params.auth\_key\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00756}00756                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00757}00757         \textcolor{keywordflow}{case} \mbox{\hyperlink{cryptodev_8h_a802780bb96ef9c241b77c3a84d29a9a4}{CRYPTO\_CHACHA20\_POLY1305}}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00758}00758                 \textcolor{keywordflow}{switch} (tls-\/>params.cipher\_key\_len) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00759}00759                 \textcolor{keywordflow}{case} 256 / 8:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00760}00760                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00761}00761                 \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00762}00762                         \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00763}00763                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00764}00764 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00765}00765                 \textcolor{comment}{/* Only TLS 1.2 and 1.3 are supported. */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00766}00766                 \textcolor{keywordflow}{if} (tls-\/>params.tls\_vmajor != TLS\_MAJOR\_VER\_ONE ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00767}00767                     tls-\/>params.tls\_vminor < TLS\_MINOR\_VER\_TWO ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00768}00768                     tls-\/>params.tls\_vminor > TLS\_MINOR\_VER\_THREE)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00769}00769                         \textcolor{keywordflow}{return} (EPROTONOSUPPORT);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00770}00770 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00771}00771                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_ac889cab24a8e813b238b40d5408590d7}{csp\_flags}} |= \mbox{\hyperlink{cryptodev_8h_af47b09e6bd73edca92a70088b074963f}{CSP\_F\_SEPARATE\_OUTPUT}} | \mbox{\hyperlink{cryptodev_8h_a07e30917d64f229cf8d0be6bb9dd18b6}{CSP\_F\_SEPARATE\_AAD}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00772}00772                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_acfa0c09adfa2af792584f68c4e791ea0}{csp\_mode}} = \mbox{\hyperlink{cryptodev_8h_a192b14004af3e22e95f59aef515453ca}{CSP\_MODE\_AEAD}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00773}00773                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_aedcb92e9d97b3936065dd5d2f3e35795}{csp\_cipher\_alg}} = \mbox{\hyperlink{cryptodev_8h_a802780bb96ef9c241b77c3a84d29a9a4}{CRYPTO\_CHACHA20\_POLY1305}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00774}00774                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_acb03603f2d528f63db6f04697d4f35fd}{csp\_cipher\_key}} = tls-\/>params.cipher\_key;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00775}00775                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_a2d1bde3549ba4427155118663392b568}{csp\_cipher\_klen}} = tls-\/>params.cipher\_key\_len;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00776}00776                 \mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}}.\mbox{\hyperlink{structcrypto__session__params_a2842a4cc524d39f9a68e4bce28fcd429}{csp\_ivlen}} = \mbox{\hyperlink{cryptodev_8h_ace9ce46ec91c53b7ab0eb75311a58deb}{CHACHA20\_POLY1305\_IV\_LEN}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00777}00777                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00778}00778         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00779}00779                 \textcolor{keywordflow}{return} (EPROTONOSUPPORT);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00780}00780         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00781}00781 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00782}00782         os = malloc(\textcolor{keyword}{sizeof}(*os), M\_KTLS\_OCF, M\_NOWAIT | M\_ZERO);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00783}00783         \textcolor{keywordflow}{if} (os == NULL)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00784}00784                 \textcolor{keywordflow}{return} (ENOMEM);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00785}00785 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00786}00786         error = \mbox{\hyperlink{crypto_8c_a7a9e78f78b77c6d2df3b53992a4f1fd2}{crypto\_newsession}}(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}}, \&\mbox{\hyperlink{cryptodev__if_8m_ad4c1657296cb58a638d6106e84afd30a}{csp}},}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00787}00787             \mbox{\hyperlink{cryptodev_8h_a180a7849c8d85a662eaec80ce75e24e5}{CRYPTO\_FLAG\_HARDWARE}} | \mbox{\hyperlink{cryptodev_8h_a6da30bc4a9ef5589e4fb58d5f6e630b7}{CRYPTO\_FLAG\_SOFTWARE}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00788}00788         \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00789}00789                 free(os, M\_KTLS\_OCF);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00790}00790                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00791}00791         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00792}00792 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00793}00793         \textcolor{keywordflow}{if} (mac\_csp.\mbox{\hyperlink{structcrypto__session__params_acfa0c09adfa2af792584f68c4e791ea0}{csp\_mode}} != \mbox{\hyperlink{cryptodev_8h_a54a2aabc68a896c51a007a50aa947bae}{CSP\_MODE\_NONE}}) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00794}00794                 error = \mbox{\hyperlink{crypto_8c_a7a9e78f78b77c6d2df3b53992a4f1fd2}{crypto\_newsession}}(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a8d19c8b2c220aa8207c4ae7ca7ecf1cf}{mac\_sid}}, \&mac\_csp,}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00795}00795                     \mbox{\hyperlink{cryptodev_8h_a180a7849c8d85a662eaec80ce75e24e5}{CRYPTO\_FLAG\_HARDWARE}} | \mbox{\hyperlink{cryptodev_8h_a6da30bc4a9ef5589e4fb58d5f6e630b7}{CRYPTO\_FLAG\_SOFTWARE}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00796}00796                 \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00797}00797                         \mbox{\hyperlink{crypto_8c_a1e5b9ab6a05e445d9e87f3efb49add06}{crypto\_freesession}}(os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00798}00798                         free(os, M\_KTLS\_OCF);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00799}00799                         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00800}00800                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00801}00801                 os-\/>\mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}} = \mbox{\hyperlink{structktls__ocf__session_a89e75a66d40bf644c75486fc30174afb}{mac\_len}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00802}00802         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00803}00803 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00804}00804         mtx\_init(\&os-\/>\mbox{\hyperlink{structktls__ocf__session_a69519ecf6ca51bbcb72dbaa38b406984}{lock}}, \textcolor{stringliteral}{"{}ktls\_ocf"{}}, NULL, MTX\_DEF);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00805}00805         tls-\/>ocf\_session = os;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00806}00806         \textcolor{keywordflow}{if} (tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a250e97ea4137501b4a8a7f28e20da3a6}{CRYPTO\_AES\_NIST\_GCM\_16}} ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00807}00807             tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a802780bb96ef9c241b77c3a84d29a9a4}{CRYPTO\_CHACHA20\_POLY1305}}) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00808}00808                 \textcolor{keywordflow}{if} (direction == KTLS\_TX) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00809}00809                         \textcolor{keywordflow}{if} (tls-\/>params.tls\_vminor == TLS\_MINOR\_VER\_THREE)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00810}00810                                 tls-\/>sw\_encrypt = \mbox{\hyperlink{ktls__ocf_8c_a4a18e0c6766e0f6a4fcd22f7baf615a9}{ktls\_ocf\_tls13\_aead\_encrypt}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00811}00811                         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00812}00812                                 tls-\/>sw\_encrypt = \mbox{\hyperlink{ktls__ocf_8c_abc66f8c39c3a09ad85eac9556f7cbe43}{ktls\_ocf\_tls12\_aead\_encrypt}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00813}00813                 \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00814}00814                         \textcolor{keywordflow}{if} (tls-\/>params.tls\_vminor == TLS\_MINOR\_VER\_THREE)}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00815}00815                                 tls-\/>sw\_decrypt = \mbox{\hyperlink{ktls__ocf_8c_a128decb3d47f79f8e2c722588d097094}{ktls\_ocf\_tls13\_aead\_decrypt}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00816}00816                         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00817}00817                                 tls-\/>sw\_decrypt = \mbox{\hyperlink{ktls__ocf_8c_a9e4334496d6f5d2a1aa61b4371a8c6c2}{ktls\_ocf\_tls12\_aead\_decrypt}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00818}00818                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00819}00819         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00820}00820                 tls-\/>sw\_encrypt = \mbox{\hyperlink{ktls__ocf_8c_aab3b4a8d61ab4b7a5ba9721a57456d15}{ktls\_ocf\_tls\_cbc\_encrypt}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00821}00821                 \textcolor{keywordflow}{if} (tls-\/>params.tls\_vminor == TLS\_MINOR\_VER\_ZERO) \{}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00822}00822                         os-\/>\mbox{\hyperlink{structktls__ocf__session_acc0ef3a2c7e5356e69f50822949aa5e8}{implicit\_iv}} = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00823}00823                         memcpy(os-\/>\mbox{\hyperlink{structktls__ocf__session_adec2f9991d37683a2ca6dfa2fdab28e5}{iv}}, tls-\/>params.iv, \mbox{\hyperlink{cryptodev_8h_a17c02e9378a5051e9520ae097b090d23}{AES\_BLOCK\_LEN}});}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00824}00824 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00825}00825                         os-\/>next\_seqno = tls-\/>next\_seqno;}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00826}00826 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00827}00827                 \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00828}00828         \}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00829}00829 }
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00830}00830         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00831}00831 \textcolor{comment}{         * AES-\/CBC is always synchronous currently.  Asynchronous}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00832}00832 \textcolor{comment}{         * operation would require multiple callbacks and an additional}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00833}00833 \textcolor{comment}{         * iovec array in ktls\_ocf\_encrypt\_state.}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00834}00834 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00835}00835         tls-\/>sync\_dispatch = \mbox{\hyperlink{cryptodev_8h_ae6bc2e493daed5397d5b9f8549f5c960}{CRYPTO\_SESS\_SYNC}}(os-\/>\mbox{\hyperlink{structktls__ocf__session_af6c8112736c324db2209dba6ab760609}{sid}}) ||}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00836}00836             tls-\/>params.cipher\_algorithm == \mbox{\hyperlink{cryptodev_8h_a28e9f7ce2ceb8ae28fc19c18c65f97f6}{CRYPTO\_AES\_CBC}};}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00837}00837         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ktls__ocf_8c_source_l00838}00838 \}}

\end{DoxyCode}
