Firefox扩展中的XPCOM加密/解密操作文件 [英] XPCOM Encrypt/Decrypt operation on file in Firefox Extension

查看:186
本文介绍了Firefox扩展中的XPCOM加密/解密操作文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Firefox扩展需要;




  • 存储用户凭据文件中,将存储在用户 local
    文件系统

  • 当需要凭证时,解密文件读取值和加密 it

  • 有时通过 http 将加密文件发送到服务器。 >


我无法找到任何 XPCOM 组件来加密/解密一个文件即可。我应该写自己的XPCOM对象,还是有其他合理的解决方案。



[注:]
这可能就像Firefox的密码管理系统一样。 Firefox将主密码和密钥存储在key3.db文件中,并使用这些值来访问存储在signons.sqlite文件中的凭据。



Firefox使用nsILoginManager接口进行操作。

解决方案

XPCOM目前没有提供使用 NSS 。您可以使用 js-ctypes 直接调用NSS函数 - 不简单可行的。您可以查看 WeaveCrypto.js 模块,用于使用对称密钥的示例实现。 DOMCrypt扩展程序例如基本上捆绑 WeaveCrypto.js 与扩展名,只调用其功能(使用浏览器分发的版本是不可推荐的 - 这是一个内部模块,其API可以随时更改)。


My Firefox extension needs to;

  • store user credentials in a file that will be stored in users local filesystem.
  • when credentials are needed, decrypt file read values and encrypt it again.
  • sometimes send encrypted file over http to a server.

I cant find any XPCOM component to encrypt / decrypt a file. Should i write my own XPCOM object, or is there any other reasonable solution for that.

[Note:] This may like Firefox's password management system. Firefox stores master password and keys in key3.db file and use these values to access credentials stored in signons.sqlite file.

Firefox uses nsILoginManager interface for its operations.

解决方案

XPCOM doesn't currently provide a way to use the encryption capabilities of NSS. You can use js-ctypes to call NSS functions directly - not simple but doable. You can take a look at the WeaveCrypto.js module for an example implementation using symmetric keys. The DOMCrypt extension for example essentially bundles WeaveCrypto.js with the extension and only calls its functions then (using the version distributed with the browser isn't recommendable - this is an internal module and its API could change any time).

这篇关于Firefox扩展中的XPCOM加密/解密操作文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆