X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/blobdiff_plain/786989941b7b4504f0234c4a318f929802e981ad..15e8239f47dbd30b4da82dfedf983e07bc2f4122:/server/chal.c?ds=sidebyside diff --git a/server/chal.c b/server/chal.c index 5258cf9c..387f0db1 100644 --- a/server/chal.c +++ b/server/chal.c @@ -1,13 +1,11 @@ /* -*-c-*- - * - * $Id$ * * Cryptographic challenges * * (c) 2005 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Trivial IP Encryption (TrIPE). * @@ -15,12 +13,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * TrIPE is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with TrIPE; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -49,16 +47,16 @@ static seqwin iseq; static void c_genkey(void) { - if (mac && GM_CLASS(mac) == algs.m && oseq < 0x07ffffff) return; + if (mac && GM_CLASS(mac) == master->algs.m && oseq < 0x07ffffff) return; if (mac) GM_DESTROY(mac); - assert(algs.mksz < sizeof(buf_t)); - rand_get(RAND_GLOBAL, buf_t, algs.mksz); - mac = GM_KEY(algs.m, buf_t, algs.mksz); + assert(master->algs.mksz < sizeof(buf_t)); + rand_get(RAND_GLOBAL, buf_t, master->algs.mksz); + mac = GM_KEY(master->algs.m, buf_t, master->algs.mksz); oseq = 0; seq_reset(&iseq); IF_TRACING(T_CHAL, { trace(T_CHAL, "chal: generated new challenge key"); - trace_block(T_CRYPTO, "chal: new key", buf_t, algs.mksz); + trace_block(T_CRYPTO, "chal: new key", buf_t, master->algs.mksz); }) } @@ -81,7 +79,7 @@ int c_new(buf *b) if (buf_putu32(b, oseq++)) return (-1); h = GM_INIT(mac); GH_HASH(h, p, BCUR(b) - p); - buf_put(b, GH_DONE(h, 0), algs.tagsz); + buf_put(b, GH_DONE(h, 0), master->algs.tagsz); GH_DESTROY(h); if (BBAD(b)) return (-1); IF_TRACING(T_CHAL, { @@ -103,7 +101,7 @@ int c_new(buf *b) int c_check(buf *b) { const octet *p; - size_t sz = 4 + algs.tagsz; + size_t sz = 4 + master->algs.tagsz; uint32 seq; ghash *h; int ok; @@ -119,14 +117,14 @@ int c_check(buf *b) } h = GM_INIT(mac); GH_HASH(h, p, 4); - ok = (memcmp(GH_DONE(h, 0), p + 4, algs.tagsz) == 0); + ok = ct_memeq(GH_DONE(h, 0), p + 4, master->algs.tagsz); GH_DESTROY(h); if (!ok) { a_warn("CHAL", "incorrect-tag", A_END); goto fail; } seq = LOAD32(p); - if (seq_check(&iseq, LOAD32(p), "CHAL")) + if (seq_check(&iseq, seq, "CHAL")) goto fail; T( trace(T_CHAL, "chal: checked challenge %lu", (unsigned long)seq); ) return (0);