\hypertarget{g__eli__integrity_8c_source}{}\doxysection{g\+\_\+eli\+\_\+integrity.\+c}
\label{g__eli__integrity_8c_source}\index{geom/eli/g\_eli\_integrity.c@{geom/eli/g\_eli\_integrity.c}}
\mbox{\hyperlink{g__eli__integrity_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2005-\/2011 Pawel Jakub Dawidek <pawel@dawidek.net>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00027}00027 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00028}00028 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00029}00029 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00030}\mbox{\hyperlink{g__eli__integrity_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00030}} \mbox{\hyperlink{g__eli__integrity_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00034}00034 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/linker.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <sys/module.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/mutex.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/bio.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/sysctl.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/kthread.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/proc.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/sched.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <sys/smp.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00045}00045 \textcolor{preprocessor}{\#include <sys/vnode.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00046}00046 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <vm/uma.h>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00048}00048 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00049}00049 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{geom_8h}{geom/geom.h}}>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00050}00050 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{geom__dbg_8h}{geom/geom\_dbg.h}}>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00051}00051 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{g__eli_8h}{geom/eli/g\_eli.h}}>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00052}00052 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{pkcs5v2_8h}{geom/eli/pkcs5v2.h}}>}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00053}00053 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00054}00054 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00055}00055 \textcolor{comment}{ * The data layout description when integrity verification is configured.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00056}00056 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00057}00057 \textcolor{comment}{ * One of the most important assumption here is that authenticated data and its}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00058}00058 \textcolor{comment}{ * HMAC has to be stored in the same place (namely in the same sector) to make}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00059}00059 \textcolor{comment}{ * it work reliable.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00060}00060 \textcolor{comment}{ * The problem is that file systems work only with sectors that are multiple of}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00061}00061 \textcolor{comment}{ * 512 bytes and a power of two number.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00062}00062 \textcolor{comment}{ * My idea to implement it is as follows.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00063}00063 \textcolor{comment}{ * Let's store HMAC in sector. This is a must. This leaves us 480 bytes for}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00064}00064 \textcolor{comment}{ * data. We can't use that directly (ie. we can't create provider with 480 bytes}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00065}00065 \textcolor{comment}{ * sector size). We need another sector from where we take only 32 bytes of data}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00066}00066 \textcolor{comment}{ * and we store HMAC of this data as well. This takes two sectors from the}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00067}00067 \textcolor{comment}{ * original provider at the input and leaves us one sector of authenticated data}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00068}00068 \textcolor{comment}{ * at the output. Not very efficient, but you got the idea.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00069}00069 \textcolor{comment}{ * Now, let's assume, we want to create provider with 4096 bytes sector.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00070}00070 \textcolor{comment}{ * To output 4096 bytes of authenticated data we need 8x480 plus 1x256, so we}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00071}00071 \textcolor{comment}{ * need nine 512-\/bytes sectors at the input to get one 4096-\/bytes sector at the}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00072}00072 \textcolor{comment}{ * output. That's better. With 4096 bytes sector we can use 89\% of size of the}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00073}00073 \textcolor{comment}{ * original provider. I find it as an acceptable cost.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00074}00074 \textcolor{comment}{ * The reliability comes from the fact, that every HMAC stored inside the sector}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00075}00075 \textcolor{comment}{ * is calculated only for the data in the same sector, so its impossible to}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00076}00076 \textcolor{comment}{ * write new data and leave old HMAC or vice versa.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00077}00077 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00078}00078 \textcolor{comment}{ * And here is the picture:}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00079}00079 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00080}00080 \textcolor{comment}{ * da0: +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/-\/+}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00081}00081 \textcolor{comment}{ *      |32b |480b| |32b |480b| |32b |480b| |32b |480b| |32b |480b| |32b |480b| |32b |480b| |32b |480b| |32b |256b |}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00082}00082 \textcolor{comment}{ *      |HMAC|Data| |HMAC|Data| |HMAC|Data| |HMAC|Data| |HMAC|Data| |HMAC|Data| |HMAC|Data| |HMAC|Data| |HMAC|Data |}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00083}00083 \textcolor{comment}{ *      +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/+ +-\/-\/-\/-\/+-\/-\/-\/-\/-\/+}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00084}00084 \textcolor{comment}{ *      |512 bytes| |512 bytes| |512 bytes| |512 bytes| |512 bytes| |512 bytes| |512 bytes| |512 bytes| |288 bytes |}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00085}00085 \textcolor{comment}{ *      +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ +-\/-\/-\/-\/-\/-\/-\/-\/-\/+ |224 unused|}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00086}00086 \textcolor{comment}{ *                                                                                                      +-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/+}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00087}00087 \textcolor{comment}{ * da0.eli: +-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00088}00088 \textcolor{comment}{ *          |480b|480b|480b|480b|480b|480b|480b|480b|256b|}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00089}00089 \textcolor{comment}{ *          +-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+-\/-\/-\/-\/+}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00090}00090 \textcolor{comment}{ *          |                 4096 bytes                 |}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00091}00091 \textcolor{comment}{ *          +-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/+}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00092}00092 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00093}00093 \textcolor{comment}{ * PS. You can use any sector size with geli(8). My example is using 4kB,}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00094}00094 \textcolor{comment}{ *     because it's most efficient. For 8kB sectors you need 2 extra sectors,}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00095}00095 \textcolor{comment}{ *     so the cost is the same as for 4kB sectors.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00096}00096 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00097}00097 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00098}00098 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00099}00099 \textcolor{comment}{ * Code paths:}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00100}00100 \textcolor{comment}{ * BIO\_READ:}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00101}00101 \textcolor{comment}{ *      g\_eli\_start -\/> g\_eli\_auth\_read -\/> g\_io\_request -\/> g\_eli\_read\_done -\/> g\_eli\_auth\_run -\/> g\_eli\_auth\_read\_done -\/> g\_io\_deliver}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00102}00102 \textcolor{comment}{ * BIO\_WRITE:}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00103}00103 \textcolor{comment}{ *      g\_eli\_start -\/> g\_eli\_auth\_run -\/> g\_eli\_auth\_write\_done -\/> g\_io\_request -\/> g\_eli\_write\_done -\/> g\_io\_deliver}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00104}00104 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00105}00105 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00106}00106 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00107}00107 \textcolor{comment}{ * Here we generate key for HMAC. Every sector has its own HMAC key, so it is}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00108}00108 \textcolor{comment}{ * not possible to copy sectors.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00109}00109 \textcolor{comment}{ * We cannot depend on fact, that every sector has its own IV, because different}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00110}00110 \textcolor{comment}{ * IV doesn't change HMAC, when we use encrypt-\/then-\/authenticate method.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00111}00111 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00112}00112 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00113}\mbox{\hyperlink{g__eli__integrity_8c_a18a8c9bd74793ca44666381e8973f436}{00113}} \mbox{\hyperlink{g__eli__integrity_8c_a18a8c9bd74793ca44666381e8973f436}{g\_eli\_auth\_keygen}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structg__eli__softc}{g\_eli\_softc}} *sc, off\_t \mbox{\hyperlink{g__raid__tr__if_8m_ad5f0842c40c7e46344fd8df70187fa0f}{offset}}, u\_char *key)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00114}00114 \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00115}00115         SHA256\_CTX ctx;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00116}00116 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00117}00117         \textcolor{comment}{/* Copy precalculated SHA256 context. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00118}00118         bcopy(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_ae776cdeaee3f3200f063487b5064d7dd}{sc\_akeyctx}}, \&ctx, \textcolor{keyword}{sizeof}(ctx));}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00119}00119         SHA256\_Update(\&ctx, (\mbox{\hyperlink{binstream_8h_ab077fa1127453be2bd9d4c3c8a768fa7}{uint8\_t}} *)\&\mbox{\hyperlink{g__raid__tr__if_8m_ad5f0842c40c7e46344fd8df70187fa0f}{offset}}, \textcolor{keyword}{sizeof}(\mbox{\hyperlink{g__raid__tr__if_8m_ad5f0842c40c7e46344fd8df70187fa0f}{offset}}));}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00120}00120         SHA256\_Final(key, \&ctx);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00121}00121 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00122}00122 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00123}00123 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00124}00124 \textcolor{comment}{ * The function is called after we read and decrypt data.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00125}00125 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00126}00126 \textcolor{comment}{ * g\_eli\_start -\/> g\_eli\_auth\_read -\/> g\_io\_request -\/> g\_eli\_read\_done -\/> g\_eli\_auth\_run -\/> G\_ELI\_AUTH\_READ\_DONE -\/> g\_io\_deliver}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00127}00127 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00128}00128 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00129}\mbox{\hyperlink{g__eli__integrity_8c_a1ce98ebcc0c42841429c24aa3c3dee42}{00129}} \mbox{\hyperlink{g__eli__integrity_8c_a1ce98ebcc0c42841429c24aa3c3dee42}{g\_eli\_auth\_read\_done}}(\textcolor{keyword}{struct} cryptop *crp)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00130}00130 \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00131}00131         \textcolor{keyword}{struct }\mbox{\hyperlink{structg__eli__softc}{g\_eli\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00132}00132         \textcolor{keyword}{struct }bio *\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00133}00133 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00134}00134         \textcolor{keywordflow}{if} (crp-\/>crp\_etype == EAGAIN) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00135}00135                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__eli_8c_a579b00aa63d80fcd91e1b8da3e8e5515}{g\_eli\_crypto\_rerun}}(crp) == 0)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00136}00136                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00137}00137         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00138}00138         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}} = (\textcolor{keyword}{struct }bio *)crp-\/>crp\_opaque;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00139}00139         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed++;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00140}00140         sc = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>geom-\/>softc;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00141}00141         if (crp-\/>crp\_etype == 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00142}00142                 \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_completed += crp-\/>crp\_payload\_length;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00143}00143                 \mbox{\hyperlink{g__eli_8h_ad99f556222c6099625689315eadadd9d}{G\_ELI\_DEBUG}}(3, \textcolor{stringliteral}{"{}Crypto READ request done (\%d/\%d) (add=\%d completed=\%jd)."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00144}00144                     \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children, crp-\/>crp\_payload\_length, (intmax\_t)\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_completed);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00145}00145         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00146}00146                 u\_int nsec, decr\_secsize, encr\_secsize, rel\_sec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00147}00147                 \textcolor{keywordtype}{int} *errorp;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00148}00148 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00149}00149                 \textcolor{comment}{/* Sectorsize of decrypted provider eg. 4096. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00150}00150                 decr\_secsize = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00151}00151                 \textcolor{comment}{/* The real sectorsize of encrypted provider, eg. 512. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00152}00152                 encr\_secsize =}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00153}00153                     LIST\_FIRST(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a899949202205997147c78c52b32b9843}{sc\_geom}}-\/>consumer)-\/>provider-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00154}00154                 \textcolor{comment}{/* Number of sectors from decrypted provider, eg. 2. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00155}00155                 nsec = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_length / decr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00156}00156                 \textcolor{comment}{/* Number of sectors from encrypted provider, eg. 18. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00157}00157                 nsec = (nsec * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}}) / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00158}00158                 \textcolor{comment}{/* Which relative sector this request decrypted. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00159}00159                 rel\_sec = ((crp-\/>crp\_buf.cb\_buf + crp-\/>crp\_payload\_start) -\/}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00160}00160                     (\textcolor{keywordtype}{char} *)\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2) / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00161}00161 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00162}00162                 errorp = (\textcolor{keywordtype}{int} *)((\textcolor{keywordtype}{char} *)\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2 + encr\_secsize * nsec +}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00163}00163                     \textcolor{keyword}{sizeof}(int) * rel\_sec);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00164}00164                 *errorp = crp-\/>crp\_etype;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00165}00165                 \mbox{\hyperlink{g__eli_8h_ad99f556222c6099625689315eadadd9d}{G\_ELI\_DEBUG}}(1,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00166}00166                     \textcolor{stringliteral}{"{}Crypto READ request failed (\%d/\%d) error=\%d."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00167}00167                     \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children, crp-\/>crp\_etype);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00168}00168                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error == 0 || \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error == EINTEGRITY)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00169}00169                         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error = crp-\/>crp\_etype == EBADMSG ?}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00170}00170                             EINTEGRITY : crp-\/>crp\_etype;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00171}00171         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00172}00172         \textcolor{keywordflow}{if} (crp-\/>crp\_cipher\_key != NULL)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00173}00173                 \mbox{\hyperlink{g__eli_8h_a6f8aafc6ae8883d71c46a348b8856b28}{g\_eli\_key\_drop}}(sc, \_\_DECONST(\textcolor{keywordtype}{void} *, crp-\/>crp\_cipher\_key));}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00174}00174         crypto\_freereq(crp);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00175}00175         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00176}00176 \textcolor{comment}{         * Do we have all sectors already?}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00177}00177 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00178}00178         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed < \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00179}00179                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00180}00180 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00181}00181         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error == 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00182}00182                 u\_int i, lsec, nsec, data\_secsize, decr\_secsize, encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00183}00183                 u\_char *srcdata, *dstdata;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00184}00184 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00185}00185                 \textcolor{comment}{/* Sectorsize of decrypted provider eg. 4096. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00186}00186                 decr\_secsize = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00187}00187                 \textcolor{comment}{/* The real sectorsize of encrypted provider, eg. 512. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00188}00188                 encr\_secsize = LIST\_FIRST(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a899949202205997147c78c52b32b9843}{sc\_geom}}-\/>consumer)-\/>provider-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00189}00189                 \textcolor{comment}{/* Number of data bytes in one encrypted sector, eg. 480. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00190}00190                 data\_secsize = sc-\/>\mbox{\hyperlink{structg__eli__softc_a7096457a870bb699d5cd9d3beb0313e7}{sc\_data\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00191}00191                 \textcolor{comment}{/* Number of sectors from decrypted provider, eg. 2. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00192}00192                 nsec = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_length / decr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00193}00193                 \textcolor{comment}{/* Number of sectors from encrypted provider, eg. 18. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00194}00194                 nsec = (nsec * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}}) / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00195}00195                 \textcolor{comment}{/* Last sector number in every big sector, eg. 9. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00196}00196                 lsec = sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}} / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00197}00197 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00198}00198                 srcdata = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00199}00199                 dstdata = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_data;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00200}00200 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00201}00201                 \textcolor{keywordflow}{for} (i = 1; i <= nsec; i++) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00202}00202                         data\_secsize = sc-\/>\mbox{\hyperlink{structg__eli__softc_a7096457a870bb699d5cd9d3beb0313e7}{sc\_data\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00203}00203                         \textcolor{keywordflow}{if} ((i \% lsec) == 0)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00204}00204                                 data\_secsize = decr\_secsize \% data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00205}00205                         bcopy(srcdata + sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}}, dstdata, data\_secsize);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00206}00206                         srcdata += encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00207}00207                         dstdata += data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00208}00208                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00209}00209         \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error == EINTEGRITY) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00210}00210                 u\_int i, lsec, nsec, data\_secsize, decr\_secsize, encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00211}00211                 \textcolor{keywordtype}{int} *errorp;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00212}00212                 off\_t coroff, corsize, dstoff;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00213}00213 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00214}00214                 \textcolor{comment}{/* Sectorsize of decrypted provider eg. 4096. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00215}00215                 decr\_secsize = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00216}00216                 \textcolor{comment}{/* The real sectorsize of encrypted provider, eg. 512. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00217}00217                 encr\_secsize = LIST\_FIRST(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a899949202205997147c78c52b32b9843}{sc\_geom}}-\/>consumer)-\/>provider-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00218}00218                 \textcolor{comment}{/* Number of data bytes in one encrypted sector, eg. 480. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00219}00219                 data\_secsize = sc-\/>\mbox{\hyperlink{structg__eli__softc_a7096457a870bb699d5cd9d3beb0313e7}{sc\_data\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00220}00220                 \textcolor{comment}{/* Number of sectors from decrypted provider, eg. 2. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00221}00221                 nsec = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_length / decr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00222}00222                 \textcolor{comment}{/* Number of sectors from encrypted provider, eg. 18. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00223}00223                 nsec = (nsec * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}}) / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00224}00224                 \textcolor{comment}{/* Last sector number in every big sector, eg. 9. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00225}00225                 lsec = sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}} / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00226}00226 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00227}00227                 errorp = (\textcolor{keywordtype}{int} *)((\textcolor{keywordtype}{char} *)\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2 + encr\_secsize * nsec);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00228}00228                 coroff = -\/1;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00229}00229                 corsize = 0;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00230}00230                 dstoff = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_offset;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00231}00231 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00232}00232                 \textcolor{keywordflow}{for} (i = 1; i <= nsec; i++) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00233}00233                         data\_secsize = sc-\/>\mbox{\hyperlink{structg__eli__softc_a7096457a870bb699d5cd9d3beb0313e7}{sc\_data\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00234}00234                         \textcolor{keywordflow}{if} ((i \% lsec) == 0)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00235}00235                                 data\_secsize = decr\_secsize \% data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00236}00236                         \textcolor{keywordflow}{if} (errorp[i -\/ 1] == EBADMSG) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00237}00237                                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00238}00238 \textcolor{comment}{                                 * Corruption detected, remember the offset if}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00239}00239 \textcolor{comment}{                                 * this is the first corrupted sector and}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00240}00240 \textcolor{comment}{                                 * increase size.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00241}00241 \textcolor{comment}{                                 */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00242}00242                                 \textcolor{keywordflow}{if} (coroff == -\/1)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00243}00243                                         coroff = dstoff;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00244}00244                                 corsize += data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00245}00245                         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00246}00246                                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00247}00247 \textcolor{comment}{                                 * No corruption, good.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00248}00248 \textcolor{comment}{                                 * Report previous corruption if there was one.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00249}00249 \textcolor{comment}{                                 */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00250}00250                                 \textcolor{keywordflow}{if} (coroff != -\/1) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00251}00251                                         \mbox{\hyperlink{g__eli_8h_ad99f556222c6099625689315eadadd9d}{G\_ELI\_DEBUG}}(0, \textcolor{stringliteral}{"{}\%s: Failed to authenticate \%jd "{}}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00252}00252                                             \textcolor{stringliteral}{"{}bytes of data at offset \%jd."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00253}00253                                             sc-\/>sc\_name, (intmax\_t)corsize,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00254}00254                                             (intmax\_t)coroff);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00255}00255                                         coroff = -\/1;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00256}00256                                         corsize = 0;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00257}00257                                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00258}00258                         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00259}00259                         dstoff += data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00260}00260                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00261}00261                 \textcolor{comment}{/* Report previous corruption if there was one. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00262}00262                 \textcolor{keywordflow}{if} (coroff != -\/1) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00263}00263                         \mbox{\hyperlink{g__eli_8h_ad99f556222c6099625689315eadadd9d}{G\_ELI\_DEBUG}}(0, \textcolor{stringliteral}{"{}\%s: Failed to authenticate \%jd "{}}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00264}00264                             \textcolor{stringliteral}{"{}bytes of data at offset \%jd."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00265}00265                             sc-\/>sc\_name, (intmax\_t)corsize, (intmax\_t)coroff);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00266}00266                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00267}00267         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00268}00268         \mbox{\hyperlink{g__eli_8c_a85cfec789b20d2d3959b02285e818978}{g\_eli\_free\_data}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00269}00269         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error != 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00270}00270                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error != EINTEGRITY) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00271}00271                         \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(0, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00272}00272                             \textcolor{stringliteral}{"{}Crypto READ request failed (error=\%d)."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00273}00273                             \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00274}00274                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00275}00275                 \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_completed = 0;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00276}00276         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00277}00277         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00278}00278 \textcolor{comment}{         * Read is finished, send it up.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00279}00279 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00280}00280         \mbox{\hyperlink{geom_8h_a0975be2dcd40a26a56a1a9bfc80433e1}{g\_io\_deliver}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00281}00281         atomic\_subtract\_int(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a239cdf3f405f19bdfe897bd9d1de8a37}{sc\_inflight}}, 1);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00282}00282         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00283}00283 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00284}00284 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00285}00285 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00286}00286 \textcolor{comment}{ * The function is called after data encryption.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00287}00287 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00288}00288 \textcolor{comment}{ * g\_eli\_start -\/> g\_eli\_auth\_run -\/> G\_ELI\_AUTH\_WRITE\_DONE -\/> g\_io\_request -\/> g\_eli\_write\_done -\/> g\_io\_deliver}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00289}00289 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00290}00290 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00291}\mbox{\hyperlink{g__eli__integrity_8c_a97f3a5057a7536ae824cbe961778a190}{00291}} \mbox{\hyperlink{g__eli__integrity_8c_a97f3a5057a7536ae824cbe961778a190}{g\_eli\_auth\_write\_done}}(\textcolor{keyword}{struct} cryptop *crp)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00292}00292 \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00293}00293         \textcolor{keyword}{struct }\mbox{\hyperlink{structg__eli__softc}{g\_eli\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00294}00294         \textcolor{keyword}{struct }\mbox{\hyperlink{structg__consumer}{g\_consumer}} *\mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00295}00295         \textcolor{keyword}{struct }bio *\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, *cbp, *cbp2;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00296}00296         u\_int nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00297}00297 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00298}00298         \textcolor{keywordflow}{if} (crp-\/>crp\_etype == EAGAIN) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00299}00299                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__eli_8c_a579b00aa63d80fcd91e1b8da3e8e5515}{g\_eli\_crypto\_rerun}}(crp) == 0)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00300}00300                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00301}00301         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00302}00302         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}} = (\textcolor{keyword}{struct }bio *)crp-\/>crp\_opaque;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00303}00303         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed++;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00304}00304         if (crp-\/>crp\_etype == 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00305}00305                 \mbox{\hyperlink{g__eli_8h_ad99f556222c6099625689315eadadd9d}{G\_ELI\_DEBUG}}(3, \textcolor{stringliteral}{"{}Crypto WRITE request done (\%d/\%d)."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00306}00306                     \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00307}00307         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00308}00308                 \mbox{\hyperlink{g__eli_8h_ad99f556222c6099625689315eadadd9d}{G\_ELI\_DEBUG}}(1, \textcolor{stringliteral}{"{}Crypto WRITE request failed (\%d/\%d) error=\%d."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00309}00309                     \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children, crp-\/>crp\_etype);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00310}00310                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error == 0)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00311}00311                         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error = crp-\/>crp\_etype;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00312}00312         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00313}00313         sc = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>geom-\/>softc;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00314}00314         \textcolor{keywordflow}{if} (crp-\/>crp\_cipher\_key != NULL)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00315}00315                 \mbox{\hyperlink{g__eli_8h_a6f8aafc6ae8883d71c46a348b8856b28}{g\_eli\_key\_drop}}(sc, \_\_DECONST(\textcolor{keywordtype}{void} *, crp-\/>crp\_cipher\_key));}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00316}00316         crypto\_freereq(crp);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00317}00317         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00318}00318 \textcolor{comment}{         * All sectors are already encrypted?}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00319}00319 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00320}00320         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed < \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00321}00321                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00322}00322         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error != 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00323}00323                 \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(0, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \textcolor{stringliteral}{"{}Crypto WRITE request failed (error=\%d)."{}},}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00324}00324                     \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00325}00325                 \mbox{\hyperlink{g__eli_8c_a85cfec789b20d2d3959b02285e818978}{g\_eli\_free\_data}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00326}00326                 cbp = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00327}00327                 \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1 = NULL;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00328}00328                 \mbox{\hyperlink{geom_8h_ae3cbea7d4bf48f25bb609df3d3f0bb28}{g\_destroy\_bio}}(cbp);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00329}00329                 \mbox{\hyperlink{geom_8h_a0975be2dcd40a26a56a1a9bfc80433e1}{g\_io\_deliver}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00330}00330                 atomic\_subtract\_int(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a239cdf3f405f19bdfe897bd9d1de8a37}{sc\_inflight}}, 1);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00331}00331                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00332}00332         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00333}00333         \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}} = LIST\_FIRST(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a899949202205997147c78c52b32b9843}{sc\_geom}}-\/>consumer);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00334}00334         cbp = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00335}00335         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1 = NULL;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00336}00336         cbp-\/>bio\_to = \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00337}00337         cbp-\/>bio\_done = \mbox{\hyperlink{g__eli_8c_a8eded9348395aad2b5271730e10bbff1}{g\_eli\_write\_done}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00338}00338 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00339}00339         \textcolor{comment}{/* Number of sectors from decrypted provider, eg. 1. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00340}00340         nsec = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_length / \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00341}00341         \textcolor{comment}{/* Number of sectors from encrypted provider, eg. 9. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00342}00342         nsec = (nsec * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}}) / \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}}-\/>\mbox{\hyperlink{structg__provider_aea3cd43d41461790b8d0afcd8c49a355}{sectorsize}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00343}00343 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00344}00344         cbp-\/>bio\_length = \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}}-\/>\mbox{\hyperlink{structg__provider_aea3cd43d41461790b8d0afcd8c49a355}{sectorsize}} * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00345}00345         cbp-\/>bio\_offset = (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_offset / \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize) * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00346}00346         cbp-\/>bio\_data = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00347}00347 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00348}00348         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00349}00349 \textcolor{comment}{         * We write more than what is requested, so we have to be ready to write}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00350}00350 \textcolor{comment}{         * more than maxphys.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00351}00351 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00352}00352         cbp2 = NULL;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00353}00353         \textcolor{keywordflow}{if} (cbp-\/>bio\_length > maxphys) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00354}00354                 cbp2 = \mbox{\hyperlink{geom_8h_ac367190962a01b4111cdf2fd2718a432}{g\_duplicate\_bio}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00355}00355                 cbp2-\/>bio\_length = cbp-\/>bio\_length -\/ maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00356}00356                 cbp2-\/>bio\_data = cbp-\/>bio\_data + maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00357}00357                 cbp2-\/>bio\_offset = cbp-\/>bio\_offset + maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00358}00358                 cbp2-\/>bio\_to = \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00359}00359                 cbp2-\/>bio\_done = \mbox{\hyperlink{g__eli_8c_a8eded9348395aad2b5271730e10bbff1}{g\_eli\_write\_done}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00360}00360                 cbp-\/>bio\_length = maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00361}00361         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00362}00362         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00363}00363 \textcolor{comment}{         * Send encrypted data to the provider.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00364}00364 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00365}00365         \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(2, cbp, \textcolor{stringliteral}{"{}Sending request."{}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00366}00366         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed = 0;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00367}00367         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children = (cbp2 != NULL ? 2 : 1);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00368}00368         \mbox{\hyperlink{geom_8h_aa433c0ba9e8cad7c7da1f9e17b46eb7a}{g\_io\_request}}(cbp, \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00369}00369         \textcolor{keywordflow}{if} (cbp2 != NULL) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00370}00370                 \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(2, cbp2, \textcolor{stringliteral}{"{}Sending request."{}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00371}00371                 \mbox{\hyperlink{geom_8h_aa433c0ba9e8cad7c7da1f9e17b46eb7a}{g\_io\_request}}(cbp2, \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00372}00372         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00373}00373         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00374}00374 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00375}00375 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00376}00376 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00377}\mbox{\hyperlink{g__eli_8h_a5afa122c0c4d3fec5a83a110edac9549}{00377}} \mbox{\hyperlink{g__eli__integrity_8c_a5afa122c0c4d3fec5a83a110edac9549}{g\_eli\_auth\_read}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structg__eli__softc}{g\_eli\_softc}} *sc, \textcolor{keyword}{struct} bio *\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}})}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00378}00378 \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00379}00379         \textcolor{keyword}{struct }\mbox{\hyperlink{structg__consumer}{g\_consumer}} *\mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00380}00380         \textcolor{keyword}{struct }bio *cbp, *cbp2;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00381}00381         \textcolor{keywordtype}{size\_t} size;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00382}00382         off\_t nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00383}00383 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00384}00384         \mbox{\hyperlink{g__eli_8h_af68c35f19b3961e7bbc34727a802c574}{G\_ELI\_SETWORKER}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_pflags, 0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00385}00385 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00386}00386         \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}} = LIST\_FIRST(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a899949202205997147c78c52b32b9843}{sc\_geom}}-\/>consumer);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00387}00387         cbp = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00388}00388         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1 = NULL;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00389}00389         cbp-\/>bio\_to = \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00390}00390         cbp-\/>bio\_done = \mbox{\hyperlink{g__eli_8c_a9ee20b44afe1f7147fddfa6ea9725efd}{g\_eli\_read\_done}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00391}00391 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00392}00392         \textcolor{comment}{/* Number of sectors from decrypted provider, eg. 1. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00393}00393         nsec = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_length / \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00394}00394         \textcolor{comment}{/* Number of sectors from encrypted provider, eg. 9. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00395}00395         nsec = (nsec * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}}) / \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}}-\/>\mbox{\hyperlink{structg__provider_aea3cd43d41461790b8d0afcd8c49a355}{sectorsize}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00396}00396 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00397}00397         cbp-\/>bio\_length = \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}}-\/>\mbox{\hyperlink{structg__provider_aea3cd43d41461790b8d0afcd8c49a355}{sectorsize}} * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00398}00398         size = cbp-\/>bio\_length;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00399}00399         size += \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}) * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00400}00400         size += \mbox{\hyperlink{g__eli_8h_a5419372124165c27b5251a5059e46607}{G\_ELI\_AUTH\_SECKEYLEN}} * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00401}00401         cbp-\/>bio\_offset = (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_offset / \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize) * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00402}00402         if (!\mbox{\hyperlink{g__eli_8c_ab1b19822f161973052c0245e98781fbb}{g\_eli\_alloc\_data}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, size)) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00403}00403                 \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(0, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \textcolor{stringliteral}{"{}Crypto auth read request failed (ENOMEM)"{}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00404}00404                 \mbox{\hyperlink{geom_8h_ae3cbea7d4bf48f25bb609df3d3f0bb28}{g\_destroy\_bio}}(cbp);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00405}00405                 \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error = ENOMEM;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00406}00406                 \mbox{\hyperlink{geom_8h_a0975be2dcd40a26a56a1a9bfc80433e1}{g\_io\_deliver}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00407}00407                 atomic\_subtract\_int(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a239cdf3f405f19bdfe897bd9d1de8a37}{sc\_inflight}}, 1);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00408}00408                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00409}00409         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00410}00410         cbp-\/>bio\_data = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00411}00411 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00412}00412         \textcolor{comment}{/* Clear the error array. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00413}00413         memset((\textcolor{keywordtype}{char} *)\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2 + cbp-\/>bio\_length, 0,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00414}00414             \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}) * nsec);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00415}00415 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00416}00416         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00417}00417 \textcolor{comment}{         * We read more than what is requested, so we have to be ready to read}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00418}00418 \textcolor{comment}{         * more than maxphys.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00419}00419 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00420}00420         cbp2 = NULL;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00421}00421         \textcolor{keywordflow}{if} (cbp-\/>bio\_length > maxphys) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00422}00422                 cbp2 = \mbox{\hyperlink{geom_8h_ac367190962a01b4111cdf2fd2718a432}{g\_duplicate\_bio}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00423}00423                 cbp2-\/>bio\_length = cbp-\/>bio\_length -\/ maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00424}00424                 cbp2-\/>bio\_data = cbp-\/>bio\_data + maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00425}00425                 cbp2-\/>bio\_offset = cbp-\/>bio\_offset + maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00426}00426                 cbp2-\/>bio\_to = \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}}-\/>\mbox{\hyperlink{structg__consumer_a6435d5aec0376e995dce3131fd3beb52}{provider}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00427}00427                 cbp2-\/>bio\_done = \mbox{\hyperlink{g__eli_8c_a9ee20b44afe1f7147fddfa6ea9725efd}{g\_eli\_read\_done}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00428}00428                 cbp-\/>bio\_length = maxphys;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00429}00429         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00430}00430         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00431}00431 \textcolor{comment}{         * Read encrypted data from provider.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00432}00432 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00433}00433         \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(2, cbp, \textcolor{stringliteral}{"{}Sending request."{}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00434}00434         \mbox{\hyperlink{geom_8h_aa433c0ba9e8cad7c7da1f9e17b46eb7a}{g\_io\_request}}(cbp, \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00435}00435         \textcolor{keywordflow}{if} (cbp2 != NULL) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00436}00436                 \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(2, cbp2, \textcolor{stringliteral}{"{}Sending request."{}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00437}00437                 \mbox{\hyperlink{geom_8h_aa433c0ba9e8cad7c7da1f9e17b46eb7a}{g\_io\_request}}(cbp2, \mbox{\hyperlink{g__part__if_8m_a294f18324585ff37641fb8aa1c9ccd82}{cp}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00438}00438         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00439}00439 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00440}00440 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00441}00441 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00442}00442 \textcolor{comment}{ * This is the main function responsible for cryptography (ie. communication}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00443}00443 \textcolor{comment}{ * with crypto(9) subsystem).}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00444}00444 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00445}00445 \textcolor{comment}{ * BIO\_READ:}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00446}00446 \textcolor{comment}{ *      g\_eli\_start -\/> g\_eli\_auth\_read -\/> g\_io\_request -\/> g\_eli\_read\_done -\/> G\_ELI\_AUTH\_RUN -\/> g\_eli\_auth\_read\_done -\/> g\_io\_deliver}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00447}00447 \textcolor{comment}{ * BIO\_WRITE:}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00448}00448 \textcolor{comment}{ *      g\_eli\_start -\/> G\_ELI\_AUTH\_RUN -\/> g\_eli\_auth\_write\_done -\/> g\_io\_request -\/> g\_eli\_write\_done -\/> g\_io\_deliver}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00449}00449 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00450}00450 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00451}\mbox{\hyperlink{g__eli_8h_abda45f20108a5bfb8a455a52cbd7b10c}{00451}} \mbox{\hyperlink{g__eli__integrity_8c_abda45f20108a5bfb8a455a52cbd7b10c}{g\_eli\_auth\_run}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structg__eli__worker}{g\_eli\_worker}} *wr, \textcolor{keyword}{struct} bio *\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}})}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00452}00452 \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00453}00453         \textcolor{keyword}{struct }\mbox{\hyperlink{structg__eli__softc}{g\_eli\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00454}00454         \textcolor{keyword}{struct }cryptopq crpq;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00455}00455         \textcolor{keyword}{struct }cryptop *crp;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00456}00456         u\_int i, lsec, nsec, data\_secsize, decr\_secsize, encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00457}00457         off\_t dstoff;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00458}00458         u\_char *p, *\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}}, *authkey, *plaindata;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00459}00459         \textcolor{keywordtype}{int} error \mbox{\hyperlink{g__bde_8h_aabb5ad70c88f55209cff7ec5684d13c1}{\_\_diagused}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00460}00460         \textcolor{keywordtype}{bool} batch;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00461}00461 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00462}00462         \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(3, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \textcolor{stringliteral}{"{}\%s"{}}, \_\_func\_\_);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00463}00463 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00464}00464         \mbox{\hyperlink{g__eli_8h_af68c35f19b3961e7bbc34727a802c574}{G\_ELI\_SETWORKER}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_pflags, wr-\/>\mbox{\hyperlink{structg__eli__worker_a5fce4959d9d95297e1b5802b03654fdd}{w\_number}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00465}00465         sc = wr-\/>\mbox{\hyperlink{structg__eli__worker_a529a3f8b3a7f2e96b3715b8f5d507495}{w\_softc}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00466}00466         \textcolor{comment}{/* Sectorsize of decrypted provider eg. 4096. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00467}00467         decr\_secsize = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00468}00468         \textcolor{comment}{/* The real sectorsize of encrypted provider, eg. 512. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00469}00469         encr\_secsize = LIST\_FIRST(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a899949202205997147c78c52b32b9843}{sc\_geom}}-\/>consumer)-\/>provider-\/>sectorsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00470}00470         \textcolor{comment}{/* Number of data bytes in one encrypted sector, eg. 480. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00471}00471         data\_secsize = sc-\/>\mbox{\hyperlink{structg__eli__softc_a7096457a870bb699d5cd9d3beb0313e7}{sc\_data\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00472}00472         \textcolor{comment}{/* Number of sectors from decrypted provider, eg. 2. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00473}00473         nsec = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_length / decr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00474}00474         \textcolor{comment}{/* Number of sectors from encrypted provider, eg. 18. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00475}00475         nsec = (nsec * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}}) / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00476}00476         \textcolor{comment}{/* Last sector number in every big sector, eg. 9. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00477}00477         lsec = sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}} / encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00478}00478         \textcolor{comment}{/* Destination offset, used for IV generation. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00479}00479         dstoff = (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_offset / \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_to-\/>sectorsize) * sc-\/>\mbox{\hyperlink{structg__eli__softc_a6212e3d8c829bd8dd2bbd1d371b910e0}{sc\_bytes\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00480}00480 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00481}00481         plaindata = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_data;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00482}00482         if (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_cmd == BIO\_READ) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00483}00483                 \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00484}00484                 p = \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} + encr\_secsize * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00485}00485                 p += \textcolor{keyword}{sizeof}(int) * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00486}00486         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00487}00487                 \textcolor{keywordtype}{size\_t} size;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00488}00488 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00489}00489                 size = encr\_secsize * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00490}00490                 size += \mbox{\hyperlink{g__eli_8h_a5419372124165c27b5251a5059e46607}{G\_ELI\_AUTH\_SECKEYLEN}} * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00491}00491                 size += \textcolor{keyword}{sizeof}(uintptr\_t);      \textcolor{comment}{/* Space for alignment. */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00492}00492                 \textcolor{keywordflow}{if} (!\mbox{\hyperlink{g__eli_8c_ab1b19822f161973052c0245e98781fbb}{g\_eli\_alloc\_data}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, size)) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00493}00493                         \mbox{\hyperlink{g__eli_8h_a779a345687882e70738352745e022c14}{G\_ELI\_LOGREQ}}(0, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \textcolor{stringliteral}{"{}Crypto request failed (ENOMEM)"{}});}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00494}00494                         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1 != NULL) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00495}00495                                 \mbox{\hyperlink{geom_8h_ae3cbea7d4bf48f25bb609df3d3f0bb28}{g\_destroy\_bio}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00496}00496                                 \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver1 = NULL;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00497}00497                         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00498}00498                         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error = ENOMEM;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00499}00499                         \mbox{\hyperlink{geom_8h_a0975be2dcd40a26a56a1a9bfc80433e1}{g\_io\_deliver}}(\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}, \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_error);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00500}00500                         \textcolor{keywordflow}{if} (sc != NULL)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00501}00501                                 atomic\_subtract\_int(\&sc-\/>\mbox{\hyperlink{structg__eli__softc_a239cdf3f405f19bdfe897bd9d1de8a37}{sc\_inflight}}, 1);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00502}00502                         \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00503}00503                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00504}00504                 \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} = \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_driver2;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00505}00505                 p = \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} + encr\_secsize * nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00506}00506         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00507}00507         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_inbed = 0;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00508}00508         \mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_children = nsec;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00509}00509 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00510}00510 \textcolor{preprocessor}{\#if defined(\_\_mips\_n64) || defined(\_\_mips\_o64)}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00511}00511         p = (\textcolor{keywordtype}{char} *)roundup((uintptr\_t)p, \textcolor{keyword}{sizeof}(uintptr\_t));}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00512}00512 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00513}00513 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00514}00514         TAILQ\_INIT(\&crpq);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00515}00515         batch = atomic\_load\_int(\&\mbox{\hyperlink{g__eli_8c_a4bd2c4ca8397244a2841fcc2627d3d31}{g\_eli\_batch}}) != 0;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00516}00516 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00517}00517         \textcolor{keywordflow}{for} (i = 1; i <= nsec; i++, dstoff += encr\_secsize) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00518}00518                 crp = crypto\_getreq(wr-\/>\mbox{\hyperlink{structg__eli__worker_a4955ad236cfa9a87082d550fe7f7c061}{w\_sid}}, M\_WAITOK);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00519}00519                 authkey = (u\_char *)p;          p += \mbox{\hyperlink{g__eli_8h_a5419372124165c27b5251a5059e46607}{G\_ELI\_AUTH\_SECKEYLEN}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00520}00520 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00521}00521                 data\_secsize = sc-\/>\mbox{\hyperlink{structg__eli__softc_a7096457a870bb699d5cd9d3beb0313e7}{sc\_data\_per\_sector}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00522}00522                 \textcolor{keywordflow}{if} ((i \% lsec) == 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00523}00523                         data\_secsize = decr\_secsize \% data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00524}00524                         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00525}00525 \textcolor{comment}{                         * Last encrypted sector of each decrypted sector is}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00526}00526 \textcolor{comment}{                         * only partially filled.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00527}00527 \textcolor{comment}{                         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00528}00528                         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_cmd == BIO\_WRITE)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00529}00529                                 memset(\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} + sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}} + data\_secsize, 0,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00530}00530                                     encr\_secsize -\/ sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}} -\/ data\_secsize);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00531}00531                 \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (data\_secsize + sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}} != encr\_secsize) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00532}00532                         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00533}00533 \textcolor{comment}{                         * If the HMAC size is not a multiple of 128 bits, the}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00534}00534 \textcolor{comment}{                         * per-\/sector data size is rounded down to ensure that}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00535}00535 \textcolor{comment}{                         * encryption can be performed without requiring any}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00536}00536 \textcolor{comment}{                         * padding.  In this case, each sector contains unused}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00537}00537 \textcolor{comment}{                         * bytes.}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00538}00538 \textcolor{comment}{                         */}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00539}00539                         \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_cmd == BIO\_WRITE)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00540}00540                                 memset(\mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} + sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}} + data\_secsize, 0,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00541}00541                                     encr\_secsize -\/ sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}} -\/ data\_secsize);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00542}00542                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00543}00543 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00544}00544                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_cmd == BIO\_WRITE) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00545}00545                         bcopy(plaindata, \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} + sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}}, data\_secsize);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00546}00546                         plaindata += data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00547}00547                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00548}00548 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00549}00549                 crypto\_use\_buf(crp, \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}}, sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}} + data\_secsize);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00550}00550                 crp-\/>crp\_opaque = (\textcolor{keywordtype}{void} *)\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00551}00551                 \mbox{\hyperlink{g__part__if_8m_a735984d41155bc1032e09bece8f8d66d}{data}} += encr\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00552}00552                 crp-\/>crp\_flags = CRYPTO\_F\_CBIFSYNC;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00553}00553                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__part__if_8m_a3786db8db96c32f69df9f7cd325a7507}{bp}}-\/>bio\_cmd == BIO\_WRITE) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00554}00554                         crp-\/>crp\_callback = \mbox{\hyperlink{g__eli__integrity_8c_a97f3a5057a7536ae824cbe961778a190}{g\_eli\_auth\_write\_done}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00555}00555                         crp-\/>crp\_op = CRYPTO\_OP\_ENCRYPT |}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00556}00556                             CRYPTO\_OP\_COMPUTE\_DIGEST;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00557}00557                 \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00558}00558                         crp-\/>crp\_callback = \mbox{\hyperlink{g__eli__integrity_8c_a1ce98ebcc0c42841429c24aa3c3dee42}{g\_eli\_auth\_read\_done}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00559}00559                         crp-\/>crp\_op = CRYPTO\_OP\_DECRYPT |}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00560}00560                             CRYPTO\_OP\_VERIFY\_DIGEST;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00561}00561                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00562}00562 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00563}00563                 crp-\/>crp\_digest\_start = 0;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00564}00564                 crp-\/>crp\_payload\_start = sc-\/>\mbox{\hyperlink{structg__eli__softc_a50a1a9f02bbadd3471006e5dfc65ac8a}{sc\_alen}};}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00565}00565                 crp-\/>crp\_payload\_length = data\_secsize;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00566}00566                 \textcolor{keywordflow}{if} ((sc-\/>\mbox{\hyperlink{structg__eli__softc_a94876b8cf2ed7da3eb3a3e1858171ef2}{sc\_flags}} \& \mbox{\hyperlink{g__eli_8h_acafc9dd961af3f154c01c7dbc38fea0d}{G\_ELI\_FLAG\_FIRST\_KEY}}) == 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00567}00567                         crp-\/>crp\_cipher\_key = \mbox{\hyperlink{g__eli_8h_a0271575799ad05ec5fb7adc0b414e137}{g\_eli\_key\_hold}}(sc, dstoff,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00568}00568                             encr\_secsize);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00569}00569                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00570}00570                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{g__eli_8h_a9759c32a5d088af02c42c2acf1513ee9}{g\_eli\_ivlen}}(sc-\/>\mbox{\hyperlink{structg__eli__softc_aecc6e7e7b1b2e05b9ded85a9ab763d74}{sc\_ealgo}}) != 0) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00571}00571                         crp-\/>crp\_flags |= CRYPTO\_F\_IV\_SEPARATE;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00572}00572                         \mbox{\hyperlink{g__eli_8h_ab07921ca3b88d093ec9b2b33a0d8d226}{g\_eli\_crypto\_ivgen}}(sc, dstoff, crp-\/>crp\_iv,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00573}00573                             \textcolor{keyword}{sizeof}(crp-\/>crp\_iv));}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00574}00574                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00575}00575 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00576}00576                 \mbox{\hyperlink{g__eli__integrity_8c_a18a8c9bd74793ca44666381e8973f436}{g\_eli\_auth\_keygen}}(sc, dstoff, authkey);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00577}00577                 crp-\/>crp\_auth\_key = authkey;}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00578}00578 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00579}00579                 \textcolor{keywordflow}{if} (batch) \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00580}00580                         TAILQ\_INSERT\_TAIL(\&crpq, crp, crp\_next);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00581}00581                 \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00582}00582                         error = crypto\_dispatch(crp);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00583}00583                         KASSERT(error == 0,}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00584}00584                             (\textcolor{stringliteral}{"{}crypto\_dispatch() failed (error=\%d)"{}}, error));}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00585}00585                 \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00586}00586         \}}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00587}00587 }
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00588}00588         \textcolor{keywordflow}{if} (batch)}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00589}00589                 crypto\_dispatch\_batch(\&crpq, 0);}
\DoxyCodeLine{\Hypertarget{g__eli__integrity_8c_source_l00590}00590 \}}

\end{DoxyCode}
