summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/asn1/t_pkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/asn1/t_pkey.c')
-rw-r--r--crypto/openssl/crypto/asn1/t_pkey.c78
1 files changed, 32 insertions, 46 deletions
diff --git a/crypto/openssl/crypto/asn1/t_pkey.c b/crypto/openssl/crypto/asn1/t_pkey.c
index a97341d..4e09c9e 100644
--- a/crypto/openssl/crypto/asn1/t_pkey.c
+++ b/crypto/openssl/crypto/asn1/t_pkey.c
@@ -60,21 +60,21 @@
#include "cryptlib.h"
#include <openssl/buffer.h>
#include <openssl/bn.h>
-#ifndef NO_RSA
+#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
#endif
-#ifndef NO_DH
+#ifndef OPENSSL_NO_DH
#include <openssl/dh.h>
#endif
-#ifndef NO_DSA
+#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
#endif
static int print(BIO *fp,const char *str,BIGNUM *num,
unsigned char *buf,int off);
-#ifndef NO_RSA
-#ifndef NO_FP_API
-int RSA_print_fp(FILE *fp, RSA *x, int off)
+#ifndef OPENSSL_NO_RSA
+#ifndef OPENSSL_NO_FP_API
+int RSA_print_fp(FILE *fp, const RSA *x, int off)
{
BIO *b;
int ret;
@@ -91,7 +91,7 @@ int RSA_print_fp(FILE *fp, RSA *x, int off)
}
#endif
-int RSA_print(BIO *bp, RSA *x, int off)
+int RSA_print(BIO *bp, const RSA *x, int off)
{
char str[128];
const char *s;
@@ -130,14 +130,10 @@ int RSA_print(BIO *bp, RSA *x, int off)
goto err;
}
- if (off)
- {
- if (off > 128) off=128;
- memset(str,' ',off);
- }
if (x->d != NULL)
{
- if (off && (BIO_write(bp,str,off) <= 0)) goto err;
+ if(!BIO_indent(bp,off,128))
+ goto err;
if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->n))
<= 0) goto err;
}
@@ -160,11 +156,11 @@ err:
if (m != NULL) OPENSSL_free(m);
return(ret);
}
-#endif /* NO_RSA */
+#endif /* OPENSSL_NO_RSA */
-#ifndef NO_DSA
-#ifndef NO_FP_API
-int DSA_print_fp(FILE *fp, DSA *x, int off)
+#ifndef OPENSSL_NO_DSA
+#ifndef OPENSSL_NO_FP_API
+int DSA_print_fp(FILE *fp, const DSA *x, int off)
{
BIO *b;
int ret;
@@ -181,9 +177,8 @@ int DSA_print_fp(FILE *fp, DSA *x, int off)
}
#endif
-int DSA_print(BIO *bp, DSA *x, int off)
+int DSA_print(BIO *bp, const DSA *x, int off)
{
- char str[128];
unsigned char *m=NULL;
int ret=0;
size_t buf_len=0,i;
@@ -210,14 +205,10 @@ int DSA_print(BIO *bp, DSA *x, int off)
goto err;
}
- if (off)
- {
- if (off > 128) off=128;
- memset(str,' ',off);
- }
if (x->priv_key != NULL)
{
- if (off && (BIO_write(bp,str,off) <= 0)) goto err;
+ if(!BIO_indent(bp,off,128))
+ goto err;
if (BIO_printf(bp,"Private-Key: (%d bit)\n",BN_num_bits(x->p))
<= 0) goto err;
}
@@ -234,23 +225,18 @@ err:
if (m != NULL) OPENSSL_free(m);
return(ret);
}
-#endif /* !NO_DSA */
+#endif /* !OPENSSL_NO_DSA */
static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
int off)
{
int n,i;
- char str[128];
const char *neg;
if (num == NULL) return(1);
neg=(num->neg)?"-":"";
- if (off)
- {
- if (off > 128) off=128;
- memset(str,' ',off);
- if (BIO_write(bp,str,off) <= 0) return(0);
- }
+ if(!BIO_indent(bp,off,128))
+ return 0;
if (BN_num_bytes(num) <= BN_BYTES)
{
@@ -274,9 +260,9 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
{
if ((i%15) == 0)
{
- str[0]='\n';
- memset(&(str[1]),' ',off+4);
- if (BIO_write(bp,str,off+1+4) <= 0) return(0);
+ if(BIO_puts(bp,"\n") <= 0
+ || !BIO_indent(bp,off+4,128))
+ return 0;
}
if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":")
<= 0) return(0);
@@ -286,9 +272,9 @@ static int print(BIO *bp, const char *number, BIGNUM *num, unsigned char *buf,
return(1);
}
-#ifndef NO_DH
-#ifndef NO_FP_API
-int DHparams_print_fp(FILE *fp, DH *x)
+#ifndef OPENSSL_NO_DH
+#ifndef OPENSSL_NO_FP_API
+int DHparams_print_fp(FILE *fp, const DH *x)
{
BIO *b;
int ret;
@@ -305,7 +291,7 @@ int DHparams_print_fp(FILE *fp, DH *x)
}
#endif
-int DHparams_print(BIO *bp, DH *x)
+int DHparams_print(BIO *bp, const DH *x)
{
unsigned char *m=NULL;
int reason=ERR_R_BUF_LIB,ret=0;
@@ -344,9 +330,9 @@ err:
}
#endif
-#ifndef NO_DSA
-#ifndef NO_FP_API
-int DSAparams_print_fp(FILE *fp, DSA *x)
+#ifndef OPENSSL_NO_DSA
+#ifndef OPENSSL_NO_FP_API
+int DSAparams_print_fp(FILE *fp, const DSA *x)
{
BIO *b;
int ret;
@@ -363,11 +349,11 @@ int DSAparams_print_fp(FILE *fp, DSA *x)
}
#endif
-int DSAparams_print(BIO *bp, DSA *x)
+int DSAparams_print(BIO *bp, const DSA *x)
{
unsigned char *m=NULL;
int reason=ERR_R_BUF_LIB,ret=0;
- size_t buf_len=0, i;
+ size_t buf_len=0,i;
if (x->p)
buf_len = (size_t)BN_num_bytes(x->p);
@@ -397,5 +383,5 @@ err:
return(ret);
}
-#endif /* !NO_DSA */
+#endif /* !OPENSSL_NO_DSA */
OpenPOWER on IntegriCloud