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

Allow using AmazonCorrettoCryptoProvider plugin on Linux to compute hashes faster #1855

Closed
aberenguel opened this issue Sep 1, 2023 · 7 comments · Fixed by #1954
Closed
Assignees

Comments

@aberenguel
Copy link
Contributor

aberenguel commented Sep 1, 2023

As discussed in #1849 , the AmazonCorrettoCryptoProvider could have great performance improvement on Linux.

Using default Provider:

[engine.task.HashTask]                  Hash: md5 => 25258ED0BD157CC9D06D9675C9B4B3C3
[engine.task.HashTask]                  Hash: sha-1 => 0229C4D391927DC3B27DA0809F79FFE0EB6DAA2F
[engine.task.HashTask]                  Hash: sha-256 => 792CD8BFD20E81A5C01648D1E45FCC301B255FF94A4865D9183440944FDE0364
[engine.task.HashTask]                  Hash time: 20.032

Using AmazonCorrettoCryptoProvider:

[engine.task.HashTask]                  Hash: md5 => 25258ED0BD157CC9D06D9675C9B4B3C3
[engine.task.HashTask]                  Hash: sha-1 => 0229C4D391927DC3B27DA0809F79FFE0EB6DAA2F
[engine.task.HashTask]                  Hash: sha-256 => 792CD8BFD20E81A5C01648D1E45FCC301B255FF94A4865D9183440944FDE0364
[engine.task.HashTask]                  Hash time: 13.739

As it is not supported in Windows yet, the jar file could be added in plugin folder. The code to support could be:

try {
    Class<?> clazz = Class.forName("com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider");
    Method method = clazz.getMethod("install");
    method.invoke(null);
} catch (Exception e) {
    LOGGER.debug("AmazonCorrettoCryptoProvider not installed", e);
}
@aberenguel
Copy link
Contributor Author

@lfcnassif Where is the better class to insert this code? Do you think it should be configurable?

@lfcnassif
Copy link
Member

Hi @aberenguel! Maybe in the processing Manager, because there are other places that compute hashes, not sure...

I think ExportFileTask would be the one that spend more time with hash computation after HashTask, since it is done for all subitems.

Is this provider loaded by the java service provider mechanism? Because AFAIK any provider installed could be used depending on the service loading order, that is non deterministic... I don't remember if there is a way to prioritize a specific provider if it is installed over the other ones, maybe it is possible.

@aberenguel
Copy link
Contributor Author

aberenguel commented Sep 1, 2023

Is this provider loaded by the java service provider mechanism?

Yes. Internally the provider is added as the highest-priority. https://github.com/corretto/amazon-corretto-crypto-provider/blob/296f3821ee8436ea8a311709c0a89e198b19466c/src/com/amazon/corretto/crypto/provider/AmazonCorrettoCryptoProvider.java#L448

  /**
   * Installs the AmazonCorrettoCryptoProvider provider as the highest-priority (i.e. default)
   * provider systemwide.
   */
  public static void install() {
    Security.insertProviderAt(INSTANCE, 1);
  }

@lfcnassif
Copy link
Member

lfcnassif commented Sep 1, 2023

Great! Could you take a look if Bouncy Castle dependency uses the same priority? This may cause a conflict or non deterministic behavior...

@aberenguel
Copy link
Contributor Author

aberenguel commented Oct 27, 2023

Great! Could you take a look if Bouncy Castle dependency uses the same priority? This may cause a conflict or non deterministic behavior...

The BouncyCastleProvider is added with Security.addProvider which means it is inserted in the end of the provider list (lowest-priority).

Security.addProvider(new BouncyCastleProvider());

@lfcnassif
Copy link
Member

lfcnassif commented Oct 27, 2023

@arisjr, since you use Linux in your processing farm, this should be of your interest. Just put the Linux x86_64 jar below into IPED's plugin folder and it should work, starting with the future IPED 4.2.0 release:
https://github.com/corretto/amazon-corretto-crypto-provider/releases

@lfcnassif lfcnassif changed the title Consider using AmazonCorrettoCryptoProvider Consider using AmazonCorrettoCryptoProvider as a plugin Oct 27, 2023
@arisjr
Copy link
Contributor

arisjr commented Oct 27, 2023

Ótima notícia. Testaremos assim que disponível!

@lfcnassif lfcnassif changed the title Consider using AmazonCorrettoCryptoProvider as a plugin Allow using AmazonCorrettoCryptoProvider plugin on Linux to compute hashes faster Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants