| 
									
										
										
										
											2016-05-18 02:52:22 +08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-06-17 20:24:59 +08:00
										 |  |  |  * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-12-06 20:20:10 +08:00
										 |  |  |  * Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							| 
									
										
										
										
											2016-05-18 02:52:22 +08:00
										 |  |  |  * this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  |  * in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  |  * https://www.openssl.org/source/license.html
 | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | #include <errno.h>
 | 
					
						
							| 
									
										
										
										
											2019-09-28 06:45:40 +08:00
										 |  |  | #include "bio_local.h"
 | 
					
						
							| 
									
										
										
										
											2015-05-14 22:56:48 +08:00
										 |  |  | #include "internal/cryptlib.h"
 | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-05-16 06:54:43 +08:00
										 |  |  | static int null_write(BIO *h, const char *buf, int num); | 
					
						
							|  |  |  | static int null_read(BIO *h, char *buf, int size); | 
					
						
							|  |  |  | static int null_puts(BIO *h, const char *str); | 
					
						
							|  |  |  | static int null_gets(BIO *h, char *str, int size); | 
					
						
							|  |  |  | static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2); | 
					
						
							| 
									
										
										
										
											2016-03-20 00:32:14 +08:00
										 |  |  | static const BIO_METHOD null_method = { | 
					
						
							| 
									
										
										
										
											1998-12-21 18:56:39 +08:00
										 |  |  |     BIO_TYPE_NULL, | 
					
						
							|  |  |  |     "NULL", | 
					
						
							| 
									
										
										
										
											2016-10-20 22:18:39 +08:00
										 |  |  |     bwrite_conv, | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  |     null_write, | 
					
						
							| 
									
										
										
										
											2016-09-06 00:26:58 +08:00
										 |  |  |     bread_conv, | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  |     null_read, | 
					
						
							|  |  |  |     null_puts, | 
					
						
							|  |  |  |     null_gets, | 
					
						
							|  |  |  |     null_ctrl, | 
					
						
							| 
									
										
										
										
											2018-01-31 22:24:24 +08:00
										 |  |  |     NULL, | 
					
						
							|  |  |  |     NULL, | 
					
						
							| 
									
										
										
										
											2017-12-18 05:04:48 +08:00
										 |  |  |     NULL,                     /* null_callback_ctrl */ | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-20 00:32:14 +08:00
										 |  |  | const BIO_METHOD *BIO_s_null(void) | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return &null_method; | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-04-20 05:31:43 +08:00
										 |  |  | static int null_read(BIO *b, char *out, int outl) | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-05-16 06:54:43 +08:00
										 |  |  | static int null_write(BIO *b, const char *in, int inl) | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return inl; | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-05-16 06:54:43 +08:00
										 |  |  | static long null_ctrl(BIO *b, int cmd, long num, void *ptr) | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     long ret = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     switch (cmd) { | 
					
						
							|  |  |  |     case BIO_CTRL_RESET: | 
					
						
							|  |  |  |     case BIO_CTRL_EOF: | 
					
						
							|  |  |  |     case BIO_CTRL_SET: | 
					
						
							|  |  |  |     case BIO_CTRL_SET_CLOSE: | 
					
						
							|  |  |  |     case BIO_CTRL_FLUSH: | 
					
						
							|  |  |  |     case BIO_CTRL_DUP: | 
					
						
							|  |  |  |         ret = 1; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case BIO_CTRL_GET_CLOSE: | 
					
						
							|  |  |  |     case BIO_CTRL_INFO: | 
					
						
							|  |  |  |     case BIO_CTRL_GET: | 
					
						
							|  |  |  |     case BIO_CTRL_PENDING: | 
					
						
							|  |  |  |     case BIO_CTRL_WPENDING: | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         ret = 0; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return ret; | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1999-04-20 05:31:43 +08:00
										 |  |  | static int null_gets(BIO *bp, char *buf, int size) | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |     return 0; | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-05-16 06:54:43 +08:00
										 |  |  | static int null_puts(BIO *bp, const char *str) | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | { | 
					
						
							|  |  |  |     if (str == NULL) | 
					
						
							| 
									
										
										
										
											2017-10-17 22:04:09 +08:00
										 |  |  |         return 0; | 
					
						
							|  |  |  |     return strlen(str); | 
					
						
							| 
									
										
										
										
											1998-12-21 18:52:47 +08:00
										 |  |  | } |