diff options
Diffstat (limited to 'src/lib/libcrypto/asn1/a_i2d_fp.c')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_i2d_fp.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c index 484bcd66eb..52bedb3f73 100644 --- a/src/lib/libcrypto/asn1/a_i2d_fp.c +++ b/src/lib/libcrypto/asn1/a_i2d_fp.c | |||
| @@ -65,24 +65,24 @@ | |||
| 65 | 65 | ||
| 66 | #ifndef OPENSSL_NO_FP_API | 66 | #ifndef OPENSSL_NO_FP_API |
| 67 | int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x) | 67 | int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x) |
| 68 | { | 68 | { |
| 69 | BIO *b; | 69 | BIO *b; |
| 70 | int ret; | 70 | int ret; |
| 71 | 71 | ||
| 72 | if ((b=BIO_new(BIO_s_file())) == NULL) | 72 | if ((b=BIO_new(BIO_s_file())) == NULL) |
| 73 | { | 73 | { |
| 74 | ASN1err(ASN1_F_ASN1_I2D_FP,ERR_R_BUF_LIB); | 74 | ASN1err(ASN1_F_ASN1_I2D_FP,ERR_R_BUF_LIB); |
| 75 | return(0); | 75 | return(0); |
| 76 | } | 76 | } |
| 77 | BIO_set_fp(b,out,BIO_NOCLOSE); | 77 | BIO_set_fp(b,out,BIO_NOCLOSE); |
| 78 | ret=ASN1_i2d_bio(i2d,b,x); | 78 | ret=ASN1_i2d_bio(i2d,b,x); |
| 79 | BIO_free(b); | 79 | BIO_free(b); |
| 80 | return(ret); | 80 | return(ret); |
| 81 | } | 81 | } |
| 82 | #endif | 82 | #endif |
| 83 | 83 | ||
| 84 | int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) | 84 | int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) |
| 85 | { | 85 | { |
| 86 | char *b; | 86 | char *b; |
| 87 | unsigned char *p; | 87 | unsigned char *p; |
| 88 | int i,j=0,n,ret=1; | 88 | int i,j=0,n,ret=1; |
| @@ -90,74 +90,74 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) | |||
| 90 | n=i2d(x,NULL); | 90 | n=i2d(x,NULL); |
| 91 | b=(char *)malloc(n); | 91 | b=(char *)malloc(n); |
| 92 | if (b == NULL) | 92 | if (b == NULL) |
| 93 | { | 93 | { |
| 94 | ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE); | 94 | ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE); |
| 95 | return(0); | 95 | return(0); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | p=(unsigned char *)b; | 98 | p=(unsigned char *)b; |
| 99 | i2d(x,&p); | 99 | i2d(x,&p); |
| 100 | 100 | ||
| 101 | for (;;) | 101 | for (;;) |
| 102 | { | 102 | { |
| 103 | i=BIO_write(out,&(b[j]),n); | 103 | i=BIO_write(out,&(b[j]),n); |
| 104 | if (i == n) break; | 104 | if (i == n) break; |
| 105 | if (i <= 0) | 105 | if (i <= 0) |
| 106 | { | 106 | { |
| 107 | ret=0; | 107 | ret=0; |
| 108 | break; | 108 | break; |
| 109 | } | 109 | } |
| 110 | j+=i; | 110 | j+=i; |
| 111 | n-=i; | 111 | n-=i; |
| 112 | } | 112 | } |
| 113 | free(b); | 113 | free(b); |
| 114 | return(ret); | 114 | return(ret); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | #endif | 117 | #endif |
| 118 | 118 | ||
| 119 | #ifndef OPENSSL_NO_FP_API | 119 | #ifndef OPENSSL_NO_FP_API |
| 120 | int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) | 120 | int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) |
| 121 | { | 121 | { |
| 122 | BIO *b; | 122 | BIO *b; |
| 123 | int ret; | 123 | int ret; |
| 124 | 124 | ||
| 125 | if ((b=BIO_new(BIO_s_file())) == NULL) | 125 | if ((b=BIO_new(BIO_s_file())) == NULL) |
| 126 | { | 126 | { |
| 127 | ASN1err(ASN1_F_ASN1_ITEM_I2D_FP,ERR_R_BUF_LIB); | 127 | ASN1err(ASN1_F_ASN1_ITEM_I2D_FP,ERR_R_BUF_LIB); |
| 128 | return(0); | 128 | return(0); |
| 129 | } | 129 | } |
| 130 | BIO_set_fp(b,out,BIO_NOCLOSE); | 130 | BIO_set_fp(b,out,BIO_NOCLOSE); |
| 131 | ret=ASN1_item_i2d_bio(it,b,x); | 131 | ret=ASN1_item_i2d_bio(it,b,x); |
| 132 | BIO_free(b); | 132 | BIO_free(b); |
| 133 | return(ret); | 133 | return(ret); |
| 134 | } | 134 | } |
| 135 | #endif | 135 | #endif |
| 136 | 136 | ||
| 137 | int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) | 137 | int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) |
| 138 | { | 138 | { |
| 139 | unsigned char *b = NULL; | 139 | unsigned char *b = NULL; |
| 140 | int i,j=0,n,ret=1; | 140 | int i,j=0,n,ret=1; |
| 141 | 141 | ||
| 142 | n = ASN1_item_i2d(x, &b, it); | 142 | n = ASN1_item_i2d(x, &b, it); |
| 143 | if (b == NULL) | 143 | if (b == NULL) |
| 144 | { | 144 | { |
| 145 | ASN1err(ASN1_F_ASN1_ITEM_I2D_BIO,ERR_R_MALLOC_FAILURE); | 145 | ASN1err(ASN1_F_ASN1_ITEM_I2D_BIO,ERR_R_MALLOC_FAILURE); |
| 146 | return(0); | 146 | return(0); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | for (;;) | 149 | for (;;) |
| 150 | { | 150 | { |
| 151 | i=BIO_write(out,&(b[j]),n); | 151 | i=BIO_write(out,&(b[j]),n); |
| 152 | if (i == n) break; | 152 | if (i == n) break; |
| 153 | if (i <= 0) | 153 | if (i <= 0) |
| 154 | { | 154 | { |
| 155 | ret=0; | 155 | ret=0; |
| 156 | break; | 156 | break; |
| 157 | } | 157 | } |
| 158 | j+=i; | 158 | j+=i; |
| 159 | n-=i; | 159 | n-=i; |
| 160 | } | 160 | } |
| 161 | free(b); | 161 | free(b); |
| 162 | return(ret); | 162 | return(ret); |
| 163 | } | 163 | } |
