[PATCH v2 07/17] crypto/cipher: Add GCM to QCryptoCipherMode

Jamin Lin posted 17 patches 1 month, 4 weeks ago
Maintainers: "Daniel P. Berrangé" <berrange@redhat.com>, "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Kane Chen <kane_chen@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
[PATCH v2 07/17] crypto/cipher: Add GCM to QCryptoCipherMode
Posted by Jamin Lin 1 month, 4 weeks ago
Introduce the GCM cipher mode so authenticated encryption can be built
on top of the existing qcrypto_cipher API. GCM is an IV-based mode, so
register it in mode_need_iv. No backend advertises it yet, so it stays
unsupported until a backend and the AAD/tag helpers are added in the
following patches.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
---
 qapi/crypto.json | 4 +++-
 crypto/cipher.c  | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/qapi/crypto.json b/qapi/crypto.json
index 2b55befef9..6e3a98ff68 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -121,10 +121,12 @@
 #
 # @ctr: Counter (Since 2.8)
 #
+# @gcm: Galois/Counter Mode (Since 11.2)
+#
 # Since: 2.6
 ##
 { 'enum': 'QCryptoCipherMode',
-  'data': ['ecb', 'cbc', 'xts', 'ctr']}
+  'data': ['ecb', 'cbc', 'xts', 'ctr', 'gcm']}
 
 ##
 # @QCryptoIVGenAlgo:
diff --git a/crypto/cipher.c b/crypto/cipher.c
index 515165e0dc..52d071a90c 100644
--- a/crypto/cipher.c
+++ b/crypto/cipher.c
@@ -66,6 +66,7 @@ static const bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX] = {
     [QCRYPTO_CIPHER_MODE_CBC] = true,
     [QCRYPTO_CIPHER_MODE_XTS] = true,
     [QCRYPTO_CIPHER_MODE_CTR] = true,
+    [QCRYPTO_CIPHER_MODE_GCM] = true,
 };
 
 
-- 
2.43.0
Re: [PATCH v2 07/17] crypto/cipher: Add GCM to QCryptoCipherMode
Posted by Markus Armbruster 1 month, 4 weeks ago
Jamin Lin <jamin_lin@aspeedtech.com> writes:

> Introduce the GCM cipher mode so authenticated encryption can be built
> on top of the existing qcrypto_cipher API. GCM is an IV-based mode, so
> register it in mode_need_iv. No backend advertises it yet, so it stays
> unsupported until a backend and the AAD/tag helpers are added in the
> following patches.
>
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> Acked-by: Daniel P. Berrangé <berrange@redhat.com>

Same person giving Reviewed-by and Acked-by is odd.  Daniel, is this
what you want?

> ---
>  qapi/crypto.json | 4 +++-
>  crypto/cipher.c  | 1 +
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/qapi/crypto.json b/qapi/crypto.json
> index 2b55befef9..6e3a98ff68 100644
> --- a/qapi/crypto.json
> +++ b/qapi/crypto.json
> @@ -121,10 +121,12 @@
>  #
>  # @ctr: Counter (Since 2.8)
>  #
> +# @gcm: Galois/Counter Mode (Since 11.2)
> +#
>  # Since: 2.6
>  ##
>  { 'enum': 'QCryptoCipherMode',
> -  'data': ['ecb', 'cbc', 'xts', 'ctr']}
> +  'data': ['ecb', 'cbc', 'xts', 'ctr', 'gcm']}
>  
>  ##
>  # @QCryptoIVGenAlgo:

Acked-by: Markus Armbruster <armbru@redhat.com>


[...]
Re: [PATCH v2 07/17] crypto/cipher: Add GCM to QCryptoCipherMode
Posted by Daniel P. Berrangé 1 month, 2 weeks ago
On Wed, Jul 15, 2026 at 06:51:41AM +0200, Markus Armbruster wrote:
> Jamin Lin <jamin_lin@aspeedtech.com> writes:
> 
> > Introduce the GCM cipher mode so authenticated encryption can be built
> > on top of the existing qcrypto_cipher API. GCM is an IV-based mode, so
> > register it in mode_need_iv. No backend advertises it yet, so it stays
> > unsupported until a backend and the AAD/tag helpers are added in the
> > following patches.
> >
> > Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> > Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> > Acked-by: Daniel P. Berrangé <berrange@redhat.com>
> 
> Same person giving Reviewed-by and Acked-by is odd.  Daniel, is this
> what you want?

Acked-by in the sense that as crypto subsys maintainer, I'm happy for
it to be merged by aspeed/arm maintainer as part of this series.

> 
> > ---
> >  qapi/crypto.json | 4 +++-
> >  crypto/cipher.c  | 1 +
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/qapi/crypto.json b/qapi/crypto.json
> > index 2b55befef9..6e3a98ff68 100644
> > --- a/qapi/crypto.json
> > +++ b/qapi/crypto.json
> > @@ -121,10 +121,12 @@
> >  #
> >  # @ctr: Counter (Since 2.8)
> >  #
> > +# @gcm: Galois/Counter Mode (Since 11.2)
> > +#
> >  # Since: 2.6
> >  ##
> >  { 'enum': 'QCryptoCipherMode',
> > -  'data': ['ecb', 'cbc', 'xts', 'ctr']}
> > +  'data': ['ecb', 'cbc', 'xts', 'ctr', 'gcm']}
> >  
> >  ##
> >  # @QCryptoIVGenAlgo:
> 
> Acked-by: Markus Armbruster <armbru@redhat.com>
> 
> 
> [...]
> 

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|