Esempio n. 1
0
int BIO_new_bio_pair(BIO** bio1_p, size_t writebuf1_len,
                     BIO** bio2_p, size_t writebuf2_len) {
  BIO *bio1 = BIO_new(bio_s_bio());
  BIO *bio2 = BIO_new(bio_s_bio());
  if (bio1 == NULL || bio2 == NULL ||
      !bio_make_pair(bio1, bio2, writebuf1_len, writebuf2_len)) {
    BIO_free(bio1);
    BIO_free(bio2);
    *bio1_p = NULL;
    *bio2_p = NULL;
    return 0;
  }

  *bio1_p = bio1;
  *bio2_p = bio2;
  return 1;
}
Esempio n. 2
0
int BIO_new_bio_pair_external_buf(BIO** bio1_p, size_t writebuf1_len,
                                  uint8_t* ext_writebuf1,
                                  BIO** bio2_p, size_t writebuf2_len,
                                  uint8_t* ext_writebuf2) {
    BIO *bio1 = NULL, *bio2 = NULL;
    int ret = 0;

    /* External buffers must have sizes greater than 0. */
    if ((ext_writebuf1 && !writebuf1_len) || (ext_writebuf2 && !writebuf2_len)) {
        goto err;
    }

    bio1 = BIO_new(bio_s_bio());
    if (bio1 == NULL) {
        goto err;
    }
    bio2 = BIO_new(bio_s_bio());
    if (bio2 == NULL) {
        goto err;
    }

    if (!bio_make_pair(bio1, bio2, writebuf1_len, ext_writebuf1, writebuf2_len,
                       ext_writebuf2)) {
        goto err;
    }
    ret = 1;

err:
    if (ret == 0) {
        if (bio1) {
            BIO_free(bio1);
            bio1 = NULL;
        }
        if (bio2) {
            BIO_free(bio2);
            bio2 = NULL;
        }
    }

    *bio1_p = bio1;
    *bio2_p = bio2;
    return ret;
}