linux/crypto/hmac.c
<<
9.4" /spapti /formti a 9.4" href="../linux+v3v123./crypto/hmac.c">9.4" img src="../.static/gfx/right.png" alt=">>">9. /spapti9. spap class="lxr_search">9.4"9.4" input typvalhidden" namvalnavtarget" ion val">9.4" input typvaltext" namvalsearch" idalsearch">9.4" buttopttypvalsubmit">Search9.4" Prefsi /a>9. /spapti4" /divti4" form ac9. input typvalhidden" namvalajax_lookup" idalajax_lookup" ion val">94" /formti94" div class="headingbottom">i div idalfile_contents"t
   1 /a> spap class="comment">/* /spapti   2 /a> spap class="comment"> * Cryptographic API. /spapti   3 /a> spap class="comment"> * /spapti   4 /a> spap class="comment"> * HMAC: Keyed-Hashing for Message Authentica    5 /a> spap class="comment"> * /spapti   6 /a> spap class="comment"> * Copyright (c) 2002 Jamvs Morris <jmorris@intercode.com.au> /spapti   7 /a> spap class="comment"> * Copyright (c) 2006 Herbert Xu <herbert@gondor.apapa.org.au> /spapti   8 /a> spap class="comment"> * /spapti   9 /a> spap class="comment"> * The HMAC implementa   3.8.a> spap class="comment"> * Copyright (c) 2002 Kazunori Miyazawa <miyazawa@linux-ipv6.org> / USAGI /spapti  11 /a> spap class="comment"> * /spapti  12 /a> spap class="comment"> * This programtis free software; you cap redistribute it and/or modify it /spapti  13 /a> spap class="comment"> * under the terms of the GNU General Public License as published by the Free /spapti  14 /a> spap class="comment"> * Software Founda   15 /a> spap class="comment"> * any later vers  16 /a> spap class="comment"> * /spapti  17 /a> spap class="comment"> */ /spapti  18 /a>i  19 /a>#include <crypto/internal/hash.h /a>>i  20 /a>#include <crypto/sca terwalk.h /a>>i  21 /a>#include <linux/err.h /a>>i  22 /a>#include <linux/init.h /a>>i  23 /a>#include <linux/kernel.h /a>>i  24 /a>#include <linux/module.h /a>>i  25 /a>#include <linux/sca terlist.h /a>>i  26 /a>#include <linux/string.h /a>>i  27 /a>i  28 /a>struct  a href="+code=hmac_ctx" class="sref">hmac_ctx /a> {i  29 /a>        struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=hash" class="sref">hash /a>;i  30 /a>};i  31 /a>i  32 /a>static  a href="+code=inline" class="sref">inline /a> void * a href="+code=align_ptr" class="sref">align_ptr /a>(void * a href="+code=p" class="sref">p /a>, unsigned int  a href="+code=align" class="sref">align /a>)i  33 /a>{i  34 /a>        return (void *) a href="+code=ALIGN" class="sref">ALIGN /a>((unsigned long) a href="+code=p" class="sref">p /a>,  a href="+code=align" class="sref">align /a>);i  35 /a>}i  36 /a>i  37 /a>static  a href="+code=inline" class="sref">inline /a> struct  a href="+code=hmac_ctx" class="sref">hmac_ctx /a> * a href="+code=hmac_ctx" class="sref">hmac_ctx /a>(struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=tfm" class="sref">tfm /a>)i  38 /a>{i  39 /a>        return  a href="+code=align_ptr" class="sref">align_ptr /a>( a href="+code=crypto_shash_ctx_aligned" class="sref">crypto_shash_ctx_aligned /a>( a href="+code=tfm" class="sref">tfm /a>) +i  40 /a>                          a href="+code=crypto_shash_statesize" class="sref">crypto_shash_statesize /a>( a href="+code=tfm" class="sref">tfm /a>) * 2,i  41 /a>                          a href="+code=crypto_tfm_ctx_alignment" class="sref">crypto_tfm_ctx_alignment /a>());i  42 /a>}i  43 /a>i  44 /a>static int  a href="+code=hmac_setkey" class="sref">hmac_setkey /a>(struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=parent" class="sref">parent /a>,i  45 /a>                       const  a href="+code=u8" class="sref">u8 /a> * a href="+code=inkey" class="sref">inkey /a>, unsigned int  a href="+code=keylen" class="sref">keylen /a>)i  46 /a>{i  47 /a>        int  a href="+code=bs" class="sref">bs /a> =  a href="+code=crypto_shash_blocksize" class="sref">crypto_shash_blocksize /a>( a href="+code=parent" class="sref">parent /a>);i  48 /a>        int  a href="+code=ds" class="sref">ds /a> =  a href="+code=crypto_shash_digestsize" class="sref">crypto_shash_digestsize /a>( a href="+code=parent" class="sref">parent /a>);i  49 /a>        int  a href="+code=ss" class="sref">ss /a> =  a href="+code=crypto_shash_statesize" class="sref">crypto_shash_statesize /a>( a href="+code=parent" class="sref">parent /a>);i  50 /a>        char * a href="+code=ipad" class="sref">ipad /a> =  a href="+code=crypto_shash_ctx_aligned" class="sref">crypto_shash_ctx_aligned /a>( a href="+code=parent" class="sref">parent /a>);i  51 /a>        char * a href="+code=opad" class="sref">opad /a> =  a href="+code=ipad" class="sref">ipad /a> +  a href="+code=ss" class="sref">ss /a>;i  52 /a>        struct  a href="+code=hmac_ctx" class="sref">hmac_ctx /a> * a href="+code=ctx" class="sref">ctx /a> =  a href="+code=align_ptr" class="sref">align_ptr /a>( a href="+code=opad" class="sref">opad /a> +  a href="+code=ss" class="sref">ss /a>,i  53 /a>                                          a href="+code=crypto_tfm_ctx_alignment" class="sref">crypto_tfm_ctx_alignment /a>());i  54 /a>        struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=hash" class="sref">hash /a> =  a href="+code=ctx" class="sref">ctx /a>-> a href="+code=hash" class="sref">hash /a>;i  55 /a>        struct {i  56 /a>                struct  a href="+code=shash_desc" class="sref">shash_desc /a>  a href="+code=shash" class="sref">shash /a>;i  57 /a>                char  a href="+code=ctx" class="sref">ctx /a>[ a href="+code=crypto_shash_descsize" class="sref">crypto_shash_descsize /a>( a href="+code=hash" class="sref">hash /a>)];i  58 /a>        }  a href="+code=desc" class="sref">desc /a>;i  59 /a>        unsigned int  a href="+code=i" class="sref">i /a>;i  60 /a>i  61 /a>         a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>. a href="+code=tfm" class="sref">tfm /a> =  a href="+code=hash" class="sref">hash /a>;i  62 /a>         a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>. a href="+code=flags" class="sref">flags /a> =  a href="+code=crypto_shash_get_flags" class="sref">crypto_shash_get_flags /a>( a href="+code=parent" class="sref">parent /a>) &i  63 /a>                             a href="+code=CRYPTO_TFM_REQ_MAY_SLEEP" class="sref">CRYPTO_TFM_REQ_MAY_SLEEP /a>;i  64 /a>i  65 /a>        if ( a href="+code=keylen" class="sref">keylen /a> >  a href="+code=bs" class="sref">bs /a>) {i  66 /a>                int  a href="+code=err" class="sref">err /a>;i  67 /a>i  68 /a>                 a href="+code=err" class="sref">err /a> =  a href="+code=crypto_shash_digest" class="sref">crypto_shash_digest /a>(& a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>,  a href="+code=inkey" class="sref">inkey /a>,  a href="+code=keylen" class="sref">keylen /a>,  a href="+code=ipad" class="sref">ipad /a>);i  69 /a>                if ( a href="+code=err" class="sref">err /a>)i  70 /a>                        return  a href="+code=err" class="sref">err /a>;i  71 /a>i  72 /a>                 a href="+code=keylen" class="sref">keylen /a> =  a href="+code=ds" class="sref">ds /a>;i  73 /a>        } elsei  74 /a>                 a href="+code=memcpy" class="sref">memcpy /a>( a href="+code=ipad" class="sref">ipad /a>,  a href="+code=inkey" class="sref">inkey /a>,  a href="+code=keylen" class="sref">keylen /a>);i  75 /a>i  76 /a>         a href="+code=memset" class="sref">memset /a>( a href="+code=ipad" class="sref">ipad /a> +  a href="+code=keylen" class="sref">keylen /a>, 0,  a href="+code=bs" class="sref">bs /a> -  a href="+code=keylen" class="sref">keylen /a>);i  77 /a>         a href="+code=memcpy" class="sref">memcpy /a>( a href="+code=opad" class="sref">opad /a>,  a href="+code=ipad" class="sref">ipad /a>,  a href="+code=bs" class="sref">bs /a>);i  78 /a>i  79 /a>        for ( a href="+code=i" class="sref">i /a> = 0;  a href="+code=i" class="sref">i /a> <  a href="+code=bs" class="sref">bs /a>;  a href="+code=i" class="sref">i /a>++) {i  80 /a>                 a href="+code=ipad" class="sref">ipad /a>[ a href="+code=i" class="sref">i /a>] ^= 0x36;i  81 /a>                 a href="+code=opad" class="sref">opad /a>[ a href="+code=i" class="sref">i /a>] ^= 0x5c;i  82 /a>        }i  83 /a>i  84 /a>        return  a href="+code=crypto_shash_init" class="sref">crypto_shash_init /a>(& a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>) ?:i  85 /a>                a href="+code=crypto_shash_update" class="sref">crypto_shash_update /a>(& a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>,  a href="+code=ipad" class="sref">ipad /a>,  a href="+code=bs" class="sref">bs /a>) ?:i  86 /a>                a href="+code=crypto_shash_export" class="sref">crypto_shash_export /a>(& a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>,  a href="+code=ipad" class="sref">ipad /a>) ?:i  87 /a>                a href="+code=crypto_shash_init" class="sref">crypto_shash_init /a>(& a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>) ?:i  88 /a>                a href="+code=crypto_shash_update" class="sref">crypto_shash_update /a>(& a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>,  a href="+code=opad" class="sref">opad /a>,  a href="+code=bs" class="sref">bs /a>) ?:i  89 /a>                a href="+code=crypto_shash_export" class="sref">crypto_shash_export /a>(& a href="+code=desc" class="sref">desc /a>. a href="+code=shash" class="sref">shash /a>,  a href="+code=opad" class="sref">opad /a>);i  90 /a>}i  91 /a>i  92 /a>static int  a href="+code=hmac_export" class="sref">hmac_export /a>(struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=pdesc" class="sref">pdesc /a>, void * a href="+code=out" class="sref">out /a>)i  93 /a>{i  94 /a>        struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=desc" class="sref">desc /a> =  a href="+code=shash_desc_ctx" class="sref">shash_desc_ctx /a>( a href="+code=pdesc" class="sref">pdesc /a>);i  95 /a>i  96 /a>         a href="+code=desc" class="sref">desc /a>-> a href="+code=flags" class="sref">flags /a> =  a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=flags" class="sref">flags /a> &  a href="+code=CRYPTO_TFM_REQ_MAY_SLEEP" class="sref">CRYPTO_TFM_REQ_MAY_SLEEP /a>;i  97 /a>i  98 /a>        return  a href="+code=crypto_shash_export" class="sref">crypto_shash_export /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=out" class="sref">out /a>);i  99 /a>}i 100 /a>i 101 /a>static int  a href="+code=hmac_import" class="sref">hmac_import /a>(struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=pdesc" class="sref">pdesc /a>, const void * a href="+code=in" class="sref">in /a>)i 102 /a>{i 103 /a>        struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=desc" class="sref">desc /a> =  a href="+code=shash_desc_ctx" class="sref">shash_desc_ctx /a>( a href="+code=pdesc" class="sref">pdesc /a>);i 104 /a>        struct  a href="+code=hmac_ctx" class="sref">hmac_ctx /a> * a href="+code=ctx" class="sref">ctx /a> =  a href="+code=hmac_ctx" class="sref">hmac_ctx /a>( a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=tfm" class="sref">tfm /a>);i 105 /a>i 106 /a>         a href="+code=desc" class="sref">desc /a>-> a href="+code=tfm" class="sref">tfm /a> =  a href="+code=ctx" class="sref">ctx /a>-> a href="+code=hash" class="sref">hash /a>;i 107 /a>         a href="+code=desc" class="sref">desc /a>-> a href="+code=flags" class="sref">flags /a> =  a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=flags" class="sref">flags /a> &  a href="+code=CRYPTO_TFM_REQ_MAY_SLEEP" class="sref">CRYPTO_TFM_REQ_MAY_SLEEP /a>;i 108 /a>i 109 /a>        return  a href="+code=crypto_shash_import" class="sref">crypto_shash_import /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=in" class="sref">in /a>);i 110 /a>}i 111 /a>i 112 /a>static int  a href="+code=hmac_init" class="sref">hmac_init /a>(struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=pdesc" class="sref">pdesc /a>)i 113 /a>{i 114 /a>        return  a href="+code=hmac_import" class="sref">hmac_import /a>( a href="+code=pdesc" class="sref">pdesc /a>,  a href="+code=crypto_shash_ctx_aligned" class="sref">crypto_shash_ctx_aligned /a>( a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=tfm" class="sref">tfm /a>));i 115 /a>}i 116 /a>i 117 /a>static int  a href="+code=hmac_update" class="sref">hmac_update /a>(struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=pdesc" class="sref">pdesc /a>,i 118 /a>                       const  a href="+code=u8" class="sref">u8 /a> * a href="+code=data" class="sref">data /a>, unsigned int  a href="+code=nbytes" class="sref">nbytes /a>)i 119 /a>{i 120 /a>        struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=desc" class="sref">desc /a> =  a href="+code=shash_desc_ctx" class="sref">shash_desc_ctx /a>( a href="+code=pdesc" class="sref">pdesc /a>);i 121 /a>i 122 /a>         a href="+code=desc" class="sref">desc /a>-> a href="+code=flags" class="sref">flags /a> =  a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=flags" class="sref">flags /a> &  a href="+code=CRYPTO_TFM_REQ_MAY_SLEEP" class="sref">CRYPTO_TFM_REQ_MAY_SLEEP /a>;i 123 /a>i 124 /a>        return  a href="+code=crypto_shash_update" class="sref">crypto_shash_update /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=data" class="sref">data /a>,  a href="+code=nbytes" class="sref">nbytes /a>);i 125 /a>}i 126 /a>i 127 /a>static int  a href="+code=hmac_final" class="sref">hmac_final /a>(struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=pdesc" class="sref">pdesc /a>,  a href="+code=u8" class="sref">u8 /a> * a href="+code=out" class="sref">out /a>)i 128 /a>{i 129 /a>        struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=parent" class="sref">parent /a> =  a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=tfm" class="sref">tfm /a>;i 130 /a>        int  a href="+code=ds" class="sref">ds /a> =  a href="+code=crypto_shash_digestsize" class="sref">crypto_shash_digestsize /a>( a href="+code=parent" class="sref">parent /a>);i 131 /a>        int  a href="+code=ss" class="sref">ss /a> =  a href="+code=crypto_shash_statesize" class="sref">crypto_shash_statesize /a>( a href="+code=parent" class="sref">parent /a>);i 132 /a>        char * a href="+code=opad" class="sref">opad /a> =  a href="+code=crypto_shash_ctx_aligned" class="sref">crypto_shash_ctx_aligned /a>( a href="+code=parent" class="sref">parent /a>) +  a href="+code=ss" class="sref">ss /a>;i 133 /a>        struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=desc" class="sref">desc /a> =  a href="+code=shash_desc_ctx" class="sref">shash_desc_ctx /a>( a href="+code=pdesc" class="sref">pdesc /a>);i 134 /a>i 135 /a>         a href="+code=desc" class="sref">desc /a>-> a href="+code=flags" class="sref">flags /a> =  a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=flags" class="sref">flags /a> &  a href="+code=CRYPTO_TFM_REQ_MAY_SLEEP" class="sref">CRYPTO_TFM_REQ_MAY_SLEEP /a>;i 136 /a>i 137 /a>        return  a href="+code=crypto_shash_final" class="sref">crypto_shash_final /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=out" class="sref">out /a>) ?:i 138 /a>                a href="+code=crypto_shash_import" class="sref">crypto_shash_import /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=opad" class="sref">opad /a>) ?:i 139 /a>                a href="+code=crypto_shash_finup" class="sref">crypto_shash_finup /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=out" class="sref">out /a>,  a href="+code=ds" class="sref">ds /a>,  a href="+code=out" class="sref">out /a>);i 140 /a>}i 141 /a>i 142 /a>static int  a href="+code=hmac_finup" class="sref">hmac_finup /a>(struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=pdesc" class="sref">pdesc /a>, const  a href="+code=u8" class="sref">u8 /a> * a href="+code=data" class="sref">data /a>,i 143 /a>                      unsigned int  a href="+code=nbytes" class="sref">nbytes /a>,  a href="+code=u8" class="sref">u8 /a> * a href="+code=out" class="sref">out /a>)i 144 /a>{i 145 /a>i 146 /a>        struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=parent" class="sref">parent /a> =  a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=tfm" class="sref">tfm /a>;i 147 /a>        int  a href="+code=ds" class="sref">ds /a> =  a href="+code=crypto_shash_digestsize" class="sref">crypto_shash_digestsize /a>( a href="+code=parent" class="sref">parent /a>);i 148 /a>        int  a href="+code=ss" class="sref">ss /a> =  a href="+code=crypto_shash_statesize" class="sref">crypto_shash_statesize /a>( a href="+code=parent" class="sref">parent /a>);i 149 /a>        char * a href="+code=opad" class="sref">opad /a> =  a href="+code=crypto_shash_ctx_aligned" class="sref">crypto_shash_ctx_aligned /a>( a href="+code=parent" class="sref">parent /a>) +  a href="+code=ss" class="sref">ss /a>;i 150 /a>        struct  a href="+code=shash_desc" class="sref">shash_desc /a> * a href="+code=desc" class="sref">desc /a> =  a href="+code=shash_desc_ctx" class="sref">shash_desc_ctx /a>( a href="+code=pdesc" class="sref">pdesc /a>);i 151 /a>i 152 /a>         a href="+code=desc" class="sref">desc /a>-> a href="+code=flags" class="sref">flags /a> =  a href="+code=pdesc" class="sref">pdesc /a>-> a href="+code=flags" class="sref">flags /a> &  a href="+code=CRYPTO_TFM_REQ_MAY_SLEEP" class="sref">CRYPTO_TFM_REQ_MAY_SLEEP /a>;i 153 /a>i 154 /a>        return  a href="+code=crypto_shash_finup" class="sref">crypto_shash_finup /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=data" class="sref">data /a>,  a href="+code=nbytes" class="sref">nbytes /a>,  a href="+code=out" class="sref">out /a>) ?:i 155 /a>                a href="+code=crypto_shash_import" class="sref">crypto_shash_import /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=opad" class="sref">opad /a>) ?:i 156 /a>                a href="+code=crypto_shash_finup" class="sref">crypto_shash_finup /a>( a href="+code=desc" class="sref">desc /a>,  a href="+code=out" class="sref">out /a>,  a href="+code=ds" class="sref">ds /a>,  a href="+code=out" class="sref">out /a>);i 157 /a>}i 158 /a>i 159 /a>static int  a href="+code=hmac_init_tfm" class="sref">hmac_init_tfm /a>(struct  a href="+code=crypto_tfm" class="sref">crypto_tfm /a> * a href="+code=tfm" class="sref">tfm /a>)i 160 /a>{i 161 /a>        struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=parent" class="sref">parent /a> =  a href="+code=__crypto_shash_cast" class="sref">__crypto_shash_cast /a>( a href="+code=tfm" class="sref">tfm /a>);i 162 /a>        struct  a href="+code=crypto_shash" class="sref">crypto_shash /a> * a href="+code=hash" class="sref">hash /a>;i 163 /a>        struct  a href="+code=crypto_instance" class="sref">crypto_instance /a> * a href="+code=inst" class="sref">inst /a> = (void *) a href="+code=tfm" class="sref">tfm /a>-> a href="+code=__crt_alg" class="sref">__crt_alg /a>;i 164 /a>        struct  a href="+code=crypto_shash_spawn" class="sref">crypto_shash_spawn /a> * a href="+code=spawn" class="sref">spawn /a> =  a href="+code=crypto_instance_ctx" class="sref">crypto_instance_ctx /a>( a href="+code=inst" class="sref">inst /a>);i 165 /a>        struct  a href="+code=hmac_ctx" class="sref">hmac_ctx /a> * a href="+code=ctx" class="sref">ctx /a> =  a href="+code=hmac_ctx" class="sref">hmac_ctx /a>( a href="+code=parent" class="sref">parent /a>);i 166 /a>i 167 /a>         a href="+code=hash" class="sref">hash /a> =  a href="+code=crypto_spawn_shash" class="sref">crypto_spawn_shash /a>( a href="+code=spawn" class="sref">spawn /a>);i 168 /a>        if ( a href="+code=IS_ERR" class="sref">IS_ERR /a>( a href="+code=hash" class="sref">hash /a>))i 169 /a>                return  a href="+code=PTR_ERR" class="sref">PTR_ERR /a>( a href="+code=hash" class="sref">hash /a>);i 170 /a>i 171 /a>         a href="+code=parent" class="sref">parent /a>-> a href="+code=descsize" class="sref">descsize /a> = sizeof(struct  a href="+code=shash_desc" class="sref">shash_desc /a>) +i 172 /a>                            a href="+code=crypto_shash_descsize" class="sref">crypto_shash_descsize /a>( a href="+code=hash" class="sref">hash /a>);i 173 /a>i 174 /a>         a href="+code=ctx" class="sref">ctx /a>-> a href="+code=hash" class="sref">hash /a> =  a href="+code=hash" class="sref">hash /a>;i 175 /a>        return 0;i 176 /a>}i 177 /a>i 178 /a>static void  a href="+code=hmac_exit_tfm" class="sref">hmac_exit_tfm /a>(struct  a href="+code=crypto_tfm" class="sref">crypto_tfm /a> * a href="+code=tfm" class="sref">tfm /a>)i 179 /a>{i 180 /a>        struct  a href="+code=hmac_ctx" class="sref">hmac_ctx /a> * a href="+code=ctx" class="sref">ctx /a> =  a href="+code=hmac_ctx" class="sref">hmac_ctx /a>( a href="+code=__crypto_shash_cast" class="sref">__crypto_shash_cast /a>( a href="+code=tfm" class="sref">tfm /a>));i 181 /a>         a href="+code=crypto_free_shash" class="sref">crypto_free_shash /a>( a href="+code=ctx" class="sref">ctx /a>-> a href="+code=hash" class="sref">hash /a>);i 182 /a>}i 183 /a>i 184 /a>static int  a href="+code=hmac_create" class="sref">hmac_create /a>(struct  a href="+code=crypto_template" class="sref">crypto_template /a> * a href="+code=tmpl" class="sref">tmpl /a>, struct  a href="+code=rtattr" class="sref">rtattr /a> ** a href="+code=tb" class="sref">tb /a>)i 185 /a>{i 186 /a>        struct  a href="+code=shash_instance" class="sref">shash_instance /a> * a href="+code=inst" class="sref">inst /a>;i 187 /a>        struct  a href="+code=crypto_alg" class="sref">crypto_alg /a> * a href="+code=alg" class="sref">alg /a>;i 188 /a>        struct  a href="+code=shash_alg" class="sref">shash_alg /a> * a href="+code=salg" class="sref">salg /a>;i 189 /a>        int  a href="+code=err" class="sref">err /a>;i 190 /a>        int  a href="+code=ds" class="sref">ds /a>;i 191 /a>        int  a href="+code=ss" class="sref">ss /a>;i 192 /a>i 193 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=crypto_check_attr_type" class="sref">crypto_check_attr_type /a>( a href="+code=tb" class="sref">tb /a>,  a href="+code=CRYPTO_ALG_TYPE_SHASH" class="sref">CRYPTO_ALG_TYPE_SHASH /a>);i 194 /a>        if ( a href="+code=err" class="sref">err /a>)i 195 /a>                return  a href="+code=err" class="sref">err /a>;i 196 /a>i 197 /a>         a href="+code=salg" class="sref">salg /a> =  a href="+code=shash_attr_alg" class="sref">shash_attr_alg /a>( a href="+code=tb" class="sref">tb /a>[1], 0, 0);i 198 /a>        if ( a href="+code=IS_ERR" class="sref">IS_ERR /a>( a href="+code=salg" class="sref">salg /a>))i 199 /a>                return  a href="+code=PTR_ERR" class="sref">PTR_ERR /a>( a href="+code=salg" class="sref">salg /a>);i 200 /a>i 201 /a>         a href="+code=err" class="sref">err /a> = - a href="+code=EINVAL" class="sref">EINVAL /a>;i 202 /a>         a href="+code=ds" class="sref">ds /a> =  a href="+code=salg" class="sref">salg /a>-> a href="+code=digestsize" class="sref">digestsize /a>;i 203 /a>         a href="+code=ss" class="sref">ss /a> =  a href="+code=salg" class="sref">salg /a>-> a href="+code=statesize" class="sref">statesize /a>;i 204 /a>         a href="+code=alg" class="sref">alg /a> = & a href="+code=salg" class="sref">salg /a>-> a href="+code=base" class="sref">base /a>;i 205 /a>        if ( a href="+code=ds" class="sref">ds /a> >  a href="+code=alg" class="sref">alg /a>-> a href="+code=cra_blocksize" class="sref">cra_blocksize /a> ||i 206 /a>             a href="+code=ss" class="sref">ss /a> <  a href="+code=alg" class="sref">alg /a>-> a href="+code=cra_blocksize" class="sref">cra_blocksize /a>)i 207 /a>                goto  a href="+code=out_put_alg" class="sref">out_put_alg /a>;i 208 /a>i 209 /a>         a href="+code=inst" class="sref">inst /a> =  a href="+code=shash_alloc_instance" class="sref">shash_alloc_instance /a>( span class="string">"hmac",  a href="+code=alg" class="sref">alg /a>);i 210 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=PTR_ERR" class="sref">PTR_ERR /a>( a href="+code=inst" class="sref">inst /a>);i 211 /a>        if ( a href="+code=IS_ERR" class="sref">IS_ERR /a>( a href="+code=inst" class="sref">inst /a>))i 212 /a>                goto  a href="+code=out_put_alg" class="sref">out_put_alg /a>;i 213 /a>i 214 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=crypto_init_shash_spawn" class="sref">crypto_init_shash_spawn /a>( a href="+code=shash_instance_ctx" class="sref">shash_instance_ctx /a>( a href="+code=inst" class="sref">inst /a>),  a href="+code=salg" class="sref">salg /a>,i 215 /a>                                       a href="+code=shash_crypto_instance" class="sref">shash_crypto_instance /a>( a href="+code=inst" class="sref">inst /a>));i 216 /a>        if ( a href="+code=err" class="sref">err /a>)i 217 /a>                goto  a href="+code=out_free_inst" class="sref">out_free_inst /a>;i 218 /a>i 219 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=base" class="sref">base /a>. a href="+code=cra_priority" class="sref">cra_priority /a> =  a href="+code=alg" class="sref">alg /a>-> a href="+code=cra_priority" class="sref">cra_priority /a>;i 220 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=base" class="sref">base /a>. a href="+code=cra_blocksize" class="sref">cra_blocksize /a> =  a href="+code=alg" class="sref">alg /a>-> a href="+code=cra_blocksize" class="sref">cra_blocksize /a>;i 221 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=base" class="sref">base /a>. a href="+code=cra_alignmask" class="sref">cra_alignmask /a> =  a href="+code=alg" class="sref">alg /a>-> a href="+code=cra_alignmask" class="sref">cra_alignmask /a>;i 222 /a>i 223 /a>         a href="+code=ss" class="sref">ss /a> =  a href="+code=ALIGN" class="sref">ALIGN /a>( a href="+code=ss" class="sref">ss /a>,  a href="+code=alg" class="sref">alg /a>-> a href="+code=cra_alignmask" class="sref">cra_alignmask /a> + 1);i 224 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=digestsize" class="sref">digestsize /a> =  a href="+code=ds" class="sref">ds /a>;i 225 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=statesize" class="sref">statesize /a> =  a href="+code=ss" class="sref">ss /a>;i 226 /a>i 227 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=base" class="sref">base /a>. a href="+code=cra_ctxsize" class="sref">cra_ctxsize /a> = sizeof(struct  a href="+code=hmac_ctx" class="sref">hmac_ctx /a>) +i 228 /a>                                      a href="+code=ALIGN" class="sref">ALIGN /a>( a href="+code=ss" class="sref">ss /a> * 2,  a href="+code=crypto_tfm_ctx_alignment" class="sref">crypto_tfm_ctx_alignment /a>());i 229 /a>i 230 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=base" class="sref">base /a>. a href="+code=cra_init" class="sref">cra_init /a> =  a href="+code=hmac_init_tfm" class="sref">hmac_init_tfm /a>;i 231 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=base" class="sref">base /a>. a href="+code=cra_exit" class="sref">cra_exit /a> =  a href="+code=hmac_exit_tfm" class="sref">hmac_exit_tfm /a>;i 232 /a>i 233 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=init" class="sref">init /a> =  a href="+code=hmac_init" class="sref">hmac_init /a>;i 234 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=update" class="sref">update /a> =  a href="+code=hmac_update" class="sref">hmac_update /a>;i 235 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=final" class="sref">final /a> =  a href="+code=hmac_final" class="sref">hmac_final /a>;i 236 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=finup" class="sref">finup /a> =  a href="+code=hmac_finup" class="sref">hmac_finup /a>;i 237 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=export" class="sref">export /a> =  a href="+code=hmac_export" class="sref">hmac_export /a>;i 238 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=import" class="sref">import /a> =  a href="+code=hmac_import" class="sref">hmac_import /a>;i 239 /a>         a href="+code=inst" class="sref">inst /a>-> a href="+code=alg" class="sref">alg /a>. a href="+code=setkey" class="sref">setkey /a> =  a href="+code=hmac_setkey" class="sref">hmac_setkey /a>;i 240 /a>i 241 /a>         a href="+code=err" class="sref">err /a> =  a href="+code=shash_register_instance" class="sref">shash_register_instance /a>( a href="+code=tmpl" class="sref">tmpl /a>,  a href="+code=inst" class="sref">inst /a>);i 242 /a>        if ( a href="+code=err" class="sref">err /a>) {i 243 /a> a href="+code=out_free_inst" class="sref">out_free_inst /a>:i 244 /a>                 a href="+code=shash_free_instance" class="sref">shash_free_instance /a>( a href="+code=shash_crypto_instance" class="sref">shash_crypto_instance /a>( a href="+code=inst" class="sref">inst /a>));i 245 /a>        }i 246 /a>i 247 /a> a href="+code=out_put_alg" class="sref">out_put_alg /a>:i 248 /a>         a href="+code=crypto_mod_put" class="sref">crypto_mod_put /a>( a href="+code=alg" class="sref">alg /a>);i 249 /a>        return  a href="+code=err" class="sref">err /a>;i 250 /a>}i 251 /a>i 252 /a>static struct  a href="+code=crypto_template" class="sref">crypto_template /a>  a href="+code=hmac_tmpl" class="sref">hmac_tmpl /a> = {i 253 /a>        . a href="+code=namv" class="sref">namv /a> =  span class="string">"hmac",i 254 /a>        . a href="+code=create" class="sref">create /a> =  a href="+code=hmac_create" class="sref">hmac_create /a>,i 255 /a>        . a href="+code=free" class="sref">free /a> =  a href="+code=shash_free_instance" class="sref">shash_free_instance /a>,i 256 /a>        . a href="+code=module" class="sref">module /a> =  a href="+code=THIS_MODULE" class="sref">THIS_MODULE /a>,i 257 /a>};i 258 /a>i 259 /a>static int  a href="+code=__init" class="sref">__init /a>  a href="+code=hmac_module_init" class="sref">hmac_module_init /a>(void)i 260 /a>{i 261 /a>        return  a href="+code=crypto_register_template" class="sref">crypto_register_template /a>(& a href="+code=hmac_tmpl" class="sref">hmac_tmpl /a>);i 262 /a>}i 263 /a>i 264 /a>static void  a href="+code=__exit" class="sref">__exit /a>  a href="+code=hmac_module_exit" class="sref">hmac_module_exit /a>(void)i 265 /a>{i 266 /a>         a href="+code=crypto_unregister_template" class="sref">crypto_unregister_template /a>(& a href="+code=hmac_tmpl" class="sref">hmac_tmpl /a>);i 267 /a>}i 268 /a>i 269 /a> a href="+code=module_init" class="sref">module_init /a>( a href="+code=hmac_module_init" class="sref">hmac_module_init /a>);i 270 /a> a href="+code=module_exit" class="sref">module_exit /a>( a href="+code=hmac_module_exit" class="sref">hmac_module_exit /a>);i 271 /a>i 272 /a> a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE /a>( span class="string">"GPL");i 273 /a> a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION /a>( span class="string">"HMAC hash algorithm");i 274 /a>
lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operations services since 1995.