Loops like this one:
[openssl.git] / crypto / pem / pem_seal.c
index 6acb04ad774df40c51b61aa1cc28397c62bf135d..2a6c5133481afeea02762f983ace99ed1cb96bf1 100644 (file)
@@ -1,5 +1,5 @@
 /* crypto/pem/pem_seal.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_RSA
 #include <stdio.h>
 #include "cryptlib.h"
-#include "evp.h"
-#include "rand.h"
-#include "objects.h"
-#include "x509.h"
-#include "pem.h"
-
-int PEM_SealInit(ctx,type,md_type,ek,ekl,iv,pubk,npubk)
-PEM_ENCODE_SEAL_CTX *ctx;
-EVP_CIPHER *type;
-EVP_MD *md_type;
-unsigned char **ek;
-int *ekl;
-unsigned char *iv;
-EVP_PKEY **pubk;
-int npubk;
+#include <openssl/evp.h>
+#include <openssl/rand.h>
+#include <openssl/objects.h>
+#include <openssl/x509.h>
+#include <openssl/pem.h>
+
+int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type, EVP_MD *md_type,
+            unsigned char **ek, int *ekl, unsigned char *iv, EVP_PKEY **pubk,
+            int npubk)
        {
        unsigned char key[EVP_MAX_KEY_LENGTH];
        int ret= -1;
@@ -89,7 +84,7 @@ int npubk;
                j=RSA_size(pubk[i]->pkey.rsa);
                if (j > max) max=j;
                }
-       s=(char *)Malloc(max*2);
+       s=(char *)OPENSSL_malloc(max*2);
        if (s == NULL)
                {
                PEMerr(PEM_F_PEM_SEALINIT,ERR_R_MALLOC_FAILURE);
@@ -113,17 +108,13 @@ int npubk;
 
        ret=npubk;
 err:
-       if (s != NULL) Free(s);
+       if (s != NULL) OPENSSL_free(s);
        memset(key,0,EVP_MAX_KEY_LENGTH);
        return(ret);
        }
 
-void PEM_SealUpdate(ctx,out,outl,in,inl)
-PEM_ENCODE_SEAL_CTX *ctx;
-unsigned char *out;
-int *outl;
-unsigned char *in;
-int inl;
+void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
+            unsigned char *in, int inl)
        {
        unsigned char buffer[1600];
        int i,j;
@@ -146,13 +137,8 @@ int inl;
                }
        }
 
-int PEM_SealFinal(ctx,sig,sigl,out,outl,priv)
-PEM_ENCODE_SEAL_CTX *ctx;
-unsigned char *sig;
-int *sigl;
-unsigned char *out;
-int *outl;
-EVP_PKEY *priv;
+int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig, int *sigl,
+            unsigned char *out, int *outl, EVP_PKEY *priv)
        {
        unsigned char *s=NULL;
        int ret=0,j;
@@ -165,7 +151,7 @@ EVP_PKEY *priv;
                }
        i=RSA_size(priv->pkey.rsa);
        if (i < 100) i=100;
-       s=(unsigned char *)Malloc(i*2);
+       s=(unsigned char *)OPENSSL_malloc(i*2);
        if (s == NULL)
                {
                PEMerr(PEM_F_PEM_SEALFINAL,ERR_R_MALLOC_FAILURE);
@@ -186,6 +172,13 @@ EVP_PKEY *priv;
 err:
        memset((char *)&(ctx->md),0,sizeof(ctx->md));
        memset((char *)&(ctx->cipher),0,sizeof(ctx->cipher));
-       if (s != NULL) Free(s);
+       if (s != NULL) OPENSSL_free(s);
        return(ret);
        }
+#else /* !NO_RSA */
+
+# if PEDANTIC
+static void *dummy=&dummy;
+# endif
+
+#endif