void bar(ivar_t *iv1, ivar_t *iv2, ivar_t *iv3) { int val1, val2, val3; val1 = cilk_spawn read_iv(iv2); write_iv(iv1, (ivar_payload_t) TEST_VAL); val3 = (int) read_iv(iv3); val2 = read_iv(iv2); printf("success in bar %i\n", val1 == val2 == val3); }
void fun() { ivar_t iv1, iv2, iv3; clear_iv(&iv1); clear_iv(&iv2); clear_iv(&iv3); int val1, val3; cilk_spawn bar(&iv1, &iv2, &iv3); val1 = read_iv(&iv1); write_iv(&iv2, (ivar_payload_t) TEST_VAL); val3 = read_iv(&iv2); write_iv(&iv3, (ivar_payload_t) TEST_VAL); printf("returning from fun...this will pop the frame\n"); }
char* serpent_decrypt(uint32_t key[KEY_LENGTH], char* input, int test) { char* output; output = (char*) malloc(sizeof(char)); output[0] = '\0'; int done = F; uint32_t round_keys[NUM_ROUND_KEYS][ROUND_KEY_LENGTH]; uint32_t current_block[BLOCK_LENGTH]; uint32_t past_block[BLOCK_LENGTH]; uint32_t iv[BLOCK_LENGTH]; char** input_ptr = &input; key_schedule(round_keys, key); if (!test) { read_iv(input_ptr, iv); /* If test there isn't an IV */ } memcpy(past_block, iv, BLOCK_LENGTH * BYTE_CHUNK_SIZE); while (!done) { done = decrypt_read_block(input_ptr, current_block); decrypt_block(round_keys, current_block, past_block, output, test); // the function sets current_block from this call to past_block for next } return output; }
void fun() { ivar_t iv; int i; clear_iv(&iv); //fill the ivar before the read write_iv(&iv, (ivar_payload_t) TEST_VAL); //read on the fast path i = read_iv(&iv); if (i != 39) abort(); printf("Ivar read successfully: %d\n", i); }
void fun() { ivar_t iv; int i; clear_iv(&iv); printf("spinning up %d ivar reads if ivar %p on the slow path\n", NREADERS, &iv); //read on the slow path TWICE for(i=0; i < NREADERS; i++) { cilk_spawn read_iv(&iv); } printf("write ivar\n"); //serial write, now the ivar should be full write_iv(&iv, (ivar_payload_t) TEST_VAL); //test the fast path -ivar is full on read printf("read after write -fast path\n"); cilk_spawn bar(&iv); printf("returning from fun...this will pop the frame\n"); }
static int decrypt_input() { Util::CipherInfo ci; ci.name = opt_decrypt; ci.password = opt_password; ci.encrypt = false; ci.aead = is_aead(ci); Util::Cipher cipher(ci); { // restore IV std::string iv; auto params= cipher.get_cipher_params(); ci.iv.resize(params.ivsize); if (ci.aead) { opt_read_size += params.tag_size; } std::ifstream read_iv(opt_iv, std::ifstream::in | std::ifstream::binary); read_iv.read(&ci.iv[0], ci.iv.size()); } cipher.accept(); process_with(cipher); return 0; }
void bar(ivar_t *iv) { int val = (int) read_iv(iv); if (val != TEST_VAL) { printf("TEST ERROR - BAD VALUE, %d, EXPECTED %d - ABORTING!\n", val, TEST_VAL); abort(); } printf("reading i in bar: %d\n", val); }