Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security Module Plugin API #713

Merged
merged 104 commits into from
Apr 27, 2020
Merged

Security Module Plugin API #713

merged 104 commits into from
Apr 27, 2020

Conversation

usmansaleem
Copy link
Member

@usmansaleem usmansaleem commented Apr 15, 2020

PR description

Introduce Security Module Plugin API. This allows to switch to a different security module provider to provide cryptographic function that can be used by NodeKey (such as sign, ECDHKeyAgreement etc.). By default register KeyPairSecurityModule otherwise attempt to load Security Module via plugin API.

CLI Options:
--security-module=<name>. (defaults to localfile)

Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
Signed-off-by: Usman Saleem <[email protected]>
@usmansaleem usmansaleem changed the title Local File Security Module Plugin Security Module Plugin API Apr 23, 2020
Signed-off-by: Usman Saleem <[email protected]>

private File nodePrivateKeyFile() {
final Optional<File> nodePrivateKeyFile =
isDocker ? Optional.empty() : Optional.ofNullable(standaloneCommands.nodePrivateKeyFile);
Copy link
Contributor

Choose a reason for hiding this comment

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

There should no be any docker specific behaviour

Copy link
Member Author

Choose a reason for hiding this comment

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

This whole file is using docker specific behavior using org/hyperledger/besu/cli/BesuCommand.java:2103

  private boolean isFullInstantiation() {
    return !isDocker;
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

It's garbage code to be deleted. We don't provide the parameter in the docker image since 29c3c14#diff-ebacf6f6ae4ee68078bb16454b23247dL19 so this part of the code is dead since July 2019. It was discussed about removing it but it was not a priority. Now, if it's confusing, it should be a priority IMO.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 I have created #785 and will clean it out in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Its a shame the docker code wasn't cleaned out before now - but the removal shouldn't be part of this work.

Conflicts:
	plugin-api/build.gradle

Signed-off-by: Usman Saleem <[email protected]>

private File nodePrivateKeyFile() {
final Optional<File> nodePrivateKeyFile =
isDocker ? Optional.empty() : Optional.ofNullable(standaloneCommands.nodePrivateKeyFile);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Its a shame the docker code wasn't cleaned out before now - but the removal shouldn't be part of this work.

private final SECP256K1.KeyPair keyPair;
private final PublicKey publicKey;

public KeyPairSecurityModule(final SECP256K1.KeyPair keyPair) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: given there's crypto operations happening here, do we want to move this to a static creator? which passes in a privkey and a PublicKey?

Copy link
Member Author

Choose a reason for hiding this comment

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

we only require SECP256K1.KeyPair. The PublicKey is the interface (with ECPoint) that is meant to be converted from SECP256K1's PublicKey. The other option would be to initialize public key on the first access via getPublicKey. I don't feel the need of creator factory method.

/**
* Registers a provider of security modules.
*
* @param name The name to identify the Security Provider Supplier Function
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param name The name to identify the Security Provider Supplier Function
* @param name The name to identify the Security Provider Supplier

Copy link
Member Author

Choose a reason for hiding this comment

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

javadoc updated.

@usmansaleem usmansaleem merged commit c2dcf62 into hyperledger:master Apr 27, 2020
usmansaleem added a commit that referenced this pull request Apr 29, 2020
Signed-off-by: Usman Saleem <[email protected]>
@usmansaleem usmansaleem deleted the nodekey_plugin branch May 4, 2020 23:52
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.

6 participants