Class: openpgp

openpgp

Main Openpgp.js class. Use this to initiate and make all calls to this library.

new openpgp()

GPG4Browsers Core interface. A single instance is hold from the beginning. To use this library call "openpgp.init()"
Source:

Methods

<inner> generate_key_pair(keyType, numBits, userId, passphrase) → {Object}

generates a new key pair for openpgp. Beta stage. Currently only supports RSA keys, and no subkeys.
Parameters:
Name Type Description
keyType Integer to indicate what type of key to make. RSA is 1. Follows algorithms outlined in OpenPGP.
numBits Integer number of bits for the key creation. (should be 1024+, generally)
userId String assumes already in form of "User Name "
passphrase String The passphrase used to encrypt the resulting private key
Source:
Returns:
{privateKey: [openpgp_msg_privatekey], privateKeyArmored: [string], publicKeyArmored: [string]}
Type
Object

<inner> init()

initializes the library: - reading the keyring from local storage - reading the config from local storage
Source:

<inner> read_message(armoredText) → {openpgp_msg_message[]}

reads message packets out of an OpenPGP armored text and returns an array of message objects
Parameters:
Name Type Description
armoredText String text to be parsed
Source:
Returns:
on error the function returns null
Type
openpgp_msg_message[]

<inner> read_messages_dearmored(input) → {openpgp_msg_message[]}

reads message packets out of an OpenPGP armored text and returns an array of message objects. Can be called externally or internally. External call will parse a de-armored messaged and return messages found. Internal will be called to read packets wrapped in other packets (i.e. compressed)
Parameters:
Name Type Description
input String dearmored text of OpenPGP packets, to be parsed
Source:
Returns:
on error the function returns null
Type
openpgp_msg_message[]

<inner> read_privateKey(armoredText) → {openpgp_msg_privatekey[]}

reads several privateKey objects from a ascii armored representation an returns openpgp_msg_privatekey objects
Parameters:
Name Type Description
armoredText String OpenPGP armored text containing the private key(s)
Source:
Returns:
on error the function returns null
Type
openpgp_msg_privatekey[]

<inner> read_publicKey(armoredText) → {openpgp_msg_publickey[]}

reads several publicKey objects from a ascii armored representation an returns openpgp_msg_publickey packets
Parameters:
Name Type Description
armoredText String OpenPGP armored text containing the public key(s)
Source:
Returns:
on error the function returns null
Type
openpgp_msg_publickey[]

<inner> write_encrypted_message(publickeys, messagetext) → {String}

creates a binary string representation of an encrypted message. The message will be encrypted with the public keys specified
Parameters:
Name Type Description
publickeys Object[] An array of {obj: [openpgp_msg_publickey]} -public keys to be used to encrypt the message
messagetext String message text to encrypt
Source:
Returns:
a binary string representation of the message which can be OpenPGP armored
Type
String

<inner> write_signed_and_encrypted_message(privatekey, publickeys, messagetext) → {String}

creates a binary string representation of an encrypted and signed message. The message will be encrypted with the public keys specified and signed with the specified private key.
Parameters:
Name Type Description
privatekey Object {obj: [openpgp_msg_privatekey]} Private key to be used to sign the message
publickeys Object[] An arraf of {obj: [openpgp_msg_publickey]} - public keys to be used to encrypt the message
messagetext String message text to encrypt and sign
Source:
Returns:
a binary string representation of the message which can be OpenPGP armored
Type
String

<inner> write_signed_message(privatekey, messagetext) → {Object}

creates a binary string representation a signed message. The message will be signed with the specified private key.
Parameters:
Name Type Description
privatekey Object {obj: [openpgp_msg_privatekey]} - the private key to be used to sign the message
messagetext String message text to sign
Source:
Returns:
{Object: text [String]}, openpgp: {String} a binary string representation of the message which can be OpenPGP armored(openpgp) and a text representation of the message (text). This can be directly used to OpenPGP armor the message
Type
Object