-/**
- * Construct hash
- *
- * @v context Context
- * @v hash Hash to fill in
- */
-static void gcm_hash ( struct gcm_context *context, union gcm_block *hash ) {
-
- /* Construct big-endian lengths block */
- hash->len.add = cpu_to_be64 ( context->len.len.add );
- hash->len.data = cpu_to_be64 ( context->len.len.data );
- DBGC2 ( context, "GCM %p len(A)||len(C):\n", context );
- DBGC2_HDA ( context, 0, hash, sizeof ( *hash ) );
-
- /* Update hash */
- gcm_xor_block ( &context->hash, hash );
- gcm_multiply_key ( &context->key, hash );
- DBGC2 ( context, "GCM %p GHASH(H,A,C):\n", context );
- DBGC2_HDA ( context, 0, hash, sizeof ( *hash ) );
-}
-
-/**
- * Construct tag
- *
- * @v context Context
- * @v tag Tag
- */
-void gcm_tag ( struct gcm_context *context, union gcm_block *tag ) {
- union gcm_block tmp;
- uint32_t offset;
-
- /* Construct hash */
- gcm_hash ( context, tag );
-
- /* Construct encrypted initial counter value */
- memcpy ( &tmp, &context->ctr, sizeof ( tmp ) );
- offset = ( ( -context->len.len.data ) / ( 8 * sizeof ( tmp ) ) );
- gcm_count ( &tmp, offset );
- cipher_encrypt ( context->raw_cipher, &context->raw_ctx, &tmp,
- &tmp, sizeof ( tmp ) );
- DBGC2 ( context, "GCM %p E(K,Y[0]):\n", context );
- DBGC2_HDA ( context, 0, &tmp, sizeof ( tmp ) );
-
- /* Construct tag */
- gcm_xor_block ( &tmp, tag );
- DBGC2 ( context, "GCM %p T:\n", context );
- DBGC2_HDA ( context, 0, tag, sizeof ( *tag ) );
-}
-