-
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:
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:
Returns:
[Integer] an integer containing the sum of all character codes % 65535
-
get_hashAlgorithmString
-
Return the algorithm type as string
- Source:
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:
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:
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:
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:
Returns:
[String] hexadecimal representation of the array
-
hexstrdump
-
create hexstring from a binary
Parameters:
Name |
Type |
Description |
str |
|
[String] string to convert |
- Source:
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_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:
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:
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:
Returns:
plaintext data of D(ciphertext) with blocksize length +2
-
openpgp_config
-
Implementation of the GPG4Browsers config object
This object contains configuration values and implements
storing and retrieving configuration them from HTML5 local storage.
This object can be accessed after calling openpgp.init()
using openpgp.config
Stored config parameters can be accessed using
openpgp.config.config
- Source:
-
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
Returns:
Armored text
-
Type
-
string
-
-
Add additional information to the armor version of an OpenPGP binary
packet block.
- Version:
- Author:
-
- Source:
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:
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:
Returns:
[String] the base64 encoded data
-
openpgp_encoding_deArmor
-
DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes
- 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.
-
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:
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:
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:
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:
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:
Returns:
[String] html encoded string
-
openpgp_packet_compressed
-
Implementation of the Compressed Data Packet (Tag 8)
RFC4880 5.6:
The Compressed Data packet contains compressed data. Typically, this
packet is found as the contents of an encrypted packet, or following
a Signature or One-Pass Signature packet, and contains a literal data
packet.
- Source:
-
openpgp_packet_encrypteddata
-
Implementation of the Symmetrically Encrypted Data Packet (Tag 9)
RFC4880 5.7: The Symmetrically Encrypted Data packet contains data encrypted
with a symmetric-key algorithm. When it has been decrypted, it contains other
packets (usually a literal data packet or compressed data packet, but in
theory other Symmetrically Encrypted Data packets or sequences of packets
that form whole OpenPGP messages).
- Source:
-
openpgp_packet_encryptedintegrityprotecteddata
-
Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18)
RFC4880 5.13: The Symmetrically Encrypted Integrity Protected Data packet is
a variant of the Symmetrically Encrypted Data packet. It is a new feature
created for OpenPGP that addresses the problem of detecting a modification to
encrypted data. It is used in combination with a Modification Detection Code
packet.
- Source:
-
openpgp_packet_encryptedsessionkey
-
Public-Key Encrypted Session Key Packets (Tag 1)
RFC4880 5.1: A Public-Key Encrypted Session Key packet holds the session key
used to encrypt a message. Zero or more Public-Key Encrypted Session Key
packets and/or Symmetric-Key Encrypted Session Key packets may precede a
Symmetrically Encrypted Data Packet, which holds an encrypted message. The
message is encrypted with the session key, and the session key is itself
encrypted and stored in the Encrypted Session Key packet(s). The
Symmetrically Encrypted Data Packet is preceded by one Public-Key Encrypted
Session Key packet for each OpenPGP key to which the message is encrypted.
The recipient of the message finds a session key that is encrypted to their
public key, decrypts the session key, and then uses the session key to
decrypt the message.
- Source:
-
openpgp_packet_keymaterial
-
Implementation of the Key Material Packet (Tag 5,6,7,14)
RFC4480 5.5:
A key material packet contains all the information about a public or
private key. There are four variants of this packet type, and two
major versions. Consequently, this section is complex.
- Source:
-
openpgp_packet_literaldata
-
Implementation of the Literal Data Packet (Tag 11)
RFC4880 5.9: A Literal Data packet contains the body of a message; data that
is not to be further interpreted.
- Source:
-
openpgp_packet_marker
-
Implementation of the strange "Marker packet" (Tag 10)
RFC4880 5.8: An experimental version of PGP used this packet as the Literal
packet, but no released version of PGP generated Literal packets with this
tag. With PGP 5.x, this packet has been reassigned and is reserved for use as
the Marker packet.
Such a packet MUST be ignored when received.
- Source:
-
openpgp_packet_modificationdetectioncode
-
Implementation of the Modification Detection Code Packet (Tag 19)
RFC4880 5.14: The Modification Detection Code packet contains a SHA-1 hash of
plaintext data, which is used to detect message modification. It is only used
with a Symmetrically Encrypted Integrity Protected Data packet. The
Modification Detection Code packet MUST be the last packet in the plaintext
data that is encrypted in the Symmetrically Encrypted Integrity Protected
Data packet, and MUST appear in no other place.
- Source:
-
openpgp_packet_onepasssignature
-
Implementation of the One-Pass Signature Packets (Tag 4)
RFC4880 5.4:
The One-Pass Signature packet precedes the signed data and contains
enough information to allow the receiver to begin calculating any
hashes needed to verify the signature. It allows the Signature
packet to be placed at the end of the message, so that the signer
can compute the entire signed message in one pass.
- Source:
-
openpgp_packet_signature
-
Implementation of the Signature Packet (Tag 2)
RFC4480 5.2:
A Signature packet describes a binding between some public key and
some data. The most common signatures are a signature of a file or a
block of text, and a signature that is a certification of a User ID.
- Source:
-
openpgp_packet_userattribute
-
The User Attribute packet is a variation of the User ID packet. It
is capable of storing more types of data than the User ID packet,
which is limited to text. Like the User ID packet, a User Attribute
packet may be certified by the key owner ("self-signed") or any other
key owner who cares to certify it. Except as noted, a User Attribute
packet may be used anywhere that a User ID packet may be used.
While User Attribute packets are not a required part of the OpenPGP
standard, implementations SHOULD provide at least enough
compatibility to properly handle a certification signature on the
User Attribute packet. A simple way to do this is by treating the
User Attribute packet as a User ID packet with opaque contents, but
an implementation may use any method desired.
- Source:
-
openpgp_packet_userid
-
A User ID packet consists of UTF-8 text that is intended to represent
the name and email address of the key holder. By convention, it
includes an RFC 2822 [RFC2822] mail name-addr, but there are no
restrictions on its content. The packet length in the header
specifies the length of the User ID.
- Source:
-
openpgp_type_keyid
-
Implementation of type key id (RFC4880 3.3)
A Key ID is an eight-octet scalar that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique. The
section "Enhanced Key Formats" below describes how Key IDs are
formed.
- Source:
-
openpgp_type_mpi
-
Implementation of type MPI (RFC4880 3.2)
Multiprecision integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used in cryptographic
calculations.
An MPI consists of two pieces: a two-octet scalar that is the length
of the MPI in bits followed by a string of octets that contain the
actual integer.
- Source:
-
openpgp_type_s2k
-
Implementation of the String-to-key specifier (RFC4880 3.7)
String-to-key (S2K) specifiers are used to convert passphrase strings
into symmetric-key encryption/decryption keys. They are used in two
places, currently: to encrypt the secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
symmetrically encrypted messages.
- Source:
-
print_debug
-
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:
[String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in.
-
print_debug_hexstr_dump
-
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:
[String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in.
-
print_error
-
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:
[String] a HTML paragraph entity with a style attribute containing the HTML encoded error message
-
print_info
-
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:
[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:
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:
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:
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:
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:
Returns:
true if the given checksum is correct; otherwise false