linux/crypto/eseqiv.c
<<
38.1 /spaon> /formn> a 38.1 href="../linux+v3.7.5/crypto/eseqiv.c">38.1 img src="../.static/gfx/right.png" alt=">>">38 /spaon>38 spao class="lxr_search">38.138.1 input typue=hidden" namue=navtarget" value=">38.1 input typue=text" namue=search" ide=search">38.1 buttiontypue=submit">Search /formn> /spaon>38 spao class="lxr_prefs"n> a href="+prefs?return=crypto/eseqiv.c"38.1 onclick="return ajax_prefs();">38.1 Prefs> /a>38 /spaon>.1 /divn>.1 form acptio="ajax+*" method="post" onsubmit="return false;">38 input typue=hidden" namue=ajax_lookup" ide=ajax_lookup" value=">3.1 /formn>3.1 div class="headingbottim">.1 .1 div ide=search_results" class="search_results"> n>.1 /divn> div ide=content">> div ide=file_contents"n
   1 /a> spao class="comment">/* /spaon>   2 /a> spao class="comment"> * eseqiv: Encrypted Sequence Number IV Generator /spaon>   3 /a> spao class="comment"> * /spaon>   4 /a> spao class="comment"> * This generator generates ao IV based iona sequence number by xoring it /spaon>   5 /a> spao class="comment"> * withna salt aod then encrypting it withnthe same key as used to encrypt /spaon>   6 /a> spao class="comment"> * the plaiontext.  This algorithm requires that the block size be equal /spaon>   7 /a> spao class="comment"> * to the IV size.  It is maioly useful for CBC. /spaon>   8 /a> spao class="comment"> * /spaon>   9 /a> spao class="comment"> * Copyright (c) 2007 Herbert Xu <herbert@gondor.apaoa.org.au> /spaon>  .10 spao class="comment"> * /spaon>  11 /a> spao class="comment"> * This program is free software; you cao redistribute it aod/or modify it /spaon>  12 /a> spao class="comment"> * under the terms of the GNU General Public License as published by the Free /spaon>  13 /a> spao class="comment"> * Software Foundaptio; either verstion2 of the License, or (at your /optio) /spaon>  14 /a> spao class="comment"> * any later verstio. /spaon>  15 /a> spao class="comment"> * /spaon>  16 /a> spao class="comment"> */ /spaon>  17 /a>>  18 /a>#include <crypto/internal/skcipher.h /a>>>  19 /a>#include <crypto/rng.h /a>>>  20 /a>#include <crypto/scatterwalk.h /a>>>  21 /a>#include <linux/err.h /a>>>  22 /a>#include <linux/init.h /a>>>  23 /a>#include <linux/kernel.h /a>>>  24 /a>#include <linux/mm.h /a>>>  25 /a>#include <linux/module.h /a>>>  26 /a>#include <linux/scatterlist.h /a>>>  27 /a>#include <linux/spiolock.h /a>>>  28 /a>#include <linux/string.h /a>>>  29 /a>>  30 /a>struct  a href="+code=eseqiv_request_ctx" class="sref">eseqiv_request_ctx /a> {>  31 /a>        struct  a href="+code=scatterlist" class="sref">scatterlist /a>  a href="+code=src" class="sref">src /a>[2];>  32 /a>        struct  a href="+code=scatterlist" class="sref">scatterlist /a>  a href="+code=dst" class="sref">dst /a>[2];>  33 /a>        char  a href="+code=tail" class="sref">tail /a>[];>  34 /a>};>  35 /a>>  36 /a>struct  a href="+code=eseqiv_ctx" class="sref">eseqiv_ctx /a> {>  37 /a>         a href="+code=spiolock_t" class="sref">spiolock_t /a>  a href="+code=lock" class="sref">lock /a>;>  38 /a>        unsigned int  a href="+code=reqoff" class="sref">reqoff /a>;>  39 /a>        char  a href="+code=salt" class="sref">salt /a>[];>  40 /a>};>  41 /a>>  42 /a>static void  a href="+code=eseqiv_complete2" class="sref">eseqiv_complete2 /a>(struct  a href="+code=skcipher_givcrypt_request" class="sref">skcipher_givcrypt_request /a> * a href="+code=req" class="sref">req /a>)>  43 /a>{>  44 /a>        struct  a href="+code=crypto_ablkcipher" class="sref">crypto_ablkcipher /a> * a href="+code=geniv" class="sref">geniv /a> =  a href="+code=skcipher_givcrypt_reqtfm" class="sref">skcipher_givcrypt_reqtfm /a>( a href="+code=req" class="sref">req /a>);>  45 /a>        struct  a href="+code=eseqiv_request_ctx" class="sref">eseqiv_request_ctx /a> * a href="+code=reqctx" class="sref">reqctx /a> =  a href="+code=skcipher_givcrypt_reqctx" class="sref">skcipher_givcrypt_reqctx /a>( a href="+code=req" class="sref">req /a>);>  46 /a>>  47 /a>         a href="+code=memcpy" class="sref">memcpy /a>( a href="+code=req" class="sref">req /a>-> a href="+code=giv" class="sref">giv /a>,  a href="+code=PTR_ALIGN" class="sref">PTR_ALIGN /a>(( a href="+code=u8" class="sref">u8 /a> *) a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=tail" class="sref">tail /a>,>  48 /a>                          a href="+code=crypto_ablkcipher_alignmask" class="sref">crypto_ablkcipher_alignmask /a>( a href="+code=geniv" class="sref">geniv /a>) + 1),>  49 /a>                a href="+code=crypto_ablkcipher_ivsize" class="sref">crypto_ablkcipher_ivsize /a>( a href="+code=geniv" class="sref">geniv /a>));>  50 /a>}>  51 /a>>  52 /a>static void  a href="+code=eseqiv_complete" class="sref">eseqiv_complete /a>(struct  a href="+code=crypto_async_request" class="sref">crypto_async_request /a> * a href="+code=base" class="sref">base /a>, int  a href="+code=err" class="sref">err /a>)>  53 /a>{>  54 /a>        struct  a href="+code=skcipher_givcrypt_request" class="sref">skcipher_givcrypt_request /a> * a href="+code=req" class="sref">req /a> =  a href="+code=base" class="sref">base /a>-> a href="+code=data" class="sref">data /a>;>  55 /a>>  56 /a>        if ( a href="+code=err" class="sref">err /a>)>  57 /a>                goto  a href="+code=out" class="sref">out /a>;>  58 /a>>  59 /a>         a href="+code=eseqiv_complete2" class="sref">eseqiv_complete2 /a>( a href="+code=req" class="sref">req /a>);>  60 /a>>  61 /a> a href="+code=out" class="sref">out /a>:>  62 /a>         a href="+code=skcipher_givcrypt_complete" class="sref">skcipher_givcrypt_complete /a>( a href="+code=req" class="sref">req /a>,  a href="+code=err" class="sref">err /a>);>  63 /a>}>  64 /a>>  65 /a>static int  a href="+code=eseqiv_givencrypt" class="sref">eseqiv_givencrypt /a>(struct  a href="+code=skcipher_givcrypt_request" class="sref">skcipher_givcrypt_request /a> * a href="+code=req" class="sref">req /a>)>  66 /a>{>  67 /a>        struct  a href="+code=crypto_ablkcipher" class="sref">crypto_ablkcipher /a> * a href="+code=geniv" class="sref">geniv /a> =  a href="+code=skcipher_givcrypt_reqtfm" class="sref">skcipher_givcrypt_reqtfm /a>( a href="+code=req" class="sref">req /a>);>  68 /a>        struct  a href="+code=eseqiv_ctx" class="sref">eseqiv_ctx /a> * a href="+code=ctx" class="sref">ctx /a> =  a href="+code=crypto_ablkcipher_ctx" class="sref">crypto_ablkcipher_ctx /a>( a href="+code=geniv" class="sref">geniv /a>);>  69 /a>        struct  a href="+code=eseqiv_request_ctx" class="sref">eseqiv_request_ctx /a> * a href="+code=reqctx" class="sref">reqctx /a> =  a href="+code=skcipher_givcrypt_reqctx" class="sref">skcipher_givcrypt_reqctx /a>( a href="+code=req" class="sref">req /a>);>  70 /a>        struct  a href="+code=ablkcipher_request" class="sref">ablkcipher_request /a> * a href="+code=subreq" class="sref">subreq /a>;>  71 /a>         a href="+code=crypto_completion_t" class="sref">crypto_completion_t /a>  a href="+code=complete" class="sref">complete /a>;>  72 /a>        void * a href="+code=data" class="sref">data /a>;>  73 /a>        struct  a href="+code=scatterlist" class="sref">scatterlist /a> * a href="+code=osrc" class="sref">osrc /a>, * a href="+code=odst" class="sref">odst /a>;>  74 /a>        struct  a href="+code=scatterlist" class="sref">scatterlist /a> * a href="+code=dst" class="sref">dst /a>;>  75 /a>        struct  a href="+code=page" class="sref">page /a> * a href="+code=srcp" class="sref">srcp /a>;>  76 /a>        struct  a href="+code=page" class="sref">page /a> * a href="+code=dstp" class="sref">dstp /a>;>  77 /a>         a href="+code=u8" class="sref">u8 /a> * a href="+code=giv" class="sref">giv /a>;>  78 /a>         a href="+code=u8" class="sref">u8 /a> * a href="+code=vsrc" class="sref">vsrc /a>;>  79 /a>         a href="+code=u8" class="sref">u8 /a> * a href="+code=vdst" class="sref">vdst /a>;>  80 /a>         a href="+code=__be64" class="sref">__be64 /a>  a href="+code=seq" class="sref">seq /a>;>  81 /a>        unsigned int  a href="+code=ivsize" class="sref">ivsize /a>;>  82 /a>        unsigned int  a href="+code=len" class="sref">len /a>;>  83 /a>        int  a href="+code=err" class="sref">err /a>;>  84 /a>>  85 /a>         a href="+code=subreq" class="sref">subreq /a> = (void *)( a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=tail" class="sref">tail /a> +  a href="+code=ctx" class="sref">ctx /a>-> a href="+code=reqoff" class="sref">reqoff /a>);>  86 /a>         a href="+code=ablkcipher_request_set_tfm" class="sref">ablkcipher_request_set_tfm /a>( a href="+code=subreq" class="sref">subreq /a>,  a href="+code=skcipher_geniv_cipher" class="sref">skcipher_geniv_cipher /a>( a href="+code=geniv" class="sref">geniv /a>));>  87 /a>>  88 /a>         a href="+code=giv" class="sref">giv /a> =  a href="+code=req" class="sref">req /a>-> a href="+code=giv" class="sref">giv /a>;>  89 /a>         a href="+code=complete" class="sref">complete /a> =  a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=base" class="sref">base /a>. a href="+code=complete" class="sref">complete /a>;>  90 /a>         a href="+code=data" class="sref">data /a> =  a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=base" class="sref">base /a>. a href="+code=data" class="sref">data /a>;>  91 /a>>  92 /a>         a href="+code=osrc" class="sref">osrc /a> =  a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=src" class="sref">src /a>;>  93 /a>         a href="+code=odst" class="sref">odst /a> =  a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=dst" class="sref">dst /a>;>  94 /a>         a href="+code=srcp" class="sref">srcp /a> =  a href="+code=sg_page" class="sref">sg_page /a>( a href="+code=osrc" class="sref">osrc /a>);>  95 /a>         a href="+code=dstp" class="sref">dstp /a> =  a href="+code=sg_page" class="sref">sg_page /a>( a href="+code=odst" class="sref">odst /a>);>  96 /a>         a href="+code=vsrc" class="sref">vsrc /a> =  a href="+code=PageHighMem" class="sref">PageHighMem /a>( a href="+code=srcp" class="sref">srcp /a>) ?  a href="+code=NULL" class="sref">NULL /a> :  a href="+code=page_address" class="sref">page_address /a>( a href="+code=srcp" class="sref">srcp /a>) +  a href="+code=osrc" class="sref">osrc /a>-> a href="+code=offset" class="sref">offset /a>;>  97 /a>         a href="+code=vdst" class="sref">vdst /a> =  a href="+code=PageHighMem" class="sref">PageHighMem /a>( a href="+code=dstp" class="sref">dstp /a>) ?  a href="+code=NULL" class="sref">NULL /a> :  a href="+code=page_address" class="sref">page_address /a>( a href="+code=dstp" class="sref">dstp /a>) +  a href="+code=odst" class="sref">odst /a>-> a href="+code=offset" class="sref">offset /a>;>  98 /a>>  99 /a>         a href="+code=ivsize" class="sref">ivsize /a> =  a href="+code=crypto_ablkcipher_ivsize" class="sref">crypto_ablkcipher_ivsize /a>( a href="+code=geniv" class="sref">geniv /a>);> 100 /a>> 101 /a>        if ( a href="+code=vsrc" class="sref">vsrc /a> !=  a href="+code=giv" class="sref">giv /a> +  a href="+code=ivsize" class="sref">ivsize /a> &&  a href="+code=vdst" class="sref">vdst /a> !=  a href="+code=giv" class="sref">giv /a> +  a href="+code=ivsize" class="sref">ivsize /a>) {> 102 /a>                 a href="+code=giv" class="sref">giv /a> =  a href="+code=PTR_ALIGN" class="sref">PTR_ALIGN /a>(( a href="+code=u8" class="sref">u8 /a> *) a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=tail" class="sref">tail /a>,> 103 /a>                                 a href="+code=crypto_ablkcipher_alignmask" class="sref">crypto_ablkcipher_alignmask /a>( a href="+code=geniv" class="sref">geniv /a>) + 1);> 104 /a>                 a href="+code=complete" class="sref">complete /a> =  a href="+code=eseqiv_complete" class="sref">eseqiv_complete /a>;> 105 /a>                 a href="+code=data" class="sref">data /a> =  a href="+code=req" class="sref">req /a>;> 106 /a>        }> 107 /a>> 108 /a>         a href="+code=ablkcipher_request_set_callback" class="sref">ablkcipher_request_set_callback /a>( a href="+code=subreq" class="sref">subreq /a>,  a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=base" class="sref">base /a>. a href="+code=flags" class="sref">flags /a>,  a href="+code=complete" class="sref">complete /a>,> 109 /a>                                         a href="+code=data" class="sref">data /a>);> 110 /a>> 111 /a>         a href="+code=sg_init_table" class="sref">sg_init_table /a>( a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=src" class="sref">src /a>, 2);> 112 /a>         a href="+code=sg_set_buf" class="sref">sg_set_buf /a>( a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=src" class="sref">src /a>,  a href="+code=giv" class="sref">giv /a>,  a href="+code=ivsize" class="sref">ivsize /a>);> 113 /a>         a href="+code=scatterwalk_crypto_chain" class="sref">scatterwalk_crypto_chain /a>( a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=src" class="sref">src /a>,  a href="+code=osrc" class="sref">osrc /a>,  a href="+code=vsrc" class="sref">vsrc /a> ==  a href="+code=giv" class="sref">giv /a> +  a href="+code=ivsize" class="sref">ivsize /a>, 2);> 114 /a>> 115 /a>         a href="+code=dst" class="sref">dst /a> =  a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=src" class="sref">src /a>;> 116 /a>        if ( a href="+code=osrc" class="sref">osrc /a> !=  a href="+code=odst" class="sref">odst /a>) {> 117 /a>                 a href="+code=sg_init_table" class="sref">sg_init_table /a>( a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=dst" class="sref">dst /a>, 2);> 118 /a>                 a href="+code=sg_set_buf" class="sref">sg_set_buf /a>( a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=dst" class="sref">dst /a>,  a href="+code=giv" class="sref">giv /a>,  a href="+code=ivsize" class="sref">ivsize /a>);> 119 /a>                 a href="+code=scatterwalk_crypto_chain" class="sref">scatterwalk_crypto_chain /a>( a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=dst" class="sref">dst /a>,  a href="+code=odst" class="sref">odst /a>,  a href="+code=vdst" class="sref">vdst /a> ==  a href="+code=giv" class="sref">giv /a> +  a href="+code=ivsize" class="sref">ivsize /a>, 2);> 120 /a>> 121 /a>                 a href="+code=dst" class="sref">dst /a> =  a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=dst" class="sref">dst /a>;> 122 /a>        }> 123 /a>> 124 /a>         a href="+code=ablkcipher_request_set_crypt" class="sref">ablkcipher_request_set_crypt /a>( a href="+code=subreq" class="sref">subreq /a>,  a href="+code=reqctx" class="sref">reqctx /a>-> a href="+code=src" class="sref">src /a>,  a href="+code=dst" class="sref">dst /a>,> 125 /a>                                      a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=nbytes" class="sref">nbytes /a> +  a href="+code=ivsize" class="sref">ivsize /a>,> 126 /a>                                      a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=info" class="sref">info /a>);> 127 /a>> 128 /a>         a href="+code=memcpy" class="sref">memcpy /a>( a href="+code=req" class="sref">req /a>-> a href="+code=creq" class="sref">creq /a>. a href="+code=info" class="sref">info /a>,  a href="+code=ctx" class="sref">ctx /a>-> a href="+code=salt" class="sref">salt /a>,  a href="+code=ivsize" class="sref">ivsize /a>);> 129 /a>> 130 /a>         a href="+code=len" class="sref">len /a> =  a href="+code=ivsize" class="sref">ivsize /a>;> 131 /a>        if ( a href="+code=ivsize" class="sref">ivsize /a> > sizeof( a href="+code=u64" class="sref">u64 /a>)) {> 132 /a>                 a href="+code=memset" class="sref">memset /a>( a href="+code=req" class="sref">req /a>-> a href="+code=giv" class="sref">giv /a>, 0,  a href="+code=ivsize" class="sref">ivsize /a> - sizeof( a href="+code=u64" class="sref">u64 /a>));> 133 /a>                 a href="+code=len" class="sref">len /a> = sizeof( a href="+code=u64" class="sref">u64 /a>);> 134 /a>        }> 135 /a>         a href="+code=seq" class="sref">seq /a> =  a href="+code=cpu_to_be64" class="sref">cpu_to_be64 /a>( a href="+code=req" class="sref">req /a>-> a href="+code=seq" class="sref">seq /a>);> 136 /a>         a href="+code=memcpy" class="sref">memcpy /a>( a href="+code=req" class="sref">req /a>-> a href="+code=giv" class="sref">giv /a> +  a href="+code=ivsize" class="sref">ivsize /a> -  a href="+code=len" class="sref">len /a>, & a href="+code=seq" class="sref">seq /a>,  a href="+code=len" class="sref">len /a>);> 137 /a>> 138 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=crypto_ablkcipher_encrypt" class="sref">crypto_ablkcipher_encrypt /a>( a href="+code=subreq" class="sref">subreq /a>);> 139 /a>        if ( a href="+code=err" class="sref">err /a>)> 140 /a>                goto  a href="+code=out" class="sref">out /a>;> 141 /a>> 142 /a>        if ( a href="+code=giv" class="sref">giv /a> !=  a href="+code=req" class="sref">req /a>-> a href="+code=giv" class="sref">giv /a>)> 143 /a>                 a href="+code=eseqiv_complete2" class="sref">eseqiv_complete2 /a>( a href="+code=req" class="sref">req /a>);> 144 /a>> 145 /a> a href="+code=out" class="sref">out /a>:> 146 /a>        return  a href="+code=err" class="sref">err /a>;> 147 /a>}> 148 /a>> 149 /a>static int  a href="+code=eseqiv_givencrypt_first" class="sref">eseqiv_givencrypt_first /a>(struct  a href="+code=skcipher_givcrypt_request" class="sref">skcipher_givcrypt_request /a> * a href="+code=req" class="sref">req /a>)> 150 /a>{> 151 /a>        struct  a href="+code=crypto_ablkcipher" class="sref">crypto_ablkcipher /a> * a href="+code=geniv" class="sref">geniv /a> =  a href="+code=skcipher_givcrypt_reqtfm" class="sref">skcipher_givcrypt_reqtfm /a>( a href="+code=req" class="sref">req /a>);> 152 /a>        struct  a href="+code=eseqiv_ctx" class="sref">eseqiv_ctx /a> * a href="+code=ctx" class="sref">ctx /a> =  a href="+code=crypto_ablkcipher_ctx" class="sref">crypto_ablkcipher_ctx /a>( a href="+code=geniv" class="sref">geniv /a>);> 153 /a>        int  a href="+code=err" class="sref">err /a> = 0;> 154 /a>> 155 /a>         a href="+code=spin_lock_bh" class="sref">spin_lock_bh /a>(& a href="+code=ctx" class="sref">ctx /a>-> a href="+code=lock" class="sref">lock /a>);> 156 /a>        if ( a href="+code=crypto_ablkcipher_crt" class="sref">crypto_ablkcipher_crt /a>( a href="+code=geniv" class="sref">geniv /a>)-> a href="+code=givencrypt" class="sref">givencrypt /a> !=  a href="+code=eseqiv_givencrypt_first" class="sref">eseqiv_givencrypt_first /a>)> 157 /a>                goto  a href="+code=unlock" class="sref">unlock /a>;> 158 /a>> 159 /a>         a href="+code=crypto_ablkcipher_crt" class="sref">crypto_ablkcipher_crt /a>( a href="+code=geniv" class="sref">geniv /a>)-> a href="+code=givencrypt" class="sref">givencrypt /a> =  a href="+code=eseqiv_givencrypt" class="sref">eseqiv_givencrypt /a>;> 160 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=crypto_rng_get_bytes" class="sref">crypto_rng_get_bytes /a>( a href="+code=crypto_default_rng" class="sref">crypto_default_rng /a>,  a href="+code=ctx" class="sref">ctx /a>-> a href="+code=salt" class="sref">salt /a>,> 161 /a>                                    a href="+code=crypto_ablkcipher_ivsize" class="sref">crypto_ablkcipher_ivsize /a>( a href="+code=geniv" class="sref">geniv /a>));> 162 /a>> 163 /a> a href="+code=unlock" class="sref">unlock /a>:> 164 /a>         a href="+code=spin_unlock_bh" class="sref">spin_unlock_bh /a>(& a href="+code=ctx" class="sref">ctx /a>-> a href="+code=lock" class="sref">lock /a>);> 165 /a>> 166 /a>        if ( a href="+code=err" class="sref">err /a>)> 167 /a>                return  a href="+code=err" class="sref">err /a>;> 168 /a>> 169 /a>        return  a href="+code=eseqiv_givencrypt" class="sref">eseqiv_givencrypt /a>( a href="+code=req" class="sref">req /a>);> 170 /a>}> 171 /a>> 172 /a>static int  a href="+code=eseqiv_init" class="sref">eseqiv_init /a>(struct  a href="+code=crypto_tfm" class="sref">crypto_tfm /a> * a href="+code=tfm" class="sref">tfm /a>)> 173 /a>{> 174 /a>        struct  a href="+code=crypto_ablkcipher" class="sref">crypto_ablkcipher /a> * a href="+code=geniv" class="sref">geniv /a> =  a href="+code=__crypto_ablkcipher_cast" class="sref">__crypto_ablkcipher_cast /a>( a href="+code=tfm" class="sref">tfm /a>);> 175 /a>        struct  a href="+code=eseqiv_ctx" class="sref">eseqiv_ctx /a> * a href="+code=ctx" class="sref">ctx /a> =  a href="+code=crypto_ablkcipher_ctx" class="sref">crypto_ablkcipher_ctx /a>( a href="+code=geniv" class="sref">geniv /a>);> 176 /a>        unsigned long  a href="+code=alignmask" class="sref">alignmask /a>;> 177 /a>        unsigned int  a href="+code=reqsize" class="sref">reqsize /a>;> 178 /a>> 179 /a>         a href="+code=spin_lock_init" class="sref">spin_lock_init /a>(& a href="+code=ctx" class="sref">ctx /a>-> a href="+code=lock" class="sref">lock /a>);> 180 /a>> 181 /a>         a href="+code=alignmask" class="sref">alignmask /a> =  a href="+code=crypto_tfm_ctx_alignment" class="sref">crypto_tfm_ctx_alignment /a>() - 1;> 182 /a>         a href="+code=reqsize" class="sref">reqsize /a> = sizeof(struct  a href="+code=eseqiv_request_ctx" class="sref">eseqiv_request_ctx /a>);> 183 /a>> 184 /a>        if ( a href="+code=alignmask" class="sref">alignmask /a> &  a href="+code=reqsize" class="sref">reqsize /a>) {> 185 /a>                 a href="+code=alignmask" class="sref">alignmask /a> &=  a href="+code=reqsize" class="sref">reqsize /a>;> 186 /a>                 a href="+code=alignmask" class="sref">alignmask /a>--;> 187 /a>        }> 188 /a>> 189 /a>         a href="+code=alignmask" class="sref">alignmask /a> = ~ a href="+code=alignmask" class="sref">alignmask /a>;> 190 /a>         a href="+code=alignmask" class="sref">alignmask /a> &=  a href="+code=crypto_ablkcipher_alignmask" class="sref">crypto_ablkcipher_alignmask /a>( a href="+code=geniv" class="sref">geniv /a>);> 191 /a>> 192 /a>         a href="+code=reqsize" class="sref">reqsize /a> +=  a href="+code=alignmask" class="sref">alignmask /a>;> 193 /a>         a href="+code=reqsize" class="sref">reqsize /a> +=  a href="+code=crypto_ablkcipher_ivsize" class="sref">crypto_ablkcipher_ivsize /a>( a href="+code=geniv" class="sref">geniv /a>);> 194 /a>         a href="+code=reqsize" class="sref">reqsize /a> =  a href="+code=ALIGN" class="sref">ALIGN /a>( a href="+code=reqsize" class="sref">reqsize /a>,  a href="+code=crypto_tfm_ctx_alignment" class="sref">crypto_tfm_ctx_alignment /a>());> 195 /a>> 196 /a>         a href="+code=ctx" class="sref">ctx /a>-> a href="+code=reqoff" class="sref">reqoff /a> =  a href="+code=reqsize" class="sref">reqsize /a> - sizeof(struct  a href="+code=eseqiv_request_ctx" class="sref">eseqiv_request_ctx /a>);> 197 /a>> 198 /a>         a href="+code=tfm" class="sref">tfm /a>-> a href="+code=crt_ablkcipher" class="sref">crt_ablkcipher /a>. a href="+code=reqsize" class="sref">reqsize /a> =  a href="+code=reqsize" class="sref">reqsize /a> +> 199 /a>                                      sizeof(struct  a href="+code=ablkcipher_request" class="sref">ablkcipher_request /a>);> 200 /a>> 201 /a>        return  a href="+code=skcipher_geniv_init" class="sref">skcipher_geniv_init /a>( a href="+code=tfm" class="sref">tfm /a>);> 202 /a>}> 203 /a>> 204 /a>static struct  a href="+code=crypto_template" class="sref">crypto_template /a>  a href="+code=eseqiv_tmpl" class="sref">eseqiv_tmpl /a>;> 205 /a>> 206 /a>static struct  a href="+code=crypto_instance" class="sref">crypto_instance /a> * a href="+code=eseqiv_alloc" class="sref">eseqiv_alloc /a>(struct  a href="+code=rtattr" class="sref">rtattr /a> ** a href="+code=tb" class="sref">tb /a>)> 207 /a>{> 208 /a>        struct  a href="+code=crypto_instance" class="sref">crypto_instance /a> * a href="+code=inst" class="sref">inst /a>;> 209 /a>        int  a href="+code=err" class="sref">err /a>;> 210 /a>> 211 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=crypto_get_default_rng" class="sref">crypto_get_default_rng /a>();> 212 /a>        if ( a href="+code=err" class="sref">err /a>)> 213 /a>                return  a href="+code=ERR_PTR" class="sref">ERR_PTR /a>( a href="+code=err" class="sref">err /a>);> 214 /a>> 215 /a>         a href="+code=inst" class="sref">inst /a> =  a href="+code=skcipher_geniv_alloc" class="sref">skcipher_geniv_alloc /a>(& a href="+code=eseqiv_tmpl" class="sref">eseqiv_tmpl /a>,  a href="+code=tb" class="sref">tb /a>, 0, 0);> 216 /a>        if ( a href="+code=IS_ERR" class="sref">IS_ERR /a>( a href="+code=inst" class="sref">inst /a>))> 217 /a>                goto  a href="+code=put_rng" class="sref">put_rng /a>;> 218 /a>> 219 /a>         a href="+code=err" class="sref">err /a> = - a href="+code=EINVAL" class="sref">EINVAL /a>;> 220 /a>        if ( a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_ablkcipher" class="sref">cra_ablkcipher /a>. a href="+code=ivsize" class="sref">ivsize /a> !=  a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_blocksize" class="sref">cra_blocksize /a>)> 221 /a>                goto  a href="+code=free_inst" class="sref">free_inst /a>;> 222 /a>> 223 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_ablkcipher" class="sref">cra_ablkcipher /a>. a href="+code=givencrypt" class="sref">givencrypt /a> =  a href="+code=eseqiv_givencrypt_first" class="sref">eseqiv_givencrypt_first /a>;> 224 /a>> 225 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_init" class="sref">cra_init /a> =  a href="+code=eseqiv_init" class="sref">eseqiv_init /a>;> 226 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_exit" class="sref">cra_exit /a> =  a href="+code=skcipher_geniv_exit" class="sref">skcipher_geniv_exit /a>;> 227 /a>> 228 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_ctxsize" class="sref">cra_ctxsize /a> = sizeof(struct  a href="+code=eseqiv_ctx" class="sref">eseqiv_ctx /a>);> 229 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_ctxsize" class="sref">cra_ctxsize /a> +=  a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=cra_ablkcipher" class="sref">cra_ablkcipher /a>. a href="+code=ivsize" class="sref">ivsize /a>;> 230 /a>> 231 /a> a href="+code=out" class="sref">out /a>:> 232 /a>        return  a href="+code=inst" class="sref">inst /a>;> 233 /a>> 234 /a> a href="+code=free_inst" class="sref">free_inst /a>:> 235 /a>         a href="+code=skcipher_geniv_free" class="sref">skcipher_geniv_free /a>( a href="+code=inst" class="sref">inst /a>);> 236 /a>         a href="+code=inst" class="sref">inst /a> =  a href="+code=ERR_PTR" class="sref">ERR_PTR /a>( a href="+code=err" class="sref">err /a>);> 237 /a> a href="+code=put_rng" class="sref">put_rng /a>:> 238 /a>         a href="+code=crypto_put_default_rng" class="sref">crypto_put_default_rng /a>();> 239 /a>        goto  a href="+code=out" class="sref">out /a>;> 240 /a>}> 241 /a>> 242 /a>static void  a href="+code=eseqiv_free" class="sref">eseqiv_free /a>(struct  a href="+code=crypto_instance" class="sref">crypto_instance /a> * a href="+code=inst" class="sref">inst /a>)> 243 /a>{> 244 /a>         a href="+code=skcipher_geniv_free" class="sref">skcipher_geniv_free /a>( a href="+code=inst" class="sref">inst /a>);> 245 /a>         a href="+code=crypto_put_default_rng" class="sref">crypto_put_default_rng /a>();> 246 /a>}> 247 /a>> 248 /a>static struct  a href="+code=crypto_template" class="sref">crypto_template /a>  a href="+code=eseqiv_tmpl" class="sref">eseqiv_tmpl /a> = {> 249 /a>        . a href="+code=namu" class="sref">namu /a> =  span class="string">"eseqiv",> 250 /a>        . a href="+code=alloc" class="sref">alloc /a> =  a href="+code=eseqiv_alloc" class="sref">eseqiv_alloc /a>,> 251 /a>        . a href="+code=free" class="sref">free /a> =  a href="+code=eseqiv_free" class="sref">eseqiv_free /a>,> 252 /a>        . a href="+code=module" class="sref">module /a> =  a href="+code=THIS_MODULE" class="sref">THIS_MODULE /a>,> 253 /a>};> 254 /a>> 255 /a>static int  a href="+code=__init" class="sref">__init /a>  a href="+code=eseqiv_module_init" class="sref">eseqiv_module_init /a>(void)> 256 /a>{> 257 /a>        return  a href="+code=crypto_register_template" class="sref">crypto_register_template /a>(& a href="+code=eseqiv_tmpl" class="sref">eseqiv_tmpl /a>);> 258 /a>}> 259 /a>> 260 /a>static void  a href="+code=__exit" class="sref">__exit /a>  a href="+code=eseqiv_module_exit" class="sref">eseqiv_module_exit /a>(void)> 261 /a>{> 262 /a>         a href="+code=crypto_unregister_template" class="sref">crypto_unregister_template /a>(& a href="+code=eseqiv_tmpl" class="sref">eseqiv_tmpl /a>);> 263 /a>}> 264 /a>> 265 /a> a href="+code=module_init" class="sref">module_init /a>( a href="+code=eseqiv_module_init" class="sref">eseqiv_module_init /a>);> 266 /a> a href="+code=module_exit" class="sref">module_exit /a>( a href="+code=eseqiv_module_exit" class="sref">eseqiv_module_exit /a>);> 267 /a>> 268 /a> a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE /a>( span class="string">"GPL");> 269 /a> a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION /a>( span class="string">"Encrypted Sequence Number IV Generator");> 270 /a>
lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operations services since 1995.