170f38
From ba962632cd008edd057f61e7e6fadbf464ff94f2 Mon Sep 17 00:00:00 2001
170f38
From: Francisco Trivino <ftrivino@redhat.com>
170f38
Date: Tue, 4 Oct 2022 17:26:51 +0200
170f38
Subject: [PATCH] Vault: fix interoperability issues with older RHEL systems
170f38
170f38
AES-128-CBC was recently enabled as default wrapping algorithm for transport of secrets.
170f38
This change was done in favor of FIPS as crypto-policies disabled 3DES in RHEL9, but
170f38
setting AES as default ended-up breaking backwards compatibility with older RHEL systems.
170f38
170f38
This commit is tuning some defaults so that interoperability with older RHEL systems
170f38
works again. The new logic reflects:
170f38
170f38
- when an old client is calling a new server, it doesn't send any value for wrapping_algo
170f38
  and the old value is used (3DES), so that the client can decrypt using 3DES.
170f38
170f38
- when a new client is calling a new server, it sends wrapping_algo = AES128_CBC
170f38
170f38
- when a new client is calling an old server, it doesn't send any value and the default is
170f38
  to use 3DES.
170f38
170f38
Finally, as this logic is able to handle overlapping wrapping algorithm between server and
170f38
client, the Option "--wrapping-algo" is hidden from "ipa vault-archive --help" and "ipa
170f38
vault-retrieve --help" commands.
170f38
170f38
Fixes: https://pagure.io/freeipa/issue/9259
170f38
Signed-off-by: Francisco Trivino <ftrivino@redhat.com>
170f38
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
170f38
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
170f38
---
170f38
 API.txt                    | 4 ++--
170f38
 VERSION.m4                 | 4 ++--
170f38
 ipaclient/plugins/vault.py | 7 ++++---
170f38
 ipaserver/plugins/vault.py | 4 ++--
170f38
 4 files changed, 10 insertions(+), 9 deletions(-)
170f38
170f38
diff --git a/API.txt b/API.txt
170f38
index 814124f600111e46c117a0c925e33a27a19b38e0..062a6c756babea6b091c5aaec7d0eaa908b41911 100644
170f38
--- a/API.txt
170f38
+++ b/API.txt
170f38
@@ -6667,7 +6667,7 @@ option: Flag('shared?', autofill=True, default=False)
170f38
 option: Str('username?', cli_name='user')
170f38
 option: Bytes('vault_data')
170f38
 option: Str('version?')
170f38
-option: StrEnum('wrapping_algo?', autofill=True, default=u'aes-128-cbc', values=[u'aes-128-cbc', u'des-ede3-cbc'])
170f38
+option: StrEnum('wrapping_algo?', autofill=True, default=u'des-ede3-cbc', values=[u'aes-128-cbc', u'des-ede3-cbc'])
170f38
 output: Entry('result')
170f38
 output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
170f38
 output: PrimaryKey('value')
170f38
@@ -6767,7 +6767,7 @@ option: Bytes('session_key')
170f38
 option: Flag('shared?', autofill=True, default=False)
170f38
 option: Str('username?', cli_name='user')
170f38
 option: Str('version?')
170f38
-option: StrEnum('wrapping_algo?', autofill=True, default=u'aes-128-cbc', values=[u'aes-128-cbc', u'des-ede3-cbc'])
170f38
+option: StrEnum('wrapping_algo?', autofill=True, default=u'des-ede3-cbc', values=[u'aes-128-cbc', u'des-ede3-cbc'])
170f38
 output: Entry('result')
170f38
 output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
170f38
 output: PrimaryKey('value')
170f38
diff --git a/VERSION.m4 b/VERSION.m4
170f38
index 0f02d48979e4af3ad737e377545c4951d5dece02..d628c69a09a43b01aad4ac1bd3a6912bef27a7fe 100644
170f38
--- a/VERSION.m4
170f38
+++ b/VERSION.m4
170f38
@@ -86,8 +86,8 @@ define(IPA_DATA_VERSION, 20100614120000)
170f38
 #                                                      #
170f38
 ########################################################
170f38
 define(IPA_API_VERSION_MAJOR, 2)
170f38
-# Last change: add Random Serial Numbers v3
170f38
-define(IPA_API_VERSION_MINOR, 249)
170f38
+# Last change: fix vault interoperability issues.
170f38
+define(IPA_API_VERSION_MINOR, 251)
170f38
 
170f38
 ########################################################
170f38
 # Following values are auto-generated from values above
170f38
diff --git a/ipaclient/plugins/vault.py b/ipaclient/plugins/vault.py
170f38
index 115171c7768d44251c17d0bcdac9c37b3a25db99..d4c84eb6bfb4cc119c599d494171b0a2417ce0ba 100644
170f38
--- a/ipaclient/plugins/vault.py
170f38
+++ b/ipaclient/plugins/vault.py
170f38
@@ -687,7 +687,7 @@ class ModVaultData(Local):
170f38
         default_algo = config.get('wrapping_default_algorithm')
170f38
         if default_algo is None:
170f38
             # old server
170f38
-            wrapping_algo = constants.VAULT_WRAPPING_AES128_CBC
170f38
+            wrapping_algo = constants.VAULT_WRAPPING_3DES
170f38
         elif default_algo in constants.VAULT_WRAPPING_SUPPORTED_ALGOS:
170f38
             # try to use server default
170f38
             wrapping_algo = default_algo
170f38
@@ -801,7 +801,8 @@ class vault_archive(ModVaultData):
170f38
             if option.name not in ('nonce',
170f38
                                    'session_key',
170f38
                                    'vault_data',
170f38
-                                   'version'):
170f38
+                                   'version',
170f38
+                                   'wrapping_algo'):
170f38
                 yield option
170f38
         for option in super(vault_archive, self).get_options():
170f38
             yield option
170f38
@@ -1053,7 +1054,7 @@ class vault_retrieve(ModVaultData):
170f38
 
170f38
     def get_options(self):
170f38
         for option in self.api.Command.vault_retrieve_internal.options():
170f38
-            if option.name not in ('session_key', 'version'):
170f38
+            if option.name not in ('session_key', 'version', 'wrapping_algo'):
170f38
                 yield option
170f38
         for option in super(vault_retrieve, self).get_options():
170f38
             yield option
170f38
diff --git a/ipaserver/plugins/vault.py b/ipaserver/plugins/vault.py
170f38
index 4d40f66c6a793a831e91c5fe25c8b5277cbd1972..574c83a9aaa64b6a4774400ea7af25343b445c03 100644
170f38
--- a/ipaserver/plugins/vault.py
170f38
+++ b/ipaserver/plugins/vault.py
170f38
@@ -1051,7 +1051,7 @@ class vault_archive_internal(PKQuery):
170f38
             'wrapping_algo?',
170f38
             doc=_('Key wrapping algorithm'),
170f38
             values=VAULT_WRAPPING_SUPPORTED_ALGOS,
170f38
-            default=VAULT_WRAPPING_DEFAULT_ALGO,
170f38
+            default=VAULT_WRAPPING_3DES,
170f38
             autofill=True,
170f38
         ),
170f38
     )
170f38
@@ -1130,7 +1130,7 @@ class vault_retrieve_internal(PKQuery):
170f38
             'wrapping_algo?',
170f38
             doc=_('Key wrapping algorithm'),
170f38
             values=VAULT_WRAPPING_SUPPORTED_ALGOS,
170f38
-            default=VAULT_WRAPPING_DEFAULT_ALGO,
170f38
+            default=VAULT_WRAPPING_3DES,
170f38
             autofill=True,
170f38
         ),
170f38
     )
170f38
-- 
170f38
2.38.1
170f38