adiantum.c (c39f2d9db0fd81ea20bb5cce9b3f082ca63753e2) adiantum.c (48ea8c6ebc96bc0990e12ee1c43d0832c23576bb)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Adiantum length-preserving encryption mode
4 *
5 * Copyright 2018 Google LLC
6 */
7
8/*

--- 19 unchanged lines hidden (view full) ---

28 * to wrap with the crypto_shash API. Rather, some details need to be handled
29 * here. Nevertheless, if needed in the future, support for other ε-∆U hash
30 * functions could be added here.
31 */
32
33#include <crypto/b128ops.h>
34#include <crypto/chacha.h>
35#include <crypto/internal/hash.h>
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Adiantum length-preserving encryption mode
4 *
5 * Copyright 2018 Google LLC
6 */
7
8/*

--- 19 unchanged lines hidden (view full) ---

28 * to wrap with the crypto_shash API. Rather, some details need to be handled
29 * here. Nevertheless, if needed in the future, support for other ε-∆U hash
30 * functions could be added here.
31 */
32
33#include <crypto/b128ops.h>
34#include <crypto/chacha.h>
35#include <crypto/internal/hash.h>
36#include <crypto/internal/poly1305.h>
36#include <crypto/internal/skcipher.h>
37#include <crypto/nhpoly1305.h>
38#include <crypto/scatterwalk.h>
39#include <linux/module.h>
40
41#include "internal.h"
42
43/*

--- 193 unchanged lines hidden (view full) ---

237 .message_bits = cpu_to_le64((u64)bulk_len * 8)
238 };
239 struct poly1305_state state;
240
241 poly1305_core_init(&state);
242
243 BUILD_BUG_ON(sizeof(header) % POLY1305_BLOCK_SIZE != 0);
244 poly1305_core_blocks(&state, &tctx->header_hash_key,
37#include <crypto/internal/skcipher.h>
38#include <crypto/nhpoly1305.h>
39#include <crypto/scatterwalk.h>
40#include <linux/module.h>
41
42#include "internal.h"
43
44/*

--- 193 unchanged lines hidden (view full) ---

238 .message_bits = cpu_to_le64((u64)bulk_len * 8)
239 };
240 struct poly1305_state state;
241
242 poly1305_core_init(&state);
243
244 BUILD_BUG_ON(sizeof(header) % POLY1305_BLOCK_SIZE != 0);
245 poly1305_core_blocks(&state, &tctx->header_hash_key,
245 &header, sizeof(header) / POLY1305_BLOCK_SIZE);
246 &header, sizeof(header) / POLY1305_BLOCK_SIZE, 1);
246
247 BUILD_BUG_ON(TWEAK_SIZE % POLY1305_BLOCK_SIZE != 0);
248 poly1305_core_blocks(&state, &tctx->header_hash_key, req->iv,
247
248 BUILD_BUG_ON(TWEAK_SIZE % POLY1305_BLOCK_SIZE != 0);
249 poly1305_core_blocks(&state, &tctx->header_hash_key, req->iv,
249 TWEAK_SIZE / POLY1305_BLOCK_SIZE);
250 TWEAK_SIZE / POLY1305_BLOCK_SIZE, 1);
250
251 poly1305_core_emit(&state, &rctx->header_hash);
252}
253
254/* Hash the left-hand part (the "bulk") of the message using NHPoly1305 */
255static int adiantum_hash_message(struct skcipher_request *req,
256 struct scatterlist *sgl, le128 *digest)
257{

--- 410 unchanged lines hidden ---
251
252 poly1305_core_emit(&state, &rctx->header_hash);
253}
254
255/* Hash the left-hand part (the "bulk") of the message using NHPoly1305 */
256static int adiantum_hash_message(struct skcipher_request *req,
257 struct scatterlist *sgl, le128 *digest)
258{

--- 410 unchanged lines hidden ---