revert more "version skew" changes that break FIPS builds
[openssl.git] / crypto / evp / openbsd_hw.c
index b4ac72dbcbfe9e87ae1c5a1647b46cf79fb396a5..3831a5731e9cd5340daccff94d64146403f34af4 100644 (file)
  * OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#include <openssl/rsa.h>
+#include "evp_locl.h"
+
+/* This stuff should now all be supported through
+ * crypto/engine/hw_openbsd_dev_crypto.c unless I botched it up */
+static void *dummy=&dummy;
+
+#if 0
+
+/* check flag after OpenSSL headers to ensure make depend works */
+#ifdef OPENSSL_OPENBSD_DEV_CRYPTO
+
 #include <fcntl.h>
 #include <stdio.h>
 #include <errno.h>
 #include <sys/ioctl.h>
 #include <crypto/cryptodev.h>
 #include <unistd.h>
-#include <openssl/evp.h>
-#include <openssl/objects.h>
-#include <openssl/rsa.h>
-#include "evp_locl.h"
 #include <assert.h>
 
-/* check flag after headers to ensure make depend works */
-#ifdef OPENSSL_OPENBSD_DEV_CRYPTO
-
 /* longest key supported in hardware */
 #define MAX_HW_KEY     24
 #define MAX_HW_IV      8
@@ -290,6 +297,17 @@ static int dev_crypto_init_digest(MD_DATA *md_data,int mac)
     return 1;
     }
 
+static int dev_crypto_cleanup_digest(MD_DATA *md_data)
+    {
+    if (ioctl(fd,CIOCFSESSION,&md_data->sess.ses) == -1)
+       {
+       err("CIOCFSESSION failed");
+       return 0;
+       }
+
+    return 1;
+    }
+
 /* FIXME: if device can do chained MACs, then don't accumulate */
 /* FIXME: move accumulation to the framework */
 static int dev_crypto_md5_init(EVP_MD_CTX *ctx)
@@ -345,7 +363,7 @@ static int do_digest(int ses,unsigned char *md,const void *data,int len)
            return 0;
            }
        }
-    printf("done\n");
+    //    printf("done\n");
 
     return 1;
     }
@@ -373,13 +391,15 @@ static int dev_crypto_md5_final(EVP_MD_CTX *ctx,unsigned char *md)
     if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT)
        {
        memcpy(md,md_data->md,MD5_DIGEST_LENGTH);
-       return 1;
+       ret=1;
+       }
+    else
+       {
+       ret=do_digest(md_data->sess.ses,md,md_data->data,md_data->len);
+       OPENSSL_free(md_data->data);
+       md_data->data=NULL;
+       md_data->len=0;
        }
-
-    ret=do_digest(md_data->sess.ses,md,md_data->data,md_data->len);
-    OPENSSL_free(md_data->data);
-    md_data->data=NULL;
-    md_data->len=0;
 
     return ret;
     }
@@ -398,6 +418,11 @@ static int dev_crypto_md5_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
     return 1;
     }
 
+static int dev_crypto_md5_cleanup(EVP_MD_CTX *ctx)
+    {
+    return dev_crypto_cleanup_digest(ctx->md_data);
+    }
+
 static const EVP_MD md5_md=
     {
     NID_md5,
@@ -408,6 +433,7 @@ static const EVP_MD md5_md=
     dev_crypto_md5_update,
     dev_crypto_md5_final,
     dev_crypto_md5_copy,
+    dev_crypto_md5_cleanup,
     EVP_PKEY_RSA_method,
     MD5_CBLOCK,
     sizeof(MD_DATA),
@@ -417,3 +443,4 @@ const EVP_MD *EVP_dev_crypto_md5(void)
     { return &md5_md; }
 
 #endif
+#endif