Constify the RSA parts of the ASN.1 library. Note some ugly casts
[openssl.git] / crypto / asn1 / i2d_r_pr.c
index cfd1fc74f5b2d92f09115ac0c9f79e4a58010ff6..518f4af9a66ee6577b17958977dbdb6ada5cf032 100644 (file)
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_RSA
 #include <stdio.h>
 #include "cryptlib.h"
-#include "bn.h"
-#include "rsa.h"
-#include "objects.h"
-#include "asn1_mac.h"
+#include <openssl/bn.h>
+#include <openssl/rsa.h>
+#include <openssl/objects.h>
+#include <openssl/asn1_mac.h>
 
-/*
- * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ERR_R_ASN1_LENGTH_MISMATCH);
- * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
- */
-
-int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
+int i2d_RSAPrivateKey(const RSA *a, unsigned char **pp)
        {
        BIGNUM *num[9];
        unsigned char data[1];
@@ -111,7 +107,7 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
 
        i2d_ASN1_INTEGER(&bs,&p);
 
-       bs.data=(unsigned char *)Malloc(max+4);
+       bs.data=(unsigned char *)OPENSSL_malloc(max+4);
        if (bs.data == NULL)
                {
                ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE);
@@ -123,8 +119,15 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp)
                bs.length=BN_bn2bin(num[i],bs.data);
                i2d_ASN1_INTEGER(&bs,&p);
                }
-       Free((char *)bs.data);
+       OPENSSL_free(bs.data);
        *pp=p;
        return(t);
        }
+#else /* !NO_RSA */
+
+# if PEDANTIC
+static void *dummy=&dummy;
+# endif
+
+#endif