dev_crypto_cipher: return immediately if allocating cin/cout failed
[openssl.git] / crypto / evp / openbsd_hw.c
index 2e4ad10560db8606e53ab5cd151e9467d4c23f20..0554019489e7c40c24e738a534715d3dcafb1a9f 100644 (file)
 #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
 
@@ -128,6 +134,8 @@ static int dev_crypto_init_key(EVP_CIPHER_CTX *ctx,int cipher,
        return 0;
 
     CDATA(ctx)->key=OPENSSL_malloc(MAX_HW_KEY);
+    if (CDATA(ctx)->key == NULL)
+        return 0;
 
     assert(ctx->cipher->iv_len <= MAX_HW_IV);
 
@@ -185,6 +193,8 @@ static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
            if(((unsigned long)in&3) || cinl != inl)
                {
                cin=OPENSSL_malloc(cinl);
+               if (cin == NULL)
+                   return 0;
                memcpy(cin,in,inl);
                cryp.src=cin;
                }
@@ -192,6 +202,12 @@ static int dev_crypto_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
            if(((unsigned long)out&3) || cinl != inl)
                {
                cout=OPENSSL_malloc(cinl);
+               if (cout == NULL)
+                   {
+                   if (cin != NULL)
+                       OPENSSL_free(cin);
+                   return 0;
+                   }
                cryp.dst=cout;
                }
 
@@ -437,3 +453,4 @@ const EVP_MD *EVP_dev_crypto_md5(void)
     { return &md5_md; }
 
 #endif
+#endif