linux/crypto/pcbc.c
<<
p/spa pspa class="lxr_search"> ="+search" method="post" onsubmit="return do_search(this);"> Search p/spa ="ajax+*" method="post" onsubmit="return false;"> pinput typ"v3hidden" nam"v3ajax_lookup" idv3ajax_lookup" lue="v3">
pdiv idv3file_contents"
o o1p/a>pspa
 class="comment">/*p/spa
  o o2p/a>pspa
 class="comment"> * PCBC:oPropagating Cipher Block Chaining modep/spa
  o o3p/a>pspa
 class="comment"> *p/spa
  o o4p/a>pspa
 class="comment"> * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.p/spa
  o o5p/a>pspa
 class="comment"> * Written by David Howells (dhowells@redhat.com)p/spa
  o o6p/a>pspa
 class="comment"> *p/spa
  o o7p/a>pspa
 class="comment"> * Derived from cbc.cp/spa
  o o8p/a>pspa
 class="comment"> * - Copyright (c) 2006 Herbert Xu <herbert@gondor.apa
a.org.au>p/spa
  o o9p/a>pspa
 class="comment"> *p/spa
  o pspa
 class="comment"> * This program is free software; you ca
 redistribute it and/or modify itp/spa
  o 11p/a>pspa
 class="comment"> * under the terms of the GNU General Public License as published by the Freep/spa
  o 12p/a>pspa
 class="comment"> * Software Foundaon>
; either versn va2 of the License, or (at your tion>
)p/spa
  o 13p/a>pspa
 class="comment"> * any later versn v.p/spa
  o 14p/a>pspa
 class="comment"> *p/spa
  o 15p/a>pspa
 class="comment"> */p/spa
  o 16p/a> o 17p/a>#include <crypto/algapi.hp/a>> o 18p/a>#include <linux/err.hp/a>> o 19p/a>#include <linux/init.hp/a>> o 20p/a>#include <linux/kernel.hp/a>> o 21p/a>#include <linux/module.hp/a>> o 22p/a>#include <linux/scatterlist.hp/a>> o 23p/a>#include <linux/slab.hp/a>> o 24p/a> o 25p/a>structopa href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctxp/a> { o 26p/a>        structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=child" class="sref">childp/a>; o 27p/a>}; o 28p/a> o 29p/a>static intopa href="+code=crypto_pcbc_setkey" class="sref">crypto_pcbc_setkeyp/a>(structopa href="+code=crypto_tfm" class="sref">crypto_tfmp/a> *pa href="+code=parent" class="sref">parentp/a>, constopa href="+code=u8" class="sref">u8p/a> *pa href="+code=key" class="sref">keyp/a>, o 30p/a>                              unsigned intopa href="+code=keylen" class="sref">keylenp/a>) o 31p/a>{ o 32p/a>        structopa href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctxp/a> *pa href="+code=ctx" class="sref">ctxp/a> =opa href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctxp/a>(pa href="+code=parent" class="sref">parentp/a>); o 33p/a>        structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=child" class="sref">childp/a> =opa href="+code=ctx" class="sref">ctxp/a>->pa href="+code=child" class="sref">childp/a>; o 34p/a>        intopa href="+code=err" class="sref">errp/a>; o 35p/a> o 36p/a>        pa href="+code=crypto_cipher_clear_flags" class="sref">crypto_cipher_clear_flagsp/a>(pa href="+code=child" class="sref">childp/a>, pa href="+code=CRYPTO_TFM_REQ_MASK" class="sref">CRYPTO_TFM_REQ_MASKp/a>); o 37p/a>        pa href="+code=crypto_cipher_set_flags" class="sref">crypto_cipher_set_flagsp/a>(pa href="+code=child" class="sref">childp/a>, pa href="+code=crypto_tfm_get_flags" class="sref">crypto_tfm_get_flagsp/a>(pa href="+code=parent" class="sref">parentp/a>) & o 38p/a>                                pa href="+code=CRYPTO_TFM_REQ_MASK" class="sref">CRYPTO_TFM_REQ_MASKp/a>); o 39p/a>        pa href="+code=err" class="sref">errp/a> =opa href="+code=crypto_cipher_setkey" class="sref">crypto_cipher_setkeyp/a>(pa href="+code=child" class="sref">childp/a>, pa href="+code=key" class="sref">keyp/a>,opa href="+code=keylen" class="sref">keylenp/a>); o 40p/a>        pa href="+code=crypto_tfm_set_flags" class="sref">crypto_tfm_set_flagsp/a>(pa href="+code=parent" class="sref">parentp/a>, pa href="+code=crypto_cipher_get_flags" class="sref">crypto_cipher_get_flagsp/a>(pa href="+code=child" class="sref">childp/a>) & o 41p/a>                             pa href="+code=CRYPTO_TFM_RES_MASK" class="sref">CRYPTO_TFM_RES_MASKp/a>); o 42p/a>        return pa href="+code=err" class="sref">errp/a>; o 43p/a>} o 44p/a> o 45p/a>static intopa href="+code=crypto_pcbc_encrypt_segment" class="sref">crypto_pcbc_encrypt_segmentp/a>(structopa href="+code=blkcipher_desc" class="sref">blkcipher_descp/a> *pa href="+code=desc" class="sref">descp/a>, o 46p/a>                                       structopa href="+code=blkcipher_walk" class="sref">blkcipher_walkp/a> *pa href="+code=walk" class="sref">walkp/a>, o 47p/a>                                       structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=tfm" class="sref">tfmp/a>) o 48p/a>{ o 49p/a>        void (*pa href="+code=fn" class="sref">fnp/a>)(structopa href="+code=crypto_tfm" class="sref">crypto_tfmp/a> *, pa href="+code=u8" class="sref">u8p/a> *, constopa href="+code=u8" class="sref">u8p/a> *) = o 50p/a>                pa href="+code=crypto_cipher_alg" class="sref">crypto_cipher_algp/a>(pa href="+code=tfm" class="sref">tfmp/a>)->pa href="+code=cia_encrypt" class="sref">cia_encryptp/a>; o 51p/a>        intopa href="+code=bsize" class="sref">bsizep/a> =opa href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksizep/a>(pa href="+code=tfm" class="sref">tfmp/a>); o 52p/a>        unsigned intopa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=nbytes" class="sref">nbytesp/a>; o 53p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=src" class="sref">srcp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=src" class="sref">srcp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>; o 54p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=dst" class="sref">dstp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=dst" class="sref">dstp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>; o 55p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=iv" class="sref">ivp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=iv" class="sref">ivp/a>; o 56p/a> o 57p/a>        do { o 58p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 59p/a>                pa href="+code=fn" class="sref">fnp/a>(pa href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfmp/a>(pa href="+code=tfm" class="sref">tfmp/a>), pa href="+code=dst" class="sref">dstp/a>, pa href="+code=iv" class="sref">ivp/a>); o 60p/a>                pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=dst" class="sref">dstp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 61p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 62p/a> o 63p/a>                pa href="+code=src" class="sref">srcp/a> +=opa href="+code=bsize" class="sref">bsizep/a>; o 64p/a>                pa href="+code=dst" class="sref">dstp/a> +=opa href="+code=bsize" class="sref">bsizep/a>; o 65p/a>        } while ((pa href="+code=nbytes" class="sref">nbytesp/a> -=opa href="+code=bsize" class="sref">bsizep/a>) >=opa href="+code=bsize" class="sref">bsizep/a>); o 66p/a> o 67p/a>        return pa href="+code=nbytes" class="sref">nbytesp/a>; o 68p/a>} o 69p/a> o 70p/a>static intopa href="+code=crypto_pcbc_encrypt_inplace" class="sref">crypto_pcbc_encrypt_inplacep/a>(structopa href="+code=blkcipher_desc" class="sref">blkcipher_descp/a> *pa href="+code=desc" class="sref">descp/a>, o 71p/a>                                       structopa href="+code=blkcipher_walk" class="sref">blkcipher_walkp/a> *pa href="+code=walk" class="sref">walkp/a>, o 72p/a>                                       structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=tfm" class="sref">tfmp/a>) o 73p/a>{ o 74p/a>        void (*pa href="+code=fn" class="sref">fnp/a>)(structopa href="+code=crypto_tfm" class="sref">crypto_tfmp/a> *, pa href="+code=u8" class="sref">u8p/a> *, constopa href="+code=u8" class="sref">u8p/a> *) = o 75p/a>                pa href="+code=crypto_cipher_alg" class="sref">crypto_cipher_algp/a>(pa href="+code=tfm" class="sref">tfmp/a>)->pa href="+code=cia_encrypt" class="sref">cia_encryptp/a>; o 76p/a>        intopa href="+code=bsize" class="sref">bsizep/a> =opa href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksizep/a>(pa href="+code=tfm" class="sref">tfmp/a>); o 77p/a>        unsigned intopa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=nbytes" class="sref">nbytesp/a>; o 78p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=src" class="sref">srcp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=src" class="sref">srcp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>; o 79p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=iv" class="sref">ivp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=iv" class="sref">ivp/a>; o 80p/a>        pa href="+code=u8" class="sref">u8p/a> pa href="+code=tmpbuf" class="sref">tmpbufp/a>[pa href="+code=bsize" class="sref">bsizep/a>]; o 81p/a> o 82p/a>        do { o 83p/a>                pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=tmpbuf" class="sref">tmpbufp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 84p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 85p/a>                pa href="+code=fn" class="sref">fnp/a>(pa href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfmp/a>(pa href="+code=tfm" class="sref">tfmp/a>), pa href="+code=src" class="sref">srcp/a>, pa href="+code=iv" class="sref">ivp/a>); o 86p/a>                pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=tmpbuf" class="sref">tmpbufp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 87p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 88p/a> o 89p/a>                pa href="+code=src" class="sref">srcp/a> +=opa href="+code=bsize" class="sref">bsizep/a>; o 90p/a>        } while ((pa href="+code=nbytes" class="sref">nbytesp/a> -=opa href="+code=bsize" class="sref">bsizep/a>) >=opa href="+code=bsize" class="sref">bsizep/a>); o 91p/a> o 92p/a>        pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=walk" class="sref">walkp/a>->pa href="+code=iv" class="sref">ivp/a>, pa href="+code=iv" class="sref">ivp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o 93p/a> o 94p/a>        return pa href="+code=nbytes" class="sref">nbytesp/a>; o 95p/a>} o 96p/a> o 97p/a>static intopa href="+code=crypto_pcbc_encrypt" class="sref">crypto_pcbc_encryptp/a>(structopa href="+code=blkcipher_desc" class="sref">blkcipher_descp/a> *pa href="+code=desc" class="sref">descp/a>, o 98p/a>                               structopa href="+code=scatterlist" class="sref">scatterlistp/a> *pa href="+code=dst" class="sref">dstp/a>, structopa href="+code=scatterlist" class="sref">scatterlistp/a> *pa href="+code=src" class="sref">srcp/a>, o 99p/a>                               unsigned intopa href="+code=nbytes" class="sref">nbytesp/a>) o100p/a>{ o101p/a>        structopa href="+code=blkcipher_walk" class="sref">blkcipher_walkp/a> pa href="+code=walk" class="sref">walkp/a>; o102p/a>        structopa href="+code=crypto_blkcipher" class="sref">crypto_blkcipherp/a> *pa href="+code=tfm" class="sref">tfmp/a> =opa href="+code=desc" class="sref">descp/a>->pa href="+code=tfm" class="sref">tfmp/a>; o103p/a>        structopa href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctxp/a> *pa href="+code=ctx" class="sref">ctxp/a> =opa href="+code=crypto_blkcipher_ctx" class="sref">crypto_blkcipher_ctxp/a>(pa href="+code=tfm" class="sref">tfmp/a>); o104p/a>        structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=child" class="sref">childp/a> =opa href="+code=ctx" class="sref">ctxp/a>->pa href="+code=child" class="sref">childp/a>; o105p/a>        intopa href="+code=err" class="sref">errp/a>; o106p/a> o107p/a>        pa href="+code=blkcipher_walk_init" class="sref">blkcipher_walk_initp/a>(&pa href="+code=walk" class="sref">walkp/a>, pa href="+code=dst" class="sref">dstp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=nbytes" class="sref">nbytesp/a>); o108p/a>        pa href="+code=err" class="sref">errp/a> =opa href="+code=blkcipher_walk_virt" class="sref">blkcipher_walk_virtp/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>); o109p/a> o110p/a>        while ((pa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=walk" class="sref">walkp/a>.pa href="+code=nbytes" class="sref">nbytesp/a>)) { o111p/a>                if (pa href="+code=walk" class="sref">walkp/a>.pa href="+code=src" class="sref">srcp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a> ==opa href="+code=walk" class="sref">walkp/a>.pa href="+code=dst" class="sref">dstp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>) o112p/a>                        pa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=crypto_pcbc_encrypt_inplace" class="sref">crypto_pcbc_encrypt_inplacep/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>, o113p/a>                                                             pa href="+code=child" class="sref">childp/a>); o114p/a>                else o115p/a>                        pa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=crypto_pcbc_encrypt_segment" class="sref">crypto_pcbc_encrypt_segmentp/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>, o116p/a>                                                             pa href="+code=child" class="sref">childp/a>); o117p/a>                pa href="+code=err" class="sref">errp/a> =opa href="+code=blkcipher_walk_done" class="sref">blkcipher_walk_donep/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>, pa href="+code=nbytes" class="sref">nbytesp/a>); o118p/a>        } o119p/a> o120p/a>        return pa href="+code=err" class="sref">errp/a>; o121p/a>} o122p/a> o123p/a>static intopa href="+code=crypto_pcbc_decrypt_segment" class="sref">crypto_pcbc_decrypt_segmentp/a>(structopa href="+code=blkcipher_desc" class="sref">blkcipher_descp/a> *pa href="+code=desc" class="sref">descp/a>, o124p/a>                                       structopa href="+code=blkcipher_walk" class="sref">blkcipher_walkp/a> *pa href="+code=walk" class="sref">walkp/a>, o125p/a>                                       structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=tfm" class="sref">tfmp/a>) o126p/a>{ o127p/a>        void (*pa href="+code=fn" class="sref">fnp/a>)(structopa href="+code=crypto_tfm" class="sref">crypto_tfmp/a> *, pa href="+code=u8" class="sref">u8p/a> *, constopa href="+code=u8" class="sref">u8p/a> *) = o128p/a>                pa href="+code=crypto_cipher_alg" class="sref">crypto_cipher_algp/a>(pa href="+code=tfm" class="sref">tfmp/a>)->pa href="+code=cia_decrypt" class="sref">cia_decryptp/a>; o129p/a>        intopa href="+code=bsize" class="sref">bsizep/a> =opa href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksizep/a>(pa href="+code=tfm" class="sref">tfmp/a>); o130p/a>        unsigned intopa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=nbytes" class="sref">nbytesp/a>; o131p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=src" class="sref">srcp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=src" class="sref">srcp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>; o132p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=dst" class="sref">dstp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=dst" class="sref">dstp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>; o133p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=iv" class="sref">ivp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=iv" class="sref">ivp/a>; o134p/a> o135p/a>        do { o136p/a>                pa href="+code=fn" class="sref">fnp/a>(pa href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfmp/a>(pa href="+code=tfm" class="sref">tfmp/a>), pa href="+code=dst" class="sref">dstp/a>, pa href="+code=src" class="sref">srcp/a>); o137p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=dst" class="sref">dstp/a>, pa href="+code=iv" class="sref">ivp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o138p/a>                pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o139p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=dst" class="sref">dstp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o140p/a> o141p/a>                pa href="+code=src" class="sref">srcp/a> +=opa href="+code=bsize" class="sref">bsizep/a>; o142p/a>                pa href="+code=dst" class="sref">dstp/a> +=opa href="+code=bsize" class="sref">bsizep/a>; o143p/a>        } while ((pa href="+code=nbytes" class="sref">nbytesp/a> -=opa href="+code=bsize" class="sref">bsizep/a>) >=opa href="+code=bsize" class="sref">bsizep/a>); o144p/a> o145p/a>        pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=walk" class="sref">walkp/a>->pa href="+code=iv" class="sref">ivp/a>, pa href="+code=iv" class="sref">ivp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o146p/a> o147p/a>        return pa href="+code=nbytes" class="sref">nbytesp/a>; o148p/a>} o149p/a> o150p/a>static intopa href="+code=crypto_pcbc_decrypt_inplace" class="sref">crypto_pcbc_decrypt_inplacep/a>(structopa href="+code=blkcipher_desc" class="sref">blkcipher_descp/a> *pa href="+code=desc" class="sref">descp/a>, o151p/a>                                       structopa href="+code=blkcipher_walk" class="sref">blkcipher_walkp/a> *pa href="+code=walk" class="sref">walkp/a>, o152p/a>                                       structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=tfm" class="sref">tfmp/a>) o153p/a>{ o154p/a>        void (*pa href="+code=fn" class="sref">fnp/a>)(structopa href="+code=crypto_tfm" class="sref">crypto_tfmp/a> *, pa href="+code=u8" class="sref">u8p/a> *, constopa href="+code=u8" class="sref">u8p/a> *) = o155p/a>                pa href="+code=crypto_cipher_alg" class="sref">crypto_cipher_algp/a>(pa href="+code=tfm" class="sref">tfmp/a>)->pa href="+code=cia_decrypt" class="sref">cia_decryptp/a>; o156p/a>        intopa href="+code=bsize" class="sref">bsizep/a> =opa href="+code=crypto_cipher_blocksize" class="sref">crypto_cipher_blocksizep/a>(pa href="+code=tfm" class="sref">tfmp/a>); o157p/a>        unsigned intopa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=nbytes" class="sref">nbytesp/a>; o158p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=src" class="sref">srcp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=src" class="sref">srcp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>; o159p/a>        pa href="+code=u8" class="sref">u8p/a> *pa href="+code=iv" class="sref">ivp/a> =opa href="+code=walk" class="sref">walkp/a>->pa href="+code=iv" class="sref">ivp/a>; o160p/a>        pa href="+code=u8" class="sref">u8p/a> pa href="+code=tmpbuf" class="sref">tmpbufp/a>[pa href="+code=bsize" class="sref">bsizep/a>]; o161p/a> o162p/a>        do { o163p/a>                pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=tmpbuf" class="sref">tmpbufp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o164p/a>                pa href="+code=fn" class="sref">fnp/a>(pa href="+code=crypto_cipher_tfm" class="sref">crypto_cipher_tfmp/a>(pa href="+code=tfm" class="sref">tfmp/a>), pa href="+code=src" class="sref">srcp/a>, pa href="+code=src" class="sref">srcp/a>); o165p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=src" class="sref">srcp/a>, pa href="+code=iv" class="sref">ivp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o166p/a>                pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=tmpbuf" class="sref">tmpbufp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o167p/a>                pa href="+code=crypto_xor" class="sref">crypto_xorp/a>(pa href="+code=iv" class="sref">ivp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o168p/a> o169p/a>                pa href="+code=src" class="sref">srcp/a> +=opa href="+code=bsize" class="sref">bsizep/a>; o170p/a>        } while ((pa href="+code=nbytes" class="sref">nbytesp/a> -=opa href="+code=bsize" class="sref">bsizep/a>) >=opa href="+code=bsize" class="sref">bsizep/a>); o171p/a> o172p/a>        pa href="+code=memcpy" class="sref">memcpyp/a>(pa href="+code=walk" class="sref">walkp/a>->pa href="+code=iv" class="sref">ivp/a>, pa href="+code=iv" class="sref">ivp/a>, pa href="+code=bsize" class="sref">bsizep/a>); o173p/a> o174p/a>        return pa href="+code=nbytes" class="sref">nbytesp/a>; o175p/a>} o176p/a> o177p/a>static intopa href="+code=crypto_pcbc_decrypt" class="sref">crypto_pcbc_decryptp/a>(structopa href="+code=blkcipher_desc" class="sref">blkcipher_descp/a> *pa href="+code=desc" class="sref">descp/a>, o178p/a>                               structopa href="+code=scatterlist" class="sref">scatterlistp/a> *pa href="+code=dst" class="sref">dstp/a>, structopa href="+code=scatterlist" class="sref">scatterlistp/a> *pa href="+code=src" class="sref">srcp/a>, o179p/a>                               unsigned intopa href="+code=nbytes" class="sref">nbytesp/a>) o180p/a>{ o181p/a>        structopa href="+code=blkcipher_walk" class="sref">blkcipher_walkp/a> pa href="+code=walk" class="sref">walkp/a>; o182p/a>        structopa href="+code=crypto_blkcipher" class="sref">crypto_blkcipherp/a> *pa href="+code=tfm" class="sref">tfmp/a> =opa href="+code=desc" class="sref">descp/a>->pa href="+code=tfm" class="sref">tfmp/a>; o183p/a>        structopa href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctxp/a> *pa href="+code=ctx" class="sref">ctxp/a> =opa href="+code=crypto_blkcipher_ctx" class="sref">crypto_blkcipher_ctxp/a>(pa href="+code=tfm" class="sref">tfmp/a>); o184p/a>        structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=child" class="sref">childp/a> =opa href="+code=ctx" class="sref">ctxp/a>->pa href="+code=child" class="sref">childp/a>; o185p/a>        intopa href="+code=err" class="sref">errp/a>; o186p/a> o187p/a>        pa href="+code=blkcipher_walk_init" class="sref">blkcipher_walk_initp/a>(&pa href="+code=walk" class="sref">walkp/a>, pa href="+code=dst" class="sref">dstp/a>, pa href="+code=src" class="sref">srcp/a>, pa href="+code=nbytes" class="sref">nbytesp/a>); o188p/a>        pa href="+code=err" class="sref">errp/a> =opa href="+code=blkcipher_walk_virt" class="sref">blkcipher_walk_virtp/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>); o189p/a> o190p/a>        while ((pa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=walk" class="sref">walkp/a>.pa href="+code=nbytes" class="sref">nbytesp/a>)) { o191p/a>                if (pa href="+code=walk" class="sref">walkp/a>.pa href="+code=src" class="sref">srcp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a> ==opa href="+code=walk" class="sref">walkp/a>.pa href="+code=dst" class="sref">dstp/a>.pa href="+code=virt" class="sref">virtp/a>.pa href="+code=addr" class="sref">addrp/a>) o192p/a>                        pa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=crypto_pcbc_decrypt_inplace" class="sref">crypto_pcbc_decrypt_inplacep/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>, o193p/a>                                                             pa href="+code=child" class="sref">childp/a>); o194p/a>                else o195p/a>                        pa href="+code=nbytes" class="sref">nbytesp/a> =opa href="+code=crypto_pcbc_decrypt_segment" class="sref">crypto_pcbc_decrypt_segmentp/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>, o196p/a>                                                             pa href="+code=child" class="sref">childp/a>); o197p/a>                pa href="+code=err" class="sref">errp/a> =opa href="+code=blkcipher_walk_done" class="sref">blkcipher_walk_donep/a>(pa href="+code=desc" class="sref">descp/a>, &pa href="+code=walk" class="sref">walkp/a>, pa href="+code=nbytes" class="sref">nbytesp/a>); o198p/a>        } o199p/a> o200p/a>        return pa href="+code=err" class="sref">errp/a>; o201p/a>} o202p/a> o203p/a>static intopa href="+code=crypto_pcbc_init_tfm" class="sref">crypto_pcbc_init_tfmp/a>(structopa href="+code=crypto_tfm" class="sref">crypto_tfmp/a> *pa href="+code=tfm" class="sref">tfmp/a>) o204p/a>{ o205p/a>        structopa href="+code=crypto_instance" class="sref">crypto_instancep/a> *pa href="+code=inst" class="sref">instp/a> =o(void *)pa href="+code=tfm" class="sref">tfmp/a>->pa href="+code=__crt_alg" class="sref">__crt_algp/a>; o206p/a>        structopa href="+code=crypto_spawn" class="sref">crypto_spawnp/a> *pa href="+code=spawn" class="sref">spawnp/a> =opa href="+code=crypto_instance_ctx" class="sref">crypto_instance_ctxp/a>(pa href="+code=inst" class="sref">instp/a>); o207p/a>        structopa href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctxp/a> *pa href="+code=ctx" class="sref">ctxp/a> =opa href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctxp/a>(pa href="+code=tfm" class="sref">tfmp/a>); o208p/a>        structopa href="+code=crypto_cipher" class="sref">crypto_cipherp/a> *pa href="+code=cipher" class="sref">cipherp/a>; o209p/a> o210p/a>        pa href="+code=cipher" class="sref">cipherp/a> =opa href="+code=crypto_spawn_cipher" class="sref">crypto_spawn_cipherp/a>(pa href="+code=spawn" class="sref">spawnp/a>); o211p/a>        if (pa href="+code=IS_ERR" class="sref">IS_ERRp/a>(pa href="+code=cipher" class="sref">cipherp/a>)) o212p/a>                return pa href="+code=PTR_ERR" class="sref">PTR_ERRp/a>(pa href="+code=cipher" class="sref">cipherp/a>); o213p/a> o214p/a>        pa href="+code=ctx" class="sref">ctxp/a>->pa href="+code=child" class="sref">childp/a> =opa href="+code=cipher" class="sref">cipherp/a>; o215p/a>        return 0; o216p/a>} o217p/a> o218p/a>static void pa href="+code=crypto_pcbc_exit_tfm" class="sref">crypto_pcbc_exit_tfmp/a>(structopa href="+code=crypto_tfm" class="sref">crypto_tfmp/a> *pa href="+code=tfm" class="sref">tfmp/a>) o219p/a>{ o220p/a>        structopa href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctxp/a> *pa href="+code=ctx" class="sref">ctxp/a> =opa href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctxp/a>(pa href="+code=tfm" class="sref">tfmp/a>); o221p/a>        pa href="+code=crypto_free_cipher" class="sref">crypto_free_cipherp/a>(pa href="+code=ctx" class="sref">ctxp/a>->pa href="+code=child" class="sref">childp/a>); o222p/a>} o223p/a> o224p/a>static structopa href="+code=crypto_instance" class="sref">crypto_instancep/a> *pa href="+code=crypto_pcbc_alloc" class="sref">crypto_pcbc_allocp/a>(structopa href="+code=rtattr" class="sref">rtattrp/a> **pa href="+code=tb" class="sref">tbp/a>) o225p/a>{ o226p/a>        structopa href="+code=crypto_instance" class="sref">crypto_instancep/a> *pa href="+code=inst" class="sref">instp/a>; o227p/a>        structopa href="+code=crypto_alg" class="sref">crypto_algp/a> *pa href="+code=alg" class="sref">algp/a>; o228p/a>        intopa href="+code=err" class="sref">errp/a>; o229p/a> o230p/a>        pa href="+code=err" class="sref">errp/a> =opa href="+code=crypto_check_attr_type" class="sref">crypto_check_attr_typep/a>(pa href="+code=tb" class="sref">tbp/a>, pa href="+code=CRYPTO_ALG_TYPE_BLKCIPHER" class="sref">CRYPTO_ALG_TYPE_BLKCIPHERp/a>); o231p/a>        if (pa href="+code=err" class="sref">errp/a>) o232p/a>                return pa href="+code=ERR_PTR" class="sref">ERR_PTRp/a>(pa href="+code=err" class="sref">errp/a>); o233p/a> o234p/a>        pa href="+code=alg" class="sref">algp/a> =opa href="+code=crypto_get_attr_alg" class="sref">crypto_get_attr_algp/a>(pa href="+code=tb" class="sref">tbp/a>, pa href="+code=CRYPTO_ALG_TYPE_CIPHER" class="sref">CRYPTO_ALG_TYPE_CIPHERp/a>, o235p/a>                                  pa href="+code=CRYPTO_ALG_TYPE_MASK" class="sref">CRYPTO_ALG_TYPE_MASKp/a>); o236p/a>        if (pa href="+code=IS_ERR" class="sref">IS_ERRp/a>(pa href="+code=alg" class="sref">algp/a>)) o237p/a>                return pa href="+code=ERR_CAST" class="sref">ERR_CASTp/a>(pa href="+code=alg" class="sref">algp/a>); o238p/a> o239p/a>        pa href="+code=inst" class="sref">instp/a> =opa href="+code=crypto_alloc_instance" class="sref">crypto_alloc_instancep/a>(pspan class="string">"pcbc", pa href="+code=alg" class="sref">algp/a>); o240p/a>        if (pa href="+code=IS_ERR" class="sref">IS_ERRp/a>(pa href="+code=inst" class="sref">instp/a>)) o241p/a>                goto pa href="+code=out_put_alg" class="sref">out_put_algp/a>; o242p/a> o243p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_flags" class="sref">cra_flagsp/a> =opa href="+code=CRYPTO_ALG_TYPE_BLKCIPHER" class="sref">CRYPTO_ALG_TYPE_BLKCIPHERp/a>; o244p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_priority" class="sref">cra_priorityp/a> =opa href="+code=alg" class="sref">algp/a>->pa href="+code=cra_priority" class="sref">cra_priorityp/a>; o245p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_blocksize" class="sref">cra_blocksizep/a> =opa href="+code=alg" class="sref">algp/a>->pa href="+code=cra_blocksize" class="sref">cra_blocksizep/a>; o246p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_alignmask" class="sref">cra_alignmaskp/a> =opa href="+code=alg" class="sref">algp/a>->pa href="+code=cra_alignmask" class="sref">cra_alignmaskp/a>; o247p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_type" class="sref">cra_typep/a> =o&pa href="+code=crypto_blkcipher_type" class="sref">crypto_blkcipher_typep/a>; o248p/a> o249p/a>        pspan class="comment">/* We access the data as u32s when xoring. */ o250p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_alignmask" class="sref">cra_alignmaskp/a> |=opa href="+code=__alignof__" class="sref">__alignof__p/a>(pa href="+code=u32" class="sref">u32p/a>) - 1; o251p/a> o252p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_blkcipher" class="sref">cra_blkcipherp/a>.pa href="+code=ivsize" class="sref">ivsizep/a> =opa href="+code=alg" class="sref">algp/a>->pa href="+code=cra_blocksize" class="sref">cra_blocksizep/a>; o253p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_blkcipher" class="sref">cra_blkcipherp/a>.pa href="+code=min_keysize" class="sref">min_keysizep/a> =opa href="+code=alg" class="sref">algp/a>->pa href="+code=cra_cipher" class="sref">cra_cipherp/a>.pa href="+code=cia_min_keysize" class="sref">cia_min_keysizep/a>; o254p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_blkcipher" class="sref">cra_blkcipherp/a>.pa href="+code=max_keysize" class="sref">max_keysizep/a> =opa href="+code=alg" class="sref">algp/a>->pa href="+code=cra_cipher" class="sref">cra_cipherp/a>.pa href="+code=cia_max_keysize" class="sref">cia_max_keysizep/a>; o255p/a> o256p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_ctxsize" class="sref">cra_ctxsizep/a> =osizeof(structopa href="+code=crypto_pcbc_ctx" class="sref">crypto_pcbc_ctxp/a>); o257p/a> o258p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_init" class="sref">cra_initp/a> =opa href="+code=crypto_pcbc_init_tfm" class="sref">crypto_pcbc_init_tfmp/a>; o259p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_exit" class="sref">cra_exitp/a> =opa href="+code=crypto_pcbc_exit_tfm" class="sref">crypto_pcbc_exit_tfmp/a>; o260p/a> o261p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_blkcipher" class="sref">cra_blkcipherp/a>.pa href="+code=setkey" class="sref">setkeyp/a> =opa href="+code=crypto_pcbc_setkey" class="sref">crypto_pcbc_setkeyp/a>; o262p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_blkcipher" class="sref">cra_blkcipherp/a>.pa href="+code=encrypt" class="sref">encryptp/a> =opa href="+code=crypto_pcbc_encrypt" class="sref">crypto_pcbc_encryptp/a>; o263p/a>        pa href="+code=inst" class="sref">instp/a>->pa href="+code=alg" class="sref">algp/a>.pa href="+code=cra_blkcipher" class="sref">cra_blkcipherp/a>.pa href="+code=decrypt" class="sref">decryptp/a> =opa href="+code=crypto_pcbc_decrypt" class="sref">crypto_pcbc_decryptp/a>; o264p/a> o265p/a>pa href="+code=out_put_alg" class="sref">out_put_algp/a>: o266p/a>        pa href="+code=crypto_mod_put" class="sref">crypto_mod_putp/a>(pa href="+code=alg" class="sref">algp/a>); o267p/a>        return pa href="+code=inst" class="sref">instp/a>; o268p/a>} o269p/a> o270p/a>static void pa href="+code=crypto_pcbc_free" class="sref">crypto_pcbc_freep/a>(structopa href="+code=crypto_instance" class="sref">crypto_instancep/a> *pa href="+code=inst" class="sref">instp/a>) o271p/a>{ o272p/a>        pa href="+code=crypto_drop_spawn" class="sref">crypto_drop_spawnp/a>(pa href="+code=crypto_instance_ctx" class="sref">crypto_instance_ctxp/a>(pa href="+code=inst" class="sref">instp/a>)); o273p/a>        pa href="+code=kfree" class="sref">kfreep/a>(pa href="+code=inst" class="sref">instp/a>); o274p/a>} o275p/a> o276p/a>static structopa href="+code=crypto_template" class="sref">crypto_templatep/a> pa href="+code=crypto_pcbc_tmpl" class="sref">crypto_pcbc_tmplp/a> =o{ o277p/a>        .pa href="+code=nam"" class="sref">nam"p/a> =opspan class="string">"pcbc", o278p/a>        .pa href="+code=alloc" class="sref">allocp/a> =opa href="+code=crypto_pcbc_alloc" class="sref">crypto_pcbc_allocp/a>, o279p/a>        .pa href="+code=free" class="sref">freep/a> =opa href="+code=crypto_pcbc_free" class="sref">crypto_pcbc_freep/a>, o280p/a>        .pa href="+code=module" class="sref">modulep/a> =opa href="+code=THIS_MODULE" class="sref">THIS_MODULEp/a>, o281p/a>}; o282p/a> o283p/a>static intopa href="+code=__init" class="sref">__initp/a> pa href="+code=crypto_pcbc_module_init" class="sref">crypto_pcbc_module_initp/a>(void) o284p/a>{ o285p/a>        return pa href="+code=crypto_register_template" class="sref">crypto_register_templatep/a>(&pa href="+code=crypto_pcbc_tmpl" class="sref">crypto_pcbc_tmplp/a>); o286p/a>} o287p/a> o288p/a>static void pa href="+code=__exit" class="sref">__exitp/a> pa href="+code=crypto_pcbc_module_exit" class="sref">crypto_pcbc_module_exitp/a>(void) o289p/a>{ o290p/a>        pa href="+code=crypto_unregister_template" class="sref">crypto_unregister_templatep/a>(&pa href="+code=crypto_pcbc_tmpl" class="sref">crypto_pcbc_tmplp/a>); o291p/a>} o292p/a> o293p/a>pa href="+code=module_init" class="sref">module_initp/a>(pa href="+code=crypto_pcbc_module_init" class="sref">crypto_pcbc_module_initp/a>); o294p/a>pa href="+code=module_exit" class="sref">module_exitp/a>(pa href="+code=crypto_pcbc_module_exit" class="sref">crypto_pcbc_module_exitp/a>); o295p/a> o296p/a>pa href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSEp/a>(pspan class="string">"GPL"); o297p/a>pa href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTIONp/a>(pspan class="string">"PCBC block cipher algorithm"); o298p/a>
lxr.linux.no kindly hosted by Redpill Linpro ASp/a>, provider of Linux consulting and operations services sinceo1995.