Skip to content

Conversation

@shekhar-himanshu
Copy link

It has been observed that sdkserevr fails to deploy VM with below error if FIPS mode is enabled:

[2025-09-09 11:57:11] [ERROR] Failed to calculate the image's md5sum
[2025-09-09 11:57:11] [ERROR] Failed to import image 'be07c4c8-2052-4e42-a8a0-91d12a61efcf'
[2025-09-09 11:57:11] [ERROR] [Thread-8394] (127.0.0.1:45562) Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/zvmsdk/smtclient.py", line 2905, in _get_md5sum
    current_md5 = hashlib.md5()
ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/zvmsdk/sdkserver.py", line 153, in serve_API
    return_data = api_func(*api_args, **api_kwargs)
  File "/usr/lib/python3.9/site-packages/zvmsdk/api.py", line 504, in image_import
    self._imageops.image_import(image_name, url, image_meta,
  File "/usr/lib/python3.9/site-packages/zvmsdk/imageops.py", line 48, in image_import
    return self._smtclient.image_import(image_name,
  File "/usr/lib/python3.9/site-packages/zvmsdk/smtclient.py", line 2686, in image_import
    real_md5sum = self._get_md5sum(import_image_fpath)
  File "/usr/lib/python3.9/site-packages/zvmsdk/smtclient.py", line 2921, in _get_md5sum
    raise exception.SDKImageOperationError(rs=3)
zvmsdk.exception.SDKImageOperationError: Image import error: Failed to calculate the md5sum of the image

This is because md5 is not allowed in FIPS enabled environment. So, this Pull Request is to use SHA256 instead of MD5 if FIPS is enabled.

Copy link
Contributor

@Bischoff Bischoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a serious problem with that. The API parameter for GET /images and POST /images is called md5sum.

Maybe we should support a parameter named sha256sum as well?

Or use a generic checksum parameter (keeping undocumented md5sum for compatibility), and determine at run time which kind it is?

I did not check what happens at database level. Maybe ther's a md5sum field too in it...

Also, please add documentation to those sections:

https://cloudlib4zvm.readthedocs.io/en/latest/restapi.html#list-images
https://cloudlib4zvm.readthedocs.io/en/latest/restapi.html#create-image

Maybe updating the unit tests would also be nice, I am not sure.

LOG.error(msg)
raise exception.SDKImageOperationError(rs=2, schema=scheme)

def _get_md5sum(self, fpath):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rename this function as it may return something else than MD5 sum.

"""Calculate the md5sum of the specific image file"""
try:
current_md5 = hashlib.md5()
current_md5 = zvmutils.get_hash_object()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also rename the current_md5 variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants