On Tue, Nov 28, 2023 at 11:57 PM Philippe Mathieu-Daudé <phi...@linaro.org> wrote:
> Hi Hyman, > > On 28/11/23 16:24, Hyman Huang wrote: > > Introduce the SM4 cipher algorithms (OSCCA GB/T 32907-2016). > > > > SM4 (GBT.32907-2016) is a cryptographic standard issued by the > > Organization of State Commercial Administration of China (OSCCA) > > as an authorized cryptographic algorithms for the use within China. > > > > Use the crypto-sm4 meson build option for enabling this feature. > > > > Signed-off-by: Hyman Huang <yong.hu...@smartx.com> > > --- > > crypto/block-luks.c | 11 ++++++++ > > crypto/cipher-gcrypt.c.inc | 8 ++++++ > > crypto/cipher-nettle.c.inc | 49 +++++++++++++++++++++++++++++++++ > > crypto/cipher.c | 6 ++++ > > meson.build | 23 ++++++++++++++++ > > meson_options.txt | 2 ++ > > qapi/crypto.json | 5 +++- > > scripts/meson-buildoptions.sh | 3 ++ > > tests/unit/test-crypto-cipher.c | 13 +++++++++ > > 9 files changed, 119 insertions(+), 1 deletion(-) > > > > diff --git a/meson.build b/meson.build > > index ec01f8b138..256d3257bb 100644 > > --- a/meson.build > > +++ b/meson.build > > @@ -1480,6 +1480,7 @@ endif > > gcrypt = not_found > > nettle = not_found > > hogweed = not_found > > +crypto_sm4 = not_found > > xts = 'none' > > > > if get_option('nettle').enabled() and get_option('gcrypt').enabled() > > @@ -1514,6 +1515,26 @@ if not gnutls_crypto.found() > > xts = 'private' > > endif > > endif > > + if get_option('crypto_sm4').enabled() > > We want to detect it by default (not only when explicitly enabled) ... > Ok, get it. > > > + if get_option('gcrypt').enabled() > > + # SM4 ALG is available in libgcrypt >= 1.9 > > + crypto_sm4 = dependency('libgcrypt', version: '>=1.9', > > + method: 'config-tool', > > + required: get_option('gcrypt')) > > + # SM4 ALG static compilation > > + if crypto_sm4.found() and get_option('prefer_static') > > + crypto_sm4 = declare_dependency(dependencies: [ > > + crypto_sm4, > > + cc.find_library('gpg-error', required: true)], > > + version: crypto_sm4.version()) > > + endif > > + else > > + # SM4 ALG is available in nettle >= 3.9 > > + crypto_sm4 = dependency('nettle', version: '>=3.9', > > + method: 'pkg-config', > > + required: get_option('nettle')) > > + endif > > ... and if it was forced with --enable-crypto_sm4 AND not found, > display an error. > Ok. > > IIUC your config you try to find the best effort implementation then > if not found, keep going silently. > > > + endif > > endif > > > > diff --git a/scripts/meson-buildoptions.sh > b/scripts/meson-buildoptions.sh > > index 680fa3f581..f189f34829 100644 > > --- a/scripts/meson-buildoptions.sh > > +++ b/scripts/meson-buildoptions.sh > > @@ -106,6 +106,7 @@ meson_options_help() { > > printf "%s\n" ' colo-proxy colo-proxy support' > > printf "%s\n" ' coreaudio CoreAudio sound support' > > printf "%s\n" ' crypto-afalg Linux AF_ALG crypto backend driver' > > + printf "%s\n" ' crypto-sm4 SM4 symmetric cipher algorithm > support' > > printf "%s\n" ' curl CURL block device driver' > > printf "%s\n" ' curses curses UI' > > printf "%s\n" ' dbus-display -display dbus support' > > @@ -282,6 +283,8 @@ _meson_option_parse() { > > --disable-coroutine-pool) printf "%s" -Dcoroutine_pool=false ;; > > --enable-crypto-afalg) printf "%s" -Dcrypto_afalg=enabled ;; > > --disable-crypto-afalg) printf "%s" -Dcrypto_afalg=disabled ;; > > + --enable-crypto-sm4) printf "%s" -Dcrypto_sm4=enabled ;; > > + --disable-crypto-sm4) printf "%s" -Dcrypto_sm4=disabled ;; > > --enable-curl) printf "%s" -Dcurl=enabled ;; > > --disable-curl) printf "%s" -Dcurl=disabled ;; > > --enable-curses) printf "%s" -Dcurses=enabled ;; > > -- Best regards