cgpgaccess.js

Summary
cgpgaccess.js
Constants
nsIExtensionManager_CONRACTIDThe component id to manage extentions
NS_APPINFO_CONTRACTIDThe component id to test the current os
FireGPG.Const.OSThe component to test the current os.
OS_WINDOWSThe value retruned by components if the os is window
idAppliThe id of firegpg.
States of the xpcom support.  Deprecated
commentThe firegpg’s comment to add to gnupg texts.
Variables
useGPGTrustIf we have to disable trusting system of gnupg.
FireGPG.Const.CurrentFolderThe folder of Firefox
Functions
loadXpcomThis function try to load the xpcom.
FireGPG.isGpgAgentActivatedReturn true if we should use the agent (option and environement variable set
FireGPGGPGAccessThis is the main class to access to the gnupg executable.
Variables
FireGPGCallThe FireGPGCall xpcom.
Functions
isUnixReturn true if we are on a unix system, false if we’re on windows.
getGPGBonusCommandReturn the custom arguement the user want to add.
getGPGCommentArgumentReturn a arguement to add a gnupg comment.
getGPGCommentArgumentReturn a arguement to disable or not the gnupg agent, as set in the options.
getGPGTrustArgumentReturn a arguement to force gnupg to use not trusted keys.
getGPGCommandReturn the command to execute GnuPG
getBaseArugments
getProxyInformationReturn the option to set the proxy for keyservers
getDiegestAlgoReturn the option to set diegest algo to use for signs hashs
getEnvReturn environement parameters
runGnupgExecute gnupg.
signSign a text.
verifyVerify a text.
listkeyList keys.
listSignsList signs.
cryptEncrypt a text.
symetricSymetricaly encrypt a text.
cryptAndSignEncrypt and sign a text.
decryptDecrypt a text.
selfTestReturn true if we’re able to call GnuPG.
kimportImport a key.
kexportExport a key.
refreshKeysFromServerSyncronize keys with the keyserver
sendKeyToServerSend a key from a keyserver
retriveKeyFromServerGet a key from a keyserver
searchKeyInServerSeach for a key in keyserver
changeTrustChange trust of a key
changePasswordChange password of a key
generateKeyGenerate a new key
deleteKeyDelete a key (!)
delUidDelete an identity of a key
revokeUidRevoke an identity of a key
addUidAdd a new identity to a key
signKeySign a key
revoqueSignDeprecated function
revokeKeyRevoke a key (!)
computeHashCompute hash of a file
runATestTest if we are currently able to run the a command.
tryToFoundTheRightCommandDo some test to be able to find a working GnuPG executable.
FireGPGGPGAccessWindowsXpcomThis class has function for building command lines for GnuPG actions on windows, when the xpcom is available.
FireGPGGPGAccessUnixXpcomThis class has function for building command lines for GnuPG actions on linux, when the xpcom is available.

Constants

nsIExtensionManager_CONRACTID

The component id to manage extentions

NS_APPINFO_CONTRACTID

The component id to test the current os

FireGPG.Const.OS

The component to test the current os.

OS_WINDOWS

The value retruned by components if the os is window

idAppli

The id of firegpg.

States of the xpcom support.  Deprecated

XPCOM_STATE_NEVERTESTEDNever tryied to use the xpcom
XPCOM_STATE_WORKSThe xpcom works and we use it.
XPCOM_STATE_DONTWORKThe xpcom doesn’t work.
XPCOM_STATE_DISABLEDThe xpcom is disabled
XPCOM_STATE_DONTWORK_IN_0_5The xpcom of version 0.5 doesn’t work.

const XPCOM_STATE_DONTWORK_IN_0_5 = 2; const XPCOM_STATE_DISABLED_IN_0_5 = 3;

const XPCOM_STATE_NEVERTESTED = 0; const XPCOM_STATE_WORKS = 1; const XPCOM_STATE_DONTWORK = 2; const XPCOM_STATE_DISABLED = 3;

comment

The firegpg’s comment to add to gnupg texts.

Variables

useGPGTrust

FireGPG.useGPGTrust

If we have to disable trusting system of gnupg.  Set in cGpg.

FireGPG.Const.CurrentFolder

FireGPG.Const.CurrentFolder

The folder of Firefox

Functions

loadXpcom

FireGPG.loadXpcom = function ()

This function try to load the xpcom.

She return false if an erreor happend, or ture if all works.

FireGPG.isGpgAgentActivated

FireGPG.isGpgAgentActivated = function()

Return true if we should use the agent (option and environement variable set

FireGPGGPGAccess

This is the main class to access to the gnupg executable.

Summary
Variables
FireGPGCallThe FireGPGCall xpcom.
Functions
isUnixReturn true if we are on a unix system, false if we’re on windows.
getGPGBonusCommandReturn the custom arguement the user want to add.
getGPGCommentArgumentReturn a arguement to add a gnupg comment.
getGPGCommentArgumentReturn a arguement to disable or not the gnupg agent, as set in the options.
getGPGTrustArgumentReturn a arguement to force gnupg to use not trusted keys.
getGPGCommandReturn the command to execute GnuPG
getBaseArugments
getProxyInformationReturn the option to set the proxy for keyservers
getDiegestAlgoReturn the option to set diegest algo to use for signs hashs
getEnvReturn environement parameters
runGnupgExecute gnupg.
signSign a text.
verifyVerify a text.
listkeyList keys.
listSignsList signs.
cryptEncrypt a text.
symetricSymetricaly encrypt a text.
cryptAndSignEncrypt and sign a text.
decryptDecrypt a text.
selfTestReturn true if we’re able to call GnuPG.
kimportImport a key.
kexportExport a key.
refreshKeysFromServerSyncronize keys with the keyserver
sendKeyToServerSend a key from a keyserver
retriveKeyFromServerGet a key from a keyserver
searchKeyInServerSeach for a key in keyserver
changeTrustChange trust of a key
changePasswordChange password of a key
generateKeyGenerate a new key
deleteKeyDelete a key (!)
delUidDelete an identity of a key
revokeUidRevoke an identity of a key
addUidAdd a new identity to a key
signKeySign a key
revoqueSignDeprecated function
revokeKeyRevoke a key (!)
computeHashCompute hash of a file
runATestTest if we are currently able to run the a command.
tryToFoundTheRightCommandDo some test to be able to find a working GnuPG executable.

Variables

FireGPGCall

The FireGPGCall xpcom.  Null if not available.

Functions

isUnix

isUnix: function()

Return true if we are on a unix system, false if we’re on windows.

getGPGBonusCommand

getGPGBonusCommand: function()

Return the custom arguement the user want to add.

getGPGCommentArgument

getGPGCommentArgument: function()

Return a arguement to add a gnupg comment.  If desactivated, return false.

getGPGCommentArgument

Return a arguement to disable or not the gnupg agent, as set in the options.

getGPGTrustArgument

getGPGTrustArgument: function (fromGpgAuth,
fromDTA)

Return a arguement to force gnupg to use not trusted keys.

Parameters

fromGpgAuthOptionnal use the GpgAuth’s parameter

getGPGCommand

getGPGCommand: function ()

Return the command to execute GnuPG

getBaseArugments

getBaseArugments: function (fromGpgAuth)

Parameters

fromGpgAuthOptional use the GpgAuth’s parameter to add verbosity to aquire the key and subkey ID when encrypting.

Return the commons arguments for all GnuPG’s commands

getProxyInformation

getProxyInformation: function ()

Return the option to set the proxy for keyservers

getDiegestAlgo

getDiegestAlgo: function ()

Return the option to set diegest algo to use for signs hashs

getEnv

getEnv: function()

Return environement parameters

runGnupg

runGnupg: function(parameters,
sdtIn,
charset)

Execute gnupg.

Parameters

parametersThe parameters for gnupg.
sdtInThe data to send to gnupg on the sdIn
charsetOptional.  The charset to read the sdtIn (UTF-8 by default)

Return

The sdOut (.out) and the sdErr (.err) of the execution

sign

sign: function (text,
password,
keyID,
notClear,
fileMode,
fileFrom,
fileTo)

Sign a text.

Parameters

textThe data to sign
passwordThe password of the private key
keyIDThe ID of the private key to use.
notClearDo not make a clear sign
fileModeOptional.  Indicate the user want to sign a file
fileFromOptional.  The file to sign
fileToOptional.  The file where to put the signature

Return

A FireGPG.GPGReturn structure.

verify

verify: function(text,
charset,
fileMode,
fileFrom,
fileSig,
fileDataForSign,
fromDTA)

Verify a text.

Parameters

textA text with the GnuPG data to test.
charsetOptional, the charset to use
fileModeOptional.  Indicate the user want to verify the signature of a file
fileFromOptional.  The file to verify
fileSigOptional.  The file with the signature

Return

A FireGPG.GPGReturn structure.

listkey

listkey: function(onlyPrivate)

List keys.

Parameters

onlyPrivateBoolean, set to true if only a private key list is wanted.

Return

A FireGPG.GPGReturn structure.

listSigns

List signs.

Return

A FireGPG.GPGReturn structure.

crypt

crypt: function(text,
keyIdList,
fromGpgAuth,
binFileMode,
fileMode,
fileFrom,
fileTo)

Encrypt a text.

Parameters

textThe data to encrypt
keyIdListA key list of recipients
fromGpgAuthOptional.  Set this to true if called form GpgAuth
binFileModeOptional.  Set this to true if data is binary (no text)
fileModeOptional.  Indicate the user want to encrypt a file
fileFromOptional.  The file to encrypt
fileToOptional.  The file where to put the encrypted content

Return

A FireGPG.GPGReturn structure.

symetric

symetric: function(text,
password,
algo,
fileMode,
fileFrom,
fileTo)

Symetricaly encrypt a text.

Parameters

textThe data to encrypt
passwordThe password
algoThe cipher used to encrypt
fileModeIndicate the user want to encrypt a file
fileFromThe file to sign
fileToThe file where to put the encrypted file

Return

A FireGPG.GPGReturn structure.

cryptAndSign

cryptAndSign: function(text,
keyIdList,
fromGpgAuth,
password,
keyID,
binFileMode,
fileMode,
fileFrom,
fileTo)

Encrypt and sign a text.

Parameters

textThe data to encrypt
keyIdListA key list of recipients
fromGpgAuthSet this to true if called form GpgAuth
passwordThe password of the private key
keyIDThe ID of the private key to use.
binFileModeSet this to true if data is binary (no text)
fileModeIndicate the user want to encrypt&sign a file
fileFromThe file to sign
fileToThe file where to put the encrypted & signed file

Return

A FireGPG.GPGReturn structure.

decrypt

decrypt: function(text,
password,
binFileMode,
fileMode,
fileFrom,
fileTo)

Decrypt a text.

Parameters

textThe data to decrypt
passwordThe password of the private key
binFileEncodedWork on binary data
fileModeIndicate the user want to Decrypt a file
fileFromThe file to decrypt
fileToThe file where to put the decrypted file

Return

A FireGPG.GPGReturn structure.

selfTest

selfTest: function()

Return true if we’re able to call GnuPG.

kimport

kimport: function(text)

Import a key.

Parameters

textA text with the GnuPG data to import.

Return

A FireGPG.GPGReturn structure.

kexport

kexport: function(key)

Export a key.

Parameters

keyThe key id to export.

Return

A FireGPG.GPGReturn structure.

refreshKeysFromServer

Syncronize keys with the keyserver

Parameters

serverThe key server to use

Return

A FireGPG.GPGReturn structure.

sendKeyToServer

sendKeyToServer: function(key,
server)

Send a key from a keyserver

Parameters

keyIdThe ked id to send
serverThe key server to use

Return

A FireGPG.GPGReturn structure.

retriveKeyFromServer

retriveKeyFromServer: function(key,
server)

Get a key from a keyserver

Parameters

keyIdThe ked id to get
serverThe key server to use

Return

A FireGPG.GPGReturn structure.

searchKeyInServer

searchKeyInServer: function(search,
server)

Seach for a key in keyserver

Parameters

searchThe text to search
serverThe key server to use

Return

A FireGPG.GPGReturn structure.

changeTrust

changeTrust: function(key,
trustLevel)

Change trust of a key

Parameters

keyThe key id
trustLevelThe new level of trusting

Return

A FireGPG.GPGReturn structure.

changePassword

changePassword: function(key,
oldpass,
newpass)

Change password of a key

Parameters

keyThe key id
oldpassThe old password
newpassThe new password

Return

A FireGPG.GPGReturn structure.

generateKey

Generate a new key

Parameters

nameThe name of the key
emailThe email of the key
commentThe cpmment of the key
password1The password of the key
password2The password of the key
keyneverexpireTrue if the key shouldn’t expire
keyexpirevalueThe expiration value of the key
keyexpiretypeThe type of the expiration value
keylengthThe length of the key
keytypeThe type of the key

Return

A FireGPG.GPGReturn structure.

deleteKey

deleteKey: function(key)

Delete a key (!)

Parameters

keyThe key to delete

Return

A FireGPG.GPGReturn structure.

delUid

delUid: function(key,
uid)

Delete an identity of a key

Parameters

keyThe key
uidThe uid to delete
passwordThe password of the key

Return

A FireGPG.GPGReturn structure.

revokeUid

revokeUid: function(key,
uid,
password,
raison)

Revoke an identity of a key

Parameters

keyThe key
uidThe uid to revoke
passwordThe password of the key
raisonThe raison of the revocation

Return

A FireGPG.GPGReturn structure.

addUid

addUid: function(key,
name,
email,
comment,
password)

Add a new identity to a key

Parameters

keyThe key to revoke
nameThe name of the new UID
emailThe email of the new UID
commentThe comment of the new UID
passwordThe password of the key

Return

A FireGPG.GPGReturn structure.

signKey

signKey: function(key,
keyForSign,
password)

Sign a key

Parameters

keyThe key
keyForSignThe key used to sign
passwordThe password of the key (used to sign)

Return

A FireGPG.GPGReturn structure.

revoqueSign

revoqueSign: function (key,
uid,
password)

Deprecated function

revokeKey

revokeKey: function (key,
password,
raison)

Revoke a key (!)

Parameters

keyThe key to revoke
raisonThe rasion to delete the key
passwordThe password of the key

Return

A FireGPG.GPGReturn structure.

computeHash

computeHash: function(hash,
file)

Compute hash of a file

Parameters

hashThe hash to use (MD5, SHA1, etc.)
fileThe file

Return

A FireGPG.GPGReturn structure.

runATest

runATest: function(option)

Test if we are currently able to run the a command.

Parameters

optionThe option to test.

Return

A FireGPG.GPGReturn structure.

tryToFoundTheRightCommand

tryToFoundTheRightCommand: function ()

Do some test to be able to find a working GnuPG executable.  This function is overwrited by the coresponding function of FireGPGGPGAccessWindowsXpcom or FireGPGGPGAccessUnixXpcom

FireGPGGPGAccessWindowsXpcom

This class has function for building command lines for GnuPG actions on windows, when the xpcom is available.

Please refer to functions marked as overwrited by this class in FireGPGGPGAccess for the descriptions of this class’s functions.

See Also

FireGPGGPGAccessUnixXpcom

FireGPGGPGAccessUnixXpcom

This class has function for building command lines for GnuPG actions on linux, when the xpcom is available.

Please refer to functions marked as overwrited by this class in FireGPGGPGAccess for the descriptions of this class’s functions.

See Also

FireGPGGPGAccessWindowsXpcom

FireGPG.useGPGTrust
If we have to disable trusting system of gnupg.
FireGPG.Const.CurrentFolder
The folder of Firefox
FireGPG.loadXpcom = function ()
This function try to load the xpcom.
FireGPG.isGpgAgentActivated = function()
Return true if we should use the agent (option and environement variable set
isUnix: function()
Return true if we are on a unix system, false if we’re on windows.
getGPGBonusCommand: function()
Return the custom arguement the user want to add.
getGPGCommentArgument: function()
Return a arguement to add a gnupg comment.
getGPGTrustArgument: function (fromGpgAuth,
fromDTA)
Return a arguement to force gnupg to use not trusted keys.
getGPGCommand: function ()
Return the command to execute GnuPG
getBaseArugments: function (fromGpgAuth)
getProxyInformation: function ()
Return the option to set the proxy for keyservers
getDiegestAlgo: function ()
Return the option to set diegest algo to use for signs hashs
getEnv: function()
Return environement parameters
runGnupg: function(parameters,
sdtIn,
charset)
Execute gnupg.
sign: function (text,
password,
keyID,
notClear,
fileMode,
fileFrom,
fileTo)
Sign a text.
verify: function(text,
charset,
fileMode,
fileFrom,
fileSig,
fileDataForSign,
fromDTA)
Verify a text.
listkey: function(onlyPrivate)
List keys.
crypt: function(text,
keyIdList,
fromGpgAuth,
binFileMode,
fileMode,
fileFrom,
fileTo)
Encrypt a text.
symetric: function(text,
password,
algo,
fileMode,
fileFrom,
fileTo)
Symetricaly encrypt a text.
cryptAndSign: function(text,
keyIdList,
fromGpgAuth,
password,
keyID,
binFileMode,
fileMode,
fileFrom,
fileTo)
Encrypt and sign a text.
decrypt: function(text,
password,
binFileMode,
fileMode,
fileFrom,
fileTo)
Decrypt a text.
selfTest: function()
Return true if we’re able to call GnuPG.
kimport: function(text)
Import a key.
kexport: function(key)
Export a key.
sendKeyToServer: function(key,
server)
Send a key from a keyserver
retriveKeyFromServer: function(key,
server)
Get a key from a keyserver
searchKeyInServer: function(search,
server)
Seach for a key in keyserver
changeTrust: function(key,
trustLevel)
Change trust of a key
changePassword: function(key,
oldpass,
newpass)
Change password of a key
deleteKey: function(key)
Delete a key (!)
delUid: function(key,
uid)
Delete an identity of a key
revokeUid: function(key,
uid,
password,
raison)
Revoke an identity of a key
addUid: function(key,
name,
email,
comment,
password)
Add a new identity to a key
signKey: function(key,
keyForSign,
password)
Sign a key
revoqueSign: function (key,
uid,
password)
Deprecated function
revokeKey: function (key,
password,
raison)
Revoke a key (!)
computeHash: function(hash,
file)
Compute hash of a file
runATest: function(option)
Test if we are currently able to run the a command.
tryToFoundTheRightCommand: function ()
Do some test to be able to find a working GnuPG executable.
FireGPG.GPGReturn = function()
This function return a basic object, with variable to return informations about a FireGPG’s operation
This class has function for building command lines for GnuPG actions on windows, when the xpcom is available.
This class has function for building command lines for GnuPG actions on linux, when the xpcom is available.
This is the main class to access to the gnupg executable.
Close