您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BIO_gets函数代码示例

51自学网 2021-06-01 19:50:04
  C++
这篇教程C++ BIO_gets函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BIO_gets函数的典型用法代码示例。如果您正苦于以下问题:C++ BIO_gets函数的具体用法?C++ BIO_gets怎么用?C++ BIO_gets使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BIO_gets函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: check_padding_and_structure

int check_padding_and_structure(out, length){    pad = out[length - 1];    if(pad > 16) return -1; // Bad padding byte    n = length - pad;    for(i = n; i < length; i++) // check padding        if(out[i] != pad) return -1;    /* match structure with known standard structure */    outfile = BIO_new(BIO_s_mem());    ASN1_parse(outfile, out, legnth, 0);    BIO_gets(outfile, (char*)output, N);    res = memem(output, 128, "SEQUENCE", 8);    if (!res) goto bad;    BIO_gets(outfile, (char*)output, N);    res = memem(output, 128, ":00", 3);    if (!res) goto bad;    res = memem(output, 128, "INTEGER", 7);    if (!res) goto bad;    BIO_gets(outfile, (char*)output, N);    res = memem(output, 128, "INTEGER", 7);    if (!res) goto bad;    /* now this integer has to be big, check minimum length */    ul = strlen((char*)res);    p = res;    while(*p) {        if (isspace(*p))            ul--;        p++;    }    if (ul < 32) goto bad;    return 0;bad:    return -1;}
开发者ID:kholia,项目名称:thesis,代码行数:35,


示例2: genHumanReadableDateTime

std::string genHumanReadableDateTime(ASN1_TIME* time) {  BIO* bio_stream = BIO_new(BIO_s_mem());  if (bio_stream == nullptr) {    return "";  }  // ANS1_TIME_print's format is: Mon DD HH:MM:SS YYYY GMT  // e.g. Jan 1 00:00:00 1970 GMT (always GMT)  auto buffer_size = 32;  char buffer[32] = {0};  if (!ASN1_TIME_print(bio_stream, time)) {    BIO_free(bio_stream);    return "";  }  // BIO_gets() returns amount of data successfully read or written  // (if the return value is positive) or that no data was successfully  // read or written if the result is 0 or -1.  if (BIO_gets(bio_stream, buffer, buffer_size) <= 0) {    BIO_free(bio_stream);    return "";  }  BIO_free(bio_stream);  return std::string(buffer);}
开发者ID:huamichaelchen,项目名称:osquery,代码行数:25,


示例3: asn1_bio_gets

static int asn1_bio_gets(BIO *b, char *str, int size){    BIO *next = BIO_next(b);    if (next == NULL)        return 0;    return BIO_gets(next, str, size);}
开发者ID:Bilibili,项目名称:openssl,代码行数:7,


示例4: main

int main(int argc, char *argv[]) {  BIO *bio_stdin, *bio_md5;  unsigned char buf[512], mdBuf[EVP_MAX_MD_SIZE];  int i, mdLength;  /* Create a BIO objects */  bio_stdin  = BIO_new_fp(stdin,  BIO_NOCLOSE);  /* Create a base64 filter and connect it to the bio_stdin */  bio_md5 = BIO_new(BIO_f_md());  BIO_set_md(bio_md5, EVP_md5());  bio_stdin = BIO_push(bio_md5, bio_stdin);  /* Read from bio_stdin, and compute the hash as a side effect. */  while(BIO_read(bio_stdin, buf, 512) > 0) {  } /* end while */  /* Now extract the hash via BIO_gets (which is kinda odd really). */  mdLength = BIO_gets(bio_md5, (char *)mdBuf, EVP_MAX_MD_SIZE);  for(i=0; i<mdLength; i++)     printf("%02x", (unsigned int)(mdBuf[i]));  printf("/n");  BIO_free_all(bio_stdin);      return 0;} /* end func main */
开发者ID:Wushaowei001,项目名称:CodeExamples,代码行数:27,


示例5: throw

/** * Converts X509_NAME struct to string. * * @param name X509_NAME struct that is converted to string. * @return converted value of X509_NAME. * @throws IOException throws exception if conversion failed. */std::string digidoc::X509Cert::toString(X509_NAME* name) throw(IOException){    BIO* mem = BIO_new(BIO_s_mem()); BIO_scope memScope(&mem);    if(mem == NULL)    {        THROW_IOEXCEPTION("Failed to allocate memory for X509_NAME conversion: %s", ERR_reason_error_string(ERR_get_error()));    }    // Convert the X509_NAME struct to string.    if(X509_NAME_print_ex(mem, name, 0, XN_FLAG_RFC2253) < 0)    {        THROW_IOEXCEPTION("Failed to convert X509_NAME struct to string: %s", ERR_reason_error_string(ERR_get_error()));    }    // Read the converted string from buffer.    char buf[128];    int bytesRead;    std::string str;    while((bytesRead = BIO_gets(mem, &buf[0], sizeof(buf))) > 0)    {        str.append(buf);    }    return str;}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:32,


示例6: linebuffer_gets

static intlinebuffer_gets(BIO *b, char *buf, int size){	if (b->next_bio == NULL)		return (0);	return (BIO_gets(b->next_bio, buf, size));}
开发者ID:jmhodges,项目名称:libssl,代码行数:7,


示例7: LUA_FUNCTION

static LUA_FUNCTION(openssl_bio_gets){  BIO* bio = CHECK_OBJECT(1, BIO, "openssl.bio");  int len = luaL_optint(L, 2, BIO_pending(bio));  char* buf;  int ret = 1;  len = len > 0 ? len : 1024;  buf = malloc(len);  len = BIO_gets(bio, buf, len);  if (len > 0)  {    lua_pushlstring(L, buf, len);    ret = 1;  }  else if (BIO_should_retry(bio))  {    lua_pushstring(L, "");    ret = 1;  }  else  {    lua_pushnil(L);    lua_pushinteger(L, len);    ret = 2;  };  free(buf);  return ret;}
开发者ID:Shaddy1884,项目名称:lua-openssl,代码行数:29,


示例8: nullf_gets

static intnullf_gets(BIO *bp, char *buf, int size){	if (bp->next_bio == NULL)		return (0);	return (BIO_gets(bp->next_bio, buf, size));}
开发者ID:awakecoding,项目名称:libressl,代码行数:7,


示例9: convertAsn1ToString

int convertAsn1ToString(ASN1_TIME *notAfter, char buffer[]) {	BIO *bio = BIO_new(BIO_s_mem());	ASN1_TIME_print(bio, notAfter);	BIO_gets(bio, buffer, BUFLEN);	BIO_free(bio);	return 0;}
开发者ID:alexanderteves,项目名称:sslexpiry,代码行数:7,


示例10: receiveFile

int receiveFile(char *socket, char *outfile){  BIO *receive = BIO_new_accept(socket);  BIO *fileout = BIO_new_file(outfile,"w");    // it seems you need to do this twice.. not sure why, but we do  // guess I'll try figure out why at some point  if (BIO_do_accept(receive) <= 0) {    fprintf(stderr, "Error setting up accept/n");    exit(0);  }  if (BIO_do_accept(receive) <= 0) {    fprintf(stderr, "Error setting up accept/n");    exit(0);  }  char tmpbuf[BUFSIZ];  // magic wrapper  BIO *bufbio = BIO_new(BIO_f_buffer());  BIO_push(bufbio, receive);  //read in the file length and store  BIO_gets(bufbio, tmpbuf, BUFSIZ);  printf("Getting file length: %s/n", tmpbuf);  unsigned int size = atoi(tmpbuf);  transmit(bufbio, fileout, size);  BIO_flush(fileout);  BIO_free(bufbio);  return 1;}
开发者ID:eltommo,项目名称:licenceliber,代码行数:35,


示例11: replace_gets

static int replace_gets(BIO *bp, char *buf, int size) {   //DEBUG_MSG(D_DEBUG, "%s", __FUNCTION__);   if (bp->next_bio == NULL)      return (0);   return (BIO_gets(bp->next_bio, buf, size));}
开发者ID:BwRy,项目名称:vector-ipa,代码行数:8,


示例12: rsa_privatekey_to_pem

/*  * Takes in an RSA object and PEM encodes it in out * @param key: the RSA private key * @param out: the string the PEM encoding goes to * @param pem_password: the password to unlock the pem encoding * @return: the length of the PEM encoding */unsigned int rsa_privatekey_to_pem(RSA *key, unsigned char **out, unsigned char *password) {    BIO *pubKey = BIO_new(BIO_s_mem());    PEM_write_bio_RSAPrivateKey(pubKey, key, NULL, NULL, 0, NULL, NULL);    unsigned char line[65];    int len = 0;    unsigned char *pem = NULL;    unsigned char *new_pem = NULL;    if (!BIO_eof(pubKey)) {        BIO_gets(pubKey, line, sizeof *pubKey);        len += strlen(line);        new_pem = (unsigned char *)realloc(pem, len*sizeof(unsigned char));        if (!new_pem) {            printf("realloc failed at length:%d/n", len);        } else {            memcpy(new_pem, "-----BEGIN PRIVATE KEY-----/n", (size_t)len);            pem = new_pem;        }    }    while (!BIO_eof(pubKey)) {        BIO_gets(pubKey, line, sizeof *pubKey);        //  current length of PEM (including newlines)        len += strlen(line);        new_pem = (unsigned char *)realloc(pem, len*sizeof(unsigned char));        if (!new_pem) {            printf("realloc failed at length:%d/n", len);            exit(EXIT_FAILURE);        } else {            memcpy(new_pem, strcat(new_pem, line), (size_t)len);            pem = new_pem;        }    }    *out = pem;    return len;}
开发者ID:mroseman95,项目名称:Crypto-Plugin,代码行数:51,


示例13: do_fp

void do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,			EVP_PKEY *key, unsigned char *sigin, int siglen)	{	int len;	int i;	for (;;)		{		i=BIO_read(bp,(char *)buf,BUFSIZE);		if (i <= 0) break;		}	if(sigin)		{		EVP_MD_CTX *ctx;		BIO_get_md_ctx(bp, &ctx);		i = EVP_VerifyFinal(ctx, sigin, (unsigned int)siglen, key); 		if(i > 0) BIO_printf(out, "Verified OK/n");		else if(i == 0) BIO_printf(out, "Verification Failure/n");		else			{			BIO_printf(bio_err, "Error Verifying Data/n");			ERR_print_errors(bio_err);			}		return;		}	if(key)		{		EVP_MD_CTX *ctx;		BIO_get_md_ctx(bp, &ctx);		if(!EVP_SignFinal(ctx, buf, (unsigned int *)&len, key)) 			{			BIO_printf(bio_err, "Error Signing Data/n");			ERR_print_errors(bio_err);			return;			}		}	else		len=BIO_gets(bp,(char *)buf,BUFSIZE);	if(binout) BIO_write(out, buf, len);	else 		{		for (i=0; i<len; i++)			{			if (sep && (i != 0))				BIO_printf(out, ":");			BIO_printf(out, "%02x",buf[i]);			}		BIO_printf(out, "/n");		}	}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:51,


示例14: main

main() {BIO *mem;int ret;ERR_load_BIO_strings();SSL_load_error_strings();OpenSSL_add_all_algorithms();mem = BIO_new(BIO_s_mem());// Example - 1: Write into Buffer// BIO_puts writes a NULL terminated string into memoryBIO_puts(mem, "Hello Aseem Sethi");  // BIO_puts points to mem_write// Read the buffer back via BIO_gets()BUF_MEM *bufMem;char data[100], data1[100];ret = BIO_gets(mem, data, 100);  // points to mem_gets =>mem_readprintf("/nBuffer Read Data: ret=%d: %s", ret, data);//Try to Read the data again. Data once read is deletedret = BIO_gets(mem, data1, 100); // result is always null terminatedprintf("/nBuffer Read Data Again: ret=%d: %s", ret, data1);printf("/n..........................");// Example - 2: Write into BufferBIO_puts(mem, "Bye..");  // points to mem_write// Read the buffer back via BIO_get_mem_data()// This is not null terminated. Read only what you need.char *buff = NULL;size_t len = BIO_get_mem_data(mem, &buff);printf("/nBuffer Read Data via get_mem_data: length=%d: %.*s", len, len, buff);printf("/n strlen: %d", strlen(buff));printf("/n........................../n");}
开发者ID:aseemsethi,项目名称:openssl-api,代码行数:36,


示例15: _mongoc_ssl_extract_subject

char *_mongoc_ssl_extract_subject (const char *filename){   X509_NAME *subject = NULL;   X509 *cert = NULL;   BIO *certbio = NULL;   BIO *strbio = NULL;   char *str = NULL;   int ret;   if (!filename) {      return NULL;   }   certbio = BIO_new (BIO_s_file ());   strbio = BIO_new (BIO_s_mem ());;   BSON_ASSERT (certbio);   BSON_ASSERT (strbio);   BIO_read_filename (certbio, filename);   if ((cert = PEM_read_bio_X509 (certbio, NULL, 0, NULL))) {      if ((subject = X509_get_subject_name (cert))) {         ret = X509_NAME_print_ex (strbio, subject, 0, XN_FLAG_RFC2253);         if ((ret > 0) && (ret < INT_MAX)) {            str = bson_malloc (ret + 2);            BIO_gets (strbio, str, ret + 1);            str [ret] = '/0';         }      }   }   if (cert) {      X509_free (cert);   }   if (certbio) {      BIO_free (certbio);   }   if (strbio) {      BIO_free (strbio);   }   return str;}
开发者ID:TylerBrock,项目名称:mongo-c-driver,代码行数:48,


示例16: pop_recvmlresp

int pop_recvmlresp(POP_SESSION *psp){#ifdef WITH_OPENSSL    assert(psp != NULL && psp->bio != NULL);#else /* WITH_OPENSSL */    assert(psp != NULL && psp->fr != NULL);#endif /* WITH_OPENSSL */    psp->resp = NULL;#ifdef WITH_OPENSSL    if (BIO_gets(psp->bio, psp->rbuf, POP_MAXRESPLEN) < 0) {	return psp->status = POP_EXCEPTION;    }#else /* WITH_OPENSSL */    if (fgets(psp->rbuf, POP_MAXRESPLEN, psp->fr) == NULL) {	return psp->status = POP_EXCEPTION;    }#endif /* WITH_OPENSSL */    psp->resp = psp->rbuf;    {	size_t len = strlen(psp->resp);	int eot = 0;	if (len > 0 && psp->eol != POP_EOL_CONT && psp->resp[0] == '.') {	    psp->resp++;	    len--;	    eot++;	}	if (len <= 0 || psp->resp[--len] != '/n') {	    return psp->status = POP_CONT;	}	psp->eol = POP_EOL_LF;	psp->resp[len] = NUL;	if (len <= 0 || psp->resp[--len] != '/r') {	    return psp->status = POP_CONT;	}	psp->eol = POP_EOL_CRLF;	psp->rbuf[len] = NUL;	if (eot && len == 0) {	    return psp->status = POP_OK;	} else {	    return psp->status = POP_CONT;	}    }}
开发者ID:kusune,项目名称:from,代码行数:48,


示例17: x509_get_not_after

Datum x509_get_not_after(PG_FUNCTION_ARGS) {	bytea *raw;	X509 *cert;	BIO *bio;	char buf[DATE_LEN];	int r;	// check for null value.	raw = PG_GETARG_BYTEA_P(0);	if (raw == NULL || VARSIZE(raw) == VARHDRSZ) {		PG_RETURN_NULL();	}	// read cert	cert = x509_from_bytea(raw);	if (cert == NULL) {		ereport(ERROR,				(errcode(ERRCODE_DATA_CORRUPTED), errmsg(						"unable to decode X509 record")));		PG_RETURN_NULL();	}	// extract 'not after' date	bio = BIO_new(BIO_s_mem());	if ((r = ASN1_TIME_print(bio, X509_get_notAfter(cert))) <= 0) {		X509_free(cert);		BIO_free(bio);		ereport(ERROR,				(errcode(ERRCODE_DATA_CORRUPTED), errmsg("unable to retrieve 'notAfter' timestamp")));		PG_RETURN_NULL();	}	// convert 'not before' date	if ((r = BIO_gets(bio, buf, DATE_LEN)) <= 0) {		X509_free(cert);		BIO_free(bio);		ereport(ERROR,				(errcode(ERRCODE_DATA_CORRUPTED), errmsg("unable to create ISO-8601 timestamp")));		PG_RETURN_NULL();	}	BIO_free(bio);	X509_free(cert);	// FIXME convert ISO-8601 timestamp	PG_RETURN_NULL();}
开发者ID:beargiles,项目名称:pgopenssltypes,代码行数:48,


示例18: OBJ_create_objects

int OBJ_create_objects(BIO *in)  {  MS_STATIC char buf[512];  int i,num=0;  char *o,*s,*l=NULL;  for (;;)    {    s=o=NULL;    i=BIO_gets(in,buf,512);    if (i <= 0) return(num);    buf[i-1]='/0';    if (!isalnum((unsigned char)buf[0])) return(num);    o=s=buf;    while (isdigit((unsigned char)*s) || (*s == '.'))      s++;    if (*s != '/0')      {      *(s++)='/0';      while (isspace((unsigned char)*s))        s++;      if (*s == '/0')        s=NULL;      else        {        l=s;        while ((*l != '/0') && !isspace((unsigned char)*l))          l++;        if (*l != '/0')          {          *(l++)='/0';          while (isspace((unsigned char)*l))            l++;          if (*l == '/0') l=NULL;          }        else          l=NULL;        }      }    else      s=NULL;    if ((o == NULL) || (*o == '/0')) return(num);    if (!OBJ_create(o,s,l)) return(num);    num++;    }  /* return(num); */  }
开发者ID:yyyyyao,项目名称:Slicer3-lib-mirrors,代码行数:47,


示例19: get_name

static int get_name(BIO *bp, char **name, unsigned int flags){    char *linebuf;    int ret = 0;    int len;    /*     * Need to hold trailing NUL (accounted for by BIO_gets() and the newline     * that will be added by sanitize_line() (the extra '1').     */    linebuf = pem_malloc(LINESIZE + 1, flags);    if (linebuf == NULL) {        PEMerr(PEM_F_GET_NAME, ERR_R_MALLOC_FAILURE);        return 0;    }    do {        len = BIO_gets(bp, linebuf, LINESIZE);        if (len <= 0) {            PEMerr(PEM_F_GET_NAME, PEM_R_NO_START_LINE);            goto err;        }        /* Strip trailing garbage and standardize ending. */        len = sanitize_line(linebuf, len, flags & ~PEM_FLAG_ONLY_B64);        /* Allow leading empty or non-matching lines. */    } while (strncmp(linebuf, beginstr, BEGINLEN) != 0             || len < TAILLEN             || strncmp(linebuf + len - TAILLEN, tailstr, TAILLEN) != 0);    linebuf[len - TAILLEN] = '/0';    len = len - BEGINLEN - TAILLEN + 1;    *name = pem_malloc(len, flags);    if (*name == NULL) {        PEMerr(PEM_F_GET_NAME, ERR_R_MALLOC_FAILURE);        goto err;    }    memcpy(*name, linebuf + BEGINLEN, len);    ret = 1;err:    pem_free(linebuf, flags, LINESIZE + 1);    return ret;}
开发者ID:Ana06,项目名称:openssl,代码行数:45,


示例20: asn1Time_to_timestamp

/** * Convert ASN1_TIME object to PostgreSQL timestamp. */int asn1Time_to_timestamp(ASN1_TIME *asn1, Timestamp *dt) {    BIO *bio;    char buf[DATE_LEN];    struct tm tm;    struct pg_tm pgtm;    int r;    // extract 'not before' date    bio = BIO_new(BIO_s_mem());    if ((r = ASN1_TIME_print(bio, asn1)) <= 0) {        BIO_free(bio);        ereport(ERROR,                (errcode(ERRCODE_DATA_CORRUPTED), errmsg("unable to retrieve timestamp")));        return 1;    }    // convert 'not before' date    if ((r = BIO_gets(bio, buf, DATE_LEN)) <= 0) {        BIO_free(bio);        ereport(ERROR,                (errcode(ERRCODE_DATA_CORRUPTED), errmsg("unable to create ISO-8601 timestamp")));        return 1;    }    BIO_free(bio);    memset(&tm, 0, sizeof(struct tm));    strptime(buf, "%b %d %T %Y %z", &tm);        pgtm.tm_sec = tm.tm_sec;    pgtm.tm_min = tm.tm_min;    pgtm.tm_hour = tm.tm_hour;    pgtm.tm_mday= tm.tm_mday;    pgtm.tm_mon= tm.tm_mon + 1;    pgtm.tm_year = tm.tm_year + 1900;    pgtm.tm_wday= tm.tm_wday;    pgtm.tm_yday = tm.tm_yday;    pgtm.tm_isdst = tm.tm_isdst;    pgtm.tm_gmtoff = 0;    pgtm.tm_zone = "UTC";    tm2timestamp(&pgtm, 0, NULL, dt);        return 0;}
开发者ID:beargiles,项目名称:pg-cert,代码行数:48,


示例21: setenv_x509_serialnumber

static int setenv_x509_serialnumber(ASN1_INTEGER *i, const char *env){	BIO *bio_out=NULL;	BUF_MEM *bptr=NULL;	char tmpbuf[256]="";	if(!(bio_out=BIO_new(BIO_s_mem())))	{		log_out_of_memory(__func__);		return -1;	}	i2a_ASN1_INTEGER(bio_out, i);	BIO_get_mem_ptr(bio_out, &bptr);	BIO_gets(bio_out, tmpbuf, sizeof(tmpbuf)-1);	BIO_free_all(bio_out);	sanitise(tmpbuf);	setenv(env, (char*)tmpbuf, 1);	return 0;}
开发者ID:adrianimboden,项目名称:burp,代码行数:18,


示例22: setenv_x509_date

static int setenv_x509_date(ASN1_TIME *tm, const char *env){	BIO *bio_out=NULL;	BUF_MEM *bptr=NULL;	char tmpbuf[256]="";	if(!(bio_out=BIO_new(BIO_s_mem())))	{		log_out_of_memory(__func__);		return -1;	}	ASN1_TIME_print(bio_out, tm);	BIO_get_mem_ptr(bio_out, &bptr);	BIO_gets(bio_out, tmpbuf, sizeof(tmpbuf)-1);	BIO_free_all(bio_out);	sanitise(tmpbuf);	setenv(env, (char*)tmpbuf, 1);	return 0;}
开发者ID:adrianimboden,项目名称:burp,代码行数:18,


示例23: mite_MD5_BIOCal

//BIO调用方式void mite_MD5_BIOCal(char *buffer,unsigned long length,unsigned char *md5){	BIO* bio_null;	BIO* bio_md;	bio_null = BIO_new(BIO_s_null());	bio_md = BIO_new(BIO_f_md());	BIO_set_md(bio_md,EVP_md5());	bio_md = BIO_push(bio_md,bio_null);	BIO_write(bio_md,buffer,length);	BIO_flush(bio_md);	//int len = BIO_gets(bio_md,(char *)md5,EVP_MAX_MD_SIZE);	//数据经过这种BIO不会被修改也不会被保留,只有摘要值是保留的	//所以需要用BIO_gets而不是BIO_read获取数据	BIO_gets(bio_md,(char *)md5,EVP_MAX_MD_SIZE);	BIO_free_all(bio_md);	//BIO_free_all(bio_null); 段错误}
开发者ID:LiTianjue,项目名称:libmite,代码行数:20,


示例24: BIO_gets

BIGNUM *ReadNumber(BIO *in,const char *szTitle)    {    char szLine[10240];    unsigned char aucBN[1024];    int nTLen=int (strlen(szTitle));    BIO_gets(in,szLine,sizeof szLine-1);    if(strncmp(szLine,szTitle,nTLen))	{#ifndef ANDROID	fprintf(stderr,"Got %s, expected %s/n",szLine,szTitle);#endif	assert(!"Unexpected input");  // TODO Find out what this exclamation point is for...	return NULL;	}    BIGNUM *bn=BN_new();    int n=int (strcspn(szLine+nTLen,"/r/n"));    szLine[nTLen+n]='/0';    if(n&1)	{	memmove(szLine+nTLen+1,szLine+nTLen,n+1);	szLine[nTLen]='0';	}    for(n=0 ; szLine[nTLen+n*2] ; ++n)	{	int h;	sscanf(&szLine[nTLen+n*2],"%02x",&h);	aucBN[n]=(unsigned char)h;	}	    BN_bin2bn(aucBN,n,bn);    return bn;    }
开发者ID:1974kpkpkp,项目名称:Open-Transactions,代码行数:37,


示例25: a2i_ASN1_STRING

int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)	{	int ret=0;	int i,j,k,m,n,again,bufsize;	unsigned char *s=NULL,*sp;	unsigned char *bufp;	int num=0,slen=0,first=1;	bufsize=BIO_gets(bp,buf,size);	for (;;)		{		if (bufsize < 1)			{			if (first)				break;			else				goto err_sl;			}		first=0;		i=bufsize;		if (buf[i-1] == '/n') buf[--i]='/0';		if (i == 0) goto err_sl;		if (buf[i-1] == '/r') buf[--i]='/0';		if (i == 0) goto err_sl;		again=(buf[i-1] == '//');		for (j=i-1; j>0; j--)			{#ifndef CHARSET_EBCDIC			if (!(	((buf[j] >= '0') && (buf[j] <= '9')) ||				((buf[j] >= 'a') && (buf[j] <= 'f')) ||				((buf[j] >= 'A') && (buf[j] <= 'F'))))#else			/* This #ifdef is not strictly necessary, since			 * the characters A...F a...f 0...9 are contiguous			 * (yes, even in EBCDIC - but not the whole alphabet).			 * Nevertheless, op_isxdigit() is faster.			 */			if (!op_isxdigit(buf[j]))#endif				{				i=j;				break;				}			}		buf[i]='/0';		/* We have now cleared all the crap off the end of the		 * line */		if (i < 2) goto err_sl;		bufp=(unsigned char *)buf;		k=0;		i-=again;		if (i%2 != 0)			{			ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_ODD_NUMBER_OF_CHARS);			goto err;			}		i/=2;		if (num+i > slen)			{			if (s == NULL)				sp=(unsigned char *)OPENSSL_malloc(					(unsigned int)num+i*2);			else				sp=(unsigned char *)OPENSSL_realloc(s,					(unsigned int)num+i*2);			if (sp == NULL)				{				ASN1err(ASN1_F_A2I_ASN1_STRING,ERR_R_MALLOC_FAILURE);				if (s != NULL) OPENSSL_free(s);				goto err;				}			s=sp;			slen=num+i*2;			}		for (j=0; j<i; j++,k+=2)			{			for (n=0; n<2; n++)				{				m=bufp[k+n];				if ((m >= '0') && (m <= '9'))					m-='0';				else if ((m >= 'a') && (m <= 'f'))					m=m-'a'+10;				else if ((m >= 'A') && (m <= 'F'))					m=m-'A'+10;				else					{					ASN1err(ASN1_F_A2I_ASN1_STRING,ASN1_R_NON_HEX_CHARACTERS);					goto err;					}				s[num+j]<<=4;				s[num+j]|=m;				}			}		num+=i;		if (again)//.........这里部分代码省略.........
开发者ID:prestocore,项目名称:browser,代码行数:101,


示例26: PEM_read_bio

int PEM_read_bio(BIO *bp, char **name, char **header, unsigned char **data,       long *len)  {  EVP_ENCODE_CTX ctx;  int end=0,i,k,bl=0,hl=0,nohead=0;  char buf[256];  BUF_MEM *nameB;  BUF_MEM *headerB;  BUF_MEM *dataB,*tmpB;    nameB=BUF_MEM_new();  headerB=BUF_MEM_new();  dataB=BUF_MEM_new();  if ((nameB == NULL) || (headerB == NULL) || (dataB == NULL))    {    BUF_MEM_free(nameB);    BUF_MEM_free(headerB);    BUF_MEM_free(dataB);    PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE);    return(0);    }  buf[254]='/0';  for (;;)    {    i=BIO_gets(bp,buf,254);    if (i <= 0)      {      PEMerr(PEM_F_PEM_READ_BIO,PEM_R_NO_START_LINE);      goto err;      }    while ((i >= 0) && (buf[i] <= ' ')) i--;    buf[++i]='/n'; buf[++i]='/0';    if (strncmp(buf,"-----BEGIN ",11) == 0)      {      i=strlen(&(buf[11]));      if (strncmp(&(buf[11+i-6]),"-----/n",6) != 0)        continue;      if (!BUF_MEM_grow(nameB,i+9))        {        PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE);        goto err;        }      memcpy(nameB->data,&(buf[11]),i-6);      nameB->data[i-6]='/0';      break;      }    }  hl=0;  if (!BUF_MEM_grow(headerB,256))    { PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; }  headerB->data[0]='/0';  for (;;)    {    i=BIO_gets(bp,buf,254);    if (i <= 0) break;    while ((i >= 0) && (buf[i] <= ' ')) i--;    buf[++i]='/n'; buf[++i]='/0';    if (buf[0] == '/n') break;    if (!BUF_MEM_grow(headerB,hl+i+9))      { PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; }    if (strncmp(buf,"-----END ",9) == 0)      {      nohead=1;      break;      }    memcpy(&(headerB->data[hl]),buf,i);    headerB->data[hl+i]='/0';    hl+=i;    }  bl=0;  if (!BUF_MEM_grow(dataB,1024))    { PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE); goto err; }  dataB->data[0]='/0';  if (!nohead)    {    for (;;)      {      i=BIO_gets(bp,buf,254);      if (i <= 0) break;      while ((i >= 0) && (buf[i] <= ' ')) i--;      buf[++i]='/n'; buf[++i]='/0';      if (i != 65) end=1;      if (strncmp(buf,"-----END ",9) == 0)        break;      if (i > 65) break;      if (!BUF_MEM_grow_clean(dataB,i+bl+9))        {        PEMerr(PEM_F_PEM_READ_BIO,ERR_R_MALLOC_FAILURE);        goto err;        }//.........这里部分代码省略.........
开发者ID:yyyyyao,项目名称:Slicer3-lib-mirrors,代码行数:101,


示例27: do_fp

int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,          EVP_PKEY *key, unsigned char *sigin, int siglen,          const char *sig_name, const char *md_name,          const char *file, BIO *bmd){    size_t len;    int i;    for (;;) {        i = BIO_read(bp, (char *)buf, BUFSIZE);        if (i < 0) {            BIO_printf(bio_err, "Read Error in %s/n", file);            ERR_print_errors(bio_err);            return 1;        }        if (i == 0)            break;    }    if (sigin) {        EVP_MD_CTX *ctx;        BIO_get_md_ctx(bp, &ctx);        i = EVP_DigestVerifyFinal(ctx, sigin, (unsigned int)siglen);        if (i > 0)            BIO_printf(out, "Verified OK/n");        else if (i == 0) {            BIO_printf(out, "Verification Failure/n");            return 1;        } else {            BIO_printf(bio_err, "Error Verifying Data/n");            ERR_print_errors(bio_err);            return 1;        }        return 0;    }    if (key) {        EVP_MD_CTX *ctx;        BIO_get_md_ctx(bp, &ctx);        len = BUFSIZE;        if (!EVP_DigestSignFinal(ctx, buf, &len)) {            BIO_printf(bio_err, "Error Signing Data/n");            ERR_print_errors(bio_err);            return 1;        }    } else {        len = BIO_gets(bp, (char *)buf, BUFSIZE);        if ((int)len < 0) {            ERR_print_errors(bio_err);            return 1;        }    }    if (binout)        BIO_write(out, buf, len);    else if (sep == 2) {        for (i = 0; i < (int)len; i++)            BIO_printf(out, "%02x", buf[i]);        BIO_printf(out, " *%s/n", file);    } else {        if (sig_name) {            BIO_puts(out, sig_name);            if (md_name)                BIO_printf(out, "-%s", md_name);            BIO_printf(out, "(%s)= ", file);        } else if (md_name)            BIO_printf(out, "%s(%s)= ", md_name, file);        else            BIO_printf(out, "(%s)= ", file);        for (i = 0; i < (int)len; i++) {            if (sep && (i != 0))                BIO_printf(out, ":");            BIO_printf(out, "%02x", buf[i]);        }        BIO_printf(out, "/n");    }    return 0;}
开发者ID:GH-JY,项目名称:openssl,代码行数:76,


示例28: MAIN

//.........这里部分代码省略.........    if (c_debug)    {        con->debug=1;        BIO_set_callback(sbio,bio_dump_callback);        BIO_set_callback_arg(sbio,(char *)bio_c_out);    }    if (c_msg)    {        SSL_set_msg_callback(con, msg_cb);        SSL_set_msg_callback_arg(con, bio_c_out);    }    SSL_set_bio(con,sbio,sbio);    SSL_set_connect_state(con);    /* ok, lets connect */    width=SSL_get_fd(con)+1;    read_tty=1;    write_tty=0;    tty_on=0;    read_ssl=1;    write_ssl=1;    cbuf_len=0;    cbuf_off=0;    sbuf_len=0;    sbuf_off=0;    /* This is an ugly hack that does a lot of assumptions */    /* We do have to handle multi-line responses which may come       in a single packet or not. We therefore have to use       BIO_gets() which does need a buffering BIO. So during       the initial chitchat we do push a buffering BIO into the       chain that is removed again later on to not disturb the       rest of the s_client operation. */    if (starttls_proto == PROTO_SMTP)    {        int foundit=0;        BIO *fbio = BIO_new(BIO_f_buffer());        BIO_push(fbio, sbio);        /* wait for multi-line response to end from SMTP */        do        {            mbuf_len = BIO_gets(fbio,mbuf,BUFSIZZ);        }        while (mbuf_len>3 && mbuf[3]=='-');        /* STARTTLS command requires EHLO... */        BIO_printf(fbio,"EHLO openssl.client.net/r/n");        (void)BIO_flush(fbio);        /* wait for multi-line response to end EHLO SMTP response */        do        {            mbuf_len = BIO_gets(fbio,mbuf,BUFSIZZ);            if (strstr(mbuf,"STARTTLS"))                foundit=1;        }        while (mbuf_len>3 && mbuf[3]=='-');        (void)BIO_flush(fbio);        BIO_pop(fbio);        BIO_free(fbio);        if (!foundit)            BIO_printf(bio_err,                       "didn't found starttls in server response,"                       " try anyway.../n");
开发者ID:peterlingoal,项目名称:openssl,代码行数:67,


示例29: def_load_bio

static int def_load_bio(CONF *conf, BIO *in, long *line){/* The macro BUFSIZE conflicts with a system macro in VxWorks */#define CONFBUFSIZE     512    int bufnum = 0, i, ii;    BUF_MEM *buff = NULL;    char *s, *p, *end;    int again;    long eline = 0;    char btmp[DECIMAL_SIZE(eline) + 1];    CONF_VALUE *v = NULL, *tv;    CONF_VALUE *sv = NULL;    char *section = NULL, *buf;    char *start, *psection, *pname;    void *h = (void *)(conf->data);    STACK_OF(BIO) *biosk = NULL;#ifndef OPENSSL_NO_POSIX_IO    char *dirpath = NULL;    OPENSSL_DIR_CTX *dirctx = NULL;#endif    if ((buff = BUF_MEM_new()) == NULL) {        CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);        goto err;    }    section = OPENSSL_strdup("default");    if (section == NULL) {        CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);        goto err;    }    if (_CONF_new_data(conf) == 0) {        CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);        goto err;    }    sv = _CONF_new_section(conf, section);    if (sv == NULL) {        CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);        goto err;    }    bufnum = 0;    again = 0;    for (;;) {        if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) {            CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);            goto err;        }        p = &(buff->data[bufnum]);        *p = '/0'; read_retry:        BIO_gets(in, p, CONFBUFSIZE - 1);        p[CONFBUFSIZE - 1] = '/0';        ii = i = strlen(p);        if (i == 0 && !again) {            /* the currently processed BIO is at EOF */            BIO *parent;#ifndef OPENSSL_NO_POSIX_IO            /* continue processing with the next file from directory */            if (dirctx != NULL) {                BIO *next;                if ((next = get_next_file(dirpath, &dirctx)) != NULL) {                    BIO_vfree(in);                    in = next;                    goto read_retry;                } else {                    OPENSSL_free(dirpath);                    dirpath = NULL;                }            }#endif            /* no more files in directory, continue with processing parent */            if ((parent = sk_BIO_pop(biosk)) == NULL) {                /* everything processed get out of the loop */                break;            } else {                BIO_vfree(in);                in = parent;                goto read_retry;            }        }        again = 0;        while (i > 0) {            if ((p[i - 1] != '/r') && (p[i - 1] != '/n'))                break;            else                i--;        }        /*         * we removed some trailing stuff so there is a new line on the end.         */        if (ii && i == ii)            again = 1;          /* long line */        else {            p[i] = '/0';            eline++;            /* another input line *///.........这里部分代码省略.........
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:101,


示例30: get_header_and_data

/** * Extract the optional PEM header, with details on the type of content and * any encryption used on the contents, and the bulk of the data from the bio. * The end of the header is marked by a blank line; if the end-of-input marker * is reached prior to a blank line, there is no header. * * The header and data arguments are BIO** since we may have to swap them * if there is no header, for efficiency. * * We need the name of the PEM-encoded type to verify the end string. */static int get_header_and_data(BIO *bp, BIO **header, BIO **data, char *name,                               unsigned int flags){    BIO *tmp = *header;    char *linebuf, *p;    int len, line, ret = 0, end = 0;    /* 0 if not seen (yet), 1 if reading header, 2 if finished header */    enum header_status got_header = MAYBE_HEADER;    unsigned int flags_mask;    size_t namelen;    /* Need to hold trailing NUL (accounted for by BIO_gets() and the newline     * that will be added by sanitize_line() (the extra '1'). */    linebuf = pem_malloc(LINESIZE + 1, flags);    if (linebuf == NULL) {        PEMerr(PEM_F_GET_HEADER_AND_DATA, ERR_R_MALLOC_FAILURE);        return 0;    }    for (line = 0; ; line++) {        flags_mask = ~0u;        len = BIO_gets(bp, linebuf, LINESIZE);        if (len <= 0) {            PEMerr(PEM_F_GET_HEADER_AND_DATA, PEM_R_SHORT_HEADER);            goto err;        }        if (got_header == MAYBE_HEADER) {            if (memchr(linebuf, ':', len) != NULL)                got_header = IN_HEADER;        }        if (!strncmp(linebuf, endstr, ENDLEN) || got_header == IN_HEADER)            flags_mask &= ~PEM_FLAG_ONLY_B64;        len = sanitize_line(linebuf, len, flags & flags_mask);        /* Check for end of header. */        if (linebuf[0] == '/n') {            if (got_header == POST_HEADER) {                /* Another blank line is an error. */                PEMerr(PEM_F_GET_HEADER_AND_DATA, PEM_R_BAD_END_LINE);                goto err;            }            got_header = POST_HEADER;            tmp = *data;            continue;        }        /* Check for end of stream (which means there is no header). */        if (strncmp(linebuf, endstr, ENDLEN) == 0) {            p = linebuf + ENDLEN;            namelen = strlen(name);            if (strncmp(p, name, namelen) != 0 ||                strncmp(p + namelen, tailstr, TAILLEN) != 0) {                PEMerr(PEM_F_GET_HEADER_AND_DATA, PEM_R_BAD_END_LINE);                goto err;            }            if (got_header == MAYBE_HEADER) {                *header = *data;                *data = tmp;            }            break;        } else if (end) {            /* Malformed input; short line not at end of data. */            PEMerr(PEM_F_GET_HEADER_AND_DATA, PEM_R_BAD_END_LINE);            goto err;        }        /*         * Else, a line of text -- could be header or data; we don't         * know yet.  Just pass it through.         */        if (BIO_puts(tmp, linebuf) < 0)            goto err;        /*         * Only encrypted files need the line length check applied.         */        if (got_header == POST_HEADER) {            /* 65 includes the trailing newline */            if (len > 65)                goto err;            if (len < 65)                end = 1;        }    }    ret = 1;err:    pem_free(linebuf, flags, LINESIZE + 1);    return ret;}
开发者ID:Ana06,项目名称:openssl,代码行数:100,



注:本文中的BIO_gets函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BIO_indent函数代码示例
C++ BIO_get_ssl函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。