linux/crypto/cbc.c
<<
alue226/spa> 2 226/form 2 226a alue22 href="../linux+v3.7.5/crypto/cbc.c">alue226img src="../.static/gfx/right.png" alt=">>">al6/spa> 2al6spa> class="lxr_search">alue="+search" method="post" onsubmit="return do_search(this);">alue226input typ hidden" nam navtarget" n> ">alue226input typ text" nam search" id search">alue226butttiotyp submit">Search 2al6spa> class="lxr_prefs" 2 226a href="+prefs?return=crypto/cbc.c"alue22 onclick="return ajax_prefs();">alue22Prefs2 226/a>al6/spa> 2ue22 26/div 2ue22 26form ac >="ajax+*" method="post" onsubmit="return false;">al6input typ hidden" nam ajax_lookup" id ajax_lookup" n> ">aue22 26/form 2aue22 26div class="headingbotttm">
2 6div id file_contents"
2 216/a>6spa> class="comment">/*6/spa>
22 226/a>6spa> class="comment"> * CBC: Cipher Block Chaining mode6/spa>
22 236/a>6spa> class="comment"> *6/spa>
22 246/a>6spa> class="comment"> * Copyright (c) 2006 Herbert Xu <herbert@gondor.apa>a.org.au>6/spa>
22 256/a>6spa> class="comment"> *6/spa>
22 266/a>6spa> class="comment"> * This program is free software; you ca> redistribute it and/or modify it6/spa>
22 276/a>6spa> class="comment"> * under the terms of the GNU General Public License as published by the Free6/spa>
22 286/a>6spa> class="comment"> * Software Founda	  >; either versptio2 of the License, or (at your "
	  >)6/spa>
22 296/a>6spa> class="comment"> * any later verspti.6/spa>
22 
	  a>6spa> class="comment"> *6/spa>
22 116/a>6spa> class="comment"> */6/spa>
22 126/a>22 136/a>#include <crypto/algapi.h6/a>>22 146/a>#include <linux/err.h6/a>>22 156/a>#include <linux/init.h6/a>>22 166/a>#include <linux/kernel.h6/a>>22 176/a>#include <linux/log2.h6/a>>22 186/a>#include <linux/module.h6/a>>22 196/a>#include <linux/scatterlist.h6/a>>22 206/a>#include <linux/slab.h6/a>>22 216/a>22 226/a>struct26a href="+code=crypto_cbc_ctx" class="sref">crypto_cbc_ctx6/a> {22 236/a>        struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=child" class="sref">child6/a>;22 246/a>};22 256/a>22 266/a>static int26a href="+code=crypto_cbc_setkey" class="sref">crypto_cbc_setkey6/a>(struct26a href="+code=crypto_tfm" class="sref">crypto_tfm6/a> *6a href="+code=parent" class="sref">parent6/a>, const26a href="+code=u8" class="sref">u86/a> *6a href="+code=key" class="sref">key6/a>,22 276/a>                             unsigned int26a href="+code=keylen" class="sref">keylen6/a>)22 286/a>{22 296/a>        struct26a href="+code=crypto_cbc_ctx" class="sref">crypto_cbc_ctx6/a> *6a href="+code=ctx" class="sref">ctx6/a> =26a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx6/a>(6a href="+code=parent" class="sref">parent6/a>);22 306/a>        struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=child" class="sref">child6/a> =26a href="+code=ctx" class="sref">ctx6/a>->6a href="+code=child" class="sref">child6/a>;22 316/a>        int26a href="+code=err" class="sref">err6/a>;22 326/a>22 336/a>        6a href="+code=crypto_cipher_clear_flags" class="sref">crypto_cipher_clear_flags6/a>(6a href="+code=child" class="sref">child6/a>, 6a href="+code=CRYPTO_TFM_REQ_MASK" class="sref">CRYPTO_TFM_REQ_MASK6/a>);22 346/a>        6a href="+code=crypto_cipher_set_flags" class="sref">crypto_cipher_set_flags6/a>(6a href="+code=child" class="sref">child6/a>, 6a href="+code=crypto_tfm_get_flags" class="sref">crypto_tfm_get_flags6/a>(6a href="+code=parent" class="sref">parent6/a>) &22 356/a>                                       6a href="+code=CRYPTO_TFM_REQ_MASK" class="sref">CRYPTO_TFM_REQ_MASK6/a>);22 366/a>        6a href="+code=err" class="sref">err6/a> =26a href="+code=crypto_cipher_setkey" class="sref">crypto_cipher_setkey6/a>(6a href="+code=child" class="sref">child6/a>, 6a href="+code=key" class="sref">key6/a>,26a href="+code=keylen" class="sref">keylen6/a>);22 376/a>        6a href="+code=crypto_tfm_set_flags" class="sref">crypto_tfm_set_flags6/a>(6a href="+code=parent" class="sref">parent6/a>, 6a href="+code=crypto_cipher_get_flags" class="sref">crypto_cipher_get_flags6/a>(6a href="+code=child" class="sref">child6/a>) &22 386/a>                                     6a href="+code=CRYPTO_TFM_RES_MASK" class="sref">CRYPTO_TFM_RES_MASK6/a>);22 396/a>        return 6a href="+code=err" class="sref">err6/a>;22 406/a>}22 416/a>22 426/a>static int26a href="+code=crypto_cbc_encrypt_segment" class="sref">crypto_cbc_encrypt_segment6/a>(struct26a href="+code=blkcipher_desc" class="sref">blkcipher_desc6/a> *6a href="+code=desc" class="sref">desc6/a>,22 436/a>                                      struct26a href="+code=blkcipher_walk" class="sref">blkcipher_walk6/a> *6a href="+code=walk" class="sref">walk6/a>,22 446/a>                                      struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=tfm" class="sref">tfm6/a>)22 456/a>{22 466/a>        void (*6a href="+code=fn" class="sref">fn6/a>)(struct26a href="+code=crypto_tfm" class="sref">crypto_tfm6/a> *, 6a href="+code=u8" class="sref">u86/a> *, const26a href="+code=u8" class="sref">u86/a> *) =22 476/a>                6a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg6/a>(6a href="+code=tfm" class="sref">tfm6/a>)->6a href="+code=cia_encrypt" class="sref">cia_encrypt6/a>;22 486/a>        int26a href="+code=bsize" class="sref">bsize6/a> =26a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize6/a>(6a href="+code=tfm" class="sref">tfm6/a>);22 496/a>        unsigned int26a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=nbytes" class="sref">nbytes6/a>;22 506/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=src" class="sref">src6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=src" class="sref">src6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>;22 516/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=dst" class="sref">dst6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=dst" class="sref">dst6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>;22 526/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=iv" class="sref">iv6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=iv" class="sref">iv6/a>;22 536/a>22 546/a>        do {22 556/a>                6a href="+code=crypto_xor" class="sref">crypto_xor6/a>(6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=src" class="sref">src6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);22 566/a>                6a href="+code=fn" class="sref">fn6/a>(6a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm6/a>(6a href="+code=tfm" class="sref">tfm6/a>), 6a href="+code=dst" class="sref">dst6/a>, 6a href="+code=iv" class="sref">iv6/a>);22 576/a>                6a href="+code=memcpy" class="sref">memcpy6/a>(6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=dst" class="sref">dst6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);22 586/a>22 596/a>                6a href="+code=src" class="sref">src6/a> +=26a href="+code=bsize" class="sref">bsize6/a>;22 606/a>                6a href="+code=dst" class="sref">dst6/a> +=26a href="+code=bsize" class="sref">bsize6/a>;22 616/a>        } while ((6a href="+code=nbytes" class="sref">nbytes6/a> -=26a href="+code=bsize" class="sref">bsize6/a>) >=26a href="+code=bsize" class="sref">bsize6/a>);22 626/a>22 636/a>        return 6a href="+code=nbytes" class="sref">nbytes6/a>;22 646/a>}22 656/a>22 666/a>static int26a href="+code=crypto_cbc_encrypt_inplace" class="sref">crypto_cbc_encrypt_inplace6/a>(struct26a href="+code=blkcipher_desc" class="sref">blkcipher_desc6/a> *6a href="+code=desc" class="sref">desc6/a>,22 676/a>                                      struct26a href="+code=blkcipher_walk" class="sref">blkcipher_walk6/a> *6a href="+code=walk" class="sref">walk6/a>,22 686/a>                                      struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=tfm" class="sref">tfm6/a>)22 696/a>{22 706/a>        void (*6a href="+code=fn" class="sref">fn6/a>)(struct26a href="+code=crypto_tfm" class="sref">crypto_tfm6/a> *, 6a href="+code=u8" class="sref">u86/a> *, const26a href="+code=u8" class="sref">u86/a> *) =22 716/a>                6a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg6/a>(6a href="+code=tfm" class="sref">tfm6/a>)->6a href="+code=cia_encrypt" class="sref">cia_encrypt6/a>;22 726/a>        int26a href="+code=bsize" class="sref">bsize6/a> =26a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize6/a>(6a href="+code=tfm" class="sref">tfm6/a>);22 736/a>        unsigned int26a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=nbytes" class="sref">nbytes6/a>;22 746/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=src" class="sref">src6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=src" class="sref">src6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>;22 756/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=iv" class="sref">iv6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=iv" class="sref">iv6/a>;22 766/a>22 776/a>        do {22 786/a>                6a href="+code=crypto_xor" class="sref">crypto_xor6/a>(6a href="+code=src" class="sref">src6/a>, 6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);22 796/a>                6a href="+code=fn" class="sref">fn6/a>(6a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm6/a>(6a href="+code=tfm" class="sref">tfm6/a>), 6a href="+code=src" class="sref">src6/a>, 6a href="+code=src" class="sref">src6/a>);22 806/a>                6a href="+code=iv" class="sref">iv6/a> =26a href="+code=src" class="sref">src6/a>;22 816/a>22 826/a>                6a href="+code=src" class="sref">src6/a> +=26a href="+code=bsize" class="sref">bsize6/a>;22 836/a>        } while ((6a href="+code=nbytes" class="sref">nbytes6/a> -=26a href="+code=bsize" class="sref">bsize6/a>) >=26a href="+code=bsize" class="sref">bsize6/a>);22 846/a>22 856/a>        6a href="+code=memcpy" class="sref">memcpy6/a>(6a href="+code=walk" class="sref">walk6/a>->6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);22 866/a>22 876/a>        return 6a href="+code=nbytes" class="sref">nbytes6/a>;22 886/a>}22 896/a>22 906/a>static int26a href="+code=crypto_cbc_encrypt" class="sref">crypto_cbc_encrypt6/a>(struct26a href="+code=blkcipher_desc" class="sref">blkcipher_desc6/a> *6a href="+code=desc" class="sref">desc6/a>,22 916/a>                              struct26a href="+code=scatterlist" class="sref">scatterlist6/a> *6a href="+code=dst" class="sref">dst6/a>, struct26a href="+code=scatterlist" class="sref">scatterlist6/a> *6a href="+code=src" class="sref">src6/a>,22 926/a>                              unsigned int26a href="+code=nbytes" class="sref">nbytes6/a>)22 936/a>{22 946/a>        struct26a href="+code=blkcipher_walk" class="sref">blkcipher_walk6/a> 6a href="+code=walk" class="sref">walk6/a>;22 956/a>        struct26a href="+code=crypto_blkcipher" class="sref">crypto_blkcipher6/a> *6a href="+code=tfm" class="sref">tfm6/a> =26a href="+code=desc" class="sref">desc6/a>->6a href="+code=tfm" class="sref">tfm6/a>;22 966/a>        struct26a href="+code=crypto_cbc_ctx" class="sref">crypto_cbc_ctx6/a> *6a href="+code=ctx" class="sref">ctx6/a> =26a href="+code=crypto_blkcipher_ctx" class="sref">crypto_blkcipher_ctx6/a>(6a href="+code=tfm" class="sref">tfm6/a>);22 976/a>        struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=child" class="sref">child6/a> =26a href="+code=ctx" class="sref">ctx6/a>->6a href="+code=child" class="sref">child6/a>;22 986/a>        int26a href="+code=err" class="sref">err6/a>;22 996/a>221006/a>        6a href="+code=blkcipher_walk_init" class="sref">blkcipher_walk_init6/a>(&6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=dst" class="sref">dst6/a>, 6a href="+code=src" class="sref">src6/a>, 6a href="+code=nbytes" class="sref">nbytes6/a>);221016/a>        6a href="+code=err" class="sref">err6/a> =26a href="+code=blkcipher_walk_virt" class="sref">blkcipher_walk_virt6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>);221026/a>221036/a>        while ((6a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=walk" class="sref">walk6/a>.6a href="+code=nbytes" class="sref">nbytes6/a>)) {221046/a>                if (6a href="+code=walk" class="sref">walk6/a>.6a href="+code=src" class="sref">src6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a> ==26a href="+code=walk" class="sref">walk6/a>.6a href="+code=dst" class="sref">dst6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>)221056/a>                        6a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=crypto_cbc_encrypt_inplace" class="sref">crypto_cbc_encrypt_inplace6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=child" class="sref">child6/a>);221066/a>                else221076/a>                        6a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=crypto_cbc_encrypt_segment" class="sref">crypto_cbc_encrypt_segment6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=child" class="sref">child6/a>);221086/a>                6a href="+code=err" class="sref">err6/a> =26a href="+code=blkcipher_walk_done" class="sref">blkcipher_walk_done6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=nbytes" class="sref">nbytes6/a>);221096/a>        }221
	  a>221116/a>        return 6a href="+code=err" class="sref">err6/a>;221126/a>}221136/a>221146/a>static int26a href="+code=crypto_cbc_decrypt_segment" class="sref">crypto_cbc_decrypt_segment6/a>(struct26a href="+code=blkcipher_desc" class="sref">blkcipher_desc6/a> *6a href="+code=desc" class="sref">desc6/a>,221156/a>                                      struct26a href="+code=blkcipher_walk" class="sref">blkcipher_walk6/a> *6a href="+code=walk" class="sref">walk6/a>,221166/a>                                      struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=tfm" class="sref">tfm6/a>)221176/a>{221186/a>        void (*6a href="+code=fn" class="sref">fn6/a>)(struct26a href="+code=crypto_tfm" class="sref">crypto_tfm6/a> *, 6a href="+code=u8" class="sref">u86/a> *, const26a href="+code=u8" class="sref">u86/a> *) =221196/a>                6a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg6/a>(6a href="+code=tfm" class="sref">tfm6/a>)->6a href="+code=cia_decrypt" class="sref">cia_decrypt6/a>;221206/a>        int26a href="+code=bsize" class="sref">bsize6/a> =26a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize6/a>(6a href="+code=tfm" class="sref">tfm6/a>);221216/a>        unsigned int26a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=nbytes" class="sref">nbytes6/a>;221226/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=src" class="sref">src6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=src" class="sref">src6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>;221236/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=dst" class="sref">dst6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=dst" class="sref">dst6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>;221246/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=iv" class="sref">iv6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=iv" class="sref">iv6/a>;221256/a>221266/a>        do {221276/a>                6a href="+code=fn" class="sref">fn6/a>(6a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm6/a>(6a href="+code=tfm" class="sref">tfm6/a>), 6a href="+code=dst" class="sref">dst6/a>, 6a href="+code=src" class="sref">src6/a>);221286/a>                6a href="+code=crypto_xor" class="sref">crypto_xor6/a>(6a href="+code=dst" class="sref">dst6/a>, 6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);221296/a>                6a href="+code=iv" class="sref">iv6/a> =26a href="+code=src" class="sref">src6/a>;2213	  a>221316/a>                6a href="+code=src" class="sref">src6/a> +=26a href="+code=bsize" class="sref">bsize6/a>;221326/a>                6a href="+code=dst" class="sref">dst6/a> +=26a href="+code=bsize" class="sref">bsize6/a>;221336/a>        } while ((6a href="+code=nbytes" class="sref">nbytes6/a> -=26a href="+code=bsize" class="sref">bsize6/a>) >=26a href="+code=bsize" class="sref">bsize6/a>);221346/a>221356/a>        6a href="+code=memcpy" class="sref">memcpy6/a>(6a href="+code=walk" class="sref">walk6/a>->6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);221366/a>221376/a>        return 6a href="+code=nbytes" class="sref">nbytes6/a>;221386/a>}221396/a>221406/a>static int26a href="+code=crypto_cbc_decrypt_inplace" class="sref">crypto_cbc_decrypt_inplace6/a>(struct26a href="+code=blkcipher_desc" class="sref">blkcipher_desc6/a> *6a href="+code=desc" class="sref">desc6/a>,221416/a>                                      struct26a href="+code=blkcipher_walk" class="sref">blkcipher_walk6/a> *6a href="+code=walk" class="sref">walk6/a>,221426/a>                                      struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=tfm" class="sref">tfm6/a>)221436/a>{221446/a>        void (*6a href="+code=fn" class="sref">fn6/a>)(struct26a href="+code=crypto_tfm" class="sref">crypto_tfm6/a> *, 6a href="+code=u8" class="sref">u86/a> *, const26a href="+code=u8" class="sref">u86/a> *) =221456/a>                6a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg6/a>(6a href="+code=tfm" class="sref">tfm6/a>)->6a href="+code=cia_decrypt" class="sref">cia_decrypt6/a>;221466/a>        int26a href="+code=bsize" class="sref">bsize6/a> =26a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize6/a>(6a href="+code=tfm" class="sref">tfm6/a>);221476/a>        unsigned int26a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=nbytes" class="sref">nbytes6/a>;221486/a>        6a href="+code=u8" class="sref">u86/a> *6a href="+code=src" class="sref">src6/a> =26a href="+code=walk" class="sref">walk6/a>->6a href="+code=src" class="sref">src6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>;221496/a>        6a href="+code=u8" class="sref">u86/a> 6a href="+code=last_iv" class="sref">last_iv6/a>[6a href="+code=bsize" class="sref">bsize6/a>];2215	  a>221516/a>        6spa> class="comment">/* Start of the last block. */6/spa>
221526/a>        6a href="+code=src" class="sref">src6/a> +=26a href="+code=nbytes" class="sref">nbytes6/a> - (6a href="+code=nbytes" class="sref">nbytes6/a> & (6a href="+code=bsize" class="sref">bsize6/a> - 1)) - 6a href="+code=bsize" class="sref">bsize6/a>;221536/a>        6a href="+code=memcpy" class="sref">memcpy6/a>(6a href="+code=last_iv" class="sref">last_iv6/a>, 6a href="+code=src" class="sref">src6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);221546/a>221556/a>        for (;;) {221566/a>                6a href="+code=fn" class="sref">fn6/a>(6a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm6/a>(6a href="+code=tfm" class="sref">tfm6/a>), 6a href="+code=src" class="sref">src6/a>, 6a href="+code=src" class="sref">src6/a>);221576/a>                if ((6a href="+code=nbytes" class="sref">nbytes6/a> -=26a href="+code=bsize" class="sref">bsize6/a>) <26a href="+code=bsize" class="sref">bsize6/a>)221586/a>                        break;221596/a>                6a href="+code=crypto_xor" class="sref">crypto_xor6/a>(6a href="+code=src" class="sref">src6/a>, 6a href="+code=src" class="sref">src6/a> - 6a href="+code=bsize" class="sref">bsize6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);221606/a>                6a href="+code=src" class="sref">src6/a> -=26a href="+code=bsize" class="sref">bsize6/a>;221616/a>        }221626/a>221636/a>        6a href="+code=crypto_xor" class="sref">crypto_xor6/a>(6a href="+code=src" class="sref">src6/a>, 6a href="+code=walk" class="sref">walk6/a>->6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);221646/a>        6a href="+code=memcpy" class="sref">memcpy6/a>(6a href="+code=walk" class="sref">walk6/a>->6a href="+code=iv" class="sref">iv6/a>, 6a href="+code=last_iv" class="sref">last_iv6/a>, 6a href="+code=bsize" class="sref">bsize6/a>);221656/a>221666/a>        return 6a href="+code=nbytes" class="sref">nbytes6/a>;221676/a>}221686/a>221696/a>static int26a href="+code=crypto_cbc_decrypt" class="sref">crypto_cbc_decrypt6/a>(struct26a href="+code=blkcipher_desc" class="sref">blkcipher_desc6/a> *6a href="+code=desc" class="sref">desc6/a>,221706/a>                              struct26a href="+code=scatterlist" class="sref">scatterlist6/a> *6a href="+code=dst" class="sref">dst6/a>, struct26a href="+code=scatterlist" class="sref">scatterlist6/a> *6a href="+code=src" class="sref">src6/a>,2nbytes6/a>;o/cbc.c#L170" iref">src6/a> +=26a href="+code=nbyteL168"st6/a>, 6a href="+code=iv" class="srK>ss="line" nam 
 L71">2 716/a>             am 
 L163">21636s="sr113172">21726/a>{221736/a>        struct26a href="+code=blkcipher_walk" class="sref">blkcipher_walk6/a> 6a href="+code=walk" class="sref">walk6/a>;221746/a>        struct26a href="+code=crypto_blkcipher" class="sref">crypto_blkcipher6/a> *6a href="+code=tfm" class="sref">tfm6/a> =26a href="+code=desc" class="sref">desc6/a>->6a href="+code=tfm" class="sref">tfm6/a>;221756/a>        struct26a href="+code=crypto_cbc_ctx" class="sref">crypto_cbc_ctx6/a> *6a href="+code=ctx" class="sref">ctx6/a> =26a href="+code=crypto_blkcipher_ctx" class="sref">crypto_blkcipher_ctx6/a>(6a href="+code=tfm" class="sref">tfm6/a>);221766/a>        struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=child" class="sref">child6/a> =26a href="+code=ctx" class="sref">ctx6/a>->6a href="+code=child" class="sref">child6/a>;221776/a>        int26a href="+code=err" class="sref">err6/a>;221786/a>221796/a>        6a href="+code=blkcipher_walk_init" class="sref">blkcipher_walk_init6/a>(&6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=dst" class="sref">dst6/a>, 6a href="+code=src" class="sref">src6/a>, 6a href="+code=nbytes" class="sref">nbytes6/a>);221806/a>        6a href="+code=err" class="sref">err6/a> =26a href="+code=blkcipher_walk_virt" class="sref">blkcipher_walk_virt6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>);221816/a>221826/a>        while ((6a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=walk" class="sref">walk6/a>.6a href="+code=nbytes" class="sref">nbytes6/a>)) {221836/a>                if (6a href="+code=walk" class="sref">walk6/a>.6a href="+code=src" class="sref">src6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a> ==26a href="+code=walk" class="sref">walk6/a>.6a href="+code=dst" class="sref">dst6/a>.6a href="+code=virt" class="sref">virt6/a>.6a href="+code=addr" class="sref">addr6/a>)221846/a>                        6a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=crypto_cbc_decrypt_inplace" class="sref">crypto_cbc_decrypt_inplace6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=child" class="sref">child6/a>);221856/a>                else221866/a>                        6a href="+code=nbytes" class="sref">nbytes6/a> =26a href="+code=crypto_cbc_decrypt_segment" class="sref">crypto_cbc_decrypt_segment6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=child" class="sref">child6/a>);221876/a>                6a href="+code=err" class="sref">err6/a> =26a href="+code=blkcipher_walk_done" class="sref">blkcipher_walk_done6/a>(6a href="+code=desc" class="sref">desc6/a>, &6a href="+code=walk" class="sref">walk6/a>, 6a href="+code=nbytes" class="sref">nbytes6/a>);221886/a>        }221896/a>221906/a>        return 6a href="+code=err" class="sref">err6/a>;221916/a>}221926/a>221936/a>static int26a href="+code=crypto_cbc_init_tfm" class="sref">crypto_cbc_init_tfm6/a>(struct26a href="+code=crypto_tfm" class="sref">crypto_tfm6/a> *6a href="+code=tfm" class="sref">tfm6/a>)221946/a>{221956/a>        struct26a href="+code=crypto_instance" class="sref">crypto_instance6/a> *6a href="+code=inst" class="sref">inst6/a> =2(void *)6a href="+code=tfm" class="sref">tfm6/a>->6a href="+code=__crt_alg" class="sref">__crt_alg6/a>;221966/a>        struct26a href="+code=crypto_spawn" class="sref">crypto_spawn6/a> *6a href="+code=spawn" class="sref">spawn6/a> =26a href="+code=crypto_instance_ctx" class="sref">crypto_instance_ctx6/a>(6a href="+code=inst" class="sref">inst6/a>);221976/a>        struct26a href="+code=crypto_cbc_ctx" class="sref">crypto_cbc_ctx6/a> *6a href="+code=ctx" class="sref">ctx6/a> =26a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx6/a>(6a href="+code=tfm" class="sref">tfm6/a>);221986/a>        struct26a href="+code=crypto_cipher" class="sref">crypto_cipher6/a> *6a href="+code=cipher" class="sref">cipher6/a>;221996/a>222006/a>        6a href="+code=cipher" class="sref">cipher6/a> =26a href="+code=crypto_spawn_cipher" class="sref">crypto_spawn_cipher6/a>(6a href="+code=spawn" class="sref">spawn6/a>);222016/a>        if (6a href="+code=IS_ERR" class="sref">IS_ERR6/a>(6a href="+code=cipher" class="sref">cipher6/a>))222026/a>                return 6a href="+code=PTR_ERR" class="sref">PTR_ERR6/a>(6a href="+code=cipher" class="sref">cipher6/a>);222036/a>222046/a>        6a href="+code=ctx" class="sref">ctx6/a>->6a href="+code=child" class="sref">child6/a> =26a href="+code=cipher" class="sref">cipher6/a>;222056/a>        return 0;222066/a>}222076/a>222086/a>static void 6a href="+code=crypto_cbc_exit_tfm" class="sref">crypto_cbc_exit_tfm6/a>(struct26a href="+code=crypto_tfm" class="sref">crypto_tfm6/a> *6a href="+code=tfm" class="sref">tfm6/a>)222096/a>{222106/a>        struct26a href="+code=crypto_cbc_ctx" class="sref">crypto_cbc_ctx6/a> *6a href="+code=ctx" class="sref">ctx6/a> =26a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx6/a>(6a href="+code=tfm" class="sref">tfm6/a>);222116/a>        6a href="+code=crypto_free_cipher" class="sref">crypto_free_cipher6/a>(6a href="+code=ctx" class="sref">ctx6/a>->6a href="+code=child" class="sref">child6/a>);222126/a>}222136/a>222146/a>static struct26a href="+code=crypto_instance" class="sref">crypto_instance6/a> *6a href="+code=crypto_cbc_alloc" class="sref">crypto_cbc_alloc6/a>(struct26a href="+code=rtattr" class="sref">rtattr6/a> **6a href="+code=tb" class="sref">tb6/a>)222156/a>{222166/a>        struct26a href="+code=crypto_instance" class="sref">crypto_instance6/a> *6a href="+code=inst" class="sref">inst6/a>;222176/a>        struct26a href="+code=crypto_alg" class="sref">crypto_alg6/a> *6a href="+code=alg" class="sref">alg6/a>;222186/a>        int26a href="+code=err" class="sref">err6/a>;222196/a>222206/a>        6a href="+code=err" class="sref">err6/a> =26a href="+code=crypto_check_attr_type" class="sref">crypto_check_attr_type6/a>(6a href="+code=tb" class="sref">tb6/a>, 6a href="+code=CRYPTO_ALG_TYPE_BLKCIPHER" class="sref">CRYPTO_ALG_TYPE_BLKCIPHER6/a>);222216/a>        if (6a href="+code=err" class="sref">err6/a>)222226/a>                return 6a href="+code=ERR_PTR" class="sref">ERR_PTR6/a>(6a href="+code=err" class="sref">err6/a>);222236/a>222246/a>        6a href="+code=alg" class="sref">alg6/a> =26a href="+code=crypto_get_attr_alg" class="sref">crypto_get_attr_alg6/a>(6a href="+code=tb" class="sref">tb6/a>, 6a href="+code=CRYPTO_ALG_TYPE_CIPHER" class="sref">CRYPTO_ALG_TYPE_CIPHER6/a>,222256/a>                                  6a href="+code=CRYPTO_ALG_TYPE_MASK" class="sref">CRYPTO_ALG_TYPE_MASK6/a>);222266/a>        if (6a href="+code=IS_ERR" class="sref">IS_ERR6/a>(6a href="+code=alg" class="sref">alg6/a>))222276/a>                return 6a href="+code=ERR_CAST" class="sref">ERR_CAST6/a>(6a href="+code=alg" class="sref">alg6/a>);222286/a>222296/a>        6a href="+code=inst" class="sref">inst6/a> =26a href="+code=ERR_PTR" class="sref">ERR_PTR6/a>(-6a href="+code=EINVAL" class="sref">EINVAL6/a>);222306/a>        if (!6a href="+code=is_power_of_2" class="sref">is_power_of_26/a>(6a href="+code=alg" class="sref">alg6/a>->6a href="+code=cra_blocksize" class="sref">cra_blocksize6/a>))222316/a>                goto26a href="+code=out_put_alg" class="sref">out_put_alg6/a>;222326/a>222336/a>        6a href="+code=inst" class="sref">inst6/a> =26a href="+code=crypto_alloc_instance" class="sref">crypto_alloc_instance6/a>(6spa> class="string">"cbc"6/spa>
, 6a href="+code=alg" class="sref">alg6/a>);222346/a>        if (6a href="+code=IS_ERR" class="sref">IS_ERR6/a>(6a href="+code=inst" class="sref">inst6/a>))222356/a>                goto26a href="+code=out_put_alg" class="sref">out_put_alg6/a>;222366/a>222376/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_flags" class="sref">cra_flags6/a> =26a href="+code=CRYPTO_ALG_TYPE_BLKCIPHER" class="sref">CRYPTO_ALG_TYPE_BLKCIPHER6/a>;222386/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_priority" class="sref">cra_priority6/a> =26a href="+code=alg" class="sref">alg6/a>->6a href="+code=cra_priority" class="sref">cra_priority6/a>;222396/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_blocksize" class="sref">cra_blocksize6/a> =26a href="+code=alg" class="sref">alg6/a>->6a href="+code=cra_blocksize" class="sref">cra_blocksize6/a>;222406/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_alignmask" class="sref">cra_alignmask6/a> =26a href="+code=alg" class="sref">alg6/a>->6a href="+code=cra_alignmask" class="sref">cra_alignmask6/a>;222416/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_type" class="sref">cra_type6/a> =2&6a href="+code=crypto_blkcipher_type" class="sref">crypto_blkcipher_type6/a>;222426/a>222436/a>        6spa> class="comment">/* We access the data as u32s when xoring. */6/spa>
222446/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_alignmask" class="sref">cra_alignmask6/a> |=26a href="+code=__alignof__" class="sref">__alignof__6/a>(6a href="+code=u32" class="sref">u326/a>) - 1;222456/a>222466/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_blkcipher" class="sref">cra_blkcipher6/a>.6a href="+code=ivsize" class="sref">ivsize6/a> =26a href="+code=alg" class="sref">alg6/a>->6a href="+code=cra_blocksize" class="sref">cra_blocksize6/a>;222476/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_blkcipher" class="sref">cra_blkcipher6/a>.6a href="+code=min_keysize" class="sref">min_keysize6/a> =26a href="+code=alg" class="sref">alg6/a>->6a href="+code=cra_cipher" class="sref">cra_cipher6/a>.6a href="+code=cia_min_keysize" class="sref">cia_min_keysize6/a>;222486/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_blkcipher" class="sref">cra_blkcipher6/a>.6a href="+code=max_keysize" class="sref">max_keysize6/a> =26a href="+code=alg" class="sref">alg6/a>->6a href="+code=cra_cipher" class="sref">cra_cipher6/a>.6a href="+code=cia_max_keysize" class="sref">cia_max_keysize6/a>;222496/a>222506/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_ctxsize" class="sref">cra_ctxsize6/a> =2sizeof(struct26a href="+code=crypto_cbc_ctx" class="sref">crypto_cbc_ctx6/a>);222516/a>222526/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_init" class="sref">cra_init6/a> =26a href="+code=crypto_cbc_init_tfm" class="sref">crypto_cbc_init_tfm6/a>;222536/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_exit" class="sref">cra_exit6/a> =26a href="+code=crypto_cbc_exit_tfm" class="sref">crypto_cbc_exit_tfm6/a>;222546/a>222556/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_blkcipher" class="sref">cra_blkcipher6/a>.6a href="+code=setkey" class="sref">setkey6/a> =26a href="+code=crypto_cbc_setkey" class="sref">crypto_cbc_setkey6/a>;222566/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_blkcipher" class="sref">cra_blkcipher6/a>.6a href="+code=encrypt" class="sref">encrypt6/a> =26a href="+code=crypto_cbc_encrypt" class="sref">crypto_cbc_encrypt6/a>;222576/a>        6a href="+code=inst" class="sref">inst6/a>->6a href="+code=alg" class="sref">alg6/a>.6a href="+code=cra_blkcipher" class="sref">cra_blkcipher6/a>.6a href="+code=decrypt" class="sref">decrypt6/a> =26a href="+code=crypto_cbc_decrypt" class="sref">crypto_cbc_decrypt6/a>;222586/a>222596/a>6a href="+code=out_put_alg" class="sref">out_put_alg6/a>:222606/a>        6a href="+code=crypto_mod_put" class="sref">crypto_mod_put6/a>(6a href="+code=alg" class="sref">alg6/a>);222616/a>        return 6a href="+code=inst" class="sref">inst6/a>;222626/a>}222636/a>222646/a>static void 6a href="+code=crypto_cbc_free" class="sref">crypto_cbc_free6/a>(struct26a href="+code=crypto_instance" class="sref">crypto_instance6/a> *6a href="+code=inst" class="sref">inst6/a>)222656/a>{222666/a>        6a href="+code=crypto_drop_spawn" class="sref">crypto_drop_spawn6/a>(6a href="+code=crypto_instance_ctx" class="sref">crypto_instance_ctx6/a>(6a href="+code=inst" class="sref">inst6/a>));222676/a>        6a href="+code=kfree" class="sref">kfree6/a>(6a href="+code=inst" class="sref">inst6/a>);222686/a>}222696/a>222706/a>static struct26a href="+code=crypto_template" class="sref">crypto_template6/a> 6a href="+code=crypto_cbc_tmpl" class="sref">crypto_cbc_tmpl6/a> =2{2nbytes6/a2;o/cb2.c#L170" iref".6a href="+code=ntes" class="sref">ntes6/a> =26spa> class="string">"cbc"6/spa>
,221636s="sr113272">2272#L170" iref".6a href="+code=alloc" class="sref">alloc6/a> =26a href="+code=crypto_cbc_alloc" class="sref">crypto_cbc_alloc6/a>,222736/a>        .6a href="+code=free" class="sref">free6/a> =26a href="+code=crypto_cbc_free" class="sref">crypto_cbc_free6/a>,222746/a>        .6a href="+code=module" class="sref">module6/a> =26a href="+code=THIS_MODULE" class="sref">THIS_MODULE6/a>,222756/a>};222766/a>222776/a>static int26a href="+code=__init" class="sref">__init6/a> 6a href="+code=crypto_cbc_module_init" class="sref">crypto_cbc_module_init6/a>(void)222786/a>{222796/a>        return 6a href="+code=crypto_register_template" class="sref">crypto_register_template6/a>(&6a href="+code=crypto_cbc_tmpl" class="sref">crypto_cbc_tmpl6/a>);222806/a>}222816/a>222826/a>static void 6a href="+code=__exit" class="sref">__exit6/a> 6a href="+code=crypto_cbc_module_exit" class="sref">crypto_cbc_module_exit6/a>(void)222836/a>{222846/a>        6a href="+code=crypto_unregister_template" class="sref">crypto_unregister_template6/a>(&6a href="+code=crypto_cbc_tmpl" class="sref">crypto_cbc_tmpl6/a>);222856/a>}222866/a>222876/a>6a href="+code=module_init" class="sref">module_init6/a>(6a href="+code=crypto_cbc_module_init" class="sref">crypto_cbc_module_init6/a>);222886/a>6a href="+code=module_exit" class="sref">module_exit6/a>(6a href="+code=crypto_cbc_module_exit" class="sref">crypto_cbc_module_exit6/a>);222896/a>222906/a>6a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE6/a>(6spa> class="string">"GPL"6/spa>
);222916/a>6a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION6/a>(6spa> class="string">"CBC block cipher algorithm"6/spa>
);222926/a>
lxr.linux.no kindly hosted by Redpill Linpro AS6/a>, provider of Linux consulting and operations services since21995.