Lines Matching refs:ctx

7 static int check_multipart( mbedtls_gcm_context *ctx,
28 TEST_EQUAL( 0, mbedtls_gcm_starts( ctx, mode,
30 TEST_EQUAL( 0, mbedtls_gcm_update_ad( ctx, add->x, n1_add ) );
31 TEST_EQUAL( 0, mbedtls_gcm_update_ad( ctx, add->x + n1_add, n2_add ) );
38 TEST_EQUAL( 0, mbedtls_gcm_update( ctx, input->x, n1, output, n1, &olen ) );
46 TEST_EQUAL( 0, mbedtls_gcm_update( ctx, input->x + n1, n2, output, n2, &olen ) );
53 TEST_EQUAL( 0, mbedtls_gcm_finish( ctx, NULL, 0, &olen, output, tag->len ) );
65 static void check_cipher_with_empty_ad( mbedtls_gcm_context *ctx,
80 TEST_EQUAL( 0, mbedtls_gcm_starts( ctx, mode,
85 TEST_EQUAL( 0, mbedtls_gcm_update_ad( ctx, NULL, 0 ) );
93 TEST_EQUAL( 0, mbedtls_gcm_update( ctx, input->x, input->len, output, input->len, &olen ) );
100 TEST_EQUAL( 0, mbedtls_gcm_finish( ctx, NULL, 0, &olen, output, tag->len ) );
108 static void check_empty_cipher_with_ad( mbedtls_gcm_context *ctx,
119 TEST_EQUAL( 0, mbedtls_gcm_starts( ctx, mode, iv->x, iv->len ) );
120 TEST_EQUAL( 0, mbedtls_gcm_update_ad( ctx, add->x, add->len ) );
125 TEST_EQUAL( 0, mbedtls_gcm_update( ctx, NULL, 0, NULL, 0, &olen ) );
130 TEST_EQUAL( 0, mbedtls_gcm_finish( ctx, NULL, 0, &olen,
139 static void check_no_cipher_no_ad( mbedtls_gcm_context *ctx,
147 TEST_EQUAL( 0, mbedtls_gcm_starts( ctx, mode,
150 TEST_EQUAL( 0, mbedtls_gcm_finish( ctx, NULL, 0, &olen, output, tag->len ) );
173 mbedtls_gcm_context ctx;
176 mbedtls_gcm_init( &ctx );
181 TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
182 TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, direction, src_str->len, iv_str->x, iv_str->len,
186 mbedtls_gcm_free( &ctx );
199 mbedtls_gcm_context ctx;
204 mbedtls_gcm_init( &ctx );
210 … TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == init_result );
213 …TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT, src_str->len, iv_str->x, iv_str…
223 if( !check_multipart( &ctx, MBEDTLS_GCM_ENCRYPT,
233 mbedtls_gcm_free( &ctx );
245 mbedtls_gcm_context ctx;
251 mbedtls_gcm_init( &ctx );
256 … TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == init_result );
259 …ret = mbedtls_gcm_auth_decrypt( &ctx, src_str->len, iv_str->x, iv_str->len, add_str->x, add_str->l…
275 if( !check_multipart( &ctx, MBEDTLS_GCM_DECRYPT,
286 mbedtls_gcm_free( &ctx );
298 mbedtls_gcm_context ctx;
300 mbedtls_gcm_init( &ctx );
302 TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
303 check_empty_cipher_with_ad( &ctx, MBEDTLS_GCM_DECRYPT,
307 mbedtls_gcm_free( &ctx );
320 mbedtls_gcm_context ctx;
322 mbedtls_gcm_init( &ctx );
324 TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
325 check_cipher_with_empty_ad( &ctx, MBEDTLS_GCM_DECRYPT,
329 mbedtls_gcm_free( &ctx );
339 mbedtls_gcm_context ctx;
341 mbedtls_gcm_init( &ctx );
343 TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
344 check_no_cipher_no_ad( &ctx, MBEDTLS_GCM_DECRYPT,
347 mbedtls_gcm_free( &ctx );
359 mbedtls_gcm_context ctx;
361 mbedtls_gcm_init( &ctx );
363 TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
364 check_empty_cipher_with_ad( &ctx, MBEDTLS_GCM_ENCRYPT,
369 mbedtls_gcm_free( &ctx );
382 mbedtls_gcm_context ctx;
384 mbedtls_gcm_init( &ctx );
386 TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
387 check_cipher_with_empty_ad( &ctx, MBEDTLS_GCM_ENCRYPT,
392 mbedtls_gcm_free( &ctx );
402 mbedtls_gcm_context ctx;
404 mbedtls_gcm_init( &ctx );
406 TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
407 check_no_cipher_no_ad( &ctx, MBEDTLS_GCM_ENCRYPT,
410 mbedtls_gcm_free( &ctx );
417 mbedtls_gcm_context ctx;
422 mbedtls_gcm_init( &ctx );
427 mbedtls_gcm_setkey( &ctx, valid_cipher, valid_buffer, invalid_bitlen ) );
430 mbedtls_gcm_free( &ctx );
439 mbedtls_gcm_context ctx;
444 mbedtls_gcm_init( &ctx );
445 TEST_EQUAL( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ), 0 );
446 TEST_EQUAL( 0, mbedtls_gcm_starts( &ctx, mode, iv->x, iv->len ) );
449 …TEST_EQUAL( MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL, mbedtls_gcm_update( &ctx, input->x, input->len, outp…
453 mbedtls_gcm_free( &ctx );