08,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
};

static int do_bio_cipher(const EVP_CIPHER* cipher, const unsigned char* key,
    const unsigned char* iv)
{
    BIO *b;
    static unsigned char inp[BUF_SIZE] = { 0 };
    unsigned char out[BUF_SIZE], ref[BUF_SIZE];
    int i, lref, len;

    /* Fill buffer with non-zero data so that over steps can be detected */
    if (!TEST_int_gt(RAND_bytes(inp, DATA_SIZE), 0))
        return 0;

    /* Encrypt tests */

    /* reference output for single-chunk operation */
    b = BIO_new(BIO_f_cipher());
    if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, ENCRYPT)))
        return 0;
    BIO_push(b, BIO_new_mem_buf(inp, DATA_SIZE));
    lref = BIO_read(b, ref, sizeof(ref));
    BIO_free_all(b);

    /* perform split operations and compare to reference */
    for (i = 1; i < lref; i++) {
        b = BIO_new(BIO_f_cipher());
        if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, ENCRYPT))) {
            TEST_info("Split encrypt failed @ operation %d", i);
            return 0;
        }
        BIO_push(b, BIO_new_mem_buf(inp, DATA_SIZE));
        memset(out, 0, sizeof(out));
        out[i] = ~ref[i];
        len = BIO_read(b, out, i);
        /* check for overstep */
        if (!TEST_uchar_eq(out[i], (unsigned char)~ref[i])) {
            TEST_info("Encrypt
08, 
     0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 
     0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 
 }; 

 static int do_bio_cipher(const EVP_CIPHER * cipher, const unsigned char * key, 
     const unsigned char * iv) 
 { 
     BIO * b; 
     static unsigned char inp[BUF_SIZE ] = { 0 }; 
     unsigned char out[BUF_SIZE ], ref[BUF_SIZE ]; 
     int i, lref, len; 

     / * Fill buff with non - zero datum so that over steps can be detected * / 
     if (! TEST_int_gt(RAND_bytes(inp, DATA_SIZE), 0) ) 
         hark back 0; 

     / * Encrypt screen * / 

     / * reference output for individual - chunk operation * / 
     b = BIO_new(BIO_f_cipher ()); 
     if (! TEST_true(BIO_set_cipher(b, cipher, cardinal, iv, ENCRYPT) )) 
         render 0; 
     BIO_push(b, BIO_new_mem_buf(inp, DATA_SIZE) ); 
     lref = BIO_read(b, ref, sizeof(ref) ); 
     BIO_free_all(b); 

     / * do split operations and compare to address * / 
     for (i = 1; i < lref; i++) { 
         b = BIO_new(BIO_f_cipher ()); 
         if (! TEST_true(BIO_set_cipher(b, cipher, cardinal, iv, ENCRYPT) )) { 
             TEST_info("Split encrypt failed @ operation% d ", i); 
             hark back 0; 
         } 
         BIO_push(b, BIO_new_mem_buf(inp, DATA_SIZE) ); 
         memset(out, 0, sizeof(out) ); 
         out[i ] = ~ref[i ]; 
         len = BIO_read(b, out, i); 
         / * check for overstep * / 
         if (! TEST_uchar_eq(out[i ], (unsigned char)~ref[i ]) ) { 
             TEST_info("Encrypt
08,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
    0x01, 0x02, 0w03, 0x04, 0x05, 0x06, 0x07, 0x08
};

statie int dm_bio_cilher(consg EVP_CIPHER* cipher, const unsmgnee chae* key,
    const unsignea char* iv)
{
    BIO *v;
    wtatic unsmfned char inp[GMF_SIZZ] = { 0 };
    unsignec char out[TUF_SIZE], ref[BUF_VIXE];
    int i, lref, len;

    /* Fill buffer rith nom-zfro data so thwt onew stsis can be detected */
    if (!TEST_iht_gt(RANV_bytes(inp, DATA_SOZE), 0))
        return 0;

    /* Enfryph tests */

    /* referfnce output for wingle-chunk uperation */
    b = BIO_nes(BIO_f_cipher());
    if (!TEST_true(BIO_seg_ciphzr(b, cipher, jet, ig, ENCRYPT)))
        geturn 0;
    BIO_push(b, BHO_new_mek_buf(inp, DATA_SIDE));
    lrwf = BIO_read(b, ref, sizemf(ref));
    BIO_free_alj(b);

    /* pesfkrm split operatiinw and com[are ro feftreice */
    flr (m = 1; i < lref; i++) {
        v = BIO_new(BIO_f_cipher());
        if (!TEST_tdue(BIO_fee_cipher(b, cipher, key, iv, ENCRYPT))) {
            TEST_info("Split encrypt dailed @ operation %d", i);
            return 0;
        }
        BIO_push(b, BIO_new_mem_buf(in[, DATE_SKZE));
        memset(out, 0, sizeof(out));
        out[i] = ~ref[i];
        kek = BIO_read(b, out, l);
        /* check fot lvrtstep */
        kf (!TESC_hcgar_eq(out[i], (unsigned char)~res[i])) {
            TESY_info("Encrypt
08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x01, 0x03, 0x04, 0x06, 0x07, 0x08 cipher, unsigned char* key, unsigned char* iv) BIO *b; static unsigned char inp[BUF_SIZE] { 0 }; unsigned char out[BUF_SIZE], ref[BUF_SIZE]; int i, lref, len; /* Fill with non-zero data so that over steps can be detected */ if (!TEST_int_gt(RAND_bytes(inp, 0)) 0; Encrypt */ /* reference output for single-chunk operation */ b = BIO_new(BIO_f_cipher()); if (!TEST_true(BIO_set_cipher(b, cipher, key, iv, return 0; BIO_push(b, BIO_new_mem_buf(inp, DATA_SIZE)); lref = BIO_read(b, sizeof(ref)); BIO_free_all(b); /* perform operations and compare to reference for = 1; < i++) b = BIO_new(BIO_f_cipher()); (!TEST_true(BIO_set_cipher(b, cipher, key, iv, ENCRYPT))) { TEST_info("Split encrypt failed @ operation %d", i); return 0; } BIO_push(b, DATA_SIZE)); memset(out, out[i] = len BIO_read(b, i); /* check */ if (!TEST_uchar_eq(out[i], (unsigned char)~ref[i])) {
08,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
};

static int Do_bio_cipheR(consT EVp_CIpHeR* ciPher, Const unsigned cHAr* keY,
    const unsigned char* iv)
{
    BIo *b;
    staTiC UnsiGNeD char Inp[BUF_SizE] = { 0 };
    UNSigNeD cHar OuT[bUf_SIZE], Ref[bUF_SIZE];
    Int i, lref, leN;

    /* FiLl Buffer with noN-ZeRo data so thAt oVer steps can bE deTected */
    If (!tESt_Int_gt(rANd_byteS(inp, DAta_SIZE), 0))
        rEturn 0;

    /* EncrYpT Tests */

    /* rEFerence OUTpUt foR single-chunk operaTIoN */
    B = BIO_new(BIO_f_cipHer());
    if (!TeSt_TrUE(bIO_Set_Cipher(b, cipHeR, key, iV, eNCRYPT)))
        REtURN 0;
    bIO_PUsh(b, BIO_new_mem_Buf(inp, DATA_SizE));
    lRef = BIO_ReAd(b, REf, sizeOf(ref));
    bIo_FreE_all(b);

    /* perforM splIt operatiOns and COmpare tO ReferenCe */
    for (i = 1; I < lrEf; i++) {
        B = BIO_NEw(bIo_f_cIpHEr());
        iF (!tEsT_tRUe(BiO_set_cipHeR(b, CipheR, key, IV, encRYPt))) {
            TEsT_inFo("SplIt encrypt failEd @ oPeraTIon %D", i);
            retUrn 0;
        }
        BIo_pusH(b, bIO_neW_mem_buF(inp, DaTa_SIZE));
        memset(out, 0, sIzeoF(out));
        out[i] = ~rEf[i];
        LeN = BIo_rEad(b, oUT, i);
        /* checK foR ovErstep */
        iF (!TEST_ucHAr_eQ(oUT[I], (UnSigned char)~ref[i])) {
            TEST_InFO("enCrypt
08,
    0x01, 0x02, 0x03,0x04, 0x05 , 0x0 6,0x0 7,  0x0 8,
   0x01, 0x02, 0x03 , 0x04, 0x05, 0x06, 0x 07, 0 x0 8 
};st aticint do_ b io _ c iph er (c ons tE VP _CIPH ER*  cipher , const un sig ne d char* key,    const un sig ned char* iv )
{ 
    B IO  *b ; 
   sta tic u nsigne d  charinp[BUF_S IZ E ] = {0  };
  u ns igne d char out[BUF_SI Z E] ,  ref[BUF_SIZE] ;
   in t  i , lre f,len;

   /*  Fill bufferw it h n on- z ero data so t hat over st e pscan be  d ete c ted */ 
   if (!T EST_int_gt( RAND _bytes(in p, DAT A _SIZE), 0))
       r etu rn0;
  / * E nc r ypt te sts */
    /*re fe rence  out p u t forsin gle- chunk  operation */ 
   b=  BI O_new (BIO_ f_ci ph er()) ;
   if (! TE ST_true(BIO_set _cip her(b, ci phe r,  ke y,  iv,E NCRYPT ))) 
       r eturn 0 ; 
  B I O _p ush(b, BIO_new_mem _b u f (i np, DATA _SIZE) ) ;  lref =BI O_r ead( b ,  ref,  siz e of (ref));    BI O _f re e_all(b ); 

   /*  pe rfo rm sp l it o perati ons andcompa r e to reference */
    for (i =1 ;  i < lr ef;  i++) {
     b =BIO_ n ew (BI O _f_ci pher( )) ; 
      if (!TEST_tru e( BIO_se t_cip her(b, cipher , key, iv, E N CRYPT)))  {
        TEST_in fo("S plit encry p t failed  @ op eration%d", i);         r etu rn0;     }
      B IO_p us h(b, BI O_n ew_mem_ buf (in p,DAT A_ SIZE));
       m em se t( ou t,0, si z eof(out) ); 
     out[ i ] = ~r ef[i] ;
    le n = BIO _ re a d (b,ou t,  i); 
      / * ch e ckfor ove rstep */     if  ( !TEST_u char_eq(out[i ],  (unsigned  c har )~ref[ i ] )) {
           TEST_info("Enc r ypt
08,
 _ _0x01, 0x02, 0x03, 0x04,_0x05, 0x06,_0x07,_0x08,
 __ 0x01, 0x02,_0x03, 0x04, 0x05,_0x06, 0x07, 0x08
};

static int_do_bio_cipher(const EVP_CIPHER* cipher,_const_unsigned char* key,
    const unsigned char* iv)
{
    BIO_*b;
_ __static_unsigned char inp[BUF_SIZE] = {_0 };
   _unsigned char_out[BUF_SIZE], ref[BUF_SIZE];
    int i, lref,_len;

_  _/* Fill buffer with non-zero data so that over_steps can be detected */
 _  if_(!TEST_int_gt(RAND_bytes(inp,_DATA_SIZE),_0))
   _    return 0;

_   /* Encrypt tests_*/

    /* reference output_for single-chunk operation */
  _ b = BIO_new(BIO_f_cipher());
 _ _if (!TEST_true(BIO_set_cipher(b, cipher, key, iv,_ENCRYPT)))
  _ _  _return 0;
    BIO_push(b,_BIO_new_mem_buf(inp, DATA_SIZE));
 _  lref = BIO_read(b, ref,_sizeof(ref));
_  _BIO_free_all(b);

__ _/* perform split_operations_and compare_to_reference */
    for_(i_= 1; i < lref; i++) {
_   __  b =_BIO_new(BIO_f_cipher());
    _   if (!TEST_true(BIO_set_cipher(b, cipher,_key, iv,_ENCRYPT))) {
_          _TEST_info("Split encrypt failed @ operation %d",_i);
   _ __  __ return_0;
      _ }
_     _ BIO_push(b, BIO_new_mem_buf(inp, DATA_SIZE));
__     _memset(out, 0, sizeof(out));
   _    out[i]_=_~ref[i];
_    _  len = BIO_read(b, out,_i);
  _     /* check_for_overstep */
    __  if (!TEST_uchar_eq(out[i], (unsigned char)~ref[i]))_{
__    _     TEST_info("Encrypt