cgpg.js

Summary
cgpg.js
Constants
FireGPG’s actions results
Functions
FireGPG.GPGReturnThis function return a basic object, with variable to return informations about a FireGPG’s operation
FireGPG.GPGKeyThis function return a basic object, who represent a PGP key
FireGPG.SortageThis is a function used to sort an array of FireGPG.GPGKey by the key name Use it like this : thearray.sort(Sortage)
FireGPGThis is the main kernel for FireGPG, who give access to all GPG functions (sign, encrypt, ...)
Functions
signFunction to sign a text.
listSignsList signatures of a key
listKeysWho return a list of key in the keyring
kimportFunction to import a sign.
kexportFunction to export a key
cryptFunction to encrypt a text.
cryptAndSignFunction to encrypt and sign a text.
verifyFunction to verify signs in a text.
layersFind each layer of a test and verify it (resurcise function)
layerverifyInternal, verify a part of a test.
decryptFunction to decrypt a text.
initGPGACCESSInit the FireGPGGPGAccess class (try to found the GnuPG’s command, etc.)
selfTestThis if are able to access to a GnuPG executable
searchKeyInServerSeach for a key in keyserver
retriveKeyFromServerGet a key from a keyserver
sendKeyToServerSend a key from a keyserver
refreshKeysFromServerSyncronize keys with the keyserver
changeTrustChange trust of a key
changePasswordChange password of a key
generateKeyGenerate a new key
deleteKeyDelete a key (!)
revokeKeyRevoke a key (!)
addUidAdd a new identity to a key
revokeUidRevoke an identity of a key
delUidDelete an identity of a key
signKeySign a key
computeHashCompute hash of a file
loadFireGPGAccessThis function will determing and ‘build’ the class to access gpg.

Constants

FireGPG’s actions results

FireGPG.Const.Results.SUCCESSThe operation was successfull or the signature is correct
FireGPG.Const.Results.CANCELThe operation was canceled, for exemple the user click on cancel when his password is asked.
FireGPG.Const.Results.ERROR_UNKNOWAn unkonw error happend
FireGPG.Const.Results.ERROR_PASSWORDThe specified password was wrong.
FireGPG.Const.Results.ERROR_NO_DATAThere wasen’t any text to do the operation
FireGPG.Const.Results.ERROR_ALREADY_SIGNThe text is already signed
FireGPG.Const.Results.ERROR_BAD_SIGNThe signature was bad
FireGPG.Const.Results.ERROR_NO_KEYImpossible to verify the signature beacause there wasn’t the public key in the keyring
FireGPG.Const.Results.ERROR_ALREADY_CRYPTThe text is already encrypted
FireGPG.Const.Results.ERROR_NO_GPG_DATAThe text is not a vlid PGP block
FireGPG.Const.Results.ERROR_INIT_FAILLEDThere is a problem with GPG, impossible to execute the executable.

Functions

FireGPG.GPGReturn

FireGPG.GPGReturn = function()

This function return a basic object, with variable to return informations about a FireGPG’s operation

Returns

An object with this variables to null :

resultThe result of the action see FireGPG’s actions results
ouputThe output form GnuPG
sdOutThe sdOut form GnuPG
encryptedThe encrypted data with GnuPG
decryptedThe decrypted data with GnuPG
signedThe signed data with GnuPG
signsresultsAn array with FireGPG.GPGReturn data for each sign’s result in the data.
signresultThe sign result for the first sign (or the current sign if we’re in the signsresults array)
signresulttextThe message for the result of the test on the first sign (or the current sign if we’re in the signsresults array)
signresultuserThe username of the key of the first sign (or the current sign if we’re in the signsresults array)
signresultdateThe date of the first sign (or the current sign if we’re in the signsresults array)
keylistAn array of FireGPG.GPGKey with the key of the specified keyring (private or public)
exportedThe exported key with GnuPG
messagetextThe message who is showed in the lasted alert (usefull when the silent mode is activated)

FireGPG.GPGKey

FireGPG.GPGKey = function()

This function return a basic object, who represent a PGP key

Returns

An object with this variables to null :

keyNameThe key’s name
keyExpiThe key’s expire date
keyDateThe key’s creation date (ou de la signature)
keyIdThe key’s id
subKeysAn array of FireGPG.GPGKey with the subkey of the key.
expiredTrue if the key is expired
revokedTrue if the key is revoked
keyTrustTrust of the key
fingerPrintThe fingerprint of the ey

FireGPG.Sortage

FireGPG.Sortage = function(a,
b)

This is a function used to sort an array of FireGPG.GPGKey by the key name Use it like this : thearray.sort(Sortage)

Parameters

aInternal
bInternal

FireGPG

This is the main kernel for FireGPG, who give access to all GPG functions (sign, encrypt, ...)

Summary
Functions
signFunction to sign a text.
listSignsList signatures of a key
listKeysWho return a list of key in the keyring
kimportFunction to import a sign.
kexportFunction to export a key
cryptFunction to encrypt a text.
cryptAndSignFunction to encrypt and sign a text.
verifyFunction to verify signs in a text.
layersFind each layer of a test and verify it (resurcise function)
layerverifyInternal, verify a part of a test.
decryptFunction to decrypt a text.
initGPGACCESSInit the FireGPGGPGAccess class (try to found the GnuPG’s command, etc.)
selfTestThis if are able to access to a GnuPG executable
searchKeyInServerSeach for a key in keyserver
retriveKeyFromServerGet a key from a keyserver
sendKeyToServerSend a key from a keyserver
refreshKeysFromServerSyncronize keys with the keyserver
changeTrustChange trust of a key
changePasswordChange password of a key
generateKeyGenerate a new key
deleteKeyDelete a key (!)
revokeKeyRevoke a key (!)
addUidAdd a new identity to a key
revokeUidRevoke an identity of a key
delUidDelete an identity of a key
signKeySign a key
computeHashCompute hash of a file
loadFireGPGAccessThis function will determing and ‘build’ the class to access gpg.

Functions

sign

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

Function to sign a text.

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user
textOptional, if not set try to use the selection.  The text to sign
keyIDOptional, if not set use the default private key or ask the user.  The private keyID used to sign.
passwordOptional, if not set ask the user.
notClearOptional, Do not make a clear sign
autoSelectPrivateOptional.  List of private key to preselect
wrapOptional.  Wrap signed text
fileModeOptional.  Indicate the user want to sign a file
fileFromOptional.  The file to sign
fileToOptional.  The file where to put the signature

listSigns

listSigns: function(key)

List signatures of a key

Parameters

keyThe key

listKeys

listKeys: function(onlyPrivate,
allKeys,
onlySignOfThisKey)

Who return a list of key in the keyring

Return a FireGPG.GPGReturn object.

Parameters

onlyPrivateOptional, default to false.  Set this to true to get only the private keys.
allKeysOptional.  Return expired and revokey keys too
onlySignOfThisKeyOptional.  Return only signs of the key

kimport

kimport: function(silent,
text,
passSecurity)

Function to import a sign.

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user
textOptional, if not set try to use the selection.  The text to import
passSecurityOptional, let’s user import anything (like private keys, booo)

kexport

kexport: function(silent,
keyID)

Function to export a key

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user
keyIDOptional, if not set use ask the user.  The public keyID to export

crypt

crypt: function(silent,
text,
keyIdList,
fromGpgAuth,
binFileMode,
autoSelect,
symetrical,
password,
fileMode,
fileFrom,
fileTo)

Function to encrypt a text.

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user
textOptional, if not set try to use the selection.  The text to encrypt
keyIdListOptional, if not set ask the user.  An array of recipients’ keys’ id to encrypt
fromGpgAuthOptional, Default to false.  Internal
binFileModeOptional, Default to false.  Set this to true if data isensn’t simple text.
autoSelectOptional, An array of recipients’ keys’ id to autoselect on the key’s list selection.
symetricalOptional.  Use symetrical encrypt
passwordOptional.  The password for symetrical encryption.
fileModeOptional.  Indicate the user want to encrypt a file
fileFromOptional.  The file to encrypt
fileToOptional.  The file where to put the encrypted content

cryptAndSign

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

Function to encrypt and sign a text.

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user
textOptional, if not set try to use the selection.  The text to sign
keyIDOptional, if not set use the default private key or ask the user.  The private keyID used to sign.
fromGpgAuthOptional, Default to false.  Internal
passwordOptional, if not set ask the user.  The password of the private key.
keyIdListOptional, if not set ask the user.  An array of recipients’ keys’ id to encrypt
binFileModeOptional, Default to false.  Set this to true if data isensn’t simple text.
autoSelectOptional, An array of recipients’ keys’ id to autoselect on the key’s list selection.
autoSelectOptional An array of private key to autoselect on key’s list selection.
fileModeOptional.  Indicate the user want to encrypt&sign a file
fileFromOptional.  The file to sign
fileToOptional.  The file where to put the encrypted & signed file

verify

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

Function to verify signs in a text.

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user
textOptional, if not set try to use the selection.  The text to verify
charsetOptional, the charset to use
signDataDeprecated parameter.
fileModeOptional.  Indicate the user want to verify the signature of a file
fileFromOptional.  The file to verify
fileSigOptional.  The file with the signature
fileDataForSignOptional.  The data with the signatur
fromDTAOptional.  True if called form DTA

layers

layers: function(text,
layer,
charset,
resultss)

Find each layer of a test and verify it (resurcise function)

Return an array of resultss FireGPG.GPGReturn object.

Parameters

textThe text to verify
layerThe current layer
resultssOptional.  The current array who should be returned.

layerverify

layerverify: function(text,
layer,
division,
charset,
dontask,
fileMode,
fileFrom,
fileSig,
nextText,
fileDataForSign,
fromDTA)

Internal, verify a part of a test.

Return a FireGPG.GPGReturn object.

Parameters

textThe text to verify
layerThe current layer
divisionThe current layer level
charsetThe charset to use
dontaskIf set to true, don’t ask to download the key
fileModeOptional.  Indicate the user want to verify the signature of a file
fileFromOptional.  The file to verify
fileSigOptional.  The file with the signature
nextTextThe Gpg output to use for signature verification (used for multi signs)
fileDataForSignOptional.  The data with the signatur
fromDTAOptional.  True if called form DTA

decrypt

decrypt: function(silent,
text,
password,
binFileEncoded,
fileMode,
fileFrom,
fileTo,
api)

Function to decrypt a text.

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user
textOptional, if not set try to use the selection.  The text to decrypt.
passwordOptional, if not set ask the user.  The password of the key used to encrypt the data.
binFileEncodedOptional Work on binary data
fileModeOptional.  Indicate the user want to Decrypt a file
fileFromOptional.  The file to decrypt
fileToOptional.  The file where to put the decrypted file
apiOptional True if it’s a call form the api

initGPGACCESS

initGPGACCESS: function()

Init the FireGPGGPGAccess class (try to found the GnuPG’s command, etc.).

selfTest

selfTest: function(silent)

This if are able to access to a GnuPG executable

Return a FireGPG.GPGReturn object.

Parameters

slientOptional, default to false.  Set this to true to disable any alert for the user

searchKeyInServer

searchKeyInServer: function(search,
silent)

Seach for a key in keyserver

Parameters

searchThe text to search
silentOptional, default to false.  Set this to true to disable any alert for the user

retriveKeyFromServer

retriveKeyFromServer: function(keyId,
silent)

Get a key from a keyserver

Parameters

keyIdThe ked id to get
silentOptional, default to false.  Set this to true to disable any alert for the user

sendKeyToServer

sendKeyToServer: function(keyId,
silent)

Send a key from a keyserver

Parameters

keyIdThe ked id to send
silentOptional, default to false.  Set this to true to disable any alert for the user

refreshKeysFromServer

refreshKeysFromServer: function(silent)

Syncronize keys with the keyserver

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user

changeTrust

changeTrust: function(silent,
key,
trustLevel)

Change trust of a key

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
keyThe key id
trustLevelThe new level of trusting

changePassword

changePassword: function(silent,
key,
oldpass,
newpass)

Change password of a key

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
keyThe key id
oldpassThe old password
newpassThe new password

generateKey

generateKey: function(silent,
name,
email,
comment,
password1,
password2,
keyneverexpire,
keyexpirevalue,
keyexpiretype,
keylength,
keytype)

Generate a new key

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
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

deleteKey

deleteKey: function(silent,
key)

Delete a key (!)

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
keyThe key to delete

revokeKey

revokeKey: function (silent,
key,
raison,
password)

Revoke a key (!)

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
keyThe key to revoke
raisonThe rasion to delete the key
passwordThe password of the key

addUid

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

Add a new identity to a key

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
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

revokeUid

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

Revoke an identity of a key

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
keyThe key
uidThe uid to revoke
passwordThe password of the key

delUid

delUid: function (silent,
key,
uid)

Delete an identity of a key

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
keyThe key
uidThe uid to delete
passwordThe password of the key

signKey

signKey: function(silent,
key,
keyForSign,
password)

Sign a key

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
keyThe key
keyForSignThe key used to sign
passwordThe password of the key (used to sign)

computeHash

computeHash: function(silent,
hash,
file)

Compute hash of a file

Parameters

silentOptional, default to false.  Set this to true to disable any alert for the user
hashThe hash to use (MD5, SHA1, etc.)
fileThe file

loadFireGPGAccess

loadFireGPGAccess: function()

This function will determing and ‘build’ the class to access gpg.

She test if the xpcom is usable, update information about the status, and select the rights function to access to gnupg as the current situtation.

She set the FireGPGGPGAccess class.

FireGPG.GPGReturn = function()
This function return a basic object, with variable to return informations about a FireGPG’s operation
FireGPG.GPGKey = function()
This function return a basic object, who represent a PGP key
FireGPG.Sortage = function(a,
b)
This is a function used to sort an array of FireGPG.GPGKey by the key name Use it like this : thearray.sort(Sortage)
sign: function(silent,
text,
keyID,
password,
notClear,
autoSelectPrivate,
wrap,
fileMode,
fileFrom,
fileTo)
Function to sign a text.
listSigns: function(key)
List signatures of a key
listKeys: function(onlyPrivate,
allKeys,
onlySignOfThisKey)
Who return a list of key in the keyring
kimport: function(silent,
text,
passSecurity)
Function to import a sign.
kexport: function(silent,
keyID)
Function to export a key
crypt: function(silent,
text,
keyIdList,
fromGpgAuth,
binFileMode,
autoSelect,
symetrical,
password,
fileMode,
fileFrom,
fileTo)
Function to encrypt a text.
cryptAndSign: function(silent,
text,
keyIdList,
fromGpgAuth,
password,
keyID,
binFileMode,
autoSelect,
autoSelectPrivate,
fileMode,
fileFrom,
fileTo)
Function to encrypt and sign a text.
verify: function(silent,
text,
charset,
signData,
fileMode,
fileFrom,
fileSig,
fileDataForSign,
fromDTA)
Function to verify signs in a text.
layers: function(text,
layer,
charset,
resultss)
Find each layer of a test and verify it (resurcise function)
layerverify: function(text,
layer,
division,
charset,
dontask,
fileMode,
fileFrom,
fileSig,
nextText,
fileDataForSign,
fromDTA)
Internal, verify a part of a test.
decrypt: function(silent,
text,
password,
binFileEncoded,
fileMode,
fileFrom,
fileTo,
api)
Function to decrypt a text.
initGPGACCESS: function()
Init the FireGPGGPGAccess class (try to found the GnuPG’s command, etc.)
selfTest: function(silent)
This if are able to access to a GnuPG executable
searchKeyInServer: function(search,
silent)
Seach for a key in keyserver
retriveKeyFromServer: function(keyId,
silent)
Get a key from a keyserver
sendKeyToServer: function(keyId,
silent)
Send a key from a keyserver
refreshKeysFromServer: function(silent)
Syncronize keys with the keyserver
changeTrust: function(silent,
key,
trustLevel)
Change trust of a key
changePassword: function(silent,
key,
oldpass,
newpass)
Change password of a key
generateKey: function(silent,
name,
email,
comment,
password1,
password2,
keyneverexpire,
keyexpirevalue,
keyexpiretype,
keylength,
keytype)
Generate a new key
deleteKey: function(silent,
key)
Delete a key (!)
revokeKey: function (silent,
key,
raison,
password)
Revoke a key (!)
addUid: function (silent,
key,
name,
email,
comment,
password)
Add a new identity to a key
revokeUid: function (silent,
key,
uid,
password)
Revoke an identity of a key
delUid: function (silent,
key,
uid)
Delete an identity of a key
signKey: function(silent,
key,
keyForSign,
password)
Sign a key
computeHash: function(silent,
hash,
file)
Compute hash of a file
loadFireGPGAccess: function()
This function will determing and ‘build’ the class to access gpg.
Close