Global

Members

bin2str

Convert an array of integers(0.255) to a string
Source:

crc_table

Internal function to calculate a CRC-24 checksum over a given string (data)
Source:

hash_headers

ASN1 object identifiers for hashes (See RFC4880 5.2.2)
Source:

Uint8Array2str

Convert a Uint8Array to a string. This currently functions the same as bin2str.
Source:

util

an instance that should be used.
Source:

Methods

calc_checksum(text) → {Integer}

Calculates a 16bit sum of a string by adding each character codes modulus 65535
Parameters:
Name Type Description
text String String to create a sum of
Source:
Returns:
An integer containing the sum of all character codes % 65535
Type
Integer

decode_utf8(utf8) → {String}

Convert a string of utf8 bytes to a native javascript string
Parameters:
Name Type Description
utf8 String A valid squence of utf8 bytes
Source:
Returns:
A native javascript string
Type
String

encode_utf8(str) → {String}

Convert a native javascript string to a string of utf8 bytes
Parameters:
Name Type Description
str String The string to convert
Source:
Returns:
A valid squence of utf8 bytes
Type
String

get_hashAlgorithmString() → {String}

Return the algorithm type as string
Source:
Returns:
String representing the message type
Type
String

getCheckSum(data) → {String}

Calculates a checksum over the given data and returns it base64 encoded
Parameters:
Name Type Description
data String Data to create a CRC-24 checksum for
Source:
Returns:
Base64 encoded checksum
Type
String

getPGPMessageType(text) → {Integer}

Finds out which Ascii Armoring type is used. This is an internal function
Parameters:
Name Type Description
text String [String] ascii armored text
Source:
Returns:
0 = MESSAGE PART n of m 1 = MESSAGE PART n 2 = SIGNED MESSAGE 3 = PGP MESSAGE 4 = PUBLIC KEY BLOCK 5 = PRIVATE KEY BLOCK null = unknown
Type
Integer

hex2bin(str) → {String}

Create binary string from a hex encoded string
Parameters:
Name Type Description
str String Hex string to convert
Source:
Returns:
String containing the binary values
Type
String

hexidump(str) → {String}

Creating a hex string from an binary array of integers (0..255)
Parameters:
Name Type Description
str String Array of bytes to convert
Source:
Returns:
Hexadecimal representation of the array
Type
String

hexstrdump(str) → {String}

Create hexstring from a binary
Parameters:
Name Type Description
str String String to convert
Source:
Returns:
String containing the hexadecimal values
Type
String

MD5()

A fast MD5 JavaScript implementation Copyright (c) 2012 Joseph Myers http://www.myersdaily.org/joseph/javascript/md5-text.html Permission to use, copy, modify, and distribute this software and its documentation for any purposes and without fee is hereby granted provided that this copyright notice appears in all copies. Of course, this soft is provided "as is" without express or implied warranty of any kind.
Source:

openpgp_cfb_decrypt(blockcipherfn, block_size, plaintext, key, resync) → {String}

This function decrypts a given plaintext using the specified blockcipher to decrypt a message
Parameters:
Name Type Description
blockcipherfn openpgp_cipher_block_fn The algorithm _encrypt_ function to encrypt data in one block_size encryption.
block_size Integer the block size in bytes of the algorithm used
plaintext String ciphertext to be decrypted provided as a string
key openpgp_byte_array key to be used to decrypt the ciphertext. This will be passed to the blockcipherfn
resync Boolean a boolean value specifying if a resync of the IV should be used or not. The encrypteddatapacket uses the "old" style with a resync. Decryption within an encryptedintegrityprotecteddata packet is not resyncing the IV.
Source:
Returns:
a string with the plaintext data
Type
String

openpgp_cfb_encrypt(prefixrandom, blockcipherfn, block_size, plaintext, key, resync) → {String}

This function encrypts a given with the specified prefixrandom using the specified blockcipher to encrypt a message
Parameters:
Name Type Description
prefixrandom String random bytes of block_size length provided as a string to be used in prefixing the data
blockcipherfn openpgp_cipher_block_fn the algorithm encrypt function to encrypt data in one block_size encryption.
block_size Integer the block size in bytes of the algorithm used
plaintext String data to be encrypted provided as a string
key openpgp_byte_array key to be used to encrypt the data. This will be passed to the blockcipherfn
resync Boolean a boolean value specifying if a resync of the IV should be used or not. The encrypteddatapacket uses the "old" style with a resync. Encryption within an encryptedintegrityprotecteddata packet is not resyncing the IV.
Source:
Returns:
a string with the encrypted data
Type
String

openpgp_cfb_mdc(blockcipherencryptfn, block_size, key, ciphertext) → {String}

Decrypts the prefixed data for the Modification Detection Code (MDC) computation
Parameters:
Name Type Description
blockcipherencryptfn openpgp_block_cipher_fn Cipher function to use
block_size Integer Blocksize of the algorithm
key openpgp_byte_array The key for encryption
ciphertext String The encrypted data
Source:
Returns:
plaintext Data of D(ciphertext) with blocksize length +2
Type
String

openpgp_crypto_asymetricDecrypt(algo, publicMPIs, secretMPIs, data) → {BigInteger}

Decrypts data using the specified public key multiprecision integers of the private key, the specified secretMPIs of the private key and the specified algorithm.
Parameters:
Name Type Description
algo Integer Algorithm to be used (See RFC4880 9.1)
publicMPIs openpgp_type_mpi[] Algorithm dependent multiprecision integers of the public key part of the private key
secretMPIs openpgp_type_mpi[] Algorithm dependent multiprecision integers of the private key used
data openpgp_type_mpi Data to be encrypted as MPI
Source:
Returns:
returns a big integer containing the decrypted data; otherwise null
Type
BigInteger

openpgp_crypto_asymetricEncrypt(algo, publicMPIs, data) → {openpgp_type_mpi|Array.<openpgp_type_mpi>}

Encrypts data using the specified public key multiprecision integers and the specified algorithm.
Parameters:
Name Type Description
algo Integer Algorithm to be used (See RFC4880 9.1)
publicMPIs openpgp_type_mpi[] Algorithm dependent multiprecision integers
data openpgp_type_mpi Data to be encrypted as MPI
Source:
Returns:
if RSA an openpgp_type_mpi; if elgamal encryption an array of two openpgp_type_mpi is returned; otherwise null
Type
openpgp_type_mpi | Array.<openpgp_type_mpi>

openpgp_crypto_generateKeyPair(keyType, numBits) → {openpgp_keypair}

Calls the necessary crypto functions to generate a keypair. Called directly by openpgp.js
Parameters:
Name Type Description
keyType Integer Follows OpenPGP algorithm convention.
numBits Integer Number of bits to make the key to be generated
Source:
Returns:
Type
openpgp_keypair

openpgp_crypto_generateSessionKey(algo) → {String}

Generating a session key for the specified symmetric algorithm
Parameters:
Name Type Description
algo Integer Algorithm to use (see RFC4880 9.2)
Source:
Returns:
Random bytes as a string to be used as a key
Type
String

openpgp_crypto_getHashByteLength(algo) → {Integer}

Returns the hash size in bytes of the specified hash algorithm type
Parameters:
Name Type Description
algo Integer Hash algorithm type (See RFC4880 9.4)
Source:
Returns:
Size in bytes of the resulting hash
Type
Integer

openpgp_crypto_getPrefixRandom(algo) → {String}

generate random byte prefix as string for the specified algorithm
Parameters:
Name Type Description
algo Integer Algorithm to use (see RFC4880 9.2)
Source:
Returns:
Random bytes with length equal to the block size of the cipher
Type
String

openpgp_crypto_getPseudoRandom(from, to) → {Integer}

Return a pseudo-random number in the specified range
Parameters:
Name Type Description
from Integer Min of the random number
to Integer Max of the random number (max 32bit)
Source:
Returns:
A pseudo random number
Type
Integer

openpgp_crypto_getRandomBigInteger(bits) → {BigInteger}

Create a secure random big integer of bits length
Parameters:
Name Type Description
bits Integer Bit length of the MPI to create
Source:
Returns:
Resulting big integer
Type
BigInteger

openpgp_crypto_getRandomBytes(length) → {String}

Retrieve secure random byte string of the specified length
Parameters:
Name Type Description
length Integer Length in bytes to generate
Source:
Returns:
Random byte string
Type
String

openpgp_crypto_getSecureRandom(from, to) → {Integer}

Return a secure random number in the specified range
Parameters:
Name Type Description
from Integer Min of the random number
to Integer Max of the random number (max 32bit)
Source:
Returns:
A secure random number
Type
Integer

openpgp_crypto_hashData(algo, data) → {String}

Create a hash on the specified data using the specified algorithm
Parameters:
Name Type Description
algo Integer Hash algorithm type (see RFC4880 9.4)
data String Data to be hashed
Source:
Returns:
hash value
Type
String

openpgp_crypto_MDCSystemBytes(algo, key, data) → {String}

retrieve the MDC prefixed bytes by decrypting them
Parameters:
Name Type Description
algo Integer Algorithm to use (see RFC4880 9.2)
key String Key as string. length is depending on the algorithm used
data String Encrypted data where the prefix is decrypted from
Source:
Returns:
Plain text data of the prefixed data
Type
String

openpgp_crypto_signData(hash_algo, algo, publicMPIs, secretMPIs, data) → {String|openpgp_type_mpi}

Create a signature on data using the specified algorithm
Parameters:
Name Type Description
hash_algo Integer hash Algorithm to use (See RFC4880 9.4)
algo Integer Asymmetric cipher algorithm to use (See RFC4880 9.1)
publicMPIs openpgp_type_mpi[] Public key multiprecision integers of the private key
secretMPIs openpgp_type_mpi[] Private key multiprecision integers which is used to sign the data
data String Data to be signed
Source:
Returns:
Type
String | openpgp_type_mpi

openpgp_crypto_symmetricDecrypt(algo, key, data, openpgp_cfb) → {String}

Symmetrically decrypts data using a key with length depending on the algorithm in openpgp_cfb mode with or without resync (MDC style)
Parameters:
Name Type Description
algo Integer Algorithm to use (see RFC4880 9.2)
key String Key as string. length is depending on the algorithm used
data String Data to be decrypted
openpgp_cfb Boolean If true use the resync (for encrypteddata); otherwise use without the resync (for MDC encrypted data)
Source:
Returns:
Plaintext data
Type
String

openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_cfb) → {String}

Symmetrically encrypts data using prefixedrandom, a key with length depending on the algorithm in openpgp_cfb mode with or without resync (MDC style)
Parameters:
Name Type Description
prefixrandom String Secure random bytes as string in length equal to the block size of the algorithm used (use openpgp_crypto_getPrefixRandom(algo) to retrieve that string
algo Integer Algorithm to use (see RFC4880 9.2)
key String Key as string. length is depending on the algorithm used
data String Data to encrypt
openpgp_cfb Boolean
Source:
Returns:
Encrypted data
Type
String

openpgp_crypto_verifySignature(algo, hash_algo, msg_MPIs, publickey_MPIs, data) → {Boolean}

Parameters:
Name Type Description
algo Integer public Key algorithm
hash_algo Integer Hash algorithm
msg_MPIs openpgp_type_mpi[] Signature multiprecision integers
publickey_MPIs openpgp_type_mpi[] Public key multiprecision integers
data String Data on where the signature was computed on.
Source:
Returns:
true if signature (sig_data was equal to data over hash)
Type
Boolean

openpgp_encoding_armor(messagetype, data, partindex, parttotal) → {String}

Armor an OpenPGP binary packet block
Parameters:
Name Type Description
messagetype Integer type of the message
data
partindex Integer
parttotal Integer
Source:
Returns:
Armored text
Type
String

openpgp_encoding_armor_addheader() → {String}

Add additional information to the armor version of an OpenPGP binary packet block.
Version:
  • 2011-12-16
Author:
  • Alex
Source:
Returns:
The header information
Type
String

openpgp_encoding_base64_decode(message) → {String}

Wrapper function for the base64 codec. This function decodes a String(message) in base64 (radix-64)
Parameters:
Name Type Description
message String Base64 encoded data
Source:
Returns:
Raw data after decoding
Type
String

openpgp_encoding_base64_encode(message) → {String}

Wrapper function for the base64 codec. This function encodes a String (message) in base64 (radix-64)
Parameters:
Name Type Description
message String The message to encode
Source:
Returns:
The base64 encoded data
Type
String

openpgp_encoding_deArmor(text) → {String|Object}

DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes
Parameters:
Name Type Description
text String OpenPGP armored message
Source:
Returns:
Either the bytes of the decoded message or an object with attribute "text" containing the message text and an attribute "openpgp" containing the bytes.
Type
String | Object

openpgp_encoding_eme_pkcs1_decode(message) → {String}

decodes a EME-PKCS1-v1_5 padding (See RFC4880 13.1.2)
Parameters:
Name Type Description
message String EME-PKCS1 padded message
Source:
Returns:
decoded message
Type
String

openpgp_encoding_eme_pkcs1_encode(message, length) → {String}

create a EME-PKCS1-v1_5 padding (See RFC4880 13.1.1)
Parameters:
Name Type Description
message String message to be padded
length Integer Length to the resulting message
Source:
Returns:
EME-PKCS1 padded message
Type
String

openpgp_encoding_emsa_pkcs1_decode(data) → {String}

extract the hash out of an EMSA-PKCS1-v1.5 padding (See RFC4880 13.1.3)
Parameters:
Name Type Description
data String Hash in pkcs1 encoding
Source:
Returns:
The hash as string
Type
String

openpgp_encoding_emsa_pkcs1_encode(algo, data, keylength) → {String}

create a EMSA-PKCS1-v1_5 padding (See RFC4880 13.1.3)
Parameters:
Name Type Description
algo Integer Hash algorithm type used
data String Data to be hashed
keylength Integer Key size of the public mpi in bytes
Source:
Returns:
Hashcode with pkcs1padding as string
Type
String

openpgp_encoding_html_encode(message) → {String}

Wrapper function for jquery library. This function escapes HTML characters within a string. This is used to prevent XSS.
Parameters:
Name Type Description
message String Message to escape
Source:
Returns:
Html encoded string
Type
String
Helper function to print a debug message. Debug messages are only printed if openpgp.config.debug is set to true. The calling Javascript context MUST define a "showMessages(text)" function. Line feeds ('\n') are automatically converted to HTML line feeds '
'
Parameters:
Name Type Description
str String String of the debug message
Source:
Returns:
An HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in.
Type
String
Helper function to print a debug message. Debug messages are only printed if openpgp.config.debug is set to true. The calling Javascript context MUST define a "showMessages(text)" function. Line feeds ('\n') are automatically converted to HTML line feeds '
' Different than print_debug because will call hexstrdump iff necessary.
Parameters:
Name Type Description
str String String of the debug message
Source:
Returns:
An HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in.
Type
String
Helper function to print an error message. The calling Javascript context MUST define a "showMessages(text)" function. Line feeds ('\n') are automatically converted to HTML line feeds '
'
Parameters:
Name Type Description
str String String of the error message
Source:
Returns:
A HTML paragraph entity with a style attribute containing the HTML encoded error message
Type
String
Helper function to print an info message. The calling Javascript context MUST define a "showMessages(text)" function. Line feeds ('\n') are automatically converted to HTML line feeds '
'.
Parameters:
Name Type Description
str String String of the info message
Source:
Returns:
A HTML paragraph entity with a style attribute containing the HTML encoded info message
Type
String

shiftRight(value, bitcount) → {String}

Shifting a string to n bits right
Parameters:
Name Type Description
value String The string to shift
bitcount Integer Amount of bits to shift (MUST be smaller than 9)
Source:
Returns:
Resulting string.
Type
String

str2bin(str) → {Integer[]}

Convert a string to an array of integers(0.255)
Parameters:
Name Type Description
str String String to convert
Source:
Returns:
An array of (binary) integers
Type
Integer[]

str2Uint8Array(str) → {Uint8Array}

Convert a string to a Uint8Array
Parameters:
Name Type Description
str String String to convert
Source:
Returns:
The array of (binary) integers
Type
Uint8Array

verifyCheckSum(data, checksum) → {Boolean}

Calculates the checksum over the given data and compares it with the given base64 encoded checksum
Parameters:
Name Type Description
data String Data to create a CRC-24 checksum for
checksum String Base64 encoded checksum
Source:
Returns:
True if the given checksum is correct; otherwise false
Type
Boolean

Type Definitions

openpgp_byte_array

An array of bytes, that is integers with values from 0 to 255
Source:

openpgp_cipher_block_fn(block, key) → {openpgp_byte_array}

Block cipher function
Parameters:
Name Type Description
block openpgp_byte_array A block to perform operations on
key openpgp_byte_array to use in encryption/decryption
Source:
Returns:
Encrypted/decrypted block
Type
openpgp_byte_array

openpgp_keypair

Properties:
Name Type Description
privateKey openpgp_packet_keymaterial
publicKey openpgp_packet_keymaterial
Source: