diff options
author | jsing <> | 2014-04-18 13:14:31 +0000 |
---|---|---|
committer | jsing <> | 2014-04-18 13:14:31 +0000 |
commit | 48839e33a53ed2d6e54cb31ec1a93635e0a4dc60 (patch) | |
tree | f569441b32f0a3293eba8921ed58e2489986006c /src/lib/libcrypto/asn1/t_pkey.c | |
parent | 8a0112534d8764e81ead87d96bc29f9f7087f881 (diff) | |
download | openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.tar.gz openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.tar.bz2 openbsd-48839e33a53ed2d6e54cb31ec1a93635e0a4dc60.zip |
More KNF.
Diffstat (limited to 'src/lib/libcrypto/asn1/t_pkey.c')
-rw-r--r-- | src/lib/libcrypto/asn1/t_pkey.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/src/lib/libcrypto/asn1/t_pkey.c b/src/lib/libcrypto/asn1/t_pkey.c index 12674e0125..579df8154c 100644 --- a/src/lib/libcrypto/asn1/t_pkey.c +++ b/src/lib/libcrypto/asn1/t_pkey.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 |
@@ -62,15 +62,17 @@ | |||
62 | #include <openssl/buffer.h> | 62 | #include <openssl/buffer.h> |
63 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
64 | 64 | ||
65 | int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, | 65 | int |
66 | unsigned char *buf, int off) | 66 | ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, |
67 | unsigned char *buf, int off) | ||
67 | { | 68 | { |
68 | int n,i; | 69 | int n, i; |
69 | const char *neg; | 70 | const char *neg; |
70 | 71 | ||
71 | if (num == NULL) return(1); | 72 | if (num == NULL) |
72 | neg = (BN_is_negative(num))?"-":""; | 73 | return (1); |
73 | if(!BIO_indent(bp,off,128)) | 74 | neg = (BN_is_negative(num)) ? "-" : ""; |
75 | if (!BIO_indent(bp, off, 128)) | ||
74 | return 0; | 76 | return 0; |
75 | if (BN_is_zero(num)) { | 77 | if (BN_is_zero(num)) { |
76 | if (BIO_printf(bp, "%s 0\n", number) <= 0) | 78 | if (BIO_printf(bp, "%s 0\n", number) <= 0) |
@@ -79,30 +81,34 @@ int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, | |||
79 | } | 81 | } |
80 | 82 | ||
81 | if (BN_num_bytes(num) <= BN_BYTES) { | 83 | if (BN_num_bytes(num) <= BN_BYTES) { |
82 | if (BIO_printf(bp,"%s %s%lu (%s0x%lx)\n",number,neg, | 84 | if (BIO_printf(bp, "%s %s%lu (%s0x%lx)\n", number, neg, |
83 | (unsigned long)num->d[0],neg,(unsigned long)num->d[0]) | 85 | (unsigned long)num->d[0], neg, |
84 | <= 0) return(0); | 86 | (unsigned long)num->d[0]) <= 0) |
87 | return (0); | ||
85 | } else { | 88 | } else { |
86 | buf[0]=0; | 89 | buf[0] = 0; |
87 | if (BIO_printf(bp,"%s%s",number, | 90 | if (BIO_printf(bp, "%s%s", number, |
88 | (neg[0] == '-')?" (Negative)":"") <= 0) | 91 | (neg[0] == '-') ? " (Negative)" : "") <= 0) |
89 | return(0); | 92 | return (0); |
90 | n=BN_bn2bin(num,&buf[1]); | 93 | n = BN_bn2bin(num, &buf[1]); |
91 | 94 | ||
92 | if (buf[1] & 0x80) | 95 | if (buf[1] & 0x80) |
93 | n++; | 96 | n++; |
94 | else buf++; | 97 | else |
98 | buf++; | ||
95 | 99 | ||
96 | for (i=0; i<n; i++) { | 100 | for (i = 0; i < n; i++) { |
97 | if ((i%15) == 0) { | 101 | if ((i % 15) == 0) { |
98 | if(BIO_puts(bp,"\n") <= 0 | 102 | if (BIO_puts(bp, "\n") <= 0 || |
99 | || !BIO_indent(bp,off+4,128)) | 103 | !BIO_indent(bp, off + 4, 128)) |
100 | return 0; | 104 | return 0; |
101 | } | 105 | } |
102 | if (BIO_printf(bp,"%02x%s",buf[i],((i+1) == n)?"":":") | 106 | if (BIO_printf(bp, "%02x%s", buf[i], |
103 | <= 0) return(0); | 107 | ((i + 1) == n) ? "" : ":") <= 0) |
108 | return (0); | ||
104 | } | 109 | } |
105 | if (BIO_write(bp,"\n",1) <= 0) return(0); | 110 | if (BIO_write(bp, "\n", 1) <= 0) |
111 | return (0); | ||
106 | } | 112 | } |
107 | return(1); | 113 | return (1); |
108 | } | 114 | } |