XPCOM Encrypt/Decrypt operation on file in Firefox Extension
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 i开发者_如何学Cs 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).
精彩评论