Global

Members

crc_table

Internal function to calculate a CRC-24 checksum over a given string (data)
Source:
  • openpgp.js, line 10915

hash_headers

ASN1 object identifiers for hashes (See RFC4880 5.2.2)
Source:
  • openpgp.js, line 10581

util

an instance that should be used.
Source:
  • openpgp.js, line 13171

Methods

bin2str

convert an array of integers(0.255) to a string
Parameters:
Name Type Description
[Array [Integer 0..255]] array of (binary) integers to convert
Source:
  • openpgp.js, line 13001
Returns:
[String] string representation of the array

calc_checksum

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:
  • openpgp.js, line 13040
Returns:
[Integer] an integer containing the sum of all character codes % 65535

get_hashAlgorithmString

Return the algorithm type as string
Source:
  • openpgp.js, line 13147
Returns:
[String] String representing the message type

getCheckSum

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:
  • openpgp.js, line 10891
Returns:
[String] base64 encoded checksum

getPGPMessageType

Finds out which Ascii Armoring type is used. This is an internal function
Parameters:
Name Type Description
text [String] ascii armored text
Source:
  • openpgp.js, line 10764
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

hex2bin

create binary string from a hex encoded string
Parameters:
Name Type Description
str [String] hex string to convert
Source:
  • openpgp.js, line 12957
Returns:
[String] string containing the binary values

hexidump

creating a hex string from an binary array of integers (0..255)
Parameters:
Name Type Description
[Array[integer 0..255]] array to convert
Source:
  • openpgp.js, line 12969
Returns:
[String] hexadecimal representation of the array

hexstrdump

create hexstring from a binary
Parameters:
Name Type Description
str [String] string to convert
Source:
  • openpgp.js, line 12937
Returns:
[String] string containing the hexadecimal values

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.js, line 3480

openpgp_cfb_decrypt

This function decrypts a given plaintext using the specified blockcipher to decrypt a message
Parameters:
Name Type Description
blockcipherfn the algorithm _encrypt_ function to encrypt data in one block_size encryption. The function must be specified as blockcipherfn([integer_array(integers 0..255)] block,[integer_array(integers 0..255)] key) returning an array of bytes (integers 0..255)
block_size the block size in bytes of the algorithm used
plaintext ciphertext to be decrypted provided as a string
key key to be used to decrypt the ciphertext as integer_array(integers 0..255)]. This will be passed to the blockcipherfn
resync 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:
  • openpgp.js, line 9022
Returns:
a string with the plaintext data

openpgp_cfb_encrypt

This function encrypts a given with the specified prefixrandom using the specified blockcipher to encrypt a message
Parameters:
Name Type Description
prefixrandom random bytes of block_size length provided as a string to be used in prefixing the data
blockcipherfn the algorithm encrypt function to encrypt data in one block_size encryption. The function must be specified as blockcipherfn([integer_array(integers 0..255)] block,[integer_array(integers 0..255)] key) returning an array of bytes (integers 0..255)
block_size the block size in bytes of the algorithm used
plaintext data to be encrypted provided as a string
key key to be used to encrypt the data as integer_array(integers 0..255)]. This will be passed to the blockcipherfn
resync 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:
  • openpgp.js, line 8885
Returns:
a string with the encrypted data

openpgp_cfb_mdc

decrypts the prefixed data for the Modification Detection Code (MDC) computation
Parameters:
Name Type Description
blockcipherencryptfn cipher function to use
block_size blocksize of the algorithm
key the key for encryption
ciphertext the encrypted data
Source:
  • openpgp.js, line 8981
Returns:
plaintext data of D(ciphertext) with blocksize length +2

openpgp_crypto_asymetricDecrypt

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 [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers of the public key part of the private key
secretMPIs [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers of the private key used
data [openpgp_type_mpi] data to be encrypted as MPI
Source:
  • openpgp.js, line 9190
Returns:
[BigInteger] returns a big integer containing the decrypted data; otherwise null

openpgp_crypto_asymetricEncrypt

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 [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers
data [openpgp_type_mpi] data to be encrypted as MPI
Source:
  • openpgp.js, line 9158
Returns:
[Object] if RSA an openpgp_type_mpi; if elgamal encryption an array of two openpgp_type_mpi is returned; otherwise null

openpgp_crypto_generateKeyPair

calls the necessary crypto functions to generate a keypair. Called directly by openpgp.js
Source:
  • openpgp.js, line 9530
Returns:
Type
privateKey: [openpgp_packet_keymaterial] , publicKey: [openpgp_packet_keymaterial]

openpgp_crypto_generateSessionKey

Generating a session key for the specified symmetric algorithm
Parameters:
Name Type Description
algo [Integer] algorithm to use (see RFC4880 9.2)
Source:
  • openpgp.js, line 9273
Returns:
[String] random bytes as a string to be used as a key

openpgp_crypto_getHashByteLength

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:
  • openpgp.js, line 9418
Returns:
[Integer] size in bytes of the resulting hash

openpgp_crypto_getPrefixRandom

generate random byte prefix as string for the specified algorithm
Parameters:
Name Type Description
algo [Integer] algorithm to use (see RFC4880 9.2)
Source:
  • openpgp.js, line 9221
Returns:
[String] random bytes with length equal to the block size of the cipher

openpgp_crypto_getPseudoRandom

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:
  • openpgp.js, line 9457
Returns:
[Integer] a pseudo random number

openpgp_crypto_getRandomBigInteger

create a secure random big integer of bits length
Parameters:
Name Type Description
bits [Integer] bit length of the MPI to create
Source:
  • openpgp.js, line 9487
Returns:
[BigInteger] resulting big integer

openpgp_crypto_getRandomBytes

retrieve secure random byte string of the specified length
Parameters:
Name Type Description
length [Integer] length in bytes to generate
Source:
  • openpgp.js, line 9443
Returns:
[String] random byte string

openpgp_crypto_getSecureRandom

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:
  • openpgp.js, line 9467
Returns:
[Integer] a secure random number

openpgp_crypto_hashData

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:
  • openpgp.js, line 9384
Returns:
[String] hash value

openpgp_crypto_MDCSystemBytes

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:
  • openpgp.js, line 9244
Returns:
[String] plain text data of the prefixed data

openpgp_crypto_signData

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 [Array[openpgp_type_mpi]] public key multiprecision integers of the private key
secretMPIs [Array[openpgp_type_mpi]] private key multiprecision integers which is used to sign the data
data [String] data to be signed
Source:
  • openpgp.js, line 9346
Returns:
[String or openpgp_type_mpi]

openpgp_crypto_symmetricDecrypt

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:
  • openpgp.js, line 8819
Returns:
[String] plaintext data

openpgp_crypto_symmetricEncrypt

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 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:
  • openpgp.js, line 8785
Returns:
[String] encrypted data

openpgp_crypto_verifySignature

Parameters:
Name Type Description
algo [Integer] public key algorithm
hash_algo [Integer] hash algorithm
msg_MPIs [Array[openpgp_type_mpi]] signature multiprecision integers
publickey_MPIs [Array[openpgp_type_mpi]] public key multiprecision integers
data [String] data on where the signature was computed on.
Source:
  • openpgp.js, line 9299
Returns:
true if signature (sig_data was equal to data over hash)

openpgp_encoding_armor

Armor an OpenPGP binary packet block
Parameters:
Name Type Description
messagetype type of the message
data
partindex
parttotal
Source:
  • openpgp.js, line 10834
Returns:
Armored text
Type
string

openpgp_encoding_armor_addheader

Add additional information to the armor version of an OpenPGP binary packet block.
Version:
  • 2011-12-16
Author:
  • Alex
Source:
  • openpgp.js, line 10814
Returns:
The header information

openpgp_encoding_base64_decode

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:
  • openpgp.js, line 10527
Returns:
[String] raw data after decoding

openpgp_encoding_base64_encode

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:
  • openpgp.js, line 10516
Returns:
[String] the base64 encoded data

openpgp_encoding_deArmor

DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes
Source:
  • openpgp.js, line 10731
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.

openpgp_encoding_eme_pkcs1_decode

decodes a EME-PKCS1-v1_5 padding (See RFC4880 13.1.2)
Parameters:
Name Type Description
message [String] EME-PKCS1 padded message
Source:
  • openpgp.js, line 10568
Returns:
[String] decoded message

openpgp_encoding_eme_pkcs1_encode

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:
  • openpgp.js, line 10549
Returns:
[String] EME-PKCS1 padded message

openpgp_encoding_emsa_pkcs1_decode

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:
  • openpgp.js, line 10617
Returns:
the hash as string

openpgp_encoding_emsa_pkcs1_encode

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:
  • openpgp.js, line 10597
Returns:
the [String] hashcode with pkcs1padding as string

openpgp_encoding_html_encode

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:
  • openpgp.js, line 10537
Returns:
[String] html encoded 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:
  • openpgp.js, line 13058
Returns:
[String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in.
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:
  • openpgp.js, line 13076
Returns:
[String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in.
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:
  • openpgp.js, line 13092
Returns:
[String] a HTML paragraph entity with a style attribute containing the HTML encoded error message
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:
  • openpgp.js, line 13105
Returns:
[String] a HTML paragraph entity with a style attribute containing the HTML encoded info message

shiftRight

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:
  • openpgp.js, line 13129
Returns:
[String] resulting string.

str2bin

convert a string to an array of integers(0.255)
Parameters:
Name Type Argument Description
String <optional>
string to convert
Source:
  • openpgp.js, line 12987
Returns:
[Array [Integer 0..255]] array of (binary) integers

str2Uint8Array

convert a string to a Uint8Array
Parameters:
Name Type Argument Description
String <optional>
string to convert
Source:
  • openpgp.js, line 13014
Returns:
[Uint8Array] array of (binary) integers

Uint8Array2str

convert a Uint8Array to a string. This currently functions the same as bin2str.
Parameters:
Name Type Argument Description
Uint8Array <optional>
array of (binary) integers to convert
Source:
  • openpgp.js, line 13027
Returns:
[String] string representation of the array

verifyCheckSum

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:
  • openpgp.js, line 10905
Returns:
true if the given checksum is correct; otherwise false