diff options
author | jsing <> | 2014-04-20 14:24:11 +0000 |
---|---|---|
committer | jsing <> | 2014-04-20 14:24:11 +0000 |
commit | f3c3afa642d281b9472832f33041f3dc51156597 (patch) | |
tree | 12a30d22cdd000ad01b121a088e9418c7a34a792 /src/lib | |
parent | 5ebe999453f510fc76906c79d60f771b13af212b (diff) | |
download | openbsd-f3c3afa642d281b9472832f33041f3dc51156597.tar.gz openbsd-f3c3afa642d281b9472832f33041f3dc51156597.tar.bz2 openbsd-f3c3afa642d281b9472832f33041f3dc51156597.zip |
More KNF.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/cryptlib.c | 112 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/cryptlib.c | 112 |
2 files changed, 124 insertions, 100 deletions
diff --git a/src/lib/libcrypto/cryptlib.c b/src/lib/libcrypto/cryptlib.c index 1024dec09e..addc27eb08 100644 --- a/src/lib/libcrypto/cryptlib.c +++ b/src/lib/libcrypto/cryptlib.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * are met: | 7 | * are met: |
8 | * | 8 | * |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * | 11 | * |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in | 13 | * notice, this list of conditions and the following disclaimer in |
@@ -58,21 +58,21 @@ | |||
58 | * This package is an SSL implementation written | 58 | * This package is an SSL implementation written |
59 | * by Eric Young (eay@cryptsoft.com). | 59 | * by Eric Young (eay@cryptsoft.com). |
60 | * The implementation was written so as to conform with Netscapes SSL. | 60 | * The implementation was written so as to conform with Netscapes SSL. |
61 | * | 61 | * |
62 | * This library is free for commercial and non-commercial use as long as | 62 | * This library is free for commercial and non-commercial use as long as |
63 | * the following conditions are aheared to. The following conditions | 63 | * the following conditions are aheared to. The following conditions |
64 | * apply to all code found in this distribution, be it the RC4, RSA, | 64 | * apply to all code found in this distribution, be it the RC4, RSA, |
65 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 65 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
66 | * included with this distribution is covered by the same copyright terms | 66 | * included with this distribution is covered by the same copyright terms |
67 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 67 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
68 | * | 68 | * |
69 | * Copyright remains Eric Young's, and as such any Copyright notices in | 69 | * Copyright remains Eric Young's, and as such any Copyright notices in |
70 | * the code are not to be removed. | 70 | * the code are not to be removed. |
71 | * If this package is used in a product, Eric Young should be given attribution | 71 | * If this package is used in a product, Eric Young should be given attribution |
72 | * as the author of the parts of the library used. | 72 | * as the author of the parts of the library used. |
73 | * This can be in the form of a textual message at program startup or | 73 | * This can be in the form of a textual message at program startup or |
74 | * in documentation (online or textual) provided with the package. | 74 | * in documentation (online or textual) provided with the package. |
75 | * | 75 | * |
76 | * Redistribution and use in source and binary forms, with or without | 76 | * Redistribution and use in source and binary forms, with or without |
77 | * modification, are permitted provided that the following conditions | 77 | * modification, are permitted provided that the following conditions |
78 | * are met: | 78 | * are met: |
@@ -87,10 +87,10 @@ | |||
87 | * Eric Young (eay@cryptsoft.com)" | 87 | * Eric Young (eay@cryptsoft.com)" |
88 | * The word 'cryptographic' can be left out if the rouines from the library | 88 | * The word 'cryptographic' can be left out if the rouines from the library |
89 | * being used are not cryptographic related :-). | 89 | * being used are not cryptographic related :-). |
90 | * 4. If you include any Windows specific code (or a derivative thereof) from | 90 | * 4. If you include any Windows specific code (or a derivative thereof) from |
91 | * the apps directory (application code) you must include an acknowledgement: | 91 | * the apps directory (application code) you must include an acknowledgement: |
92 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 92 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
93 | * | 93 | * |
94 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 94 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
95 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 95 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
96 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 96 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -102,7 +102,7 @@ | |||
102 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 102 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
103 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 103 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
104 | * SUCH DAMAGE. | 104 | * SUCH DAMAGE. |
105 | * | 105 | * |
106 | * The licence and distribution terms for any publically available version or | 106 | * The licence and distribution terms for any publically available version or |
107 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 107 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
108 | * copied and put under another distribution licence | 108 | * copied and put under another distribution licence |
@@ -110,7 +110,7 @@ | |||
110 | */ | 110 | */ |
111 | /* ==================================================================== | 111 | /* ==================================================================== |
112 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 112 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
113 | * ECDH support in OpenSSL originally developed by | 113 | * ECDH support in OpenSSL originally developed by |
114 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 114 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
115 | */ | 115 | */ |
116 | 116 | ||
@@ -197,7 +197,8 @@ CRYPTO_get_new_lockid(char *name) | |||
197 | char *str; | 197 | char *str; |
198 | int i; | 198 | int i; |
199 | 199 | ||
200 | if ((app_locks == NULL) && ((app_locks = sk_OPENSSL_STRING_new_null()) == NULL)) { | 200 | if ((app_locks == NULL) && |
201 | ((app_locks = sk_OPENSSL_STRING_new_null()) == NULL)) { | ||
201 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); | 202 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); |
202 | return (0); | 203 | return (0); |
203 | } | 204 | } |
@@ -226,28 +227,32 @@ CRYPTO_get_new_dynlockid(void) | |||
226 | CRYPTO_dynlock *pointer = NULL; | 227 | CRYPTO_dynlock *pointer = NULL; |
227 | 228 | ||
228 | if (dynlock_create_callback == NULL) { | 229 | if (dynlock_create_callback == NULL) { |
229 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK); | 230 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
231 | CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK); | ||
230 | return (0); | 232 | return (0); |
231 | } | 233 | } |
232 | CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); | 234 | CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); |
233 | if ((dyn_locks == NULL) | 235 | if ((dyn_locks == NULL) && |
234 | && ((dyn_locks = sk_CRYPTO_dynlock_new_null()) == NULL)) { | 236 | ((dyn_locks = sk_CRYPTO_dynlock_new_null()) == NULL)) { |
235 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); | 237 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); |
236 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); | 238 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
239 | ERR_R_MALLOC_FAILURE); | ||
237 | return (0); | 240 | return (0); |
238 | } | 241 | } |
239 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); | 242 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); |
240 | 243 | ||
241 | pointer = (CRYPTO_dynlock *)malloc(sizeof(CRYPTO_dynlock)); | 244 | pointer = (CRYPTO_dynlock *)malloc(sizeof(CRYPTO_dynlock)); |
242 | if (pointer == NULL) { | 245 | if (pointer == NULL) { |
243 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); | 246 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
247 | ERR_R_MALLOC_FAILURE); | ||
244 | return (0); | 248 | return (0); |
245 | } | 249 | } |
246 | pointer->references = 1; | 250 | pointer->references = 1; |
247 | pointer->data = dynlock_create_callback(__FILE__, __LINE__); | 251 | pointer->data = dynlock_create_callback(__FILE__, __LINE__); |
248 | if (pointer->data == NULL) { | 252 | if (pointer->data == NULL) { |
249 | free(pointer); | 253 | free(pointer); |
250 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); | 254 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
255 | ERR_R_MALLOC_FAILURE); | ||
251 | return (0); | 256 | return (0); |
252 | } | 257 | } |
253 | 258 | ||
@@ -272,13 +277,14 @@ CRYPTO_get_new_dynlockid(void) | |||
272 | free(pointer); | 277 | free(pointer); |
273 | } else | 278 | } else |
274 | i += 1; /* to avoid 0 */ | 279 | i += 1; /* to avoid 0 */ |
275 | return - i; | 280 | return -i; |
276 | } | 281 | } |
277 | 282 | ||
278 | void | 283 | void |
279 | CRYPTO_destroy_dynlockid(int i) | 284 | CRYPTO_destroy_dynlockid(int i) |
280 | { | 285 | { |
281 | CRYPTO_dynlock *pointer = NULL; | 286 | CRYPTO_dynlock *pointer = NULL; |
287 | |||
282 | if (i) | 288 | if (i) |
283 | i = -i - 1; | 289 | i = -i - 1; |
284 | if (dynlock_destroy_callback == NULL) | 290 | if (dynlock_destroy_callback == NULL) |
@@ -310,6 +316,7 @@ struct CRYPTO_dynlock_value * | |||
310 | CRYPTO_get_dynlock_value(int i) | 316 | CRYPTO_get_dynlock_value(int i) |
311 | { | 317 | { |
312 | CRYPTO_dynlock *pointer = NULL; | 318 | CRYPTO_dynlock *pointer = NULL; |
319 | |||
313 | if (i) | 320 | if (i) |
314 | i = -i - 1; | 321 | i = -i - 1; |
315 | 322 | ||
@@ -328,20 +335,21 @@ CRYPTO_get_dynlock_value(int i) | |||
328 | } | 335 | } |
329 | 336 | ||
330 | struct CRYPTO_dynlock_value * | 337 | struct CRYPTO_dynlock_value * |
331 | (*CRYPTO_get_dynlock_create_callback(void))( | 338 | (*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line) |
332 | const char *file, int line) | ||
333 | { | 339 | { |
334 | return (dynlock_create_callback); | 340 | return (dynlock_create_callback); |
335 | } | 341 | } |
336 | 342 | ||
337 | void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, | 343 | void |
344 | (*CRYPTO_get_dynlock_lock_callback(void))(int mode, | ||
338 | struct CRYPTO_dynlock_value *l, const char *file, int line) | 345 | struct CRYPTO_dynlock_value *l, const char *file, int line) |
339 | { | 346 | { |
340 | return (dynlock_lock_callback); | 347 | return (dynlock_lock_callback); |
341 | } | 348 | } |
342 | 349 | ||
343 | void (*CRYPTO_get_dynlock_destroy_callback(void))( | 350 | void |
344 | struct CRYPTO_dynlock_value *l, const char *file, int line) | 351 | (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, |
352 | const char *file, int line) | ||
345 | { | 353 | { |
346 | return (dynlock_destroy_callback); | 354 | return (dynlock_destroy_callback); |
347 | } | 355 | } |
@@ -367,13 +375,15 @@ CRYPTO_set_dynlock_destroy_callback( | |||
367 | dynlock_destroy_callback = func; | 375 | dynlock_destroy_callback = func; |
368 | } | 376 | } |
369 | 377 | ||
370 | void (*CRYPTO_get_locking_callback(void))(int mode, int type, | 378 | void |
371 | const char *file, int line) | 379 | (*CRYPTO_get_locking_callback(void))(int mode, int type, const char *file, |
380 | int line) | ||
372 | { | 381 | { |
373 | return (locking_callback); | 382 | return (locking_callback); |
374 | } | 383 | } |
375 | 384 | ||
376 | int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type, | 385 | int |
386 | (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type, | ||
377 | const char *file, int line) | 387 | const char *file, int line) |
378 | { | 388 | { |
379 | return (add_lock_callback); | 389 | return (add_lock_callback); |
@@ -527,23 +537,23 @@ CRYPTO_lock(int mode, int type, const char *file, int line) | |||
527 | char *rw_text, *operation_text; | 537 | char *rw_text, *operation_text; |
528 | 538 | ||
529 | if (mode & CRYPTO_LOCK) | 539 | if (mode & CRYPTO_LOCK) |
530 | operation_text="lock "; | 540 | operation_text = "lock "; |
531 | else if (mode & CRYPTO_UNLOCK) | 541 | else if (mode & CRYPTO_UNLOCK) |
532 | operation_text="unlock"; | 542 | operation_text = "unlock"; |
533 | else | 543 | else |
534 | operation_text="ERROR "; | 544 | operation_text = "ERROR "; |
535 | 545 | ||
536 | if (mode & CRYPTO_READ) | 546 | if (mode & CRYPTO_READ) |
537 | rw_text="r"; | 547 | rw_text = "r"; |
538 | else if (mode & CRYPTO_WRITE) | 548 | else if (mode & CRYPTO_WRITE) |
539 | rw_text="w"; | 549 | rw_text = "w"; |
540 | else | 550 | else |
541 | rw_text="ERROR"; | 551 | rw_text = "ERROR"; |
542 | 552 | ||
543 | CRYPTO_THREADID_current(&id); | 553 | CRYPTO_THREADID_current(&id); |
544 | fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\n", | 554 | fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\n", |
545 | CRYPTO_THREADID_hash(&id), rw_text, operation_text, | 555 | CRYPTO_THREADID_hash(&id), rw_text, operation_text, |
546 | CRYPTO_get_lock_name(type), file, line); | 556 | CRYPTO_get_lock_name(type), file, line); |
547 | } | 557 | } |
548 | #endif | 558 | #endif |
549 | if (type < 0) { | 559 | if (type < 0) { |
@@ -578,9 +588,9 @@ CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, | |||
578 | CRYPTO_THREADID id; | 588 | CRYPTO_THREADID id; |
579 | CRYPTO_THREADID_current(&id); | 589 | CRYPTO_THREADID_current(&id); |
580 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", | 590 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", |
581 | CRYPTO_THREADID_hash(&id), before, amount, ret, | 591 | CRYPTO_THREADID_hash(&id), before, amount, ret, |
582 | CRYPTO_get_lock_name(type), | 592 | CRYPTO_get_lock_name(type), |
583 | file, line); | 593 | file, line); |
584 | } | 594 | } |
585 | #endif | 595 | #endif |
586 | } else { | 596 | } else { |
@@ -592,10 +602,8 @@ CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, | |||
592 | CRYPTO_THREADID id; | 602 | CRYPTO_THREADID id; |
593 | CRYPTO_THREADID_current(&id); | 603 | CRYPTO_THREADID_current(&id); |
594 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", | 604 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", |
595 | CRYPTO_THREADID_hash(&id), | 605 | CRYPTO_THREADID_hash(&id), *pointer, amount, ret, |
596 | *pointer, amount, ret, | 606 | CRYPTO_get_lock_name(type), file, line); |
597 | CRYPTO_get_lock_name(type), | ||
598 | file, line); | ||
599 | } | 607 | } |
600 | #endif | 608 | #endif |
601 | *pointer = ret; | 609 | *pointer = ret; |
@@ -614,7 +622,8 @@ CRYPTO_get_lock_name(int type) | |||
614 | else if (type - CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks)) | 622 | else if (type - CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks)) |
615 | return("ERROR"); | 623 | return("ERROR"); |
616 | else | 624 | else |
617 | return (sk_OPENSSL_STRING_value(app_locks, type - CRYPTO_NUM_LOCKS)); | 625 | return (sk_OPENSSL_STRING_value(app_locks, |
626 | type - CRYPTO_NUM_LOCKS)); | ||
618 | } | 627 | } |
619 | 628 | ||
620 | #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ | 629 | #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ |
@@ -651,26 +660,29 @@ OPENSSL_cpuid_setup(void) | |||
651 | 660 | ||
652 | trigger = 1; | 661 | trigger = 1; |
653 | if ((env = getenv("OPENSSL_ia32cap"))) { | 662 | if ((env = getenv("OPENSSL_ia32cap"))) { |
654 | int off = (env[0]=='~') ? 1 : 0; | 663 | int off = (env[0] == '~') ? 1 : 0; |
655 | if (!sscanf(env+off, "%lli",(long long *)&vec)) | 664 | if (!sscanf(env+off, "%lli",(long long *)&vec)) |
656 | vec = strtoul(env+off, NULL, 0); | 665 | vec = strtoul(env + off, NULL, 0); |
657 | if (off) | 666 | if (off) |
658 | vec = OPENSSL_ia32_cpuid()&~vec; | 667 | vec = OPENSSL_ia32_cpuid() & ~vec; |
659 | } else | 668 | } else |
660 | vec = OPENSSL_ia32_cpuid(); | 669 | vec = OPENSSL_ia32_cpuid(); |
661 | 670 | ||
662 | /* | 671 | /* |
663 | * |(1<<10) sets a reserved bit to signal that variable | 672 | * |(1<<10) sets a reserved bit to signal that variable |
664 | * was initialized already... This is to avoid interference | 673 | * was initialized already... This is to avoid interference |
665 | * with cpuid snippets in ELF .init segment. | 674 | * with cpuid snippets in ELF .init segment. |
666 | */ | 675 | */ |
667 | OPENSSL_ia32cap_P[0] = (unsigned int)vec|(1 << 10); | 676 | OPENSSL_ia32cap_P[0] = (unsigned int)vec | (1 << 10); |
668 | OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32); | 677 | OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32); |
669 | } | 678 | } |
670 | #endif | 679 | #endif |
671 | 680 | ||
672 | #else | 681 | #else |
673 | unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; | 682 | unsigned long * |
683 | OPENSSL_ia32cap_loc(void) | ||
684 | { | ||
685 | return NULL; | ||
674 | } | 686 | } |
675 | #endif | 687 | #endif |
676 | int OPENSSL_NONPIC_relocated = 0; | 688 | int OPENSSL_NONPIC_relocated = 0; |
diff --git a/src/lib/libssl/src/crypto/cryptlib.c b/src/lib/libssl/src/crypto/cryptlib.c index 1024dec09e..addc27eb08 100644 --- a/src/lib/libssl/src/crypto/cryptlib.c +++ b/src/lib/libssl/src/crypto/cryptlib.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * are met: | 7 | * are met: |
8 | * | 8 | * |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * | 11 | * |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in | 13 | * notice, this list of conditions and the following disclaimer in |
@@ -58,21 +58,21 @@ | |||
58 | * This package is an SSL implementation written | 58 | * This package is an SSL implementation written |
59 | * by Eric Young (eay@cryptsoft.com). | 59 | * by Eric Young (eay@cryptsoft.com). |
60 | * The implementation was written so as to conform with Netscapes SSL. | 60 | * The implementation was written so as to conform with Netscapes SSL. |
61 | * | 61 | * |
62 | * This library is free for commercial and non-commercial use as long as | 62 | * This library is free for commercial and non-commercial use as long as |
63 | * the following conditions are aheared to. The following conditions | 63 | * the following conditions are aheared to. The following conditions |
64 | * apply to all code found in this distribution, be it the RC4, RSA, | 64 | * apply to all code found in this distribution, be it the RC4, RSA, |
65 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | 65 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation |
66 | * included with this distribution is covered by the same copyright terms | 66 | * included with this distribution is covered by the same copyright terms |
67 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 67 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
68 | * | 68 | * |
69 | * Copyright remains Eric Young's, and as such any Copyright notices in | 69 | * Copyright remains Eric Young's, and as such any Copyright notices in |
70 | * the code are not to be removed. | 70 | * the code are not to be removed. |
71 | * If this package is used in a product, Eric Young should be given attribution | 71 | * If this package is used in a product, Eric Young should be given attribution |
72 | * as the author of the parts of the library used. | 72 | * as the author of the parts of the library used. |
73 | * This can be in the form of a textual message at program startup or | 73 | * This can be in the form of a textual message at program startup or |
74 | * in documentation (online or textual) provided with the package. | 74 | * in documentation (online or textual) provided with the package. |
75 | * | 75 | * |
76 | * Redistribution and use in source and binary forms, with or without | 76 | * Redistribution and use in source and binary forms, with or without |
77 | * modification, are permitted provided that the following conditions | 77 | * modification, are permitted provided that the following conditions |
78 | * are met: | 78 | * are met: |
@@ -87,10 +87,10 @@ | |||
87 | * Eric Young (eay@cryptsoft.com)" | 87 | * Eric Young (eay@cryptsoft.com)" |
88 | * The word 'cryptographic' can be left out if the rouines from the library | 88 | * The word 'cryptographic' can be left out if the rouines from the library |
89 | * being used are not cryptographic related :-). | 89 | * being used are not cryptographic related :-). |
90 | * 4. If you include any Windows specific code (or a derivative thereof) from | 90 | * 4. If you include any Windows specific code (or a derivative thereof) from |
91 | * the apps directory (application code) you must include an acknowledgement: | 91 | * the apps directory (application code) you must include an acknowledgement: |
92 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 92 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
93 | * | 93 | * |
94 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 94 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
95 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 95 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
96 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 96 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
@@ -102,7 +102,7 @@ | |||
102 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 102 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
103 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 103 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
104 | * SUCH DAMAGE. | 104 | * SUCH DAMAGE. |
105 | * | 105 | * |
106 | * The licence and distribution terms for any publically available version or | 106 | * The licence and distribution terms for any publically available version or |
107 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 107 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
108 | * copied and put under another distribution licence | 108 | * copied and put under another distribution licence |
@@ -110,7 +110,7 @@ | |||
110 | */ | 110 | */ |
111 | /* ==================================================================== | 111 | /* ==================================================================== |
112 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 112 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
113 | * ECDH support in OpenSSL originally developed by | 113 | * ECDH support in OpenSSL originally developed by |
114 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | 114 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. |
115 | */ | 115 | */ |
116 | 116 | ||
@@ -197,7 +197,8 @@ CRYPTO_get_new_lockid(char *name) | |||
197 | char *str; | 197 | char *str; |
198 | int i; | 198 | int i; |
199 | 199 | ||
200 | if ((app_locks == NULL) && ((app_locks = sk_OPENSSL_STRING_new_null()) == NULL)) { | 200 | if ((app_locks == NULL) && |
201 | ((app_locks = sk_OPENSSL_STRING_new_null()) == NULL)) { | ||
201 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); | 202 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE); |
202 | return (0); | 203 | return (0); |
203 | } | 204 | } |
@@ -226,28 +227,32 @@ CRYPTO_get_new_dynlockid(void) | |||
226 | CRYPTO_dynlock *pointer = NULL; | 227 | CRYPTO_dynlock *pointer = NULL; |
227 | 228 | ||
228 | if (dynlock_create_callback == NULL) { | 229 | if (dynlock_create_callback == NULL) { |
229 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK); | 230 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
231 | CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK); | ||
230 | return (0); | 232 | return (0); |
231 | } | 233 | } |
232 | CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); | 234 | CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); |
233 | if ((dyn_locks == NULL) | 235 | if ((dyn_locks == NULL) && |
234 | && ((dyn_locks = sk_CRYPTO_dynlock_new_null()) == NULL)) { | 236 | ((dyn_locks = sk_CRYPTO_dynlock_new_null()) == NULL)) { |
235 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); | 237 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); |
236 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); | 238 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
239 | ERR_R_MALLOC_FAILURE); | ||
237 | return (0); | 240 | return (0); |
238 | } | 241 | } |
239 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); | 242 | CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); |
240 | 243 | ||
241 | pointer = (CRYPTO_dynlock *)malloc(sizeof(CRYPTO_dynlock)); | 244 | pointer = (CRYPTO_dynlock *)malloc(sizeof(CRYPTO_dynlock)); |
242 | if (pointer == NULL) { | 245 | if (pointer == NULL) { |
243 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); | 246 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
247 | ERR_R_MALLOC_FAILURE); | ||
244 | return (0); | 248 | return (0); |
245 | } | 249 | } |
246 | pointer->references = 1; | 250 | pointer->references = 1; |
247 | pointer->data = dynlock_create_callback(__FILE__, __LINE__); | 251 | pointer->data = dynlock_create_callback(__FILE__, __LINE__); |
248 | if (pointer->data == NULL) { | 252 | if (pointer->data == NULL) { |
249 | free(pointer); | 253 | free(pointer); |
250 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, ERR_R_MALLOC_FAILURE); | 254 | CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID, |
255 | ERR_R_MALLOC_FAILURE); | ||
251 | return (0); | 256 | return (0); |
252 | } | 257 | } |
253 | 258 | ||
@@ -272,13 +277,14 @@ CRYPTO_get_new_dynlockid(void) | |||
272 | free(pointer); | 277 | free(pointer); |
273 | } else | 278 | } else |
274 | i += 1; /* to avoid 0 */ | 279 | i += 1; /* to avoid 0 */ |
275 | return - i; | 280 | return -i; |
276 | } | 281 | } |
277 | 282 | ||
278 | void | 283 | void |
279 | CRYPTO_destroy_dynlockid(int i) | 284 | CRYPTO_destroy_dynlockid(int i) |
280 | { | 285 | { |
281 | CRYPTO_dynlock *pointer = NULL; | 286 | CRYPTO_dynlock *pointer = NULL; |
287 | |||
282 | if (i) | 288 | if (i) |
283 | i = -i - 1; | 289 | i = -i - 1; |
284 | if (dynlock_destroy_callback == NULL) | 290 | if (dynlock_destroy_callback == NULL) |
@@ -310,6 +316,7 @@ struct CRYPTO_dynlock_value * | |||
310 | CRYPTO_get_dynlock_value(int i) | 316 | CRYPTO_get_dynlock_value(int i) |
311 | { | 317 | { |
312 | CRYPTO_dynlock *pointer = NULL; | 318 | CRYPTO_dynlock *pointer = NULL; |
319 | |||
313 | if (i) | 320 | if (i) |
314 | i = -i - 1; | 321 | i = -i - 1; |
315 | 322 | ||
@@ -328,20 +335,21 @@ CRYPTO_get_dynlock_value(int i) | |||
328 | } | 335 | } |
329 | 336 | ||
330 | struct CRYPTO_dynlock_value * | 337 | struct CRYPTO_dynlock_value * |
331 | (*CRYPTO_get_dynlock_create_callback(void))( | 338 | (*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line) |
332 | const char *file, int line) | ||
333 | { | 339 | { |
334 | return (dynlock_create_callback); | 340 | return (dynlock_create_callback); |
335 | } | 341 | } |
336 | 342 | ||
337 | void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, | 343 | void |
344 | (*CRYPTO_get_dynlock_lock_callback(void))(int mode, | ||
338 | struct CRYPTO_dynlock_value *l, const char *file, int line) | 345 | struct CRYPTO_dynlock_value *l, const char *file, int line) |
339 | { | 346 | { |
340 | return (dynlock_lock_callback); | 347 | return (dynlock_lock_callback); |
341 | } | 348 | } |
342 | 349 | ||
343 | void (*CRYPTO_get_dynlock_destroy_callback(void))( | 350 | void |
344 | struct CRYPTO_dynlock_value *l, const char *file, int line) | 351 | (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, |
352 | const char *file, int line) | ||
345 | { | 353 | { |
346 | return (dynlock_destroy_callback); | 354 | return (dynlock_destroy_callback); |
347 | } | 355 | } |
@@ -367,13 +375,15 @@ CRYPTO_set_dynlock_destroy_callback( | |||
367 | dynlock_destroy_callback = func; | 375 | dynlock_destroy_callback = func; |
368 | } | 376 | } |
369 | 377 | ||
370 | void (*CRYPTO_get_locking_callback(void))(int mode, int type, | 378 | void |
371 | const char *file, int line) | 379 | (*CRYPTO_get_locking_callback(void))(int mode, int type, const char *file, |
380 | int line) | ||
372 | { | 381 | { |
373 | return (locking_callback); | 382 | return (locking_callback); |
374 | } | 383 | } |
375 | 384 | ||
376 | int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type, | 385 | int |
386 | (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type, | ||
377 | const char *file, int line) | 387 | const char *file, int line) |
378 | { | 388 | { |
379 | return (add_lock_callback); | 389 | return (add_lock_callback); |
@@ -527,23 +537,23 @@ CRYPTO_lock(int mode, int type, const char *file, int line) | |||
527 | char *rw_text, *operation_text; | 537 | char *rw_text, *operation_text; |
528 | 538 | ||
529 | if (mode & CRYPTO_LOCK) | 539 | if (mode & CRYPTO_LOCK) |
530 | operation_text="lock "; | 540 | operation_text = "lock "; |
531 | else if (mode & CRYPTO_UNLOCK) | 541 | else if (mode & CRYPTO_UNLOCK) |
532 | operation_text="unlock"; | 542 | operation_text = "unlock"; |
533 | else | 543 | else |
534 | operation_text="ERROR "; | 544 | operation_text = "ERROR "; |
535 | 545 | ||
536 | if (mode & CRYPTO_READ) | 546 | if (mode & CRYPTO_READ) |
537 | rw_text="r"; | 547 | rw_text = "r"; |
538 | else if (mode & CRYPTO_WRITE) | 548 | else if (mode & CRYPTO_WRITE) |
539 | rw_text="w"; | 549 | rw_text = "w"; |
540 | else | 550 | else |
541 | rw_text="ERROR"; | 551 | rw_text = "ERROR"; |
542 | 552 | ||
543 | CRYPTO_THREADID_current(&id); | 553 | CRYPTO_THREADID_current(&id); |
544 | fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\n", | 554 | fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\n", |
545 | CRYPTO_THREADID_hash(&id), rw_text, operation_text, | 555 | CRYPTO_THREADID_hash(&id), rw_text, operation_text, |
546 | CRYPTO_get_lock_name(type), file, line); | 556 | CRYPTO_get_lock_name(type), file, line); |
547 | } | 557 | } |
548 | #endif | 558 | #endif |
549 | if (type < 0) { | 559 | if (type < 0) { |
@@ -578,9 +588,9 @@ CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, | |||
578 | CRYPTO_THREADID id; | 588 | CRYPTO_THREADID id; |
579 | CRYPTO_THREADID_current(&id); | 589 | CRYPTO_THREADID_current(&id); |
580 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", | 590 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", |
581 | CRYPTO_THREADID_hash(&id), before, amount, ret, | 591 | CRYPTO_THREADID_hash(&id), before, amount, ret, |
582 | CRYPTO_get_lock_name(type), | 592 | CRYPTO_get_lock_name(type), |
583 | file, line); | 593 | file, line); |
584 | } | 594 | } |
585 | #endif | 595 | #endif |
586 | } else { | 596 | } else { |
@@ -592,10 +602,8 @@ CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, | |||
592 | CRYPTO_THREADID id; | 602 | CRYPTO_THREADID id; |
593 | CRYPTO_THREADID_current(&id); | 603 | CRYPTO_THREADID_current(&id); |
594 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", | 604 | fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", |
595 | CRYPTO_THREADID_hash(&id), | 605 | CRYPTO_THREADID_hash(&id), *pointer, amount, ret, |
596 | *pointer, amount, ret, | 606 | CRYPTO_get_lock_name(type), file, line); |
597 | CRYPTO_get_lock_name(type), | ||
598 | file, line); | ||
599 | } | 607 | } |
600 | #endif | 608 | #endif |
601 | *pointer = ret; | 609 | *pointer = ret; |
@@ -614,7 +622,8 @@ CRYPTO_get_lock_name(int type) | |||
614 | else if (type - CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks)) | 622 | else if (type - CRYPTO_NUM_LOCKS > sk_OPENSSL_STRING_num(app_locks)) |
615 | return("ERROR"); | 623 | return("ERROR"); |
616 | else | 624 | else |
617 | return (sk_OPENSSL_STRING_value(app_locks, type - CRYPTO_NUM_LOCKS)); | 625 | return (sk_OPENSSL_STRING_value(app_locks, |
626 | type - CRYPTO_NUM_LOCKS)); | ||
618 | } | 627 | } |
619 | 628 | ||
620 | #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ | 629 | #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ |
@@ -651,26 +660,29 @@ OPENSSL_cpuid_setup(void) | |||
651 | 660 | ||
652 | trigger = 1; | 661 | trigger = 1; |
653 | if ((env = getenv("OPENSSL_ia32cap"))) { | 662 | if ((env = getenv("OPENSSL_ia32cap"))) { |
654 | int off = (env[0]=='~') ? 1 : 0; | 663 | int off = (env[0] == '~') ? 1 : 0; |
655 | if (!sscanf(env+off, "%lli",(long long *)&vec)) | 664 | if (!sscanf(env+off, "%lli",(long long *)&vec)) |
656 | vec = strtoul(env+off, NULL, 0); | 665 | vec = strtoul(env + off, NULL, 0); |
657 | if (off) | 666 | if (off) |
658 | vec = OPENSSL_ia32_cpuid()&~vec; | 667 | vec = OPENSSL_ia32_cpuid() & ~vec; |
659 | } else | 668 | } else |
660 | vec = OPENSSL_ia32_cpuid(); | 669 | vec = OPENSSL_ia32_cpuid(); |
661 | 670 | ||
662 | /* | 671 | /* |
663 | * |(1<<10) sets a reserved bit to signal that variable | 672 | * |(1<<10) sets a reserved bit to signal that variable |
664 | * was initialized already... This is to avoid interference | 673 | * was initialized already... This is to avoid interference |
665 | * with cpuid snippets in ELF .init segment. | 674 | * with cpuid snippets in ELF .init segment. |
666 | */ | 675 | */ |
667 | OPENSSL_ia32cap_P[0] = (unsigned int)vec|(1 << 10); | 676 | OPENSSL_ia32cap_P[0] = (unsigned int)vec | (1 << 10); |
668 | OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32); | 677 | OPENSSL_ia32cap_P[1] = (unsigned int)(vec >> 32); |
669 | } | 678 | } |
670 | #endif | 679 | #endif |
671 | 680 | ||
672 | #else | 681 | #else |
673 | unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; | 682 | unsigned long * |
683 | OPENSSL_ia32cap_loc(void) | ||
684 | { | ||
685 | return NULL; | ||
674 | } | 686 | } |
675 | #endif | 687 | #endif |
676 | int OPENSSL_NONPIC_relocated = 0; | 688 | int OPENSSL_NONPIC_relocated = 0; |