@@ -301,6 +301,8 @@ static void __maybe_unused crypto_lskcipher_show(
seq_printf(m, "chunksize : %u\n", skcipher->co.chunksize);
seq_printf(m, "statesize : %u\n", skcipher->co.statesize);
seq_printf(m, "tailsize : %u\n", skcipher->co.tailsize);
+ seq_printf(m, "incremental : %s\n", skcipher->co.twopass ?
+ "no" : "yes");
}
static int __maybe_unused crypto_lskcipher_report(
@@ -837,6 +837,8 @@ static void crypto_skcipher_show(struct seq_file *m, struct crypto_alg *alg)
seq_printf(m, "walksize : %u\n", skcipher->walksize);
seq_printf(m, "statesize : %u\n", skcipher->statesize);
seq_printf(m, "tailsize : %u\n", skcipher->tailsize);
+ seq_printf(m, "incremental : %s\n", skcipher->twopass ?
+ "no" : "yes");
}
static int __maybe_unused crypto_skcipher_report(
@@ -105,6 +105,7 @@ struct crypto_istat_cipher {
* @statesize: Size of the internal state for the algorithm.
* @tailsize: Minimum number of bytes to withhold until the end of operation.
* Used by algorithms such as CTS to support chaining.
+ * @twopass: The algorithm needs two passes over the input, e.g., adiantum.
* @stat: Statistics for cipher algorithm
* @base: Definition of a generic crypto algorithm.
*/
@@ -115,6 +116,7 @@ struct crypto_istat_cipher {
unsigned int chunksize; \
unsigned int statesize; \
unsigned int tailsize; \
+ bool twopass; \
\
SKCIPHER_ALG_COMMON_STAT \
\
@@ -576,6 +578,36 @@ static inline unsigned int crypto_lskcipher_tailsize(
return crypto_lskcipher_alg(tfm)->co.tailsize;
}
+/**
+ * crypto_skcipher_isincremental() - check incremental ability
+ * @tfm: cipher handle
+ *
+ * Most skcipher algorithms can accept data in an incremental fashion.
+ * However, some such as adiantum cannot as they need to pass through
+ * the data twice.
+ *
+ * Return: true if algorithm can accept data incrementally.
+ */
+static inline bool crypto_skcipher_isincremental(struct crypto_skcipher *tfm)
+{
+ return !crypto_skcipher_alg_common(tfm)->twopass;
+}
+
+/**
+ * crypto_lskcipher_isincremental() - check incremental ability
+ * @tfm: cipher handle
+ *
+ * Most lskcipher algorithms can accept data in an incremental fashion.
+ * However, some such as adiantum cannot as they need to pass through
+ * the data twice.
+ *
+ * Return: true if algorithm can accept data incrementally.
+ */
+static inline bool crypto_lskcipher_isincremental(struct crypto_lskcipher *tfm)
+{
+ return !crypto_lskcipher_alg(tfm)->co.twopass;
+}
+
static inline unsigned int crypto_sync_skcipher_blocksize(
struct crypto_sync_skcipher *tfm)
{
Algorithms such as adiantum requires two passes over the input and therefore cannot support incremental processing. Add a new attribute to identify them. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --- crypto/lskcipher.c | 2 ++ crypto/skcipher.c | 2 ++ include/crypto/skcipher.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+)