Unbreak the OpenSSL and NSS crypto builds in the wake of r24652
authorGreg Hudson <ghudson@mit.edu>
Thu, 24 Feb 2011 18:18:11 +0000 (18:18 +0000)
committerGreg Hudson <ghudson@mit.edu>
Thu, 24 Feb 2011 18:18:11 +0000 (18:18 +0000)
(Fortuna as default PRNG), and remove some unnecessary related files.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24656 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/krb/prng/fortuna/prng_fortuna.c
src/lib/crypto/nss/Makefile.in
src/lib/crypto/nss/sha2/Makefile.in
src/lib/crypto/nss/sha2/sha2.c [deleted file]
src/lib/crypto/nss/sha2/sha2.h [deleted file]
src/lib/crypto/openssl/Makefile.in
src/lib/crypto/openssl/aes/Makefile.in
src/lib/crypto/openssl/aes/aes.h [moved from src/lib/crypto/openssl/sha2/sha256.c with 68% similarity]
src/lib/crypto/openssl/sha2/Makefile.in
src/lib/crypto/openssl/sha2/sha2.h
src/lib/crypto/openssl/stubs.c [new file with mode: 0644]

index 72eac2035bbe57189f98cdcca3c97684ad703184..a1ff73035b17f845ce5f42e1137dcc0b5b645492 100644 (file)
@@ -76,9 +76,7 @@
 
 #include "k5-int.h"
 #include "prng.h"
-#ifndef OPENSSL
 #include "aes.h"
-#endif
 #include "enc_provider.h"
 #include "sha2.h"
 #include "enc_provider.h"
@@ -189,7 +187,7 @@ inc_counter(struct fortuna_state *st)
 static void
 encrypt_counter(struct fortuna_state *st, unsigned char *dst)
 {
-    aes_enc_blk(st->counter, dst, &st->ciph);
+    krb5int_aes_enc_blk(st->counter, dst, &st->ciph);
     inc_counter(st);
 }
 
index 7016e924b271833bc3fb741cde2d80623e0ccca5..a1d587887b5017f83a41814c4dfbe35da4dc2d43 100644 (file)
@@ -20,15 +20,18 @@ DEFS=
 
 STLIBOBJS=\
        hmac.o  \
-       pbkdf2.o                
+       pbkdf2.o \
+       stubs.o
 
 OBJS=\
        $(OUTPRE)hmac.$(OBJEXT) \
-       $(OUTPRE)pbkdf2.$(OBJEXT)               
+       $(OUTPRE)pbkdf2.$(OBJEXT) \
+       $(OUTPRE)stubs.$(OBJEXT)
 
 SRCS=\
        $(srcdir)/hmac.c        \
-       $(srcdir)/pbkdf2.c      
+       $(srcdir)/pbkdf2.c      \
+       $(srcdir)/stubs.c
 
 STOBJLISTS= des/OBJS.ST md4/OBJS.ST    \
        md5/OBJS.ST sha1/OBJS.ST sha2/OBJS.ST   \
index a8edb60d9e26e4ddbeeda80e4bc53a44d577d9b8..1a2bcbb823f1e795afe801374a67765d2377d16a 100644 (file)
@@ -1,19 +1,23 @@
-mydir=lib$(S)crypto$(S)nss$(S)sha2
+# Nothing here!  But we can't remove this directory as the build
+# system currently assumes that all modules have the same directory
+# structure.
+
+mydir=lib$(S)crypto$(S)nss$(S)aes
 BUILDTOP=$(REL)..$(S)..$(S)..$(S)..
+LOCALINCLUDES = -I$(srcdir)/.. -I$(srcdir)/../../krb/dk  -I$(srcdir)/../../../../include
 DEFS=
-CRYPTO_IMPL_CFLAGS=@CRYPTO_IMPL_CFLAGS@
-LOCALINCLUDES = -I$(srcdir)/.. $(CRYPTO_IMPL_CFLAGS)
 
 PROG_LIBPATH=-L$(TOPLIBD)
 PROG_RPATH=$(KRB5_LIBDIR)
 
-STLIBOBJS= sha2.o
+STLIBOBJS=
+
+OBJS=
 
-OBJS= $(OUTPRE)sha2.$(OBJEXT) 
+SRCS=
 
-SRCS= $(srcdir)/sha2.c
 
-all-unix:: all-libobjs
+all-unix:: all-libobjs 
 
 includes:: depend
 
@@ -22,4 +26,3 @@ depend:: $(SRCS)
 clean-unix:: clean-libobjs
 
 @libobj_frag@
-
diff --git a/src/lib/crypto/nss/sha2/sha2.c b/src/lib/crypto/nss/sha2/sha2.c
deleted file mode 100644 (file)
index 71f27b4..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
-#include "k5-int.h"
-#include "sha2.h"
-
-void sha2Init(SHA2_INFO *shsInfo)
-{
-    return;
-}
-
-void sha2Update(SHA2_INFO *shsInfo, const SHS_BYTE *buffer, unsigned int count)
-{
-    return;
-}
-
-void sha2Final(SHA2_INFO *shsInfo)
-{
-    return;
-}
diff --git a/src/lib/crypto/nss/sha2/sha2.h b/src/lib/crypto/nss/sha2/sha2.h
deleted file mode 100644 (file)
index ade8b61..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-#ifndef _SHA2_DEFINED
-
-#include "k5-int.h"
-
-#define _SHA2_DEFINED
-
-typedef krb5_octet      SHS_BYTE;
-#define SHA2_DIGESTSIZE  32
-
-/* The structure for storing SHA2 info */
-
-typedef struct {
-    void *nss_ctxt;
-    unsigned char   digestBuf[SHA2_DIGESTSIZE]; /* output */
-    unsigned int    digestLen; /* output */
-} SHA2_INFO;
-
-void sha2Init(SHA2_INFO *shsInfo);
-void sha2Update(SHA2_INFO *shsInfo, const SHS_BYTE *buffer, unsigned int count);
-void sha2Final(SHA2_INFO *shsInfo);
-
-#endif /* _SHA2_DEFINED */
index ff43d56d82a658ae8858df012972fd0b57fe4d08..f3992c21ace8371d6d51e372df07b315f80dc424 100644 (file)
@@ -18,17 +18,20 @@ DEFS=
 STLIBOBJS=\
        hmac.o  \
        init.o  \
-       pbkdf2.o
+       pbkdf2.o \
+       stubs.o
 
 OBJS=\
        $(OUTPRE)hmac.$(OBJEXT) \
        $(OUTPRE)init.$(OBJEXT) \
-       $(OUTPRE)pbkdf2.$(OBJEXT)
+       $(OUTPRE)pbkdf2.$(OBJEXT) \
+       $(OUTPRE)stubs.$(OBJEXT)
 
 SRCS=\
        $(srcdir)/hmac.c        \
        $(srcdir)/init.c        \
-       $(srcdir)/pbkdf2.c      
+       $(srcdir)/pbkdf2.c      \
+       $(srcdir)/stubs.c
 
 STOBJLISTS= des/OBJS.ST md4/OBJS.ST    \
        md5/OBJS.ST sha1/OBJS.ST sha2/OBJS.ST   \
index b8a7de924c207a15f8ac509ff563dce0815e6f07..6df0e0d44eb96fcdc5c841d3b46eabc2d545edb1 100644 (file)
@@ -4,12 +4,9 @@
 
 mydir=lib$(S)crypto$(S)openssl$(S)aes
 BUILDTOP=$(REL)..$(S)..$(S)..$(S)..
-LOCALINCLUDES = -I$(srcdir)/.. -I$(srcdir)/../../krb/dk  -I$(srcdir)/../../../../include
+LOCALINCLUDES=
 DEFS=
 
-PROG_LIBPATH=-L$(TOPLIBD)
-PROG_RPATH=$(KRB5_LIBDIR)
-
 STLIBOBJS=
 
 OBJS=
@@ -25,4 +22,3 @@ depend:: $(SRCS)
 clean-unix:: clean-libobjs
 
 @libobj_frag@
-
similarity index 68%
rename from src/lib/crypto/openssl/sha2/sha256.c
rename to src/lib/crypto/openssl/aes/aes.h
index c57805203f419dfd8f9c6376c6596296d06a37e5..4aa9eb84809f94ce7c562c5df84ce8316dc44b55 100644 (file)
@@ -1,8 +1,8 @@
 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/* lib/crypto/openssl/sha2/sha256.c
- *
- * Copyright (C) 2010 by the Massachusetts Institute of Technology.
- * All rights reserved.
+/* lib/crypto/openssl/aes/aes.h - AES translation macros */
+/*
+ * Copyright 2011 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
  *
  * Export of this software from the United States of America may
  *   require a specific license from the United States Government.
  * or implied warranty.
  */
 
-#include "sha2.h"
+#ifndef _AES_H
+#define _AES_H
+
+/* This header maps some of the names of the built-in AES types and functions
+ * (those used by the Fortuna PRNG) to the OpenSSL equivalents. */
+#include <openssl/aes.h>
+
+#define aes_ctx AES_KEY
+#define krb5int_aes_enc_key(k, len, ctx) AES_set_encrypt_key(k, 8*(len), ctx)
+#define krb5int_aes_enc_blk(in, out, ctx) AES_encrypt(in, out, ctx)
 
+#endif /* _AES_H */
index edb93bd27bd287f66545f614a919c76b9fb319f6..cddb434e497cbed33ad8bb59fb830c8836b555b0 100644 (file)
@@ -1,17 +1,22 @@
-mydir=lib$(S)crypto$(S)openssl$(S)sha2
+# Nothing here!  But we can't remove this directory as the build
+# system currently assumes that all modules have the same directory
+# structure.
+
+mydir=lib$(S)crypto$(S)openssl$(S)aes
 BUILDTOP=$(REL)..$(S)..$(S)..$(S)..
+LOCALINCLUDES=
 DEFS=
 
 PROG_LIBPATH=-L$(TOPLIBD)
 PROG_RPATH=$(KRB5_LIBDIR)
 
-STLIBOBJS= sha256.o
+STLIBOBJS=
 
-OBJS= $(OUTPRE)sha256.$(OBJEXT) 
+OBJS=
 
-SRCS= $(srcdir)/sha256.c
+SRCS=
 
-all-unix:: all-libobjs
+all-unix:: all-libobjs 
 
 includes:: depend
 
@@ -20,4 +25,3 @@ depend:: $(SRCS)
 clean-unix:: clean-libobjs
 
 @libobj_frag@
-
index a80fbcb7af26dcd385260a7659e38d7c992bedd3..0f61d5dc41ff8f2fba3a3610e6ffc17353a08802 100644 (file)
 
 #ifndef _SHA2_DEFINED
 
-#include "k5-int.h"
-#include <openssl/evp.h>
 #include <openssl/sha.h>
 
 #define _SHA2_DEFINED
 
-#define SHA2_DIGESTSIZE  32
-
 #define sha2Init SHA256_Init
 #define sha2Update SHA256_Update 
 #define sha2Final SHA256_Final
diff --git a/src/lib/crypto/openssl/stubs.c b/src/lib/crypto/openssl/stubs.c
new file mode 100644 (file)
index 0000000..220df38
--- /dev/null
@@ -0,0 +1,69 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/* lib/crypto/openssl/stubs.c - OpenSSL stub functions */
+/*
+ * Copyright (C) 2011 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Export of this software from the United States of America may
+ *   require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ */
+
+/*
+ * This file defines symbols which must be exported by libk5crypto because they
+ * are in the export list (for the sake of test programs), but which are not
+ * used when OpenSSL is the back end.
+ */
+
+#include "k5-int.h"
+
+/*
+ * These functions are used by the Fortuna PRNG and test program.  They are
+ * defined to OpenSSL equivalents when the OpenSSL back end headers are
+ * used.
+ */
+void krb5int_aes_enc_blk(void);
+void krb5int_aes_enc_key(void);
+void sha2Final(void);
+void sha2Init(void);
+void sha2Update(void);
+
+void krb5int_aes_enc_blk(void)
+{
+    abort();
+}
+
+void krb5int_aes_enc_key(void)
+{
+    abort();
+}
+
+void sha2Final(void)
+{
+    abort();
+}
+
+void sha2Init(void)
+{
+    abort();
+}
+
+void sha2Update(void)
+{
+    abort();
+}