linux/crypto/tea.c
<<
n> 55"/spaaja 55"/formja 55"a n> 55 href="../linux+v3.7.5/crypto/tea.c">n> 55"img src="../.static/gfx/right.png" alt=">>">n>"/spaajan>"spaa class="lxr_search">n> n> 55"input typ14.hidden" nam14.navtarget" v3.14.">n> 55"input typ14.text" nam14.search" id4.search">n> 55"butt> typ14.submit">Search ja 55"/formja "/spaajan>"spaa class="lxr_prefs"ja 55"a href="+prefs?return=crypto/tea.c"n> 55 onclick="return ajax_prefs();">n> 55Prefsa 55"/a>n>"/spaaja 55 5"/divja 55 5"form ac = a="ajax+*" method="post" onsubmit="return false;">n>"input typ14.hidden" nam14.ajax_lookup" id4.ajax_lookup" v3.14.">n 55 5"/formjan 55 5"div class="headingbott>m">a "div id4.file_contents"j
5 51"/a>"spaa class="comment">/*5"/spaaja5 52"/a>"spaa class="comment"> * Cryptographic API."/spaaja5 53"/a>"spaa class="comment"> *"/spaaja5 54"/a>"spaa class="comment"> * TEA, XTEA, and XETA crypto alogrithms"/spaaja5 55"/a>"spaa class="comment"> *"/spaaja5 56"/a>"spaa class="comment"> * The TEA and Xtended TEA algorithms were developed by David Wheeler5"/spaaja5 57"/a>"spaa class="comment"> * and Roger5Needham at the Computer5Laboratory of Cambridge University."/spaaja5 58"/a>"spaa class="comment"> *"/spaaja5 59"/a>"spaa class="comment"> * Due to the order5of e v3.a  >
 in XTEA many people have incorrectly"/spaaja5 on va>"spaa class="comment"> * implemented it.  XETA (XTEA in the wrong order), exists for"/spaaja5 11"/a>"spaa class="comment"> * compa  bility with these implementa  >
s."/spaaja5 12"/a>"spaa class="comment"> *"/spaaja5 13"/a>"spaa class="comment"> * Copyright (c) 2004 Aaron Grothe ajgrothe@yahoo.com"/spaaja5 14"/a>"spaa class="comment"> *"/spaaja5 15"/a>"spaa class="comment"> * This program is free software; you caa redistribute it and/or modify"/spaaja5 16"/a>"spaa class="comment"> * it under5the terms of the GNU General Public License as published by"/spaaja5 17"/a>"spaa class="comment"> * the Free Software Founda  >
; either5version 2 of the License, or"/spaaja5 18"/a>"spaa class="comment"> * (at your5o1 = a) any later5version."/spaaja5 19"/a>"spaa class="comment"> *"/spaaja5 2n va>"spaa class="comment"> */"/spaaja5 21"/a>a5 22"/a>#include <linux/init.h"/a>>a5 23"/a>#include <linux/module.h"/a>>a5 24"/a>#include <linux/mm.h"/a>>a5 25"/a>#include <asm/byteorder.h"/a>>a5 26"/a>#include <linux/crypto.h"/a>>a5 27"/a>#include <linux/typ1s.h"/a>>a5 28"/a>a5 29"/a>#define5"a href="+code=TEA_KEY_SIZE" class="sref">TEA_KEY_SIZE"/a>            16a5 30"/a>#define5"a href="+code=TEA_BLOCK_SIZE" class="sref">TEA_BLOCK_SIZE"/a>          8a5 31"/a>#define5"a href="+code=TEA_ROUNDS" class="sref">TEA_ROUNDS"/a>            5 32a5 32"/a>#define5"a href="+code=TEA_DELTA" class="sref">TEA_DELTA"/a>            5  0x9e3779b9a5 33"/a>a5 34"/a>#define5"a href="+code=XTEA_KEY_SIZE" class="sref">XTEA_KEY_SIZE"/a>           16a5 35"/a>#define5"a href="+code=XTEA_BLOCK_SIZE" class="sref">XTEA_BLOCK_SIZE"/a>         8a5 36"/a>#define5"a href="+code=XTEA_ROUNDS" class="sref">XTEA_ROUNDS"/a>            532a5 37"/a>#define5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a>            5 0x9e3779b9a5 38"/a>a5 39"/a>struct5"a href="+code=tea_ctx" class="sref">tea_ctx"/a> {a5 40"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=KEY" class="sref">KEY"/a>[4];a5 41"/a>};a5 42"/a>a5 43"/a>struct5"a href="+code=xtea_ctx" class="sref">xtea_ctx"/a> {a5 44"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=KEY" class="sref">KEY"/a>[4];a5 45"/a>};a5 46"/a>a5 47"/a>static int5"a href="+code=tea_setkey" class="sref">tea_setkey"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=in_key" class="sref">in_key"/a>,a5 48"/a>            5         unsigned int5"a href="+code=key_len" class="sref">key_len"/a>)a5 49"/a>{a5 50"/a>        struct5"a href="+code=tea_ctx" class="sref">tea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5 51"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=key" class="sref">key"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=in_key" class="sref">in_key"/a>;a5 52"/a>a5 53"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[0] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[0]);a5 54"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[1] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[1]);a5 55"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[2] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[2]);a5 56"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[3] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[3]);a5 57"/a>a5 58"/a>        return 0; a5 59"/a>a5 60"/a>}a5 61"/a>a5 62"/a>static void5"a href="+code=tea_encrypt" class="sref">tea_encrypt"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, "a href="+code=u8" class="sref">u8"/a> *"a href="+code=dst" class="sref">dst"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=src" class="sref">src"/a>)a5 63"/a>{a5 64"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=y" class="sref">y"/a>, "a href="+code=z" class="sref">z"/a>, "a href="+code=n" class="sref">n"/a>, "a href="+code=sum" class="sref">sum"/a> =50;a5 65"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=k0" class="sref">k0"/a>, "a href="+code=k1" class="sref">k1"/a>, "a href="+code=k2" class="sref">k2"/a>, "a href="+code=k3" class="sref">k3"/a>;a5 66"/a>        struct5"a href="+code=tea_ctx" class="sref">tea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5 67"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=in" class="sref">in"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=src" class="sref">src"/a>;a5 68"/a>        "a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=out" class="sref">out"/a> =5("a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=dst" class="sref">dst"/a>;a5 69"/a>a5 70"/a>        "a href="+code=y" class="sref">y"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[0]);a5 71"/a>        "a href="+code=z" class="sref">z"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[1]);a5 72"/a>a5 73"/a>        "a href="+code=k0" class="sref">k0"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[0];a5 74"/a>        "a href="+code=k1" class="sref">k1"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[1];a5 75"/a>        "a href="+code=k2" class="sref">k2"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[2];a5 76"/a>        "a href="+code=k3" class="sref">k3"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[3];a5 77"/a>a5 78"/a>        "a href="+code=n" class="sref">n"/a> =5"a href="+code=TEA_ROUNDS" class="sref">TEA_ROUNDS"/a>;a5 79"/a>a5 80"/a>        while5("a href="+code=n" class="sref">n"/a>-- > 0) {a5 81"/a>                "a href="+code=sum" class="sref">sum"/a> +=5"a href="+code=TEA_DELTA" class="sref">TEA_DELTA"/a>;a5 82"/a>                "a href="+code=y" class="sref">y"/a> +=5(("a href="+code=z" class="sref">z"/a> << 4) + "a href="+code=k0" class="sref">k0"/a>) ^5("a href="+code=z" class="sref">z"/a> + "a href="+code=sum" class="sref">sum"/a>) ^5(("a href="+code=z" class="sref">z"/a> >> 5) + "a href="+code=k1" class="sref">k1"/a>);a5 83"/a>                "a href="+code=z" class="sref">z"/a> +=5(("a href="+code=y" class="sref">y"/a> << 4) + "a href="+code=k2" class="sref">k2"/a>) ^5("a href="+code=y" class="sref">y"/a> + "a href="+code=sum" class="sref">sum"/a>) ^5(("a href="+code=y" class="sref">y"/a> >> 5) + "a href="+code=k3" class="sref">k3"/a>);a5 84"/a>        }a5 85"/a>        a5 86"/a>        "a href="+code=out" class="sref">out"/a>[0] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=y" class="sref">y"/a>);a5 87"/a>        "a href="+code=out" class="sref">out"/a>[1] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=z" class="sref">z"/a>);a5 88"/a>}a5 89"/a>a5 90"/a>static void5"a href="+code=tea_decrypt" class="sref">tea_decrypt"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, "a href="+code=u8" class="sref">u8"/a> *"a href="+code=dst" class="sref">dst"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=src" class="sref">src"/a>)a5 91"/a>{a5 92"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=y" class="sref">y"/a>, "a href="+code=z" class="sref">z"/a>, "a href="+code=n" class="sref">n"/a>, "a href="+code=sum" class="sref">sum"/a>;a5 93"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=k0" class="sref">k0"/a>, "a href="+code=k1" class="sref">k1"/a>, "a href="+code=k2" class="sref">k2"/a>, "a href="+code=k3" class="sref">k3"/a>;a5 94"/a>        struct5"a href="+code=tea_ctx" class="sref">tea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5 95"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=in" class="sref">in"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=src" class="sref">src"/a>;a5 96"/a>        "a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=out" class="sref">out"/a> =5("a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=dst" class="sref">dst"/a>;a5 97"/a>a5 98"/a>        "a href="+code=y" class="sref">y"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[0]);a5 99"/a>        "a href="+code=z" class="sref">z"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[1]);a5100"/a>a5101"/a>        "a href="+code=k0" class="sref">k0"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[0];a5102"/a>        "a href="+code=k1" class="sref">k1"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[1];a5103"/a>        "a href="+code=k2" class="sref">k2"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[2];a5104"/a>        "a href="+code=k3" class="sref">k3"/a> =5"a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[3];a5105"/a>a5106"/a>        "a href="+code=sum" class="sref">sum"/a> =5"a href="+code=TEA_DELTA" class="sref">TEA_DELTA"/a> << 5;a5107"/a>a5108"/a>        "a href="+code=n" class="sref">n"/a> =5"a href="+code=TEA_ROUNDS" class="sref">TEA_ROUNDS"/a>;a5109"/a>a5110"/a>        while5("a href="+code=n" class="sref">n"/a>-- > 0) {a5111"/a>                "a href="+code=z" class="sref">z"/a> -=5(("a href="+code=y" class="sref">y"/a> << 4) + "a href="+code=k2" class="sref">k2"/a>) ^5("a href="+code=y" class="sref">y"/a> + "a href="+code=sum" class="sref">sum"/a>) ^5(("a href="+code=y" class="sref">y"/a> >> 5) + "a href="+code=k3" class="sref">k3"/a>);a5112"/a>                "a href="+code=y" class="sref">y"/a> -=5(("a href="+code=z" class="sref">z"/a> << 4) + "a href="+code=k0" class="sref">k0"/a>) ^5("a href="+code=z" class="sref">z"/a> + "a href="+code=sum" class="sref">sum"/a>) ^5(("a href="+code=z" class="sref">z"/a> >> 5) + "a href="+code=k1" class="sref">k1"/a>);a5113"/a>                "a href="+code=sum" class="sref">sum"/a> -=5"a href="+code=TEA_DELTA" class="sref">TEA_DELTA"/a>;a5114"/a>        }a5115"/a>        a5116"/a>        "a href="+code=out" class="sref">out"/a>[0] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=y" class="sref">y"/a>);a5117"/a>        "a href="+code=out" class="sref">out"/a>[1] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=z" class="sref">z"/a>);a5118"/a>}a5119"/a>a5120"/a>static int5"a href="+code=xtea_setkey" class="sref">xtea_setkey"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=in_key" class="sref">in_key"/a>,a5121"/a>                       unsigned int5"a href="+code=key_len" class="sref">key_len"/a>)a5122"/a>{a5123"/a>        struct5"a href="+code=xtea_ctx" class="sref">xtea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5124"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=key" class="sref">key"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=in_key" class="sref">in_key"/a>;a5125"/a>a5126"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[0] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[0]);a5127"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[1] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[1]);a5128"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[2] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[2]);a5129"/a>        "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>[3] =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=key" class="sref">key"/a>[3]);a5130"/a>a5131"/a>        return 0; a5132"/a>a5133"/a>}a5134"/a>a5135"/a>static void5"a href="+code=xtea_encrypt" class="sref">xtea_encrypt"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, "a href="+code=u8" class="sref">u8"/a> *"a href="+code=dst" class="sref">dst"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=src" class="sref">src"/a>)a5136"/a>{a5137"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=y" class="sref">y"/a>, "a href="+code=z" class="sref">z"/a>, "a href="+code=sum" class="sref">sum"/a> =50;a5138"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=limit" class="sref">limit"/a> =5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a> *5"a href="+code=XTEA_ROUNDS" class="sref">XTEA_ROUNDS"/a>;a5139"/a>        struct5"a href="+code=xtea_ctx" class="sref">xtea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5140"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=in" class="sref">in"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=src" class="sref">src"/a>;a5141"/a>        "a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=out" class="sref">out"/a> =5("a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=dst" class="sref">dst"/a>;a5142"/a>a5143"/a>        "a href="+code=y" class="sref">y"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[0]);a5144"/a>        "a href="+code=z" class="sref">z"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[1]);a5145"/a>a5146"/a>        while5("a href="+code=sum" class="sref">sum"/a> !=5"a href="+code=limit" class="sref">limit"/a>) {a5147"/a>                "a href="+code=y" class="sref">y"/a> +=5(("a href="+code=z" class="sref">z"/a> << 4 ^ "a href="+code=z" class="sref">z"/a> >> 5) + "a href="+code=z" class="sref">z"/a>) ^5("a href="+code=sum" class="sref">sum"/a> + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a>&3]); a5148"/a>            5   "a href="+code=sum" class="sref">sum"/a> +=5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a>;a5149"/a>            5   "a href="+code=z" class="sref">z"/a> +=5(("a href="+code=y" class="sref">y"/a> << 4 ^ "a href="+code=y" class="sref">y"/a> >> 5) + "a href="+code=y" class="sref">y"/a>) ^5("a href="+code=sum" class="sref">sum"/a> + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a>>>11 &3]); a5150"/a>        }a5151"/a>        a5152"/a>        "a href="+code=out" class="sref">out"/a>[0] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=y" class="sref">y"/a>);a5153"/a>        "a href="+code=out" class="sref">out"/a>[1] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=z" class="sref">z"/a>);a5154"/a>}a5155"/a>a5156"/a>static void5"a href="+code=xtea_decrypt" class="sref">xtea_decrypt"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, "a href="+code=u8" class="sref">u8"/a> *"a href="+code=dst" class="sref">dst"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=src" class="sref">src"/a>)a5157"/a>{a5158"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=y" class="sref">y"/a>, "a href="+code=z" class="sref">z"/a>, "a href="+code=sum" class="sref">sum"/a>;a5159"/a>        struct5"a href="+code=tea_ctx" class="sref">tea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5160"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=in" class="sref">in"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=src" class="sref">src"/a>;a5161"/a>        "a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=out" class="sref">out"/a> =5("a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=dst" class="sref">dst"/a>;a5162"/a>a5163"/a>        "a href="+code=y" class="sref">y"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[0]);a5164"/a>        "a href="+code=z" class="sref">z"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[1]);a5165"/a>a5166"/a>        "a href="+code=sum" class="sref">sum"/a> =5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a> *5"a href="+code=XTEA_ROUNDS" class="sref">XTEA_ROUNDS"/a>;a5167"/a>a5168"/a>        while5("a href="+code=sum" class="sref">sum"/a>) {a5169"/a>            5   "a href="+code=z" class="sref">z"/a> -=5(("a href="+code=y" class="sref">y"/a> << 4 ^ "a href="+code=y" class="sref">y"/a> >> 5) + "a href="+code=y" class="sref">y"/a>) ^5("a href="+code=sum" class="sref">sum"/a> + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a>>>11 & 3]);a5170"/a>                "a href="+code=sum" class="sref">sum"/a> -=5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a>;a5171"/a>                "a href="+code=y" class="sref">y"/a> -=5(("a href="+code=z" class="sref">z"/a> << 4 ^ "a href="+code=z" class="sref">z"/a> >> 5) + "a href="+code=z" class="sref">z"/a>) ^5("a href="+code=sum" class="sref">sum"/a> + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a> & 3]);a5172"/a>        }a5173"/a>        a5174"/a>        "a href="+code=out" class="sref">out"/a>[0] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=y" class="sref">y"/a>);a5175"/a>        "a href="+code=out" class="sref">out"/a>[1] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=z" class="sref">z"/a>);a5176"/a>}a5177"/a>a5178"/a>a5179"/a>static void5"a href="+code=xeta_encrypt" class="sref">xeta_encrypt"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, "a href="+code=u8" class="sref">u8"/a> *"a href="+code=dst" class="sref">dst"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=src" class="sref">src"/a>)a5180"/a>{a5181"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=y" class="sref">y"/a>, "a href="+code=z" class="sref">z"/a>, "a href="+code=sum" class="sref">sum"/a> =50;a5182"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=limit" class="sref">limit"/a> =5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a> *5"a href="+code=XTEA_ROUNDS" class="sref">XTEA_ROUNDS"/a>;a5183"/a>        struct5"a href="+code=xtea_ctx" class="sref">xtea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5184"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=in" class="sref">in"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=src" class="sref">src"/a>;a5185"/a>        "a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=out" class="sref">out"/a> =5("a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=dst" class="sref">dst"/a>;a5186"/a>a5187"/a>        "a href="+code=y" class="sref">y"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[0]);a5188"/a>        "a href="+code=z" class="sref">z"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[1]);a5189"/a>a5190"/a>        while5("a href="+code=sum" class="sref">sum"/a> !=5"a href="+code=limit" class="sref">limit"/a>) {a5191"/a>                "a href="+code=y" class="sref">y"/a> +=5("a href="+code=z" class="sref">z"/a> << 4 ^ "a href="+code=z" class="sref">z"/a> >> 5) + ("a href="+code=z" class="sref">z"/a> ^ "a href="+code=sum" class="sref">sum"/a>) + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a>&3];a5192"/a>                "a href="+code=sum" class="sref">sum"/a> +=5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a>;a5193"/a>                "a href="+code=z" class="sref">z"/a> +=5("a href="+code=y" class="sref">y"/a> << 4 ^ "a href="+code=y" class="sref">y"/a> >> 5) + ("a href="+code=y" class="sref">y"/a> ^ "a href="+code=sum" class="sref">sum"/a>) + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a>>>11 &3];a5194"/a>        }a5195"/a>        a5196"/a>        "a href="+code=out" class="sref">out"/a>[0] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=y" class="sref">y"/a>);a5197"/a>        "a href="+code=out" class="sref">out"/a>[1] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=z" class="sref">z"/a>);a5198"/a>}a5199"/a>a5200"/a>static void5"a href="+code=xeta_decrypt" class="sref">xeta_decrypt"/a>(struct5"a href="+code=crypto_tfm" class="sref">crypto_tfm"/a> *"a href="+code=tfm" class="sref">tfm"/a>, "a href="+code=u8" class="sref">u8"/a> *"a href="+code=dst" class="sref">dst"/a>, const5"a href="+code=u8" class="sref">u8"/a> *"a href="+code=src" class="sref">src"/a>)a5201"/a>{a5202"/a>        "a href="+code=u32" class="sref">u32"/a> "a href="+code=y" class="sref">y"/a>, "a href="+code=z" class="sref">z"/a>, "a href="+code=sum" class="sref">sum"/a>;a5203"/a>        struct5"a href="+code=tea_ctx" class="sref">tea_ctx"/a> *"a href="+code=ctx" class="sref">ctx"/a> =5"a href="+code=crypto_tfm_ctx" class="sref">crypto_tfm_ctx"/a>("a href="+code=tfm" class="sref">tfm"/a>);a5204"/a>        const5"a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=in" class="sref">in"/a> =5(const5"a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=src" class="sref">src"/a>;a5205"/a>        "a href="+code=__le32" class="sref">__le32"/a> *"a href="+code=out" class="sref">out"/a> =5("a href="+code=__le32" class="sref">__le32"/a> *)"a href="+code=dst" class="sref">dst"/a>;a5206"/a>a5207"/a>        "a href="+code=y" class="sref">y"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[0]);a5208"/a>        "a href="+code=z" class="sref">z"/a> =5"a href="+code=le32_to_cpu" class="sref">le32_to_cpu"/a>("a href="+code=in" class="sref">in"/a>[1]);a5209"/a>a5210"/a>        "a href="+code=sum" class="sref">sum"/a> =5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a> *5"a href="+code=XTEA_ROUNDS" class="sref">XTEA_ROUNDS"/a>;a5211"/a>a5212"/a>        while5("a href="+code=sum" class="sref">sum"/a>) {a5213"/a>                "a href="+code=z" class="sref">z"/a> -=5("a href="+code=y" class="sref">y"/a> << 4 ^ "a href="+code=y" class="sref">y"/a> >> 5) + ("a href="+code=y" class="sref">y"/a> ^ "a href="+code=sum" class="sref">sum"/a>) + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a>>>11 & 3];a5214"/a>                "a href="+code=sum" class="sref">sum"/a> -=5"a href="+code=XTEA_DELTA" class="sref">XTEA_DELTA"/a>;a5215"/a>                "a href="+code=y" class="sref">y"/a> -=5("a href="+code=z" class="sref">z"/a> << 4 ^ "a href="+code=z" class="sref">z"/a> >> 5) + ("a href="+code=z" class="sref">z"/a> ^ "a href="+code=sum" class="sref">sum"/a>) + "a href="+code=ctx" class="sref">ctx"/a>->"a href="+code=KEY" class="sref">KEY"/a>["a href="+code=sum" class="sref">sum"/a> & 3];a5216"/a>        }a5217"/a>        a5218"/a>        "a href="+code=out" class="sref">out"/a>[0] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=y" class="sref">y"/a>);a5219"/a>        "a href="+code=out" class="sref">out"/a>[1] =5"a href="+code=cpu_to_le32" class="sref">cpu_to_le32"/a>("a href="+code=z" class="sref">z"/a>);a5220"/a>}a5221"/a>a5222"/a>static struct5"a href="+code=crypto_alg" class="sref">crypto_alg"/a> "a href="+code=tea_algs" class="sref">tea_algs"/a>[3] =5{ {a5223"/a>        ."a href="+code=cra_nam1" class="sref">cra_nam1"/a>               =       "span class="string">"tea",a5224"/a>        ."a href="+code=cra_flags" class="sref">cra_flags"/a>              =       "a href="+code=CRYPTO_ALG_TYPE_CIPHER" class="sref">CRYPTO_ALG_TYPE_CIPHER"/a>,a5225"/a>        ."a href="+code=cra_blocksiz1" class="sref">cra_blocksiz1"/a>          =       "a href="+code=TEA_BLOCK_SIZE" class="sref">TEA_BLOCK_SIZE"/a>,a5226"/a>        ."a href="+code=cra_ctxsiz1" class="sref">cra_ctxsiz1"/a>            =       siz1of (struct5"a href="+code=tea_ctx" class="sref">tea_ctx"/a>),a5227"/a>        ."a href="+code=cra_alignmask" class="sref">cra_alignmask"/a>          =       3,a5228"/a>        ."a href="+code=cra_modul1" class="sref">cra_modul1"/a>             =       "a href="+code=THIS_MODULE" class="sref">THIS_MODULE"/a>,a5229"/a>        ."a href="+code=cra_u" class="sref">cra_u"/a>                  =       { ."a href="+code=cipher" class="sref">cipher"/a> =5{a5230"/a>        ."a href="+code=cia_min_keysiz1" class="sref">cia_min_keysiz1"/a>        =       "a href="+code=TEA_KEY_SIZE" class="sref">TEA_KEY_SIZE"/a>,a5231"/a>        ."a href="+code=cia_max_keysiz1" class="sref">cia_max_keysiz1"/a>        =       "a href="+code=TEA_KEY_SIZE" class="sref">TEA_KEY_SIZE"/a>,a5232"/a>        ."a href="+code=cia_setkey" class="sref">cia_setkey"/a>             =       "a href="+code=tea_setkey" class="sref">tea_setkey"/a>,a5233"/a>        ."a href="+code=cia_encrypt" class="sref">cia_encrypt"/a>            =       "a href="+code=tea_encrypt" class="sref">tea_encrypt"/a>,a5234"/a>        ."a href="+code=cia_decrypt" class="sref">cia_decrypt"/a>            =       "a href="+code=tea_decrypt" class="sref">tea_decrypt"/a> } }a5235"/a>},5{a5236"/a>        ."a href="+code=cra_nam1" class="sref">cra_nam1"/a>               =       "span class="string">"xtea",a5237"/a>        ."a href="+code=cra_flags" class="sref">cra_flags"/a>              =       "a href="+code=CRYPTO_ALG_TYPE_CIPHER" class="sref">CRYPTO_ALG_TYPE_CIPHER"/a>,a5238"/a>        ."a href="+code=cra_blocksiz1" class="sref">cra_blocksiz1"/a>          =       "a href="+code=XTEA_BLOCK_SIZE" class="sref">XTEA_BLOCK_SIZE"/a>,a5239"/a>        ."a href="+code=cra_ctxsiz1" class="sref">cra_ctxsiz1"/a>            =       siz1of (struct5"a href="+code=xtea_ctx" class="sref">xtea_ctx"/a>),a5240"/a>        ."a href="+code=cra_alignmask" class="sref">cra_alignmask"/a>          =       3,a5241"/a>        ."a href="+code=cra_modul1" class="sref">cra_modul1"/a>             =       "a href="+code=THIS_MODULE" class="sref">THIS_MODULE"/a>,a5242"/a>        ."a href="+code=cra_u" class="sref">cra_u"/a>                  =       { ."a href="+code=cipher" class="sref">cipher"/a> =5{a5243"/a>        ."a href="+code=cia_min_keysiz1" class="sref">cia_min_keysiz1"/a>        =       "a href="+code=XTEA_KEY_SIZE" class="sref">XTEA_KEY_SIZE"/a>,a5244"/a>        ."a href="+code=cia_max_keysiz1" class="sref">cia_max_keysiz1"/a>        =       "a href="+code=XTEA_KEY_SIZE" class="sref">XTEA_KEY_SIZE"/a>,a5245"/a>        ."a href="+code=cia_setkey" class="sref">cia_setkey"/a>             =       "a href="+code=xtea_setkey" class="sref">xtea_setkey"/a>,a5246"/a>        ."a href="+code=cia_encrypt" class="sref">cia_encrypt"/a>            =       "a href="+code=xtea_encrypt" class="sref">xtea_encrypt"/a>,a5247"/a>        ."a href="+code=cia_decrypt" class="sref">cia_decrypt"/a>            =       "a href="+code=xtea_decrypt" class="sref">xtea_decrypt"/a> } }a5248"/a>},5{a5249"/a>        ."a href="+code=cra_nam1" class="sref">cra_nam1"/a>               =       "span class="string">"xeta",a5250"/a>        ."a href="+code=cra_flags" class="sref">cra_flags"/a>              =       "a href="+code=CRYPTO_ALG_TYPE_CIPHER" class="sref">CRYPTO_ALG_TYPE_CIPHER"/a>,a5251"/a>        ."a href="+code=cra_blocksiz1" class="sref">cra_blocksiz1"/a>          =       "a href="+code=XTEA_BLOCK_SIZE" class="sref">XTEA_BLOCK_SIZE"/a>,a5252"/a>        ."a href="+code=cra_ctxsiz1" class="sref">cra_ctxsiz1"/a>            =       siz1of (struct5"a href="+code=xtea_ctx" class="sref">xtea_ctx"/a>),a5253"/a>        ."a href="+code=cra_alignmask" class="sref">cra_alignmask"/a>          =       3,a5254"/a>        ."a href="+code=cra_modul1" class="sref">cra_modul1"/a>             =       "a href="+code=THIS_MODULE" class="sref">THIS_MODULE"/a>,a5255"/a>        ."a href="+code=cra_u" class="sref">cra_u"/a>                  =       { ."a href="+code=cipher" class="sref">cipher"/a> =5{a5256"/a>        ."a href="+code=cia_min_keysiz1" class="sref">cia_min_keysiz1"/a>        =       "a href="+code=XTEA_KEY_SIZE" class="sref">XTEA_KEY_SIZE"/a>,a5257"/a>        ."a href="+code=cia_max_keysiz1" class="sref">cia_max_keysiz1"/a>        =       "a href="+code=XTEA_KEY_SIZE" class="sref">XTEA_KEY_SIZE"/a>,a5258"/a>        ."a href="+code=cia_setkey" class="sref">cia_setkey"/a>             =       "a href="+code=xtea_setkey" class="sref">xtea_setkey"/a>,a5259"/a>        ."a href="+code=cia_encrypt" class="sref">cia_encrypt"/a>            =       "a href="+code=xeta_encrypt" class="sref">xeta_encrypt"/a>,a5260"/a>        ."a href="+code=cia_decrypt" class="sref">cia_decrypt"/a>            =       "a href="+code=xeta_decrypt" class="sref">xeta_decrypt"/a> } }a5261"/a>} };a5262"/a>a5263"/a>static int5"a href="+code=__init" class="sref">__init"/a> "a href="+code=tea_mod_init" class="sref">tea_mod_init"/a>(void)a5264"/a>{a5265"/a>        return "a href="+code=crypto_register_algs" class="sref">crypto_register_algs"/a>("a href="+code=tea_algs" class="sref">tea_algs"/a>, "a href="+code=ARRAY_SIZE" class="sref">ARRAY_SIZE"/a>("a href="+code=tea_algs" class="sref">tea_algs"/a>));a5266"/a>}a5267"/a>a5268"/a>static void5"a href="+code=__exit" class="sref">__exit"/a> "a href="+code=tea_mod_fini" class="sref">tea_mod_fini"/a>(void)a5269"/a>{a5270"/a>        "a href="+code=crypto_unregister_algs" class="sref">crypto_unregister_algs"/a>("a href="+code=tea_algs" class="sref">tea_algs"/a>, "a href="+code=ARRAY_SIZE" class="sref">ARRAY_SIZE"/a>("a href="+code=tea_algs" class="sref">tea_algs"/a>));a5271"/a>}a5272"/a>a5273"/a>"a href="+code=MODULE_ALIAS" class="sref">MODULE_ALIAS"/a>("span class="string">"xtea");a5274"/a>"a href="+code=MODULE_ALIAS" class="sref">MODULE_ALIAS"/a>("span class="string">"xeta");a5275"/a>a5276"/a>"a href="+code=modul1_init" class="sref">modul1_init"/a>("a href="+code=tea_mod_init" class="sref">tea_mod_init"/a>);a5277"/a>"a href="+code=modul1_exit" class="sref">modul1_exit"/a>("a href="+code=tea_mod_fini" class="sref">tea_mod_fini"/a>);a5278"/a>a5279"/a>"a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE"/a>("span class="string">"GPL");a5280"/a>"a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION"/a>("span class="string">"TEA, XTEA & XETA Cryptographic Algorithms");a5281"/a>
lxr.linux.no kindly hosted by Redpill Linpro AS"/a>, provider of Linux consulting and operations services since51995.