alexanderlukanin13 / coolname

Random Name and Slug Generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MD5 not supported without usedforsecurity=False in FIPS 140-2 environment

szelenka opened this issue · comments

In FIPS environments, the use of md5 algorithm must use the usedforsecurity=False kwarg, otherwise it will assert with:

│     import coolname                                                                                                                                                                                                            
│   File "/opt/python/lib/python3.10/site-packages/coolname/__init__.py", line 7, in <module>                                                                                                                                    
│     from .impl import generate, generate_slug, get_combinations_count,\                                                                                                                                                        
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 565, in <module>                                                                                                                                      
│     _default = _create_default_generator()                                                                                                                                                                                     
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 561, in _create_default_generator                                                                                                                     
│     return RandomGenerator(config)                                                                                                                                                                                             
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 246, in __init__                                                                                                                                      
│     self._lists[None] = self._lists[None].squash(True, {})                                                                                                                                                                     
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 156, in squash                                                                                                                                        
│     result = super().squash(hard, cache)                                                                                                                                                                                       
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 37, in squash                                                                                                                                         
│     self._lists = [x.squash(hard, cache) for x in self._lists]                                                                                                                                                                 
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 37, in <listcomp>                                                                                                                                     
│     self._lists = [x.squash(hard, cache) for x in self._lists]                                                                                                                                                                 
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 156, in squash                                                                                                                                        
│     result = super().squash(hard, cache)                                                                                                                                                                                       
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 37, in squash                                                                                                                                         
│     self._lists = [x.squash(hard, cache) for x in self._lists]                                                                                                                                                                 
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 37, in <listcomp>                                                                                                                                     
│     self._lists = [x.squash(hard, cache) for x in self._lists]                                                                                                                                                                 
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 37, in squash                                                                                                                                         
│     self._lists = [x.squash(hard, cache) for x in self._lists]                                                                                                                                                                 
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 37, in <listcomp>                                                                                                                                     
│     self._lists = [x.squash(hard, cache) for x in self._lists]                                                                                                                                                                 
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 164, in squash                                                                                                                                        
│     if result._hash in cache:  # noqa                                                                                                                                                                                          
│   File "/opt/python/lib/python3.10/site-packages/coolname/impl.py", line 84, in _hash                                                                                                                                          
│     md5 = hashlib.md5()                                                                                                                                                                                                         
│ ValueError: [digital envelope routines] disabled for fips     

Reference other libraries which encountered this:

@szelenka Thank you for reporting this issue! I took a slightly different approach to implementation, but result should be the same. Please check coolname==2.1.0 and let me know if it works on your system.

that change should work, thanks!