summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--crypto/asn1/t_pkey.c90
-rw-r--r--crypto/evp/evp.h54
-rwxr-xr-xutil/pod2mantest2
4 files changed, 122 insertions, 28 deletions
diff --git a/CHANGES b/CHANGES
index b45fea657e..19d5c346ae 100644
--- a/CHANGES
+++ b/CHANGES
@@ -558,8 +558,8 @@
[Bodo Moeller, Lutz Jaenicke]
*) Rationalise EVP so it can be extended: don't include a union of
- cipher/digest structures, add init/cleanup functions. This also reduces
- the number of header dependencies.
+ cipher/digest structures, add init/cleanup functions for EVP_MD_CTX
+ (similar to those existing for EVP_CIPHER_CTX).
Usage example:
EVP_MD_CTX md;
diff --git a/crypto/asn1/t_pkey.c b/crypto/asn1/t_pkey.c
index c456b67b01..652b26b7b0 100644
--- a/crypto/asn1/t_pkey.c
+++ b/crypto/asn1/t_pkey.c
@@ -100,10 +100,34 @@ int RSA_print(BIO *bp, const RSA *x, int off)
char str[128];
const char *s;
unsigned char *m=NULL;
- int i,ret=0;
+ int ret=0;
+ size_t buf_len=0, i;
- i=RSA_size(x);
- m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
+ if (x->n)
+ buf_len = (size_t)BN_num_bytes(x->n);
+ if (x->e)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->e)))
+ buf_len = i;
+ if (x->d)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->d)))
+ buf_len = i;
+ if (x->p)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->p)))
+ buf_len = i;
+ if (x->q)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
+ buf_len = i;
+ if (x->dmp1)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->dmp1)))
+ buf_len = i;
+ if (x->dmq1)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->dmq1)))
+ buf_len = i;
+ if (x->iqmp)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->iqmp)))
+ buf_len = i;
+
+ m=(unsigned char *)OPENSSL_malloc(buf_len+10);
if (m == NULL)
{
RSAerr(RSA_F_RSA_PRINT,ERR_R_MALLOC_FAILURE);
@@ -165,22 +189,25 @@ int DSA_print(BIO *bp, const DSA *x, int off)
{
char str[128];
unsigned char *m=NULL;
- int i,ret=0;
- BIGNUM *bn=NULL;
-
- if (x->p != NULL)
- bn=x->p;
- else if (x->priv_key != NULL)
- bn=x->priv_key;
- else if (x->pub_key != NULL)
- bn=x->pub_key;
-
- /* larger than needed but what the hell :-) */
- if (bn != NULL)
- i=BN_num_bytes(bn)*2;
- else
- i=256;
- m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
+ int ret=0;
+ size_t buf_len=0,i;
+
+ if (x->p)
+ buf_len = (size_t)BN_num_bytes(x->p);
+ if (x->q)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
+ buf_len = i;
+ if (x->g)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->g)))
+ buf_len = i;
+ if (x->priv_key)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->priv_key)))
+ buf_len = i;
+ if (x->pub_key)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->pub_key)))
+ buf_len = i;
+
+ m=(unsigned char *)OPENSSL_malloc(buf_len+10);
if (m == NULL)
{
DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE);
@@ -572,10 +599,15 @@ int DHparams_print_fp(FILE *fp, const DH *x)
int DHparams_print(BIO *bp, const DH *x)
{
unsigned char *m=NULL;
- int reason=ERR_R_BUF_LIB,i,ret=0;
+ int reason=ERR_R_BUF_LIB,ret=0;
+ size_t buf_len=0, i;
- i=BN_num_bytes(x->p);
- m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
+ if (x->p)
+ buf_len = (size_t)BN_num_bytes(x->p);
+ if (x->g)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->g)))
+ buf_len = i;
+ m=(unsigned char *)OPENSSL_malloc(buf_len+10);
if (m == NULL)
{
reason=ERR_R_MALLOC_FAILURE;
@@ -625,10 +657,18 @@ int DSAparams_print_fp(FILE *fp, const DSA *x)
int DSAparams_print(BIO *bp, const DSA *x)
{
unsigned char *m=NULL;
- int reason=ERR_R_BUF_LIB,i,ret=0;
+ int reason=ERR_R_BUF_LIB,ret=0;
+ size_t buf_len=0,i;
- i=BN_num_bytes(x->p);
- m=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
+ if (x->p)
+ buf_len = (size_t)BN_num_bytes(x->p);
+ if (x->q)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
+ buf_len = i;
+ if (x->g)
+ if (buf_len < (i = (size_t)BN_num_bytes(x->g)))
+ buf_len = i;
+ m=(unsigned char *)OPENSSL_malloc(buf_len+10);
if (m == NULL)
{
reason=ERR_R_MALLOC_FAILURE;
diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h
index 8bb0782472..1a679d5e20 100644
--- a/crypto/evp/evp.h
+++ b/crypto/evp/evp.h
@@ -74,6 +74,48 @@
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#endif
+#ifndef OPENSSL_NO_MD2
+#include <openssl/md2.h>
+#endif
+#ifndef OPENSSL_NO_MD4
+#include <openssl/md4.h>
+#endif
+#ifndef OPENSSL_NO_MD5
+#include <openssl/md5.h>
+#endif
+#ifndef OPENSSL_NO_SHA
+#include <openssl/sha.h>
+#endif
+#ifndef OPENSSL_NO_RIPEMD
+#include <openssl/ripemd.h>
+#endif
+#ifndef OPENSSL_NO_DES
+#include <openssl/des.h>
+#endif
+#ifndef OPENSSL_NO_RC4
+#include <openssl/rc4.h>
+#endif
+#ifndef OPENSSL_NO_RC2
+#include <openssl/rc2.h>
+#endif
+#ifndef OPENSSL_NO_RC5
+#include <openssl/rc5.h>
+#endif
+#ifndef OPENSSL_NO_BF
+#include <openssl/blowfish.h>
+#endif
+#ifndef OPENSSL_NO_CAST
+#include <openssl/cast.h>
+#endif
+#ifndef OPENSSL_NO_IDEA
+#include <openssl/idea.h>
+#endif
+#ifndef OPENSSL_NO_MDC2
+#include <openssl/mdc2.h>
+#endif
+#ifndef OPENSSL_NO_AES
+#include <openssl/aes.h>
+#endif
/*
#define EVP_RC2_KEY_SIZE 16
@@ -91,6 +133,18 @@
/* Default PKCS#5 iteration count */
#define PKCS5_DEFAULT_ITER 2048
+#ifndef OPENSSL_NO_RSA
+#include <openssl/rsa.h>
+#endif
+
+#ifndef OPENSSL_NO_DSA
+#include <openssl/dsa.h>
+#endif
+
+#ifndef OPENSSL_NO_DH
+#include <openssl/dh.h>
+#endif
+
#include <openssl/objects.h>
#define EVP_PK_RSA 0x0001
diff --git a/util/pod2mantest b/util/pod2mantest
index a67433407b..449ef14f1b 100755
--- a/util/pod2mantest
+++ b/util/pod2mantest
@@ -11,7 +11,7 @@
IFS=:
-try_without_dir=true
+try_without_dir=false
# First we try "pod2man", then "$dir/pod2man" for each item in $PATH.
for dir in dummy:$PATH; do
if [ "$try_without_dir" = true ]; then