diff options
author | jsing <> | 2014-04-18 07:09:23 +0000 |
---|---|---|
committer | jsing <> | 2014-04-18 07:09:23 +0000 |
commit | 47f3f755de44fe72026c26b61f3534245e51ce63 (patch) | |
tree | 530ccfa4465ec1e141f16ac55eccd5e456d9dadf /src/lib/libcrypto/asn1/a_i2d_fp.c | |
parent | f843014abcc7498613638ca7bdc47b3123ea2544 (diff) | |
download | openbsd-47f3f755de44fe72026c26b61f3534245e51ce63.tar.gz openbsd-47f3f755de44fe72026c26b61f3534245e51ce63.tar.bz2 openbsd-47f3f755de44fe72026c26b61f3534245e51ce63.zip |
More KNF.
Diffstat (limited to 'src/lib/libcrypto/asn1/a_i2d_fp.c')
-rw-r--r-- | src/lib/libcrypto/asn1/a_i2d_fp.c | 108 |
1 files changed, 57 insertions, 51 deletions
diff --git a/src/lib/libcrypto/asn1/a_i2d_fp.c b/src/lib/libcrypto/asn1/a_i2d_fp.c index 93e6d8351b..082ba1b3a8 100644 --- a/src/lib/libcrypto/asn1/a_i2d_fp.c +++ b/src/lib/libcrypto/asn1/a_i2d_fp.c | |||
@@ -5,21 +5,21 @@ | |||
5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
8 | * | 8 | * |
9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | 11 | * apply to all code found in this distribution, be it the RC4, RSA, |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
13 | * included with this distribution is covered by the same copyright terms | 13 | * included with this distribution is covered by the same copyright terms |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
15 | * | 15 | * |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
18 | * If this package is used in a product, Eric Young should be given attribution | 18 | * If this package is used in a product, Eric Young should be given attribution |
19 | * as the author of the parts of the library used. | 19 | * as the author of the parts of the library used. |
20 | * This can be in the form of a textual message at program startup or | 20 | * This can be in the form of a textual message at program startup or |
21 | * in documentation (online or textual) provided with the package. | 21 | * in documentation (online or textual) provided with the package. |
22 | * | 22 | * |
23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
25 | * are met: | 25 | * are met: |
@@ -34,10 +34,10 @@ | |||
34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 37 | * 4. If you include any Windows specific code (or a derivative thereof) from |
38 | * the apps directory (application code) you must include an acknowledgement: | 38 | * the apps directory (application code) you must include an acknowledgement: |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
40 | * | 40 | * |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -49,7 +49,7 @@ | |||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
52 | * | 52 | * |
53 | * The licence and distribution terms for any publically available version or | 53 | * The licence and distribution terms for any publically available version or |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
@@ -64,92 +64,98 @@ | |||
64 | #ifndef NO_OLD_ASN1 | 64 | #ifndef NO_OLD_ASN1 |
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 |
68 | ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x) | ||
68 | { | 69 | { |
69 | BIO *b; | 70 | BIO *b; |
70 | int ret; | 71 | int ret; |
71 | 72 | ||
72 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 73 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
73 | ASN1err(ASN1_F_ASN1_I2D_FP,ERR_R_BUF_LIB); | 74 | ASN1err(ASN1_F_ASN1_I2D_FP, ERR_R_BUF_LIB); |
74 | return(0); | 75 | return (0); |
75 | } | 76 | } |
76 | BIO_set_fp(b,out,BIO_NOCLOSE); | 77 | BIO_set_fp(b, out, BIO_NOCLOSE); |
77 | ret=ASN1_i2d_bio(i2d,b,x); | 78 | ret = ASN1_i2d_bio(i2d, b, x); |
78 | BIO_free(b); | 79 | BIO_free(b); |
79 | return(ret); | 80 | return (ret); |
80 | } | 81 | } |
81 | #endif | 82 | #endif |
82 | 83 | ||
83 | int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) | 84 | int |
85 | ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x) | ||
84 | { | 86 | { |
85 | char *b; | 87 | char *b; |
86 | unsigned char *p; | 88 | unsigned char *p; |
87 | int i,j=0,n,ret=1; | 89 | int i, j = 0, n, ret = 1; |
88 | 90 | ||
89 | n=i2d(x,NULL); | 91 | n = i2d(x, NULL); |
90 | b=(char *)malloc(n); | 92 | b = (char *)malloc(n); |
91 | if (b == NULL) { | 93 | if (b == NULL) { |
92 | ASN1err(ASN1_F_ASN1_I2D_BIO,ERR_R_MALLOC_FAILURE); | 94 | ASN1err(ASN1_F_ASN1_I2D_BIO, ERR_R_MALLOC_FAILURE); |
93 | return(0); | 95 | return (0); |
94 | } | 96 | } |
95 | 97 | ||
96 | p=(unsigned char *)b; | 98 | p = (unsigned char *)b; |
97 | i2d(x,&p); | 99 | i2d(x, &p); |
98 | 100 | ||
99 | for (;;) { | 101 | for (;;) { |
100 | i=BIO_write(out,&(b[j]),n); | 102 | i = BIO_write(out, &(b[j]), n); |
101 | if (i == n) break; | 103 | if (i == n) |
104 | break; | ||
102 | if (i <= 0) { | 105 | if (i <= 0) { |
103 | ret=0; | 106 | ret = 0; |
104 | break; | 107 | break; |
105 | } | 108 | } |
106 | j+=i; | 109 | j += i; |
107 | n-=i; | 110 | n -= i; |
108 | } | 111 | } |
109 | free(b); | 112 | free(b); |
110 | return(ret); | 113 | return (ret); |
111 | } | 114 | } |
112 | 115 | ||
113 | #endif | 116 | #endif |
114 | 117 | ||
115 | #ifndef OPENSSL_NO_FP_API | 118 | #ifndef OPENSSL_NO_FP_API |
116 | int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) | 119 | int |
120 | ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x) | ||
117 | { | 121 | { |
118 | BIO *b; | 122 | BIO *b; |
119 | int ret; | 123 | int ret; |
120 | 124 | ||
121 | if ((b=BIO_new(BIO_s_file())) == NULL) { | 125 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
122 | ASN1err(ASN1_F_ASN1_ITEM_I2D_FP,ERR_R_BUF_LIB); | 126 | ASN1err(ASN1_F_ASN1_ITEM_I2D_FP, ERR_R_BUF_LIB); |
123 | return(0); | 127 | return (0); |
124 | } | 128 | } |
125 | BIO_set_fp(b,out,BIO_NOCLOSE); | 129 | BIO_set_fp(b, out, BIO_NOCLOSE); |
126 | ret=ASN1_item_i2d_bio(it,b,x); | 130 | ret = ASN1_item_i2d_bio(it, b, x); |
127 | BIO_free(b); | 131 | BIO_free(b); |
128 | return(ret); | 132 | return (ret); |
129 | } | 133 | } |
130 | #endif | 134 | #endif |
131 | 135 | ||
132 | int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) | 136 | int |
137 | ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x) | ||
133 | { | 138 | { |
134 | unsigned char *b = NULL; | 139 | unsigned char *b = NULL; |
135 | int i,j=0,n,ret=1; | 140 | int i, j = 0, n, ret = 1; |
136 | 141 | ||
137 | n = ASN1_item_i2d(x, &b, it); | 142 | n = ASN1_item_i2d(x, &b, it); |
138 | if (b == NULL) { | 143 | if (b == NULL) { |
139 | ASN1err(ASN1_F_ASN1_ITEM_I2D_BIO,ERR_R_MALLOC_FAILURE); | 144 | ASN1err(ASN1_F_ASN1_ITEM_I2D_BIO, ERR_R_MALLOC_FAILURE); |
140 | return(0); | 145 | return (0); |
141 | } | 146 | } |
142 | 147 | ||
143 | for (;;) { | 148 | for (;;) { |
144 | i=BIO_write(out,&(b[j]),n); | 149 | i = BIO_write(out, &(b[j]), n); |
145 | if (i == n) break; | 150 | if (i == n) |
151 | break; | ||
146 | if (i <= 0) { | 152 | if (i <= 0) { |
147 | ret=0; | 153 | ret = 0; |
148 | break; | 154 | break; |
149 | } | 155 | } |
150 | j+=i; | 156 | j += i; |
151 | n-=i; | 157 | n -= i; |
152 | } | 158 | } |
153 | free(b); | 159 | free(b); |
154 | return(ret); | 160 | return (ret); |
155 | } | 161 | } |