Skip to content

Migrate to M2crypto - #44962

Merged
rallytime merged 8 commits into
saltstack:oxygenfrom
DSRCorporation:m2crypto
Jan 26, 2018
Merged

rallytime merged 8 commits into
saltstack:oxygenfrom
DSRCorporation:m2crypto

Conversation

@DmitryKuzmenko

@DmitryKuzmenko DmitryKuzmenko commented Dec 13, 2017 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Use M2Crypto by default if installed instead of Cryptodome or Crypto everywhere in Salt.

What issues does this PR fix or reference?

Implements #44923

Tests written?

Extended the existing test. Full coverage is coming after modularizing the crypto backend.

Commits signed with GPG?

Yes

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

Tests and docs are coming.

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

It's done as I see. @thatch45 @cachedout @cro could you please spent take some time to review this?

@thatch45

thatch45 commented Jan 4, 2018

Copy link
Copy Markdown
Contributor

At first glance this looks great, can you run a master on pycrypto and a minion on m2 and vis-versa?

@DmitryKuzmenko DmitryKuzmenko changed the title [DO NOT MERGE] Migrate to M2crypto Migrate to M2crypto Jan 5, 2018
@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

@thatch45 It's designed to can do this, but I haven't tested this case. I'll check. Thank you for the point.

@thatch45

thatch45 commented Jan 5, 2018

Copy link
Copy Markdown
Contributor

Thanks, we don't want to introduce a minion/master inconsistency in any direction

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

@thatch45 I've tested manually in different configurations, master-minion connection works fine. So new master + M2Crypto will work fine with old pyCrypto minions and vice versa.

Comment thread salt/crypt.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the cipher used by the pycrypto lib? Can't the encryption type be autodetected so that we could use AES here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes this is used by pycrypto by default. We could use autodetect here, I think. But I need to have a review to say exactly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am ok with this otherwise because this is not a default setting. If anything to just get this into the codebase.
But we should look at autodetect here in a future PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Salt requires pycrypto>=2.6.1, but pycrypto 2.6.1 doesn't support AES algorithm. So it looks to better to make this change later when user will have a way to choose what cryptographic backend to use to not be surprised.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But yes, it's a very good catch, it should be changed to autodetect, or configurable in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks fro the research, again, I am ok with where we are here do far and I think that we can move forward, the password protected key here is not default and we can make this configurable in the future

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

re-run py

@rallytime

Copy link
Copy Markdown
Contributor

@cachedout and @cro Can you review this please?

@DmitryKuzmenko There's a small conflict here on in the oxygen release notes, so this will need to be rebased before we can merge it in.

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

@rallytime done!

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

Conflicting again, I've rebased it once again.

@rallytime
rallytime removed the request for review from cro January 23, 2018 22:19
Comment thread salt/crypt.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sha1? This brings to mind the 2017 collision attacks on sha1.

cc: @thatch45

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Crypto in salt.crypt uses SHA hash package that does SHA1 signature.
Here is the same as we discussed above with Tom: if we'd like to use for instance SHA256 we have to either change this behavior in both M2Crypto and pyCrypto implementations or we'll break master-minion compatibility if they run in different configurations.
What I've done in this PR is cloned the current Crypto behavior replaced it with M2Crypto to keep the compatibility.
So I propose to keep this PR as is and do any feature improvements in different issues. And the first one we'd have to do is modularize the crypt package. This'd make it configurable and testable including writing compatibility tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is fine. 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

@DmitryKuzmenko

Copy link
Copy Markdown
Contributor Author

The branch had conflicts, I've rebased it.

@rallytime
rallytime merged commit 4697769 into saltstack:oxygen Jan 26, 2018
rallytime pushed a commit to rallytime/salt-bootstrap that referenced this pull request Jan 26, 2018
This is due to the change in Salt for Oxygen:
saltstack/salt#44962
@DmitryKuzmenko
DmitryKuzmenko deleted the m2crypto branch October 23, 2020 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants