pike.git / src / post_modules / Nettle / cipher.cmod

version» Context lines:

pike.git/src/post_modules/Nettle/cipher.cmod:4103:    apply_external(1, f_Nettle_Cipher_block_size_fun_num, args);    }       PIKEFUN int(1..) key_size()    {    apply_external(1, f_Nettle_Cipher_key_size_fun_num, args);    }       PIKEFUN int(1..) iv_size()    { -  apply_external(1, f_Nettle_Cipher_block_size_fun_num, args); +  push_int(13);    }       /*! @class State    */    PIKECLASS State    program_flags PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT;    {    /*! @decl inherit CTR::State    */   
pike.git/src/post_modules/Nettle/cipher.cmod:4218:    apply_current(ccm_state_inh_ctr_state_set_decrypt_key_fun_num, args);    }       PIKEFUN object(Nettle_AEAD_State) set_iv(string(8bit) iv)    {    int iv_len = iv->len;    uint8_t *ctr_iv;       iv->flags |= STRING_CLEAR_ON_EXIT;    NO_WIDE_STRING(iv); +  if (iv_len < 7 || iv_len > 13) { +  Pike_error("Nonce length must be between 7 and 13 bytes.\n"); +  }       reset_string_builder(&THIS->abuf);    reset_string_builder(&THIS->pbuf); -  if (iv_len < 7) { -  Pike_error("Too short nonce for CCM. Must be at least 7 bytes.\n"); -  } +     if (THIS->nonce) {    free_string(THIS->nonce);    THIS->nonce = NULL;    } -  if (iv_len > 13) { -  THIS->nonce = string_slice(iv, 0, 12); -  iv_len = 13; -  } else { +     add_ref(THIS->nonce = iv); -  } +        ctr_iv = STR0(THIS->ctr->iv);       *(ctr_iv++) = 14 - iv_len;       memcpy(ctr_iv, STR0(iv), iv_len);    memset(ctr_iv + iv_len, 0, 15 - iv_len);       RETURN this_object();    }    -  +  PIKEFUN int(0..) iv_size() +  optflags OPT_EXTERNAL_DEPEND; +  { +  if( THIS->nonce ) +  push_int(THIS->nonce->len); +  else +  push_int(13); +  } +  +     PIKEFUN object(Nettle_AEAD_State) update(string(8bit) public_data)    {    if (!public_data->len) return;       NO_WIDE_STRING(public_data);       string_builder_shared_strcat(&THIS->abuf, public_data);       RETURN this_object();    }