From owner-svn-src-user@FreeBSD.ORG Thu Apr 11 22:38:15 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E3FF8BEF; Thu, 11 Apr 2013 22:38:15 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wi0-x229.google.com (mail-wi0-x229.google.com [IPv6:2a00:1450:400c:c05::229]) by mx1.freebsd.org (Postfix) with ESMTP id 0A6021FBB; Thu, 11 Apr 2013 22:38:11 +0000 (UTC) Received: by mail-wi0-f169.google.com with SMTP id c10so1122038wiw.2 for ; Thu, 11 Apr 2013 15:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=tYsesWq0XGe7M/P2FUobQX37hKwfaFSIvWHHoWZn/cw=; b=h6YfOL4/O3x61QW64FkL+mzUbaCsXUyx4cvv195yCcyTbPPxAHuIV9Bkkqs1zfhUda Dg3kEh2Nhu/TUspv/bh8tYOqS6kh62UsD8nuaMOWYNOfSuI0FZWNhVHtLQjJPt+xbI5t 6b05pnederRcf6k/uYhWh+3QYtD3hGrqvWzAESnsedGPGvzaAIJoHNrVjBUE0C6VxigE Jh16q9We5FNRGXoWCQ4bn8cB85O7Wu4ayxXF5WxI8Sr+rTR+4q6i+OsskibkCgHa4Ixl HXktJSnalLWFQxrVwoMSpGgu7RoQ3g/FGQa29f3sXYHniemrzQ9XZit95LNRdQBVodfY 3ZZw== MIME-Version: 1.0 X-Received: by 10.194.88.138 with SMTP id bg10mr13831886wjb.13.1365719891133; Thu, 11 Apr 2013 15:38:11 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.217.121.136 with HTTP; Thu, 11 Apr 2013 15:38:11 -0700 (PDT) In-Reply-To: <201304111555.r3BFtq0g019604@svn.freebsd.org> References: <201304111555.r3BFtq0g019604@svn.freebsd.org> Date: Thu, 11 Apr 2013 15:38:11 -0700 X-Google-Sender-Auth: 2SQAhX_tga5TGZCP8ezfxg5OHfU Message-ID: Subject: Re: svn commit: r249365 - in user/andre/tcp-ao/sys: conf crypto crypto/cmac crypto/hmac crypto/rijndael From: Adrian Chadd To: Andre Oppermann Content-Type: text/plain; charset=ISO-8859-1 Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Apr 2013 22:38:16 -0000 Are you planning on making TCP-AO compile time optional? Adrian On 11 April 2013 08:55, Andre Oppermann wrote: > Author: andre > Date: Thu Apr 11 15:55:52 2013 > New Revision: 249365 > URL: http://svnweb.freebsd.org/changeset/base/249365 > > Log: > Adjust the HMAC and CMAC functions to the FreeBSD environment > and include them into the kernel build in preparation for use > in the TCP-AO code. > > Note that we do not have explicit_bzero() so the compiler may > optimize away the bzero() to wipe out key storage on the stack > before returning. > > Sponsored by: Juniper Networks > > Modified: > user/andre/tcp-ao/sys/conf/files > user/andre/tcp-ao/sys/crypto/cmac/cmac.c > user/andre/tcp-ao/sys/crypto/cmac/cmac.h > user/andre/tcp-ao/sys/crypto/hmac/hmac.c > user/andre/tcp-ao/sys/crypto/hmac/hmac.h > user/andre/tcp-ao/sys/crypto/rijndael/rijndael-api.c > user/andre/tcp-ao/sys/crypto/rijndael/rijndael.h > user/andre/tcp-ao/sys/crypto/sha1.h > > Modified: user/andre/tcp-ao/sys/conf/files > ============================================================================== > --- user/andre/tcp-ao/sys/conf/files Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/conf/files Thu Apr 11 15:55:52 2013 (r249365) > @@ -541,8 +541,8 @@ crypto/sha1.c optional carp | crypto | > netgraph_mppc_encryption | sctp > crypto/sha2/sha2.c optional crypto | geom_bde | ipsec | random | \ > sctp | zfs > -crypto/cmac/cmac.c optional crypto | netinet | netinet6 > -crypto/hmac/hmac.c optional crypto | netinet | netinet6 > +crypto/cmac/cmac.c optional inet | inet6 > +crypto/hmac/hmac.c optional inet | inet6 > ddb/db_access.c optional ddb > ddb/db_break.c optional ddb > ddb/db_capture.c optional ddb > @@ -3116,6 +3116,7 @@ netinet/tcp_timer.c optional inet | ine > netinet/tcp_timewait.c optional inet | inet6 > netinet/tcp_usrreq.c optional inet | inet6 > netinet/udp_usrreq.c optional inet | inet6 > +netinet/tcp_ao.c optional inet | inet6 > netinet/libalias/alias.c optional libalias inet | netgraph_nat inet > netinet/libalias/alias_db.c optional libalias inet | netgraph_nat inet > netinet/libalias/alias_mod.c optional libalias | netgraph_nat > > Modified: user/andre/tcp-ao/sys/crypto/cmac/cmac.c > ============================================================================== > --- user/andre/tcp-ao/sys/crypto/cmac/cmac.c Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/crypto/cmac/cmac.c Thu Apr 11 15:55:52 2013 (r249365) > @@ -24,8 +24,10 @@ > #include > #include > > -#include > -#include > +#include > +#include > + > +#define explicit_bzero(a, b) bzero(a, b) > > #define LSHIFT(v, r) do { \ > int i; \ > > Modified: user/andre/tcp-ao/sys/crypto/cmac/cmac.h > ============================================================================== > --- user/andre/tcp-ao/sys/crypto/cmac/cmac.h Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/crypto/cmac/cmac.h Thu Apr 11 15:55:52 2013 (r249365) > @@ -19,6 +19,10 @@ > #ifndef _CMAC_H_ > #define _CMAC_H_ > > +#ifndef _RIJNDAEL_H_ > +#include > +#endif > + > #define AES_CMAC_KEY_LENGTH 16 > #define AES_CMAC_DIGEST_LENGTH 16 > > > Modified: user/andre/tcp-ao/sys/crypto/hmac/hmac.c > ============================================================================== > --- user/andre/tcp-ao/sys/crypto/hmac/hmac.c Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/crypto/hmac/hmac.c Thu Apr 11 15:55:52 2013 (r249365) > @@ -24,10 +24,12 @@ > #include > #include > > -#include > +#include > #include > -#include > -#include > +#include > +#include > + > +#define explicit_bzero(a, b) bzero(a, b) > > void > HMAC_MD5_Init(HMAC_MD5_CTX *ctx, const u_int8_t *key, u_int key_len) > @@ -144,9 +146,9 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, c > int i; > > if (key_len > SHA256_BLOCK_LENGTH) { > - SHA256Init(&ctx->ctx); > - SHA256Update(&ctx->ctx, key, key_len); > - SHA256Final(ctx->key, &ctx->ctx); > + SHA256_Init(&ctx->ctx); > + SHA256_Update(&ctx->ctx, key, key_len); > + SHA256_Final(ctx->key, &ctx->ctx); > ctx->key_len = SHA256_DIGEST_LENGTH; > } else { > bcopy(key, ctx->key, key_len); > @@ -158,8 +160,8 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, c > for (i = 0; i < SHA256_BLOCK_LENGTH; i++) > k_ipad[i] ^= 0x36; > > - SHA256Init(&ctx->ctx); > - SHA256Update(&ctx->ctx, k_ipad, SHA256_BLOCK_LENGTH); > + SHA256_Init(&ctx->ctx); > + SHA256_Update(&ctx->ctx, k_ipad, SHA256_BLOCK_LENGTH); > > explicit_bzero(k_ipad, sizeof k_ipad); > } > @@ -167,7 +169,7 @@ HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, c > void > HMAC_SHA256_Update(HMAC_SHA256_CTX *ctx, const u_int8_t *data, u_int len) > { > - SHA256Update(&ctx->ctx, data, len); > + SHA256_Update(&ctx->ctx, data, len); > } > > void > @@ -176,17 +178,17 @@ HMAC_SHA256_Final(u_int8_t digest[SHA256 > u_int8_t k_opad[SHA256_BLOCK_LENGTH]; > int i; > > - SHA256Final(digest, &ctx->ctx); > + SHA256_Final(digest, &ctx->ctx); > > bzero(k_opad, SHA256_BLOCK_LENGTH); > bcopy(ctx->key, k_opad, ctx->key_len); > for (i = 0; i < SHA256_BLOCK_LENGTH; i++) > k_opad[i] ^= 0x5c; > > - SHA256Init(&ctx->ctx); > - SHA256Update(&ctx->ctx, k_opad, SHA256_BLOCK_LENGTH); > - SHA256Update(&ctx->ctx, digest, SHA256_DIGEST_LENGTH); > - SHA256Final(digest, &ctx->ctx); > + SHA256_Init(&ctx->ctx); > + SHA256_Update(&ctx->ctx, k_opad, SHA256_BLOCK_LENGTH); > + SHA256_Update(&ctx->ctx, digest, SHA256_DIGEST_LENGTH); > + SHA256_Final(digest, &ctx->ctx); > > explicit_bzero(k_opad, sizeof k_opad); > } > > Modified: user/andre/tcp-ao/sys/crypto/hmac/hmac.h > ============================================================================== > --- user/andre/tcp-ao/sys/crypto/hmac/hmac.h Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/crypto/hmac/hmac.h Thu Apr 11 15:55:52 2013 (r249365) > @@ -19,6 +19,10 @@ > #ifndef _HMAC_H_ > #define _HMAC_H_ > > +#include > +#include > +#include > + > typedef struct _HMAC_MD5_CTX { > MD5_CTX ctx; > u_int8_t key[MD5_BLOCK_LENGTH]; > @@ -32,7 +36,7 @@ typedef struct _HMAC_SHA1_CTX { > } HMAC_SHA1_CTX; > > typedef struct _HMAC_SHA256_CTX { > - SHA2_CTX ctx; > + SHA256_CTX ctx; > u_int8_t key[SHA256_BLOCK_LENGTH]; > u_int key_len; > } HMAC_SHA256_CTX; > > Modified: user/andre/tcp-ao/sys/crypto/rijndael/rijndael-api.c > ============================================================================== > --- user/andre/tcp-ao/sys/crypto/rijndael/rijndael-api.c Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/crypto/rijndael/rijndael-api.c Thu Apr 11 15:55:52 2013 (r249365) > @@ -45,6 +45,13 @@ rijndael_set_key(rijndael_ctx *ctx, cons > } > > void > +rijndael_set_key_enc_only(rijndael_ctx *ctx, const u_char *key, int bits) > +{ > + > + ctx->Nr = rijndaelKeySetupEnc(ctx->ek, key, bits); > +} > + > +void > rijndael_decrypt(const rijndael_ctx *ctx, const u_char *src, u_char *dst) > { > > > Modified: user/andre/tcp-ao/sys/crypto/rijndael/rijndael.h > ============================================================================== > --- user/andre/tcp-ao/sys/crypto/rijndael/rijndael.h Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/crypto/rijndael/rijndael.h Thu Apr 11 15:55:52 2013 (r249365) > @@ -42,6 +42,7 @@ typedef struct { > } rijndael_ctx; > > void rijndael_set_key(rijndael_ctx *, const u_char *, int); > +void rijndael_set_key_enc_only(rijndael_ctx *, const u_char *, int); > void rijndael_decrypt(const rijndael_ctx *, const u_char *, u_char *); > void rijndael_encrypt(const rijndael_ctx *, const u_char *, u_char *); > > > Modified: user/andre/tcp-ao/sys/crypto/sha1.h > ============================================================================== > --- user/andre/tcp-ao/sys/crypto/sha1.h Thu Apr 11 14:45:43 2013 (r249364) > +++ user/andre/tcp-ao/sys/crypto/sha1.h Thu Apr 11 15:55:52 2013 (r249365) > @@ -68,5 +68,7 @@ typedef struct sha1_ctxt SHA1_CTX; > #endif /* _KERNEL */ > > #define SHA1_RESULTLEN (160/8) > +#define SHA1_BLOCK_LENGTH 64 > +#define SHA1_DIGEST_LENGTH SHA1_RESULTLEN > > #endif /*_NETINET6_SHA1_H_*/