本文整理汇总了C++中BIO_copy_next_retry函数的典型用法代码示例。如果您正苦于以下问题:C++ BIO_copy_next_retry函数的具体用法?C++ BIO_copy_next_retry怎么用?C++ BIO_copy_next_retry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BIO_copy_next_retry函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: nullf_ctrl
static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
{
long ret;
if (b->next_bio == NULL)
return 0;
switch (cmd) {
case BIO_C_DO_STATE_MACHINE:
BIO_clear_retry_flags(b);
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
BIO_copy_next_retry(b);
break;
case BIO_CTRL_DUP:
ret = 0L;
break;
default:
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
}
return ret;
}
开发者ID:RTEMS,项目名称:rtems-libbsd,代码行数:20,代码来源:bf_null.c
示例2: acpt_write
static int acpt_write (BIO * b, const char *in, int inl)
{
int ret;
BIO_ACCEPT *data;
BIO_clear_retry_flags (b);
data = (BIO_ACCEPT *) b->ptr;
while (b->next_bio == NULL)
{
ret = acpt_state (b, data);
if (ret <= 0)
return (ret);
}
ret = BIO_write (b->next_bio, in, inl);
BIO_copy_next_retry (b);
return (ret);
}
开发者ID:274914765,项目名称:C,代码行数:20,代码来源:bss_acpt.c
示例3: acpt_read
static int acpt_read (BIO * b, char *out, int outl)
{
int ret = 0;
BIO_ACCEPT *data;
BIO_clear_retry_flags (b);
data = (BIO_ACCEPT *) b->ptr;
while (b->next_bio == NULL)
{
ret = acpt_state (b, data);
if (ret <= 0)
return (ret);
}
ret = BIO_read (b->next_bio, out, outl);
BIO_copy_next_retry (b);
return (ret);
}
开发者ID:274914765,项目名称:C,代码行数:20,代码来源:bss_acpt.c
示例4: proxy_read
int proxy_read(BIO *b, char *buf, int sz)
{
int r;
struct proxy_ctx *ctx = (struct proxy_ctx *) b->ptr;
assert(buf);
if (!b->next_bio)
return 0;
if (!ctx->connected) {
assert(ctx->connect);
if (!ctx->connect(b))
return 0;
}
r = BIO_read(b->next_bio, buf, sz);
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
return r;
}
开发者ID:AlexeySalmin,项目名称:tlsdate,代码行数:21,代码来源:proxy-bio-plan9.c
示例5: md_write
static int md_write(BIO *b, const char *in, int inl)
{
int ret=0;
EVP_MD_CTX *ctx;
if ((in == NULL) || (inl <= 0)) return(0);
ctx=b->ptr;
if ((ctx != NULL) && (b->next_bio != NULL))
ret=BIO_write(b->next_bio,in,inl);
if (b->init)
{
if (ret > 0)
{
EVP_DigestUpdate(ctx,(unsigned char *)in,
(unsigned int)ret);
}
}
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
return(ret);
}
开发者ID:S0043640wipro,项目名称:RiCRiPInt,代码行数:22,代码来源:bio_md.c
示例6: nbiof_write
static int nbiof_write(BIO *b, const char *in, int inl)
{
NBIO_TEST *nt;
int ret = 0;
int num;
unsigned char n;
if ((in == NULL) || (inl <= 0))
return (0);
if (b->next_bio == NULL)
return (0);
nt = (NBIO_TEST *)b->ptr;
BIO_clear_retry_flags(b);
if (nt->lwn > 0) {
num = nt->lwn;
nt->lwn = 0;
} else {
if (RAND_bytes(&n, 1) <= 0)
return -1;
num = (n & 7);
}
if (inl > num)
inl = num;
if (num == 0) {
ret = -1;
BIO_set_retry_write(b);
} else {
ret = BIO_write(b->next_bio, in, inl);
if (ret < 0) {
BIO_copy_next_retry(b);
nt->lwn = inl;
}
}
return (ret);
}
开发者ID:TheTypoMaster,项目名称:openssl,代码行数:39,代码来源:bf_nbio.c
示例7: proxy_ctrl
long proxy_ctrl(BIO *b, int cmd, long num, void *ptr)
{
long ret;
struct proxy_ctx *ctx;
if (!b->next_bio)
return 0;
ctx = (struct proxy_ctx *) b->ptr;
assert(ctx);
switch (cmd) {
case BIO_C_DO_STATE_MACHINE:
BIO_clear_retry_flags(b);
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
BIO_copy_next_retry(b);
break;
case BIO_CTRL_DUP:
ret = 0;
break;
default:
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
}
return ret;
}
开发者ID:AlexeySalmin,项目名称:tlsdate,代码行数:23,代码来源:proxy-bio-plan9.c
示例8: nbiof_read
static int nbiof_read (BIO * b, char *out, int outl)
{
int ret = 0;
#if 1
int num;
unsigned char n;
#endif
if (out == NULL)
return (0);
if (b->next_bio == NULL)
return (0);
BIO_clear_retry_flags (b);
#if 1
RAND_pseudo_bytes (&n, 1);
num = (n & 0x07);
if (outl > num)
outl = num;
if (num == 0)
{
ret = -1;
BIO_set_retry_read (b);
}
else
#endif
{
ret = BIO_read (b->next_bio, out, outl);
if (ret < 0)
BIO_copy_next_retry (b);
}
return (ret);
}
开发者ID:274914765,项目名称:C,代码行数:37,代码来源:bf_nbio.c
示例9: buffer_read
static int
buffer_read(BIO *b, char *out, int outl)
{
int i, num = 0;
BIO_F_BUFFER_CTX *ctx;
if (out == NULL)
return (0);
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
if ((ctx == NULL) || (b->next_bio == NULL))
return (0);
num = 0;
BIO_clear_retry_flags(b);
start:
i = ctx->ibuf_len;
/* If there is stuff left over, grab it */
if (i != 0) {
if (i > outl)
i = outl;
memcpy(out, &(ctx->ibuf[ctx->ibuf_off]), i);
ctx->ibuf_off += i;
ctx->ibuf_len -= i;
num += i;
if (outl == i)
return (num);
outl -= i;
out += i;
}
/* We may have done a partial read. try to do more.
* We have nothing in the buffer.
* If we get an error and have read some data, just return it
* and let them retry to get the error again.
* copy direct to parent address space */
if (outl > ctx->ibuf_size) {
for (;;) {
i = BIO_read(b->next_bio, out, outl);
if (i <= 0) {
BIO_copy_next_retry(b);
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
return (num);
}
num += i;
if (outl == i)
return (num);
out += i;
outl -= i;
}
}
/* else */
/* we are going to be doing some buffering */
i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size);
if (i <= 0) {
BIO_copy_next_retry(b);
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
return (num);
}
ctx->ibuf_off = 0;
ctx->ibuf_len = i;
/* Lets re-read using ourselves :-) */
goto start;
}
开发者ID:2trill2spill,项目名称:nextgen,代码行数:70,代码来源:bf_buff.c
示例10: crlfbuffer_read
static int crlfbuffer_read(BIO *b, char *out, int outl)
{
int ret=0;
BIO_CRLFBUFFER_CTX *ctx;
if (out == NULL) return(0);
if (b->next_bio == NULL) return(0);
ctx=(BIO_CRLFBUFFER_CTX *)b->ptr;
// First copy what's in the current buffer
int i = ctx->ibuf_len;
if (i != 0)
{
if (i > outl)
i = outl;
memcpy(out, &(ctx->ibuf[ctx->ibuf_off]), i);
ctx->ibuf_off += i;
ctx->ibuf_len -= i;
ret += i;
outl -= i;
out += i;
}
// Now read any remaining direct from source
if (outl > 0)
ret += BIO_read(b->next_bio,out,outl);
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
if (ret > 0)
{
BIO_CRLFBUFFER_CTX *new_ctx = (BIO_CRLFBUFFER_CTX *)b->ptr;
char *p = out;
char *q = out;
int qlen = 0;
int plen = ret;
while(plen > 0)
{
if (*p == '\r')
{
p++;
plen--;
*q++ = '\n';
qlen++;
new_ctx->got_cr = true;
}
else if (*p == '\n')
{
p++;
plen--;
if (!new_ctx->got_cr)
{
*q++ = '\n';
qlen++;
}
new_ctx->got_cr = false;
}
else
{
*q++ = *p++;
plen--;
qlen++;
new_ctx->got_cr = false;
}
}
*q++ = 0;
ret = qlen;
}
return(ret);
}
开发者ID:SpareSimian,项目名称:mulberry-main,代码行数:70,代码来源:bf_crlfbuf.c
示例11: asn1_bio_write
static int asn1_bio_write(BIO *b, const char *in, int inl)
{
BIO_ASN1_BUF_CTX *ctx;
int wrmax, wrlen, ret;
unsigned char *p;
if (!in || (inl < 0) || (b->next_bio == NULL))
return 0;
ctx = (BIO_ASN1_BUF_CTX *)b->ptr;
if (ctx == NULL)
return 0;
wrlen = 0;
ret = -1;
for (;;) {
switch (ctx->state) {
/* Setup prefix data, call it */
case ASN1_STATE_START:
if (!asn1_bio_setup_ex(b, ctx, ctx->prefix,
ASN1_STATE_PRE_COPY, ASN1_STATE_HEADER))
return 0;
break;
/* Copy any pre data first */
case ASN1_STATE_PRE_COPY:
ret = asn1_bio_flush_ex(b, ctx, ctx->prefix_free,
ASN1_STATE_HEADER);
if (ret <= 0)
goto done;
break;
case ASN1_STATE_HEADER:
ctx->buflen = ASN1_object_size(0, inl, ctx->asn1_tag) - inl;
OPENSSL_assert(ctx->buflen <= ctx->bufsize);
p = ctx->buf;
ASN1_put_object(&p, 0, inl, ctx->asn1_tag, ctx->asn1_class);
ctx->copylen = inl;
ctx->state = ASN1_STATE_HEADER_COPY;
break;
case ASN1_STATE_HEADER_COPY:
ret = BIO_write(b->next_bio, ctx->buf + ctx->bufpos, ctx->buflen);
if (ret <= 0)
goto done;
ctx->buflen -= ret;
if (ctx->buflen)
ctx->bufpos += ret;
else {
ctx->bufpos = 0;
ctx->state = ASN1_STATE_DATA_COPY;
}
break;
case ASN1_STATE_DATA_COPY:
if (inl > ctx->copylen)
wrmax = ctx->copylen;
else
wrmax = inl;
ret = BIO_write(b->next_bio, in, wrmax);
if (ret <= 0)
break;
wrlen += ret;
ctx->copylen -= ret;
in += ret;
inl -= ret;
if (ctx->copylen == 0)
ctx->state = ASN1_STATE_HEADER;
if (inl == 0)
goto done;
break;
default:
BIO_clear_retry_flags(b);
return 0;
}
}
done:
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
return (wrlen > 0) ? wrlen : ret;
}
开发者ID:AnClark,项目名称:openssl,代码行数:97,代码来源:bio_asn1.c
示例12: bio_zlib_ctrl
static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr)
{
BIO_ZLIB_CTX *ctx;
int ret, *ip;
int ibs, obs;
if (!b->next_bio)
return 0;
ctx = (BIO_ZLIB_CTX *) b->ptr;
switch (cmd) {
case BIO_CTRL_RESET:
ctx->ocount = 0;
ctx->odone = 0;
ret = 1;
break;
case BIO_CTRL_FLUSH:
ret = bio_zlib_flush(b);
if (ret > 0)
ret = BIO_flush(b->next_bio);
break;
case BIO_C_SET_BUFF_SIZE:
ibs = -1;
obs = -1;
if (ptr != NULL) {
ip = ptr;
if (*ip == 0)
ibs = (int)num;
else
obs = (int)num;
} else {
ibs = (int)num;
obs = ibs;
}
if (ibs != -1) {
OPENSSL_free(ctx->ibuf);
ctx->ibuf = NULL;
ctx->ibufsize = ibs;
}
if (obs != -1) {
OPENSSL_free(ctx->obuf);
ctx->obuf = NULL;
ctx->obufsize = obs;
}
ret = 1;
break;
case BIO_C_DO_STATE_MACHINE:
BIO_clear_retry_flags(b);
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
BIO_copy_next_retry(b);
break;
default:
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
}
return ret;
}
开发者ID:AmesianX,项目名称:openssl,代码行数:64,代码来源:c_zlib.c
示例13: bio_zlib_write
static int bio_zlib_write(BIO *b, const char *in, int inl)
{
BIO_ZLIB_CTX *ctx;
int ret;
z_stream *zout;
if (!in || !inl)
return 0;
ctx = (BIO_ZLIB_CTX *) b->ptr;
if (ctx->odone)
return 0;
zout = &ctx->zout;
BIO_clear_retry_flags(b);
if (!ctx->obuf) {
ctx->obuf = OPENSSL_malloc(ctx->obufsize);
/* Need error here */
if (!ctx->obuf) {
COMPerr(COMP_F_BIO_ZLIB_WRITE, ERR_R_MALLOC_FAILURE);
return 0;
}
ctx->optr = ctx->obuf;
ctx->ocount = 0;
deflateInit(zout, ctx->comp_level);
zout->next_out = ctx->obuf;
zout->avail_out = ctx->obufsize;
}
/* Obtain input data directly from supplied buffer */
zout->next_in = (void *)in;
zout->avail_in = inl;
for (;;) {
/* If data in output buffer write it first */
while (ctx->ocount) {
ret = BIO_write(b->next_bio, ctx->optr, ctx->ocount);
if (ret <= 0) {
/* Total data written */
int tot = inl - zout->avail_in;
BIO_copy_next_retry(b);
if (ret < 0)
return (tot > 0) ? tot : ret;
return tot;
}
ctx->optr += ret;
ctx->ocount -= ret;
}
/* Have we consumed all supplied data? */
if (!zout->avail_in)
return inl;
/* Compress some more */
/* Reset buffer */
ctx->optr = ctx->obuf;
zout->next_out = ctx->obuf;
zout->avail_out = ctx->obufsize;
/* Compress some more */
ret = deflate(zout, 0);
if (ret != Z_OK) {
COMPerr(COMP_F_BIO_ZLIB_WRITE, COMP_R_ZLIB_DEFLATE_ERROR);
ERR_add_error_data(2, "zlib error:", zError(ret));
return 0;
}
ctx->ocount = ctx->obufsize - zout->avail_out;
}
}
开发者ID:AmesianX,项目名称:openssl,代码行数:64,代码来源:c_zlib.c
示例14: ssl_ctrl
static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
{
SSL **sslp,*ssl;
BIO_SSL *bs;
BIO *dbio,*bio;
long ret=1;
bs=(BIO_SSL *)b->ptr;
ssl=bs->ssl;
if ((ssl == NULL) && (cmd != BIO_C_SET_SSL))
return(0);
switch (cmd)
{
case BIO_CTRL_RESET:
SSL_shutdown(ssl);
if (ssl->handshake_func == ssl->method->ssl_connect)
SSL_set_connect_state(ssl);
else if (ssl->handshake_func == ssl->method->ssl_accept)
SSL_set_accept_state(ssl);
SSL_clear(ssl);
if (b->next_bio != NULL)
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
else if (ssl->rbio != NULL)
ret=BIO_ctrl(ssl->rbio,cmd,num,ptr);
else
ret=1;
break;
case BIO_CTRL_INFO:
ret=0;
break;
case BIO_C_SSL_MODE:
if (num) /* client mode */
SSL_set_connect_state(ssl);
else
SSL_set_accept_state(ssl);
break;
case BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT:
ret=bs->renegotiate_timeout;
if (num < 60) num=5;
bs->renegotiate_timeout=(unsigned long)num;
bs->last_time=(unsigned long)time(NULL);
break;
case BIO_C_SET_SSL_RENEGOTIATE_BYTES:
ret=bs->renegotiate_count;
if ((long)num >=512)
bs->renegotiate_count=(unsigned long)num;
break;
case BIO_C_GET_SSL_NUM_RENEGOTIATES:
ret=bs->num_renegotiates;
break;
case BIO_C_SET_SSL:
if (ssl != NULL)
{
ssl_free(b);
if (!ssl_new(b))
return 0;
}
b->shutdown=(int)num;
ssl=(SSL *)ptr;
((BIO_SSL *)b->ptr)->ssl=ssl;
bio=SSL_get_rbio(ssl);
if (bio != NULL)
{
if (b->next_bio != NULL)
BIO_push(bio,b->next_bio);
b->next_bio=bio;
CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO);
}
b->init=1;
break;
case BIO_C_GET_SSL:
if (ptr != NULL)
{
sslp=(SSL **)ptr;
*sslp=ssl;
}
else
ret=0;
break;
case BIO_CTRL_GET_CLOSE:
ret=b->shutdown;
break;
case BIO_CTRL_SET_CLOSE:
b->shutdown=(int)num;
break;
case BIO_CTRL_WPENDING:
ret=BIO_ctrl(ssl->wbio,cmd,num,ptr);
break;
case BIO_CTRL_PENDING:
ret=SSL_pending(ssl);
if (ret == 0)
ret=BIO_pending(ssl->rbio);
break;
case BIO_CTRL_FLUSH:
BIO_clear_retry_flags(b);
ret=BIO_ctrl(ssl->wbio,cmd,num,ptr);
BIO_copy_next_retry(b);
//.........这里部分代码省略.........
开发者ID:neominds,项目名称:ric13351,代码行数:101,代码来源:bio_ssl.c
示例15: ok_write
static int ok_write(BIO *b, const char *in, int inl)
{
int ret = 0, n, i;
BIO_OK_CTX *ctx;
if (inl <= 0)
return inl;
ctx = (BIO_OK_CTX *)b->ptr;
ret = inl;
if ((ctx == NULL) || (b->next_bio == NULL) || (b->init == 0))
return (0);
if (ctx->sigio && !sig_out(b))
return 0;
do {
BIO_clear_retry_flags(b);
n = ctx->buf_len - ctx->buf_off;
while (ctx->blockout && n > 0) {
i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n);
if (i <= 0) {
BIO_copy_next_retry(b);
if (!BIO_should_retry(b))
ctx->cont = 0;
return (i);
}
ctx->buf_off += i;
n -= i;
}
/* at this point all pending data has been written */
ctx->blockout = 0;
if (ctx->buf_len == ctx->buf_off) {
ctx->buf_len = OK_BLOCK_BLOCK;
ctx->buf_off = 0;
}
if ((in == NULL) || (inl <= 0))
return (0);
n = (inl + ctx->buf_len > OK_BLOCK_SIZE + OK_BLOCK_BLOCK) ?
(int)(OK_BLOCK_SIZE + OK_BLOCK_BLOCK - ctx->buf_len) : inl;
memcpy((unsigned char *)(&(ctx->buf[ctx->buf_len])),
(unsigned char *)in, n);
ctx->buf_len += n;
inl -= n;
in += n;
if (ctx->buf_len >= OK_BLOCK_SIZE + OK_BLOCK_BLOCK) {
if (!block_out(b)) {
BIO_clear_retry_flags(b);
return 0;
}
}
} while (inl > 0);
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
return (ret);
}
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:63,代码来源:bio_ok.c
示例16: enc_ctrl
static long enc_ctrl(BIO *b, int cmd, long num, void *ptr)
{
BIO *dbio;
BIO_ENC_CTX *ctx,*dctx;
long ret=1;
int i;
EVP_CIPHER_CTX **c_ctx;
ctx=(BIO_ENC_CTX *)b->ptr;
switch (cmd)
{
case BIO_CTRL_RESET:
ctx->ok=1;
ctx->finished=0;
EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL,
ctx->cipher.encrypt);
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
case BIO_CTRL_EOF: /* More to read */
if (ctx->cont <= 0)
ret=1;
else
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
case BIO_CTRL_WPENDING:
ret=ctx->buf_len-ctx->buf_off;
if (ret <= 0)
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
case BIO_CTRL_PENDING: /* More to read in buffer */
ret=ctx->buf_len-ctx->buf_off;
if (ret <= 0)
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
case BIO_CTRL_FLUSH:
/* do a final write */
again:
while (ctx->buf_len != ctx->buf_off)
{
i=enc_write(b,NULL,0);
if (i < 0)
return i;
}
if (!ctx->finished)
{
ctx->finished=1;
ctx->buf_off=0;
ret=EVP_CipherFinal_ex(&(ctx->cipher),
(unsigned char *)ctx->buf,
&(ctx->buf_len));
ctx->ok=(int)ret;
if (ret <= 0) break;
/* push out the bytes */
goto again;
}
/* Finally flush the underlying BIO */
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
case BIO_C_GET_CIPHER_STATUS:
ret=(long)ctx->ok;
break;
case BIO_C_DO_STATE_MACHINE:
BIO_clear_retry_flags(b);
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
BIO_copy_next_retry(b);
break;
case BIO_C_GET_CIPHER_CTX:
c_ctx=(EVP_CIPHER_CTX **)ptr;
(*c_ctx)= &(ctx->cipher);
b->init=1;
break;
case BIO_CTRL_DUP:
dbio=(BIO *)ptr;
dctx=(BIO_ENC_CTX *)dbio->ptr;
EVP_CIPHER_CTX_init(&dctx->cipher);
ret = EVP_CIPHER_CTX_copy(&dctx->cipher,&ctx->cipher);
if (ret)
dbio->init=1;
break;
default:
ret=BIO_ctrl(b->next_bio,cmd,num,ptr);
break;
}
return(ret);
}
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:89,代码来源:bio_enc.cpp
示例17: bio_rdp_tls_ctrl
static long bio_rdp_tls_ctrl(BIO* bio, int cmd, long num, void* ptr)
{
BIO* ssl_rbio;
BIO* ssl_wbio;
BIO* next_bio;
int status = -1;
BIO_RDP_TLS* tls = (BIO_RDP_TLS*) BIO_get_data(bio);
if (!tls)
return 0;
if (!tls->ssl && (cmd != BIO_C_SET_SSL))
return 0;
next_bio = BIO_next(bio);
ssl_rbio = tls->ssl ? SSL_get_rbio(tls->ssl) : NULL;
ssl_wbio = tls->ssl ? SSL_get_wbio(tls->ssl) : NULL;
switch (cmd)
{
case BIO_CTRL_RESET:
SSL_shutdown(tls->ssl);
if (SSL_in_connect_init(tls->ssl))
SSL_set_connect_state(tls->ssl);
else if (SSL_in_accept_init(tls->ssl))
SSL_set_accept_state(tls->ssl);
SSL_clear(tls->ssl);
if (next_bio)
status = BIO_ctrl(next_bio, cmd, num, ptr);
else if (ssl_rbio)
status = BIO_ctrl(ssl_rbio, cmd, num, ptr);
else
status = 1;
break;
case BIO_C_GET_FD:
status = BIO_ctrl(ssl_rbio, cmd, num, ptr);
break;
case BIO_CTRL_INFO:
status = 0;
break;
case BIO_CTRL_SET_CALLBACK:
status = 0;
break;
case BIO_CTRL_GET_CALLBACK:
*((ULONG_PTR*) ptr) = (ULONG_PTR) SSL_get_info_callback(tls->ssl);
status = 1;
break;
case BIO_C_SSL_MODE:
if (num)
SSL_set_connect_state(tls->ssl);
else
SSL_set_accept_state(tls->ssl);
status = 1;
break;
case BIO_CTRL_GET_CLOSE:
status = BIO_get_shutdown(bio);
break;
case BIO_CTRL_SET_CLOSE:
BIO_set_shutdown(bio, (int) num);
status = 1;
break;
case BIO_CTRL_WPENDING:
status = BIO_ctrl(ssl_wbio, cmd, num, ptr);
break;
case BIO_CTRL_PENDING:
status = SSL_pending(tls->ssl);
if (status == 0)
status = BIO_pending(ssl_rbio);
break;
case BIO_CTRL_FLUSH:
BIO_clear_retry_flags(bio);
status = BIO_ctrl(ssl_wbio, cmd, num, ptr);
BIO_copy_next_retry(bio);
status = 1;
break;
case BIO_CTRL_PUSH:
if (next_bio && (next_bio != ssl_rbio))
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L
SSL_set_bio(tls->ssl, next_bio, next_bio);
CRYPTO_add(&(bio->next_bio->references), 1, CRYPTO_LOCK_BIO);
//.........这里部分代码省略.........
开发者ID:dcatonR1,项目名称:FreeRDP,代码行数:101,代码来源:tls.c
示例18: md_ctrl
static long md_ctrl(BIO *b, int cmd, long num, void *ptr)
{
EVP_MD_CTX *ctx, *dctx, **pctx;
const EVP_MD **ppmd;
EVP_MD *md;
long ret = 1;
BIO *dbio, *next;
ctx = BIO_get_data(b);
next = BIO_next(b);
switch (cmd) {
case BIO_CTRL_RESET:
if (BIO_get_init(b))
ret = EVP_DigestInit_ex(ctx, ctx->digest, NULL);
else
ret = 0;
if (ret > 0)
ret = BIO_ctrl(next, cmd, num, ptr);
break;
case BIO_C_GET_MD:
if (BIO_get_init(b)) {
ppmd = ptr;
*ppmd = ctx->digest;
} else
ret = 0;
break;
case BIO_C_GET_MD_CTX:
pctx = ptr;
*pctx = ctx;
BIO_set_init(b, 1);
break;
case BIO_C_SET_MD_CTX:
if (BIO_get_init(b))
BIO_set_data(b, ptr);
else
ret = 0;
break;
case BIO_C_DO_STATE_MACHINE:
BIO_clear_retry_flags(b);
ret = BIO_ctrl(next, cmd, num, ptr);
BIO_copy_next_retry(b);
break;
case BIO_C_SET_MD:
md = ptr;
ret = EVP_DigestInit_ex(ctx, md, NULL);
if (ret > 0)
BIO_set_init(b, 1);
break;
case BIO_CTRL_DUP:
dbio = ptr;
dctx = BIO_get_data(dbio);
if (!EVP_MD_CTX_copy_ex(dctx, ctx))
return 0;
BIO_set_init(b, 1);
break;
default:
ret = BIO_ctrl(next, cmd, num, ptr);
break;
}
return ret;
}
开发者ID:Ana06,项目名称:openssl,代码行数:64,代码来源:bio_md.c
示例19: bio_ber_get_header
int bio_ber_get_header(BIO *bio, BIO_BER_CTX *ctx)
{
char buf[64];
int i,j,n;
int ret;
unsigned char *p;
unsigned long length
int tag;
int class;
long max;
BIO_clear_retry_flags(b);
/* Pack the buffer down if there is a hole at the front */
if (ctx->buf_off != 0)
{
p=ctx->buf;
j=ctx->buf_off;
n=ctx->buf_len-j;
for (i=0; i<n; i++)
{
p[0]=p[j];
p++;
}
ctx->buf_len-j;
ctx->buf_off=0;
}
/* If there is more room, read some more data */
i=BER_BUF_SIZE-ctx->buf_len;
if (i)
{
i=BIO_read(bio->next_bio,&(ctx->buf[ctx->buf_len]),i);
if (i <= 0)
{
BIO_copy_next_retry(b);
return(i);
}
else
ctx->buf_len+=i;
}
max=ctx->buf_len;
p=ctx->buf;
ret=ASN1_get_object(&p,&length,&tag,&class,max);
if (ret & 0x80)
{
if ((ctx->buf_len < BER_BUF_SIZE) &&
(ERR_GET_REASON(ERR_peek_error()) == ASN1_R_TOO_LONG))
{
ERR_clear_error(); /* clear the error */
BIO_set_retry_read(b);
}
return(-1);
}
/* We have no error, we have a header, so make use of it */
if ((ctx->tag >= 0) && (ctx->tag != tag))
{
BIOerr(BIO_F_BIO_BER_GET_HEADER,BIO_R_TAG_MISMATCH);
sprintf(buf,"tag=%d, got %d",ctx->tag,tag);
ERR_add_error_data(1,buf);
return(-1);
}
if (ret & 0x01)
if (ret & V_ASN1_CONSTRUCTED)
}
开发者ID:RafaelRMachado,项目名称:MinnowBoard,代码行数:69,代码来源:bio_ber.c
示例20: ok_write
static int ok_write(BIO *b, const char *in, int inl)
{
int ret = 0, n, i;
BIO_OK_CTX *ctx;
BIO *next;
if (inl <= 0)
return inl;
ctx = BIO_get_data(b);
next = BIO_next(b);
ret = inl;
if ((ctx == NULL) || (next == NULL) || (BIO_get_init(b) == 0))
return 0;
if (ctx->sigio && !sig_out(b))
return 0;
do {
BIO_clear_retry_flags(b);
n = ctx->buf_len - ctx->buf_off;
while (ctx->blockout && n > 0) {
i = BIO_write(next, &(ctx->buf[ctx->buf_off]), n);
if (i <= 0) {
BIO_copy_next_retry(b);
if (!BIO_should_retry(b))
ctx->cont = 0;
return i;
}
ctx->buf_off += i;
n -= i;
}
/* at this point all pending data has been written */
ctx->blockout = 0;
if (ctx->buf_len == ctx->buf_off) {
ctx->buf_len = OK_BLOCK_BLOCK;
ctx->buf_off = 0;
}
if ((in == NULL) || (inl <= 0))
return 0;
n = (inl + ctx->buf_len > OK_BLOCK_SIZE + OK_BLOCK_BLOCK) ?
(int)(OK_BLOCK_SIZE + OK_BLOCK_BLOCK - ctx->buf_len) : inl;
memcpy(&ctx->buf[ctx->buf_len], in, n);
ctx->buf_len += n;
inl -= n;
in += n;
if (ctx->buf_len >= OK_BLOCK_SIZE + OK_BLOCK_BLOCK) {
if (!block_out(b)) {
BIO_clear_retry_flags(b);
return 0;
}
}
} while (inl > 0);
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
return ret;
}
开发者ID:Ana06,项目名称:openssl,代码行数:64,代码来源:bio_ok.c
注:本文中的BIO_copy_next_retry函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论