2016-05-17 18:52:22 +00:00
|
|
|
/*
|
2018-02-13 12:51:29 +00:00
|
|
|
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 10:52:47 +00:00
|
|
|
*
|
2016-05-17 18:52:22 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* 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 10:52:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2019-09-27 21:58:06 +00:00
|
|
|
#include "bio_local.h"
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/cryptlib.h"
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2000-05-15 22:54:43 +00: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-19 16:32:14 +00:00
|
|
|
static const BIO_METHOD null_method = {
|
2015-01-22 03:40:55 +00:00
|
|
|
BIO_TYPE_NULL,
|
|
|
|
"NULL",
|
2016-10-20 14:18:39 +00:00
|
|
|
/* TODO: Convert to new style write function */
|
|
|
|
bwrite_conv,
|
2015-01-22 03:40:55 +00:00
|
|
|
null_write,
|
2016-09-05 16:26:58 +00:00
|
|
|
/* TODO: Convert to new style read function */
|
|
|
|
bread_conv,
|
2015-01-22 03:40:55 +00:00
|
|
|
null_read,
|
|
|
|
null_puts,
|
|
|
|
null_gets,
|
|
|
|
null_ctrl,
|
2018-01-31 14:24:24 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2017-12-17 21:04:48 +00:00
|
|
|
NULL, /* null_callback_ctrl */
|
2015-01-22 03:40:55 +00:00
|
|
|
};
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2016-03-19 16:32:14 +00:00
|
|
|
const BIO_METHOD *BIO_s_null(void)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
2017-10-17 14:04:09 +00:00
|
|
|
return &null_method;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
static int null_read(BIO *b, char *out, int outl)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
2017-10-17 14:04:09 +00:00
|
|
|
return 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2000-05-15 22:54:43 +00:00
|
|
|
static int null_write(BIO *b, const char *in, int inl)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
2017-10-17 14:04:09 +00:00
|
|
|
return inl;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2000-05-15 22:54:43 +00:00
|
|
|
static long null_ctrl(BIO *b, int cmd, long num, void *ptr)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
long ret = 1;
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
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 14:04:09 +00:00
|
|
|
return ret;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
static int null_gets(BIO *bp, char *buf, int size)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
2017-10-17 14:04:09 +00:00
|
|
|
return 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2000-05-15 22:54:43 +00:00
|
|
|
static int null_puts(BIO *bp, const char *str)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
if (str == NULL)
|
2017-10-17 14:04:09 +00:00
|
|
|
return 0;
|
|
|
|
return strlen(str);
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|