在 Java AES 加密中使用提供程序
Using providers in Java AES encryption
这可能是一个菜鸟问题,但我对提供商的工作方式感到困惑。我试过阅读此 https://docs.oracle.com/javase/7/docs/technotes/guides/security/overview/jsoverview.html,但它对我来说不太有意义。假设我们有:
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC")
和
Cipher cipher= Cipher.getInstance("AES/CBC/PKCS5Padding")
根据 link 听起来好像提供者指示正在使用的实现,但 AES/CBC/PKCS5Padding 基本上与提供者无关?在这个例子中,bouncy castle(我猜 "BC" 对应的)碰巧有一个比默认实现更有效的算法吗?谢谢你的时间。
isn't AES/CBC/PKCS5Padding basically the same independent of the
provider?
是的,是的。
In the example does bouncy castle (what I'm guessing "BC" corresponds
to) happen to have a more efficient algorithm than the default
implementation?
可能不会。特别是在 AES 的情况下,最近的 Oracle 提供商可能比 Bouncycastle 快得多,因为他们在可用时使用本机 AES 硬件。
So why specify the provider?
好的,我知道您没有问过这个问题,但这似乎就是您要去的地方。在大多数情况下,您应该 而不是 指定提供商。一般规则是避免指定提供商,除非您有充分的理由这样做。不指定提供程序会增加可移植性。
不幸的是,我遇到过一些您可能需要指定提供商的情况。 JCE 中提供的抽象并不能涵盖实践中出现的所有情况。如果您 运行 属于其中之一,最好再问一个单独的问题。
这可能是一个菜鸟问题,但我对提供商的工作方式感到困惑。我试过阅读此 https://docs.oracle.com/javase/7/docs/technotes/guides/security/overview/jsoverview.html,但它对我来说不太有意义。假设我们有:
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC")
和
Cipher cipher= Cipher.getInstance("AES/CBC/PKCS5Padding")
根据 link 听起来好像提供者指示正在使用的实现,但 AES/CBC/PKCS5Padding 基本上与提供者无关?在这个例子中,bouncy castle(我猜 "BC" 对应的)碰巧有一个比默认实现更有效的算法吗?谢谢你的时间。
isn't AES/CBC/PKCS5Padding basically the same independent of the provider?
是的,是的。
In the example does bouncy castle (what I'm guessing "BC" corresponds to) happen to have a more efficient algorithm than the default implementation?
可能不会。特别是在 AES 的情况下,最近的 Oracle 提供商可能比 Bouncycastle 快得多,因为他们在可用时使用本机 AES 硬件。
So why specify the provider?
好的,我知道您没有问过这个问题,但这似乎就是您要去的地方。在大多数情况下,您应该 而不是 指定提供商。一般规则是避免指定提供商,除非您有充分的理由这样做。不指定提供程序会增加可移植性。
不幸的是,我遇到过一些您可能需要指定提供商的情况。 JCE 中提供的抽象并不能涵盖实践中出现的所有情况。如果您 运行 属于其中之一,最好再问一个单独的问题。