linux/crypto/pcbc.c
<<
opti"v4/spaval "v4/formal "v4a opti"v href="../linux+v3 666/crypto/pcbc.c">opti"v4img src="../.static/gfx/right.png" alt=">>">op4/spavalop4spav class="lxr_search">optiopti"v4input typ hidden" nam navtarget" > ">opti"v4input typ text" nam search" id search">opti"v4butt1" typ submit">Searchopti"vPrefsl "v4/a>op4/spavalti"v v4/divalti"v v4form acon v="ajax+*" method="post" onsubmit="return false;">op4input typ hidden" nam ajax_lookup" id ajax_lookup" > ">oti"v v4/formaloti"v v4div class="headingbott1m">l 4div id file_contents"a
v v14/a>4spav class="comment">/*4/spavalv v24/a>4spav class="comment"> * PCBC:vPropagating Cipher Block Chaining mode4/spavalv v34/a>4spav class="comment"> *4/spavalv v44/a>4spav class="comment"> * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.4/spavalv v54/a>4spav class="comment"> * Written by David Howells (dhowells@redhat.com)4/spavalv v64/a>4spav class="comment"> *4/spavalv v74/a>4spav class="comment"> * Derived from cbc.c4/spavalv v84/a>4spav class="comment"> * - Copyright (c) 2006 Herbert Xu <herbert@gondor.apava.org.au>4/spavalv v94/a>4spav class="comment"> *4/spavalv  4spav class="comment"> * This program is free software; you cav redistribute it and/or modify it4/spavalv 114/a>4spav class="comment"> * under the terms of the GNU General Public License as published by the Free4/spavalv 124/a>4spav class="comment"> * Software Foundaon v; either vers11"
2 of the License, or (at your tion v)4/spavalv 134/a>4spav class="comment"> * any later vers11".4/spavalv 144/a>4spav class="comment"> *4/spavalv 154/a>4spav class="comment"> */4/spavalv 164/a>lv 174/a>#include <crypto/algapi.h4/a>>lv 184/a>#include <linux/err.h4/a>>lv 194/a>#include <linux/init.h4/a>>lv 204/a>#include <linux/kernel.h4/a>>lv 214/a>#include <linux/module.h4/a>>lv 224/a>#include <linux/scatterlist.h4/a>>lv 234/a>#include <linux/slab.h4/a>>lv 244/a>lv 254/a>structv4a href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctx4/a> {lv 264/a>        structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=child" class="sref">child4/a>;lv 274/a>};lv 284/a>lv 294/a>static intv4a href="+code=crypto_pcbc_setkey" class="sref">crypto_pcbc_setkey4/a>(structv4a href="+code=crypto_tfm" class="sref">crypto_tfm4/a> *4a href="+code=parent" class="sref">parent4/a>, constv4a href="+code=u8" class="sref">u84/a> *4a href="+code=key" class="sref">key4/a>,lv 304/a>                              unsigned intv4a href="+code=keylen" class="sref">keylen4/a>)lv 314/a>{lv 324/a>        structv4a href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctx4/a> *4a href="+code=ctx" class="sref">ctx4/a> =v4a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx4/a>(4a href="+code=parent" class="sref">parent4/a>);lv 334/a>        structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=child" class="sref">child4/a> =v4a href="+code=ctx" class="sref">ctx4/a>->4a href="+code=child" class="sref">child4/a>;lv 344/a>        intv4a href="+code=err" class="sref">err4/a>;lv 354/a>lv 364/a>        4a href="+code=crypto_cipher_clear_flags" class="sref">crypto_cipher_clear_flags4/a>(4a href="+code=child" class="sref">child4/a>, 4a href="+code=CRYPTO_TFM_REQ_MASK" class="sref">CRYPTO_TFM_REQ_MASK4/a>);lv 374/a>        4a href="+code=crypto_cipher_set_flags" class="sref">crypto_cipher_set_flags4/a>(4a href="+code=child" class="sref">child4/a>, 4a href="+code=crypto_tfm_get_flags" class="sref">crypto_tfm_get_flags4/a>(4a href="+code=parent" class="sref">parent4/a>) &lv 384/a>                                4a href="+code=CRYPTO_TFM_REQ_MASK" class="sref">CRYPTO_TFM_REQ_MASK4/a>);lv 394/a>        4a href="+code=err" class="sref">err4/a> =v4a href="+code=crypto_cipher_setkey" class="sref">crypto_cipher_setkey4/a>(4a href="+code=child" class="sref">child4/a>, 4a href="+code=key" class="sref">key4/a>,v4a href="+code=keylen" class="sref">keylen4/a>);lv 404/a>        4a href="+code=crypto_tfm_set_flags" class="sref">crypto_tfm_set_flags4/a>(4a href="+code=parent" class="sref">parent4/a>, 4a href="+code=crypto_cipher_get_flags" class="sref">crypto_cipher_get_flags4/a>(4a href="+code=child" class="sref">child4/a>) &lv 414/a>                             4a href="+code=CRYPTO_TFM_RES_MASK" class="sref">CRYPTO_TFM_RES_MASK4/a>);lv 424/a>        return 4a href="+code=err" class="sref">err4/a>;lv 434/a>}lv 444/a>lv 454/a>static intv4a href="+code=crypto_pcbc_encrypt_segment" class="sref">crypto_pcbc_encrypt_segment4/a>(structv4a href="+code=blkcipher_desc" class="sref">blkcipher_desc4/a> *4a href="+code=desc" class="sref">desc4/a>,lv 464/a>                                       structv4a href="+code=blkcipher_walk" class="sref">blkcipher_walk4/a> *4a href="+code=walk" class="sref">walk4/a>,lv 474/a>                                       structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=tfm" class="sref">tfm4/a>)lv 484/a>{lv 494/a>        void (*4a href="+code=fn" class="sref">fn4/a>)(structv4a href="+code=crypto_tfm" class="sref">crypto_tfm4/a> *, 4a href="+code=u8" class="sref">u84/a> *, constv4a href="+code=u8" class="sref">u84/a> *) =lv 504/a>                4a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg4/a>(4a href="+code=tfm" class="sref">tfm4/a>)->4a href="+code=cia_encrypt" class="sref">cia_encrypt4/a>;lv 514/a>        intv4a href="+code=bsize" class="sref">bsize4/a> =v4a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv 524/a>        unsigned intv4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=nbytes" class="sref">nbytes4/a>;lv 534/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=src" class="sref">src4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=src" class="sref">src4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>;lv 544/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=dst" class="sref">dst4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=dst" class="sref">dst4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>;lv 554/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=iv" class="sref">iv4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=iv" class="sref">iv4/a>;lv 564/a>lv 574/a>        do {lv 584/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 594/a>                4a href="+code=fn" class="sref">fn4/a>(4a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm4/a>(4a href="+code=tfm" class="sref">tfm4/a>), 4a href="+code=dst" class="sref">dst4/a>, 4a href="+code=iv" class="sref">iv4/a>);lv 604/a>                4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=dst" class="sref">dst4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 614/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 624/a>lv 634/a>                4a href="+code=src" class="sref">src4/a> +=v4a href="+code=bsize" class="sref">bsize4/a>;lv 644/a>                4a href="+code=dst" class="sref">dst4/a> +=v4a href="+code=bsize" class="sref">bsize4/a>;lv 654/a>        } while ((4a href="+code=nbytes" class="sref">nbytes4/a> -=v4a href="+code=bsize" class="sref">bsize4/a>) >=v4a href="+code=bsize" class="sref">bsize4/a>);lv 664/a>lv 674/a>        return 4a href="+code=nbytes" class="sref">nbytes4/a>;lv 684/a>}lv 694/a>lv 704/a>static intv4a href="+code=crypto_pcbc_encrypt_inplace" class="sref">crypto_pcbc_encrypt_inplace4/a>(structv4a href="+code=blkcipher_desc" class="sref">blkcipher_desc4/a> *4a href="+code=desc" class="sref">desc4/a>,lv 714/a>                                       structv4a href="+code=blkcipher_walk" class="sref">blkcipher_walk4/a> *4a href="+code=walk" class="sref">walk4/a>,lv 724/a>                                       structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=tfm" class="sref">tfm4/a>)lv 734/a>{lv 744/a>        void (*4a href="+code=fn" class="sref">fn4/a>)(structv4a href="+code=crypto_tfm" class="sref">crypto_tfm4/a> *, 4a href="+code=u8" class="sref">u84/a> *, constv4a href="+code=u8" class="sref">u84/a> *) =lv 754/a>                4a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg4/a>(4a href="+code=tfm" class="sref">tfm4/a>)->4a href="+code=cia_encrypt" class="sref">cia_encrypt4/a>;lv 764/a>        intv4a href="+code=bsize" class="sref">bsize4/a> =v4a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv 774/a>        unsigned intv4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=nbytes" class="sref">nbytes4/a>;lv 784/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=src" class="sref">src4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=src" class="sref">src4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>;lv 794/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=iv" class="sref">iv4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=iv" class="sref">iv4/a>;lv 804/a>        4a href="+code=u8" class="sref">u84/a> 4a href="+code=tmpbuf" class="sref">tmpbuf4/a>[4a href="+code=bsize" class="sref">bsize4/a>];lv 814/a>lv 824/a>        do {lv 834/a>                4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=tmpbuf" class="sref">tmpbuf4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 844/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 854/a>                4a href="+code=fn" class="sref">fn4/a>(4a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm4/a>(4a href="+code=tfm" class="sref">tfm4/a>), 4a href="+code=src" class="sref">src4/a>, 4a href="+code=iv" class="sref">iv4/a>);lv 864/a>                4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=tmpbuf" class="sref">tmpbuf4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 874/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 884/a>lv 894/a>                4a href="+code=src" class="sref">src4/a> +=v4a href="+code=bsize" class="sref">bsize4/a>;lv 904/a>        } while ((4a href="+code=nbytes" class="sref">nbytes4/a> -=v4a href="+code=bsize" class="sref">bsize4/a>) >=v4a href="+code=bsize" class="sref">bsize4/a>);lv 914/a>lv 924/a>        4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=walk" class="sref">walk4/a>->4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv 934/a>lv 944/a>        return 4a href="+code=nbytes" class="sref">nbytes4/a>;lv 954/a>}lv 964/a>lv 974/a>static intv4a href="+code=crypto_pcbc_encrypt" class="sref">crypto_pcbc_encrypt4/a>(structv4a href="+code=blkcipher_desc" class="sref">blkcipher_desc4/a> *4a href="+code=desc" class="sref">desc4/a>,lv 984/a>                               structv4a href="+code=scatterlist" class="sref">scatterlist4/a> *4a href="+code=dst" class="sref">dst4/a>, structv4a href="+code=scatterlist" class="sref">scatterlist4/a> *4a href="+code=src" class="sref">src4/a>,lv 994/a>                               unsigned intv4a href="+code=nbytes" class="sref">nbytes4/a>)lv1004/a>{lv1014/a>        structv4a href="+code=blkcipher_walk" class="sref">blkcipher_walk4/a> 4a href="+code=walk" class="sref">walk4/a>;lv1024/a>        structv4a href="+code=crypto_blkcipher" class="sref">crypto_blkcipher4/a> *4a href="+code=tfm" class="sref">tfm4/a> =v4a href="+code=desc" class="sref">desc4/a>->4a href="+code=tfm" class="sref">tfm4/a>;lv1034/a>        structv4a href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctx4/a> *4a href="+code=ctx" class="sref">ctx4/a> =v4a href="+code=crypto_blkcipher_ctx" class="sref">crypto_blkcipher_ctx4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv1044/a>        structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=child" class="sref">child4/a> =v4a href="+code=ctx" class="sref">ctx4/a>->4a href="+code=child" class="sref">child4/a>;lv1054/a>        intv4a href="+code=err" class="sref">err4/a>;lv1064/a>lv1074/a>        4a href="+code=blkcipher_walk_init" class="sref">blkcipher_walk_init4/a>(&4a href="+code=walk" class="sref">walk4/a>, 4a href="+code=dst" class="sref">dst4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=nbytes" class="sref">nbytes4/a>);lv1084/a>        4a href="+code=err" class="sref">err4/a> =v4a href="+code=blkcipher_walk_virt" class="sref">blkcipher_walk_virt4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>);lv1094/a>lv1104/a>        while ((4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=walk" class="sref">walk4/a>.4a href="+code=nbytes" class="sref">nbytes4/a>)) {lv1114/a>                if (4a href="+code=walk" class="sref">walk4/a>.4a href="+code=src" class="sref">src4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a> ==v4a href="+code=walk" class="sref">walk4/a>.4a href="+code=dst" class="sref">dst4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>)lv1124/a>                        4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=crypto_pcbc_encrypt_inplace" class="sref">crypto_pcbc_encrypt_inplace4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>,lv1134/a>                                                             4a href="+code=child" class="sref">child4/a>);lv1144/a>                elselv1154/a>                        4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=crypto_pcbc_encrypt_segment" class="sref">crypto_pcbc_encrypt_segment4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>,lv1164/a>                                                             4a href="+code=child" class="sref">child4/a>);lv1174/a>                4a href="+code=err" class="sref">err4/a> =v4a href="+code=blkcipher_walk_done" class="sref">blkcipher_walk_done4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>, 4a href="+code=nbytes" class="sref">nbytes4/a>);lv1184/a>        }lv1194/a>lv1204/a>        return 4a href="+code=err" class="sref">err4/a>;lv1214/a>}lv1224/a>lv1234/a>static intv4a href="+code=crypto_pcbc_decrypt_segment" class="sref">crypto_pcbc_decrypt_segment4/a>(structv4a href="+code=blkcipher_desc" class="sref">blkcipher_desc4/a> *4a href="+code=desc" class="sref">desc4/a>,lv1244/a>                                       structv4a href="+code=blkcipher_walk" class="sref">blkcipher_walk4/a> *4a href="+code=walk" class="sref">walk4/a>,lv1254/a>                                       structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=tfm" class="sref">tfm4/a>)lv1264/a>{lv1274/a>        void (*4a href="+code=fn" class="sref">fn4/a>)(structv4a href="+code=crypto_tfm" class="sref">crypto_tfm4/a> *, 4a href="+code=u8" class="sref">u84/a> *, constv4a href="+code=u8" class="sref">u84/a> *) =lv1284/a>                4a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg4/a>(4a href="+code=tfm" class="sref">tfm4/a>)->4a href="+code=cia_decrypt" class="sref">cia_decrypt4/a>;lv1294/a>        intv4a href="+code=bsize" class="sref">bsize4/a> =v4a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv1304/a>        unsigned intv4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=nbytes" class="sref">nbytes4/a>;lv1314/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=src" class="sref">src4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=src" class="sref">src4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>;lv1324/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=dst" class="sref">dst4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=dst" class="sref">dst4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>;lv1334/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=iv" class="sref">iv4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=iv" class="sref">iv4/a>;lv1344/a>lv1354/a>        do {lv1364/a>                4a href="+code=fn" class="sref">fn4/a>(4a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm4/a>(4a href="+code=tfm" class="sref">tfm4/a>), 4a href="+code=dst" class="sref">dst4/a>, 4a href="+code=src" class="sref">src4/a>);lv1374/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=dst" class="sref">dst4/a>, 4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1384/a>                4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1394/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=dst" class="sref">dst4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1404/a>lv1414/a>                4a href="+code=src" class="sref">src4/a> +=v4a href="+code=bsize" class="sref">bsize4/a>;lv1424/a>                4a href="+code=dst" class="sref">dst4/a> +=v4a href="+code=bsize" class="sref">bsize4/a>;lv1434/a>        } while ((4a href="+code=nbytes" class="sref">nbytes4/a> -=v4a href="+code=bsize" class="sref">bsize4/a>) >=v4a href="+code=bsize" class="sref">bsize4/a>);lv1444/a>lv1454/a>        4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=walk" class="sref">walk4/a>->4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1464/a>lv1474/a>        return 4a href="+code=nbytes" class="sref">nbytes4/a>;lv1484/a>}lv1494/a>lv1504/a>static intv4a href="+code=crypto_pcbc_decrypt_inplace" class="sref">crypto_pcbc_decrypt_inplace4/a>(structv4a href="+code=blkcipher_desc" class="sref">blkcipher_desc4/a> *4a href="+code=desc" class="sref">desc4/a>,lv1514/a>                                       structv4a href="+code=blkcipher_walk" class="sref">blkcipher_walk4/a> *4a href="+code=walk" class="sref">walk4/a>,lv1524/a>                                       structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=tfm" class="sref">tfm4/a>)lv1534/a>{lv1544/a>        void (*4a href="+code=fn" class="sref">fn4/a>)(structv4a href="+code=crypto_tfm" class="sref">crypto_tfm4/a> *, 4a href="+code=u8" class="sref">u84/a> *, constv4a href="+code=u8" class="sref">u84/a> *) =lv1554/a>                4a href="+code=crypto_cipher_alg" class="sref">crypto_cipher_alg4/a>(4a href="+code=tfm" class="sref">tfm4/a>)->4a href="+code=cia_decrypt" class="sref">cia_decrypt4/a>;lv1564/a>        intv4a href="+code=bsize" class="sref">bsize4/a> =v4a href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksize4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv1574/a>        unsigned intv4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=nbytes" class="sref">nbytes4/a>;lv1584/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=src" class="sref">src4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=src" class="sref">src4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>;lv1594/a>        4a href="+code=u8" class="sref">u84/a> *4a href="+code=iv" class="sref">iv4/a> =v4a href="+code=walk" class="sref">walk4/a>->4a href="+code=iv" class="sref">iv4/a>;lv1604/a>        4a href="+code=u8" class="sref">u84/a> 4a href="+code=tmpbuf" class="sref">tmpbuf4/a>[4a href="+code=bsize" class="sref">bsize4/a>];lv1614/a>lv1624/a>        do {lv1634/a>                4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=tmpbuf" class="sref">tmpbuf4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1644/a>                4a href="+code=fn" class="sref">fn4/a>(4a href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfm4/a>(4a href="+code=tfm" class="sref">tfm4/a>), 4a href="+code=src" class="sref">src4/a>, 4a href="+code=src" class="sref">src4/a>);lv1654/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=src" class="sref">src4/a>, 4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1664/a>                4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=tmpbuf" class="sref">tmpbuf4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1674/a>                4a href="+code=crypto_xor" class="sref">crypto_xor4/a>(4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1684/a>lv1694/a>                4a href="+code=src" class="sref">src4/a> +=v4a href="+code=bsize" class="sref">bsize4/a>;lv1704/a>        } while ((4a href="+code=nbytes" class="sref">nbytes4/a> -=v4a href="+code=bsize" class="sref">bsize4/a>) >=v4a href="+code=bsize" class="sref">bsize4/a>);lv1714/a>lv1724/a>        4a href="+code=memcpy" class="sref">memcpy4/a>(4a href="+code=walk" class="sref">walk4/a>->4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=iv" class="sref">iv4/a>, 4a href="+code=bsize" class="sref">bsize4/a>);lv1734/a>lv1744/a>        return 4a href="+code=nbytes" class="sref">nbytes4/a>;lv1754/a>}lv1764/a>lv1774/a>static intv4a href="+code=crypto_pcbc_decrypt" class="sref">crypto_pcbc_decrypt4/a>(structv4a href="+code=blkcipher_desc" class="sref">blkcipher_desc4/a> *4a href="+code=desc" class="sref">desc4/a>,lv1784/a>                               structv4a href="+code=scatterlist" class="sref">scatterlist4/a> *4a href="+code=dst" class="sref">dst4/a>, structv4a href="+code=scatterlist" class="sref">scatterlist4/a> *4a href="+code=src" class="sref">src4/a>,lv1794/a>                               unsigned intv4a href="+code=nbytes" class="sref">nbytes4/a>)lv1804/a>{lv1814/a>        structv4a href="+code=blkcipher_walk" class="sref">blkcipher_walk4/a> 4a href="+code=walk" class="sref">walk4/a>;lv1824/a>        structv4a href="+code=crypto_blkcipher" class="sref">crypto_blkcipher4/a> *4a href="+code=tfm" class="sref">tfm4/a> =v4a href="+code=desc" class="sref">desc4/a>->4a href="+code=tfm" class="sref">tfm4/a>;lv1834/a>        structv4a href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctx4/a> *4a href="+code=ctx" class="sref">ctx4/a> =v4a href="+code=crypto_blkcipher_ctx" class="sref">crypto_blkcipher_ctx4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv1844/a>        structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=child" class="sref">child4/a> =v4a href="+code=ctx" class="sref">ctx4/a>->4a href="+code=child" class="sref">child4/a>;lv1854/a>        intv4a href="+code=err" class="sref">err4/a>;lv1864/a>lv1874/a>        4a href="+code=blkcipher_walk_init" class="sref">blkcipher_walk_init4/a>(&4a href="+code=walk" class="sref">walk4/a>, 4a href="+code=dst" class="sref">dst4/a>, 4a href="+code=src" class="sref">src4/a>, 4a href="+code=nbytes" class="sref">nbytes4/a>);lv1884/a>        4a href="+code=err" class="sref">err4/a> =v4a href="+code=blkcipher_walk_virt" class="sref">blkcipher_walk_virt4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>);lv1894/a>lv1904/a>        while ((4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=walk" class="sref">walk4/a>.4a href="+code=nbytes" class="sref">nbytes4/a>)) {lv1914/a>                if (4a href="+code=walk" class="sref">walk4/a>.4a href="+code=src" class="sref">src4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a> ==v4a href="+code=walk" class="sref">walk4/a>.4a href="+code=dst" class="sref">dst4/a>.4a href="+code=virt" class="sref">virt4/a>.4a href="+code=addr" class="sref">addr4/a>)lv1924/a>                        4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=crypto_pcbc_decrypt_inplace" class="sref">crypto_pcbc_decrypt_inplace4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>,lv1934/a>                                                             4a href="+code=child" class="sref">child4/a>);lv1944/a>                elselv1954/a>                        4a href="+code=nbytes" class="sref">nbytes4/a> =v4a href="+code=crypto_pcbc_decrypt_segment" class="sref">crypto_pcbc_decrypt_segment4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>,lv1964/a>                                                             4a href="+code=child" class="sref">child4/a>);lv1974/a>                4a href="+code=err" class="sref">err4/a> =v4a href="+code=blkcipher_walk_done" class="sref">blkcipher_walk_done4/a>(4a href="+code=desc" class="sref">desc4/a>, &4a href="+code=walk" class="sref">walk4/a>, 4a href="+code=nbytes" class="sref">nbytes4/a>);lv1984/a>        }lv1994/a>lv2004/a>        return 4a href="+code=err" class="sref">err4/a>;lv2014/a>}lv2024/a>lv2034/a>static intv4a href="+code=crypto_pcbc_init_tfm" class="sref">crypto_pcbc_init_tfm4/a>(structv4a href="+code=crypto_tfm" class="sref">crypto_tfm4/a> *4a href="+code=tfm" class="sref">tfm4/a>)lv2044/a>{lv2054/a>        structv4a href="+code=crypto_instance" class="sref">crypto_instance4/a> *4a href="+code=inst" class="sref">inst4/a> =v(void *)4a href="+code=tfm" class="sref">tfm4/a>->4a href="+code=__crt_alg" class="sref">__crt_alg4/a>;lv2064/a>        structv4a href="+code=crypto_spawn" class="sref">crypto_spawn4/a> *4a href="+code=spawn" class="sref">spawn4/a> =v4a href="+code=crypto_instance_ctx" class="sref">crypto_instance_ctx4/a>(4a href="+code=inst" class="sref">inst4/a>);lv2074/a>        structv4a href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctx4/a> *4a href="+code=ctx" class="sref">ctx4/a> =v4a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv2084/a>        structv4a href="+code=crypto_cipher" class="sref">crypto_cipher4/a> *4a href="+code=cipher" class="sref">cipher4/a>;lv2094/a>lv2104/a>        4a href="+code=cipher" class="sref">cipher4/a> =v4a href="+code=crypto_spawn_cipher" class="sref">crypto_spawn_cipher4/a>(4a href="+code=spawn" class="sref">spawn4/a>);lv2114/a>        if (4a href="+code=IS_ERR" class="sref">IS_ERR4/a>(4a href="+code=cipher" class="sref">cipher4/a>))lv2124/a>                return 4a href="+code=PTR_ERR" class="sref">PTR_ERR4/a>(4a href="+code=cipher" class="sref">cipher4/a>);lv2134/a>lv2144/a>        4a href="+code=ctx" class="sref">ctx4/a>->4a href="+code=child" class="sref">child4/a> =v4a href="+code=cipher" class="sref">cipher4/a>;lv2154/a>        return 0;lv2164/a>}lv2174/a>lv2184/a>static void 4a href="+code=crypto_pcbc_exit_tfm" class="sref">crypto_pcbc_exit_tfm4/a>(structv4a href="+code=crypto_tfm" class="sref">crypto_tfm4/a> *4a href="+code=tfm" class="sref">tfm4/a>)lv2194/a>{lv2204/a>        structv4a href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctx4/a> *4a href="+code=ctx" class="sref">ctx4/a> =v4a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx4/a>(4a href="+code=tfm" class="sref">tfm4/a>);lv2214/a>        4a href="+code=crypto_free_cipher" class="sref">crypto_free_cipher4/a>(4a href="+code=ctx" class="sref">ctx4/a>->4a href="+code=child" class="sref">child4/a>);lv2224/a>}lv2234/a>lv2244/a>static structv4a href="+code=crypto_instance" class="sref">crypto_instance4/a> *4a href="+code=crypto_pcbc_alloc" class="sref">crypto_pcbc_alloc4/a>(structv4a href="+code=rtattr" class="sref">rtattr4/a> **4a href="+code=tb" class="sref">tb4/a>)lv2254/a>{lv2264/a>        structv4a href="+code=crypto_instance" class="sref">crypto_instance4/a> *4a href="+code=inst" class="sref">inst4/a>;lv2274/a>        structv4a href="+code=crypto_alg" class="sref">crypto_alg4/a> *4a href="+code=alg" class="sref">alg4/a>;lv2284/a>        intv4a href="+code=err" class="sref">err4/a>;lv2294/a>lv2304/a>        4a href="+code=err" class="sref">err4/a> =v4a href="+code=crypto_check_attr_type" class="sref">crypto_check_attr_type4/a>(4a href="+code=tb" class="sref">tb4/a>, 4a href="+code=CRYPTO_ALG_TYPE_BLKCIPHER" class="sref">CRYPTO_ALG_TYPE_BLKCIPHER4/a>);lv2314/a>        if (4a href="+code=err" class="sref">err4/a>)lv2324/a>                return 4a href="+code=ERR_PTR" class="sref">ERR_PTR4/a>(4a href="+code=err" class="sref">err4/a>);lv2334/a>lv2344/a>        4a href="+code=alg" class="sref">alg4/a> =v4a href="+code=crypto_get_attr_alg" class="sref">crypto_get_attr_alg4/a>(4a href="+code=tb" class="sref">tb4/a>, 4a href="+code=CRYPTO_ALG_TYPE_CIPHER" class="sref">CRYPTO_ALG_TYPE_CIPHER4/a>,lv2354/a>                                  4a href="+code=CRYPTO_ALG_TYPE_MASK" class="sref">CRYPTO_ALG_TYPE_MASK4/a>);lv2364/a>        if (4a href="+code=IS_ERR" class="sref">IS_ERR4/a>(4a href="+code=alg" class="sref">alg4/a>))lv2374/a>                return 4a href="+code=ERR_CAST" class="sref">ERR__CAS4/a>(4a href="+code=alg" class="sref">alg4/a>)v2384/a>lv2394/a>        4a href="+code=inst" class="sref">inst4/a> =v4a href="+code=crypto_alloc_instance" class="sref">crypto_alloc_instance4/a>(4span class="string">"pcbc", 4a href="+code=alg" class="sref">alg4/a>)v2404/a>        if (4a href="+code=IS_ERR" class="sref">IS_ERR4/a>(4a href="+code=inst" class="sref">inst4/a>))lv2414/a>                goto 4a href="+code=out_put_alg" class="sref">out_put_alg4/a>;lv2424/a>lv2434/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_flags" class="sref">cra_flags4/a> =v4a href="+code=CRYPTO_ALG_TYPE_BLKCIPHER" class="sref">CRYPTO_ALG_TYPE_BLKCIPHER4/a>;lv2444/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_priority" class="sref">cra_priority4/a> =v4a href="+code=alg" class="sref">alg4/a>->4a href="+code=cra_priority" class="sref">cra_priority4/a>;lv2454/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_blocksize" class="sref">cra_blocksize4/a> =v4a href="+code=alg" class="sref">alg4/a>->4a href="+code=cra_blocksize" class="sref">cra_blocksize4/a>;lv2464/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_alignmask" class="sref">cra_alignmask4/a> =v4a href="+code=alg" class="sref">alg4/a>->4a href="+code=cra_alignmask" class="sref">cra_alignmask4/a>;lv2474/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_type" class="sref">cra_type4/a> =v&4a href="+code=crypto_blkcipher_type" class="sref">crypto_blkcipher_type4/a>;lv2484/a>lv2494/a>        4span class="comment">/* We access the data as u32s when xoring. */lv2504/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_alignmask" class="sref">cra_alignmask4/a> |=v4a href="+code=__alignof__" class="sref">__alignof__4/a>(4a href="+code=u32" class="sref">u324/a>) - 1;lv2514/a>lv2524/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_blkcipher" class="sref">cra_blkcipher4/a>.4a href="+code=ivsize" class="sref">ivsize4/a> =v4a href="+code=alg" class="sref">alg4/a>->4a href="+code=cra_blocksize" class="sref">cra_blocksize4/a>;lv2534/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_blkcipher" class="sref">cra_blkcipher4/a>.4a href="+code=min_keysize" class="sref">min_keysize4/a> =v4a href="+code=alg" class="sref">alg4/a>->4a href="+code=cra_cipher" class="sref">cra_cipher4/a>.4a href="+code=cia_min_keysize" class="sref">cia_min_keysize4/a>;lv2544/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_blkcipher" class="sref">cra_blkcipher4/a>.4a href="+code=max_keysize" class="sref">max_keysize4/a> =v4a href="+code=alg" class="sref">alg4/a>->4a href="+code=cra_cipher" class="sref">cra_cipher4/a>.4a href="+code=cia_max_keysize" class="sref">cia_max_keysize4/a>;lv2554/a>lv2564/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_ctxsize" class="sref">cra_ctxsize4/a> =vsizeof(structv4a href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctx4/a>)v2574/a>lv2584/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_init" class="sref">cra_init4/a> =v4a href="+code=crypto_pcbc_init_tfm" class="sref">crypto_pcbc_init_tfm4/a>v2594/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_exit" class="sref">cra_exit4/a> =v4a href="+code=crypto_pcbc_exit_tfm" class="sref">crypto_pcbc_exit_tfm4/a>v2604/a>lv2614/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_blkcipher" class="sref">cra_blkcipher4/a>.4a href="+code=setkey" class="sref">setkey4/a> =v4a href="+code=crypto_pcbc_setkey" class="sref">crypto_pcbc_setkey4/a>v2624/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_blkcipher" class="sref">cra_blkcipher4/a>.4a href="+code=encrypt" class="sref">encrypt4/a> =v4a href="+code=crypto_pcbc_encrypt" class="sref">crypto_pcbc_encrypt4/a>v2634/a>        4a href="+code=inst" class="sref">inst4/a>->4a href="+code=alg" class="sref">alg4/a>.4a href="+code=cra_blkcipher" class="sref">cra_blkcipher4/a>.4a href="+code=decrypt" class="sref">decrypt4/a> =v4a href="+code=crypto_pcbc_decrypt" class="sref">crypto_pcbc_decrypt4/a>;lv2644/a>lv2654/a>4a href="+code=out_put_alg" class="sref">out_put_alg4/a>:lv2664/a>        4a href="+code=crypto_mod_put" class="sref">crypto_mod_put4/a>(4a href="+code=alg" class="sref">alg4/a>)v2674/a>        return 4a href="+code=inst" class="sref">inst4/a>;lv2684/a>}lv2694/a>lv2704/a>static void 4a href="+code=crypto_pcbc_free" class="sref">crypto_pcbc_free4/a>(structv4a href="+code=crypto_instance" class="sref">crypto_instance4/a> *4a href="+code=inst" class="sref">inst4/a>)lv2714/a>{lv2724/a>        4a href="+code=crypto_drop_spawn" class="sref">crypto_drop_spawn4/a>(4a href="+code=crypto_instance_ctx" class="sref">crypto_instance_ctx4/a>(4a href="+code=inst" class="sref">inst4/a>))v2734/a>        4a href="+code=kfree" class="sref">kfree4/a>(4a href="+code=inst" class="sref">inst4/a>)v2744/a>}lv2754/a>lv2764/a>static structv4a href="+code=crypto_template" class="sref">crypto_template4/a> 4a href="+code=crypto_pcbc_tmpl" class="sref">crypto_pcbc_tmpl4/a> =v{lv2774/a>        .4a href="+code=nam
" class="sref">nam
4/a> =v4span class="string">"pcbc",lv2784/a>        .4a href="+code=alloc" class="sref">alloc4/a> =v4a href="+code=crypto_pcbc_alloc" class="sref">crypto_pcbc_alloc4/a>,lv2794/a>        .4a href="+code=free" class="sref">free4/a> =v4a href="+code=crypto_pcbc_free" class="sref">crypto_pcbc_free4/a>,lv2804/a>        .4a href="+code=module" class="sref">module4/a> =v4a href="+code=THIS_MODULE" class="sref">THIS_MODULE4/a>,lv2814/a>}v2824/a>lv2834/a>static intv4a href="+code=__init" class="sref">__init4/a> 4a href="+code=crypto_pcbc_module_init" class="sref">crypto_pcbc_module_init4/a>(void)lv2844/a>{lv2854/a>        return 4a href="+code=crypto_register_template" class="sref">crypto_register_template4/a>(&4a href="+code=crypto_pcbc_tmpl" class="sref">crypto_pcbc_tmpl4/a>)v2864/a>}lv2874/a>lv2884/a>static void 4a href="+code=__exit" class="sref">__exit4/a> 4a href="+code=crypto_pcbc_module_exit" class="sref">crypto_pcbc_module_exit4/a>(void)lv2894/a>{lv2904/a>        4a href="+code=crypto_unregister_template" class="sref">crypto_unregister_template4/a>(&4a href="+code=crypto_pcbc_tmpl" class="sref">crypto_pcbc_tmpl4/a>)v2914/a>}lv2924/a>lv2934/a>4a href="+code=module_init" class="sref">module_init4/a>(4a href="+code=crypto_pcbc_module_init" class="sref">crypto_pcbc_module_init4/a>)v2944/a>4a href="+code=module_exit" class="sref">module_exit4/a>(4a href="+code=crypto_pcbc_module_exit" class="sref">crypto_pcbc_module_exit4/a>)v2954/a>lv2964/a>4a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE4/a>(4span class="string">"GPL")v2974/a>4a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION4/a>(4span class="string">"PCBC block cipher algorithm")v2984/a>
lxr.linux.no kindly hosted by href="crhttp://www.redpill-linpro.no">Redpill Linpro AS4/a>, provider of Linux consulting and operations services sincev1995.