Skip to content

Commit 314d0f0

Browse files
ebiggersherbertx
authored andcommitted
crypto: skcipher - make chunksize and walksize accessors internal
The 'chunksize' and 'walksize' properties of skcipher algorithms are implementation details that users of the skcipher API should not be looking at. So move their accessor functions from <crypto/skcipher.h> to <crypto/internal/skcipher.h>. Signed-off-by: Eric Biggers <ebiggers@google.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 81bcbb1 commit 314d0f0

2 files changed

Lines changed: 60 additions & 60 deletions

File tree

‎include/crypto/internal/skcipher.h‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,66 @@ static inline unsigned int crypto_skcipher_alg_max_keysize(
205205
return alg->max_keysize;
206206
}
207207

208+
static inline unsigned int crypto_skcipher_alg_chunksize(
209+
struct skcipher_alg *alg)
210+
{
211+
if ((alg->base.cra_flags & CRYPTO_ALG_TYPE_MASK) ==
212+
CRYPTO_ALG_TYPE_BLKCIPHER)
213+
return alg->base.cra_blocksize;
214+
215+
if (alg->base.cra_ablkcipher.encrypt)
216+
return alg->base.cra_blocksize;
217+
218+
return alg->chunksize;
219+
}
220+
221+
static inline unsigned int crypto_skcipher_alg_walksize(
222+
struct skcipher_alg *alg)
223+
{
224+
if ((alg->base.cra_flags & CRYPTO_ALG_TYPE_MASK) ==
225+
CRYPTO_ALG_TYPE_BLKCIPHER)
226+
return alg->base.cra_blocksize;
227+
228+
if (alg->base.cra_ablkcipher.encrypt)
229+
return alg->base.cra_blocksize;
230+
231+
return alg->walksize;
232+
}
233+
234+
/**
235+
* crypto_skcipher_chunksize() - obtain chunk size
236+
* @tfm: cipher handle
237+
*
238+
* The block size is set to one for ciphers such as CTR. However,
239+
* you still need to provide incremental updates in multiples of
240+
* the underlying block size as the IV does not have sub-block
241+
* granularity. This is known in this API as the chunk size.
242+
*
243+
* Return: chunk size in bytes
244+
*/
245+
static inline unsigned int crypto_skcipher_chunksize(
246+
struct crypto_skcipher *tfm)
247+
{
248+
return crypto_skcipher_alg_chunksize(crypto_skcipher_alg(tfm));
249+
}
250+
251+
/**
252+
* crypto_skcipher_walksize() - obtain walk size
253+
* @tfm: cipher handle
254+
*
255+
* In some cases, algorithms can only perform optimally when operating on
256+
* multiple blocks in parallel. This is reflected by the walksize, which
257+
* must be a multiple of the chunksize (or equal if the concern does not
258+
* apply)
259+
*
260+
* Return: walk size in bytes
261+
*/
262+
static inline unsigned int crypto_skcipher_walksize(
263+
struct crypto_skcipher *tfm)
264+
{
265+
return crypto_skcipher_alg_walksize(crypto_skcipher_alg(tfm));
266+
}
267+
208268
/* Helpers for simple block cipher modes of operation */
209269
struct skcipher_ctx_simple {
210270
struct crypto_cipher *cipher; /* underlying block cipher */

‎include/crypto/skcipher.h‎

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -293,66 +293,6 @@ static inline unsigned int crypto_sync_skcipher_ivsize(
293293
return crypto_skcipher_ivsize(&tfm->base);
294294
}
295295

296-
static inline unsigned int crypto_skcipher_alg_chunksize(
297-
struct skcipher_alg *alg)
298-
{
299-
if ((alg->base.cra_flags & CRYPTO_ALG_TYPE_MASK) ==
300-
CRYPTO_ALG_TYPE_BLKCIPHER)
301-
return alg->base.cra_blocksize;
302-
303-
if (alg->base.cra_ablkcipher.encrypt)
304-
return alg->base.cra_blocksize;
305-
306-
return alg->chunksize;
307-
}
308-
309-
static inline unsigned int crypto_skcipher_alg_walksize(
310-
struct skcipher_alg *alg)
311-
{
312-
if ((alg->base.cra_flags & CRYPTO_ALG_TYPE_MASK) ==
313-
CRYPTO_ALG_TYPE_BLKCIPHER)
314-
return alg->base.cra_blocksize;
315-
316-
if (alg->base.cra_ablkcipher.encrypt)
317-
return alg->base.cra_blocksize;
318-
319-
return alg->walksize;
320-
}
321-
322-
/**
323-
* crypto_skcipher_chunksize() - obtain chunk size
324-
* @tfm: cipher handle
325-
*
326-
* The block size is set to one for ciphers such as CTR. However,
327-
* you still need to provide incremental updates in multiples of
328-
* the underlying block size as the IV does not have sub-block
329-
* granularity. This is known in this API as the chunk size.
330-
*
331-
* Return: chunk size in bytes
332-
*/
333-
static inline unsigned int crypto_skcipher_chunksize(
334-
struct crypto_skcipher *tfm)
335-
{
336-
return crypto_skcipher_alg_chunksize(crypto_skcipher_alg(tfm));
337-
}
338-
339-
/**
340-
* crypto_skcipher_walksize() - obtain walk size
341-
* @tfm: cipher handle
342-
*
343-
* In some cases, algorithms can only perform optimally when operating on
344-
* multiple blocks in parallel. This is reflected by the walksize, which
345-
* must be a multiple of the chunksize (or equal if the concern does not
346-
* apply)
347-
*
348-
* Return: walk size in bytes
349-
*/
350-
static inline unsigned int crypto_skcipher_walksize(
351-
struct crypto_skcipher *tfm)
352-
{
353-
return crypto_skcipher_alg_walksize(crypto_skcipher_alg(tfm));
354-
}
355-
356296
/**
357297
* crypto_skcipher_blocksize() - obtain block size of cipher
358298
* @tfm: cipher handle

0 commit comments

Comments
 (0)