diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_i2d_fp.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_i2d_fp.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c index aee29a7790..f4f1b73ebe 100644 --- a/src/lib/libcrypto/asn1/a_i2d_fp.c +++ b/src/lib/libcrypto/asn1/a_i2d_fp.c | |||
@@ -59,9 +59,11 @@ | |||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include <openssl/buffer.h> | 61 | #include <openssl/buffer.h> |
62 | #include <openssl/asn1_mac.h> | 62 | #include <openssl/asn1.h> |
63 | 63 | ||
64 | #ifndef NO_FP_API | 64 | #ifndef NO_OLD_ASN1 |
65 | |||
66 | #ifndef OPENSSL_NO_FP_API | ||
65 | int ASN1_i2d_fp(int (*i2d)(), FILE *out, unsigned char *x) | 67 | int ASN1_i2d_fp(int (*i2d)(), FILE *out, unsigned char *x) |
66 | { | 68 | { |
67 | BIO *b; | 69 | BIO *b; |
@@ -111,3 +113,51 @@ int ASN1_i2d_bio(int (*i2d)(), BIO *out, unsigned char *x) | |||
111 | OPENSSL_free(b); | 113 | OPENSSL_free(b); |
112 | return(ret); | 114 | return(ret); |
113 | } | 115 | } |
116 | |||
117 | #endif | ||
118 | |||
119 | #ifndef OPENSSL_NO_FP_API | ||
120 | int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) | ||
121 | { | ||
122 | BIO *b; | ||
123 | int ret; | ||
124 | |||
125 | if ((b=BIO_new(BIO_s_file())) == NULL) | ||
126 | { | ||
127 | ASN1err(ASN1_F_ASN1_I2D_FP,ERR_R_BUF_LIB); | ||
128 | return(0); | ||
129 | } | ||
130 | BIO_set_fp(b,out,BIO_NOCLOSE); | ||
131 | ret=ASN1_item_i2d_bio(it,b,x); | ||
132 | BIO_free(b); | ||
133 | return(ret); | ||
134 | } | ||
135 | #endif | ||
136 | |||
137 | int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) | ||
138 | { | ||
139 | unsigned char *b = NULL; | ||
140 | int i,j=0,n,ret=1; | ||
141 | |||
142 | n = ASN1_item_i2d(x, &b, it); | ||
143 | if (b == NULL) | ||
144 | { | ||
145 | ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE); | ||
146 | return(0); | ||
147 | } | ||
148 | |||
149 | for (;;) | ||
150 | { | ||
151 | i=BIO_write(out,&(b[j]),n); | ||
152 | if (i == n) break; | ||
153 | if (i <= 0) | ||
154 | { | ||
155 | ret=0; | ||
156 | break; | ||
157 | } | ||
158 | j+=i; | ||
159 | n-=i; | ||
160 | } | ||
161 | OPENSSL_free(b); | ||
162 | return(ret); | ||
163 | } | ||