Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys move the "context size" struct member (which is a pure s...



details:   https://anonhg.NetBSD.org/src/rev/9f37bc51ea74
branches:  trunk
changeset: 765382:9f37bc51ea74
user:      drochner <drochner%NetBSD.org@localhost>
date:      Tue May 24 18:59:21 2011 +0000

description:
move the "context size" struct member (which is a pure software
implementation thing) from the abstract xform descriptor to
the cryptosoft implementation part -- for sanity, and now clients
of opencrypto don't depend on headers of cipher implementations anymore

diffstat:

 sys/arch/x86/x86/via_padlock.c    |  12 ++++++------
 sys/opencrypto/cryptosoft.c       |  22 +++++++++++-----------
 sys/opencrypto/cryptosoft_xform.c |  34 ++++++++++++++++++----------------
 sys/opencrypto/xform.c            |  32 ++++++++++++++++----------------
 sys/opencrypto/xform.h            |   8 +-------
 5 files changed, 52 insertions(+), 56 deletions(-)

diffs (truncated from 407 to 300 lines):

diff -r a0bbae67c3fc -r 9f37bc51ea74 sys/arch/x86/x86/via_padlock.c
--- a/sys/arch/x86/x86/via_padlock.c    Tue May 24 18:52:51 2011 +0000
+++ b/sys/arch/x86/x86/via_padlock.c    Tue May 24 18:59:21 2011 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: via.c,v 1.8 2006/11/17 07:47:56 tom Exp $     */
-/*     $NetBSD: via_padlock.c,v 1.14 2011/02/19 13:52:28 jmcneill Exp $ */
+/*     $NetBSD: via_padlock.c,v 1.15 2011/05/24 18:59:21 drochner Exp $ */
 
 /*-
  * Copyright (c) 2003 Jason Wright
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.14 2011/02/19 13:52:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.15 2011/05/24 18:59:21 drochner Exp $");
 
 #ifdef _KERNEL_OPT
 # include "rnd.h"
@@ -313,14 +313,14 @@
                        }
                        ses->swd = swd;
 
-                       swd->sw_ictx = malloc(axf->auth_hash->ctxsize,
+                       swd->sw_ictx = malloc(axf->ctxsize,
                            M_CRYPTO_DATA, M_NOWAIT);
                        if (swd->sw_ictx == NULL) {
                                via_padlock_crypto_freesession(sc, sesn);
                                return (ENOMEM);
                        }
 
-                       swd->sw_octx = malloc(axf->auth_hash->ctxsize,
+                       swd->sw_octx = malloc(axf->ctxsize,
                            M_CRYPTO_DATA, M_NOWAIT);
                        if (swd->sw_octx == NULL) {
                                via_padlock_crypto_freesession(sc, sesn);
@@ -365,7 +365,7 @@
 {
        struct via_padlock_softc *sc = arg;
        struct swcr_data *swd;
-       const struct auth_hash *axf;
+       const struct swcr_auth_hash *axf;
        int sesn;
        uint32_t sid = ((uint32_t)tid) & 0xffffffff;
 
@@ -379,7 +379,7 @@
 
        if (sc->sc_sessions[sesn].swd) {
                swd = sc->sc_sessions[sesn].swd;
-               axf = swd->sw_axf->auth_hash;
+               axf = swd->sw_axf;
 
                if (swd->sw_ictx) {
                        memset(swd->sw_ictx, 0, axf->ctxsize);
diff -r a0bbae67c3fc -r 9f37bc51ea74 sys/opencrypto/cryptosoft.c
--- a/sys/opencrypto/cryptosoft.c       Tue May 24 18:52:51 2011 +0000
+++ b/sys/opencrypto/cryptosoft.c       Tue May 24 18:59:21 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptosoft.c,v 1.34 2011/05/24 18:52:51 drochner Exp $ */
+/*     $NetBSD: cryptosoft.c,v 1.35 2011/05/24 18:59:22 drochner Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $       */
 /*     $OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $ */
 
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.34 2011/05/24 18:52:51 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.35 2011/05/24 18:59:22 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -479,7 +479,7 @@
 
        axf = sw->sw_axf;
 
-       memcpy(&ctx, sw->sw_ictx, axf->auth_hash->ctxsize);
+       memcpy(&ctx, sw->sw_ictx, axf->ctxsize);
 
        switch (outtype) {
        case CRYPTO_BUF_CONTIG:
@@ -519,7 +519,7 @@
                        return EINVAL;
 
                axf->Final(aalg, &ctx);
-               memcpy(&ctx, sw->sw_octx, axf->auth_hash->ctxsize);
+               memcpy(&ctx, sw->sw_octx, axf->ctxsize);
                axf->Update(&ctx, aalg, axf->auth_hash->hashsize);
                axf->Final(aalg, &ctx);
                break;
@@ -752,14 +752,14 @@
                        axf = &swcr_auth_hash_hmac_ripemd_160_96;
                        goto authcommon;        /* leave this for safety */
                authcommon:
-                       (*swd)->sw_ictx = malloc(axf->auth_hash->ctxsize,
+                       (*swd)->sw_ictx = malloc(axf->ctxsize,
                            M_CRYPTO_DATA, M_NOWAIT);
                        if ((*swd)->sw_ictx == NULL) {
                                swcr_freesession(NULL, i);
                                return ENOBUFS;
                        }
 
-                       (*swd)->sw_octx = malloc(axf->auth_hash->ctxsize,
+                       (*swd)->sw_octx = malloc(axf->ctxsize,
                            M_CRYPTO_DATA, M_NOWAIT);
                        if ((*swd)->sw_octx == NULL) {
                                swcr_freesession(NULL, i);
@@ -796,7 +796,7 @@
                case CRYPTO_SHA1_KPDK:
                        axf = &swcr_auth_hash_key_sha1;
                auth2common:
-                       (*swd)->sw_ictx = malloc(axf->auth_hash->ctxsize,
+                       (*swd)->sw_ictx = malloc(axf->ctxsize,
                            M_CRYPTO_DATA, M_NOWAIT);
                        if ((*swd)->sw_ictx == NULL) {
                                swcr_freesession(NULL, i);
@@ -827,7 +827,7 @@
                case CRYPTO_SHA1:
                        axf = &swcr_auth_hash_sha1;
                auth3common:
-                       (*swd)->sw_ictx = malloc(axf->auth_hash->ctxsize,
+                       (*swd)->sw_ictx = malloc(axf->ctxsize,
                            M_CRYPTO_DATA, M_NOWAIT);
                        if ((*swd)->sw_ictx == NULL) {
                                swcr_freesession(NULL, i);
@@ -916,11 +916,11 @@
                        axf = swd->sw_axf;
 
                        if (swd->sw_ictx) {
-                               memset(swd->sw_ictx, 0, axf->auth_hash->ctxsize);
+                               memset(swd->sw_ictx, 0, axf->ctxsize);
                                free(swd->sw_ictx, M_CRYPTO_DATA);
                        }
                        if (swd->sw_octx) {
-                               memset(swd->sw_octx, 0, axf->auth_hash->ctxsize);
+                               memset(swd->sw_octx, 0, axf->ctxsize);
                                free(swd->sw_octx, M_CRYPTO_DATA);
                        }
                        break;
@@ -930,7 +930,7 @@
                        axf = swd->sw_axf;
 
                        if (swd->sw_ictx) {
-                               memset(swd->sw_ictx, 0, axf->auth_hash->ctxsize);
+                               memset(swd->sw_ictx, 0, axf->ctxsize);
                                free(swd->sw_ictx, M_CRYPTO_DATA);
                        }
                        if (swd->sw_octx) {
diff -r a0bbae67c3fc -r 9f37bc51ea74 sys/opencrypto/cryptosoft_xform.c
--- a/sys/opencrypto/cryptosoft_xform.c Tue May 24 18:52:51 2011 +0000
+++ b/sys/opencrypto/cryptosoft_xform.c Tue May 24 18:59:21 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptosoft_xform.c,v 1.20 2011/05/24 18:52:51 drochner Exp $ */
+/*     $NetBSD: cryptosoft_xform.c,v 1.21 2011/05/24 18:59:22 drochner Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/xform.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $    */
 /*     $OpenBSD: xform.c,v 1.19 2002/08/16 22:47:25 dhartmei Exp $     */
 
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: cryptosoft_xform.c,v 1.20 2011/05/24 18:52:51 drochner Exp $");
+__KERNEL_RCSID(1, "$NetBSD: cryptosoft_xform.c,v 1.21 2011/05/24 18:59:22 drochner Exp $");
 
 #include <crypto/blowfish/blowfish.h>
 #include <crypto/cast128/cast128.h>
@@ -54,9 +54,11 @@
 #include <sys/md5.h>
 #include <sys/rmd160.h>
 #include <sys/sha1.h>
+#include <sys/sha2.h>
 
 struct swcr_auth_hash {
        const struct auth_hash *auth_hash;
+       int ctxsize;
        void (*Init)(void *);
        int  (*Update)(void *, const uint8_t *, uint16_t);
        void (*Final)(uint8_t *, void *);
@@ -222,80 +224,80 @@
 
 /* Authentication instances */
 static const struct swcr_auth_hash swcr_auth_hash_null = {
-       &auth_hash_null,
+       &auth_hash_null, sizeof(int), /* NB: context isn't used */
        null_init, null_update, null_final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_md5 = {
-       &auth_hash_hmac_md5,
+       &auth_hash_hmac_md5, sizeof(MD5_CTX),
        (void (*) (void *)) MD5Init, MD5Update_int,
        (void (*) (u_int8_t *, void *)) MD5Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha1 = {
-       &auth_hash_hmac_sha1,
+       &auth_hash_hmac_sha1, sizeof(SHA1_CTX),
        SHA1Init_int, SHA1Update_int, SHA1Final_int
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_ripemd_160 = {
-       &auth_hash_hmac_ripemd_160,
+       &auth_hash_hmac_ripemd_160, sizeof(RMD160_CTX),
        (void (*)(void *)) RMD160Init, RMD160Update_int,
        (void (*)(u_int8_t *, void *)) RMD160Final
 };
 static const struct swcr_auth_hash swcr_auth_hash_hmac_md5_96 = {
-       &auth_hash_hmac_md5_96,
+       &auth_hash_hmac_md5_96, sizeof(MD5_CTX),
        (void (*) (void *)) MD5Init, MD5Update_int,
        (void (*) (u_int8_t *, void *)) MD5Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha1_96 = {
-       &auth_hash_hmac_sha1_96,
+       &auth_hash_hmac_sha1_96, sizeof(SHA1_CTX),
        SHA1Init_int, SHA1Update_int, SHA1Final_int
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_ripemd_160_96 = {
-       &auth_hash_hmac_ripemd_160_96,
+       &auth_hash_hmac_ripemd_160_96, sizeof(RMD160_CTX),
        (void (*)(void *)) RMD160Init, RMD160Update_int,
        (void (*)(u_int8_t *, void *)) RMD160Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_key_md5 = {
-       &auth_hash_key_md5,
+       &auth_hash_key_md5, sizeof(MD5_CTX),
        (void (*)(void *)) MD5Init, MD5Update_int,
        (void (*)(u_int8_t *, void *)) MD5Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_key_sha1 = {
-       &auth_hash_key_sha1,
+       &auth_hash_key_sha1, sizeof(SHA1_CTX),
        SHA1Init_int, SHA1Update_int, SHA1Final_int
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_md5 = {
-       &auth_hash_md5,
+       &auth_hash_md5, sizeof(MD5_CTX),
        (void (*) (void *)) MD5Init, MD5Update_int,
        (void (*) (u_int8_t *, void *)) MD5Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_sha1 = {
-       &auth_hash_sha1,
+       &auth_hash_sha1, sizeof(SHA1_CTX),
        (void (*)(void *)) SHA1Init, SHA1Update_int,
        (void (*)(u_int8_t *, void *)) SHA1Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha2_256 = {
-       &auth_hash_hmac_sha2_256,
+       &auth_hash_hmac_sha2_256, sizeof(SHA256_CTX),
        (void (*)(void *)) SHA256_Init, SHA256Update_int,
        (void (*)(u_int8_t *, void *)) SHA256_Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha2_384 = {
-       &auth_hash_hmac_sha2_384,
+       &auth_hash_hmac_sha2_384, sizeof(SHA384_CTX),
        (void (*)(void *)) SHA384_Init, SHA384Update_int,
        (void (*)(u_int8_t *, void *)) SHA384_Final
 };
 
 static const struct swcr_auth_hash swcr_auth_hash_hmac_sha2_512 = {
-       &auth_hash_hmac_sha2_384,
+       &auth_hash_hmac_sha2_512, sizeof(SHA512_CTX),
        (void (*)(void *)) SHA512_Init, SHA512Update_int,
        (void (*)(u_int8_t *, void *)) SHA512_Final
 };
diff -r a0bbae67c3fc -r 9f37bc51ea74 sys/opencrypto/xform.c
--- a/sys/opencrypto/xform.c    Tue May 24 18:52:51 2011 +0000
+++ b/sys/opencrypto/xform.c    Tue May 24 18:59:21 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform.c,v 1.25 2011/05/23 13:51:10 drochner Exp $ */
+/*     $NetBSD: xform.c,v 1.26 2011/05/24 18:59:23 drochner Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/xform.c,v 1.1.2.1 2002/11/21 23:34:23 sam Exp $    */
 /*     $OpenBSD: xform.c,v 1.19 2002/08/16 22:47:25 dhartmei Exp $     */
 
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform.c,v 1.25 2011/05/23 13:51:10 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform.c,v 1.26 2011/05/24 18:59:23 drochner Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -143,72 +143,72 @@
 /* Authentication instances */
 const struct auth_hash auth_hash_null = {
        CRYPTO_NULL_HMAC, "NULL-HMAC",
-       0, 0, 12, 64, sizeof(int)               /* NB: context isn't used */
+       0, 0, 12, 64
 };
 
 const struct auth_hash auth_hash_hmac_md5 = {



Home | Main Index | Thread Index | Old Index