diff options
author | jsing <> | 2018-02-20 17:15:27 +0000 |
---|---|---|
committer | jsing <> | 2018-02-20 17:15:27 +0000 |
commit | 4f1ee631944961365c3b2ee139bc108c1ceff2ed (patch) | |
tree | aaa79b91c7a94144ce88e4371f39e925adcc904d /src | |
parent | 2f0d52b8a3e3ce63552d3125a01f70077b6e6b1a (diff) | |
download | openbsd-4f1ee631944961365c3b2ee139bc108c1ceff2ed.tar.gz openbsd-4f1ee631944961365c3b2ee139bc108c1ceff2ed.tar.bz2 openbsd-4f1ee631944961365c3b2ee139bc108c1ceff2ed.zip |
Provide BIO_get_new_index().
Based on BoringSSL.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 1 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bio.h | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 16 |
3 files changed, 24 insertions, 2 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 23030bdb15..2252220278 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -280,6 +280,7 @@ BIO_get_data | |||
280 | BIO_get_ex_data | 280 | BIO_get_ex_data |
281 | BIO_get_ex_new_index | 281 | BIO_get_ex_new_index |
282 | BIO_get_host_ip | 282 | BIO_get_host_ip |
283 | BIO_get_new_index | ||
283 | BIO_get_port | 284 | BIO_get_port |
284 | BIO_get_retry_BIO | 285 | BIO_get_retry_BIO |
285 | BIO_get_retry_reason | 286 | BIO_get_retry_reason |
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index 8efeba2005..1d34f082ee 100644 --- a/src/lib/libcrypto/bio/bio.h +++ b/src/lib/libcrypto/bio/bio.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bio.h,v 1.33 2018/02/18 12:59:06 tb Exp $ */ | 1 | /* $OpenBSD: bio.h,v 1.34 2018/02/20 17:15:27 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -103,6 +103,12 @@ extern "C" { | |||
103 | #define BIO_TYPE_FILTER 0x0200 | 103 | #define BIO_TYPE_FILTER 0x0200 |
104 | #define BIO_TYPE_SOURCE_SINK 0x0400 | 104 | #define BIO_TYPE_SOURCE_SINK 0x0400 |
105 | 105 | ||
106 | /* | ||
107 | * BIO_TYPE_START is the first user-allocated BIO type. No pre-defined type, | ||
108 | * flag bits aside, may exceed this value. | ||
109 | */ | ||
110 | #define BIO_TYPE_START 128 | ||
111 | |||
106 | /* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. | 112 | /* BIO_FILENAME_READ|BIO_CLOSE to open or close on free. |
107 | * BIO_set_fp(in,stdin,BIO_NOCLOSE); */ | 113 | * BIO_set_fp(in,stdin,BIO_NOCLOSE); */ |
108 | #define BIO_NOCLOSE 0x00 | 114 | #define BIO_NOCLOSE 0x00 |
@@ -580,6 +586,7 @@ int | |||
580 | BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, | 586 | BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, |
581 | asn1_ps_func **psuffix_free); | 587 | asn1_ps_func **psuffix_free); |
582 | 588 | ||
589 | int BIO_get_new_index(void); | ||
583 | BIO_METHOD *BIO_s_file(void ); | 590 | BIO_METHOD *BIO_s_file(void ); |
584 | BIO *BIO_new_file(const char *filename, const char *mode); | 591 | BIO *BIO_new_file(const char *filename, const char *mode); |
585 | BIO *BIO_new_fp(FILE *stream, int close_flag); | 592 | BIO *BIO_new_fp(FILE *stream, int close_flag); |
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index 4e5405d6af..b2acd01342 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bio_lib.c,v 1.24 2018/02/18 12:58:25 tb Exp $ */ | 1 | /* $OpenBSD: bio_lib.c,v 1.25 2018/02/20 17:15:27 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -64,6 +64,20 @@ | |||
64 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
65 | #include <openssl/stack.h> | 65 | #include <openssl/stack.h> |
66 | 66 | ||
67 | int | ||
68 | BIO_get_new_index(void) | ||
69 | { | ||
70 | static int bio_type_index = BIO_TYPE_START; | ||
71 | int index; | ||
72 | |||
73 | /* The index will collide with the BIO flag bits if it exceeds 255. */ | ||
74 | index = CRYPTO_add(&bio_type_index, 1, CRYPTO_LOCK_BIO); | ||
75 | if (index > 255) | ||
76 | return -1; | ||
77 | |||
78 | return index; | ||
79 | } | ||
80 | |||
67 | BIO * | 81 | BIO * |
68 | BIO_new(BIO_METHOD *method) | 82 | BIO_new(BIO_METHOD *method) |
69 | { | 83 | { |