Web Cryptography API:如何发现支持的算法?
Web Cryptography API: Howto discover supported algorithms?
Web Cryptography API 通过 JavaScript 支持使用浏览器的本机加密功能,例如可靠的随机数生成器或使用不同算法进行加密或签名的可能性。
规范列出了 overview of algorithms 作为实施者的起点,但添加了以下编辑说明:
Note: All algorithms listed should be considered as "features at risk", barring implementors adopting them. Their inclusion in the Editor's Draft reflects requests for their inclusion by members of the community, and are included as an exercise to ensure the robustness of the API defined in this specification.
As such, the list of algorithms, and the recommendations, may be significantly altered in future revisions.
据我了解,规范背后的想法是为密码学提供一个接口,而不是写下具体的算法(这完全有道理!)。
如何确定客户端是否支持特定算法?隐藏实现细节是一种很好的做法,但由于算法必须具有所谓的 可识别的算法名称 我不明白您为什么不想公开已注册的算法。
仍然没有指定接口,您注册算法的对象描述如下:
This specification makes use of an internal object, [[supportedAlgorithms]].
This internal object is not exposed to applications.
在当前状态下发现可用算法的唯一可能性是捕捉微妙界面的NotSupportedError。
从我的角度来看,发现是简单的程序流程,错误应该作为异常处理,而不是实现逻辑。
有什么提示或建议吗?也欢迎链接到适当的 w3c-mailinglist 讨论。
未计划对算法发现接口的支持。
这个问题在 2012 年的 w3c working groups mailinglist 上进行了详细讨论,其中提出了一些问题,请参阅线程“RE: Strawman proposal for the low-level API - about the interoperable set of algo and algo naming" and "RE: Algorithm Discovery (was Re: Strawman proposal for the low-level API - about the interoperable set of algo and algo naming)”。
讨论的一点总结了发现机制的问题:
(1) Discovery as I read the various appends, deals with the
algorithms not the permutations of parameters that may be allowed or
supported, so thus discovery of the algorithm may be successful but
may still fail, and thus the extra effort for discovery is overhead
and extra code path
与 "Bug 25985 - WebCrypto should be inter-operable" and during a phone conference in July 2014 工作组再次部分讨论了该问题,工作组决定 "Resolve the problem later" 使用配置文件。
规范中也提到了这一点:
In particular, we are expecting a "browser profile" to be created of
interoperable algorithms for Web browsers.
想法是为传统网络浏览器、智能电视等创建配置文件。如果存在特定配置文件,则必须支持某些算法。这将在未来经过测试阶段后决定。
我不确定您的实施要求是什么以及在运行时的什么时候您需要知道支持的算法,但我在一个预先知道所需算法的特定项目中使用了 WebCrypto API .
我们能够在初始化期间执行一系列简单测试,以确定我们的算法是否受支持。这一点,结合一些已知的缺陷(window.msCrypto 定义?IE11 和 SHA-1 缺失,window.crypto.webkitSubtle 定义?Webkit 和 AES-GCM 缺失等),使我们至少能够及早知道是否支持在那里,要么使用替代算法,替代实现要么失败。
Web Cryptography API 通过 JavaScript 支持使用浏览器的本机加密功能,例如可靠的随机数生成器或使用不同算法进行加密或签名的可能性。
规范列出了 overview of algorithms 作为实施者的起点,但添加了以下编辑说明:
Note: All algorithms listed should be considered as "features at risk", barring implementors adopting them. Their inclusion in the Editor's Draft reflects requests for their inclusion by members of the community, and are included as an exercise to ensure the robustness of the API defined in this specification.
As such, the list of algorithms, and the recommendations, may be significantly altered in future revisions.
据我了解,规范背后的想法是为密码学提供一个接口,而不是写下具体的算法(这完全有道理!)。
如何确定客户端是否支持特定算法?隐藏实现细节是一种很好的做法,但由于算法必须具有所谓的 可识别的算法名称 我不明白您为什么不想公开已注册的算法。 仍然没有指定接口,您注册算法的对象描述如下:
This specification makes use of an internal object, [[supportedAlgorithms]].
This internal object is not exposed to applications.
在当前状态下发现可用算法的唯一可能性是捕捉微妙界面的NotSupportedError。
从我的角度来看,发现是简单的程序流程,错误应该作为异常处理,而不是实现逻辑。
有什么提示或建议吗?也欢迎链接到适当的 w3c-mailinglist 讨论。
未计划对算法发现接口的支持。
这个问题在 2012 年的 w3c working groups mailinglist 上进行了详细讨论,其中提出了一些问题,请参阅线程“RE: Strawman proposal for the low-level API - about the interoperable set of algo and algo naming" and "RE: Algorithm Discovery (was Re: Strawman proposal for the low-level API - about the interoperable set of algo and algo naming)”。
讨论的一点总结了发现机制的问题:
(1) Discovery as I read the various appends, deals with the algorithms not the permutations of parameters that may be allowed or supported, so thus discovery of the algorithm may be successful but may still fail, and thus the extra effort for discovery is overhead and extra code path
与 "Bug 25985 - WebCrypto should be inter-operable" and during a phone conference in July 2014 工作组再次部分讨论了该问题,工作组决定 "Resolve the problem later" 使用配置文件。 规范中也提到了这一点:
In particular, we are expecting a "browser profile" to be created of interoperable algorithms for Web browsers.
想法是为传统网络浏览器、智能电视等创建配置文件。如果存在特定配置文件,则必须支持某些算法。这将在未来经过测试阶段后决定。
我不确定您的实施要求是什么以及在运行时的什么时候您需要知道支持的算法,但我在一个预先知道所需算法的特定项目中使用了 WebCrypto API .
我们能够在初始化期间执行一系列简单测试,以确定我们的算法是否受支持。这一点,结合一些已知的缺陷(window.msCrypto 定义?IE11 和 SHA-1 缺失,window.crypto.webkitSubtle 定义?Webkit 和 AES-GCM 缺失等),使我们至少能够及早知道是否支持在那里,要么使用替代算法,替代实现要么失败。