Blame SOURCES/0013-Vault-fix-interoperability-issues-with-older-RHEL-systems_rhbz#2148255.patch

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