From 8545feb03d997a7b163a595aec939003420b099e Mon Sep 17 00:00:00 2001 From: Michal Kolodziej Date: Fri, 12 Apr 2013 13:00:09 +0200 Subject: [PATCH] Fixed documentation for cfb and crypto files --- Makefile | 4 + doc/global.html | 6032 ++++--------------- doc/index.html | 93 +- doc/openpgp.cfb.js.html | 339 ++ doc/openpgp.crypto.js.html | 479 ++ doc/scripts/prettify/Apache-License-2.0.txt | 202 + doc/scripts/prettify/lang-css.js | 2 + doc/scripts/prettify/prettify.js | 28 + doc/styles/jsdoc-default.css | 9 +- doc/styles/prettify-jsdoc.css | 111 + doc/styles/prettify-tomorrow.css | 132 + src/ciphers/openpgp.cfb.js | 64 +- src/ciphers/openpgp.crypto.js | 122 +- 13 files changed, 2624 insertions(+), 4993 deletions(-) create mode 100644 doc/openpgp.cfb.js.html create mode 100644 doc/openpgp.crypto.js.html create mode 100644 doc/scripts/prettify/Apache-License-2.0.txt create mode 100644 doc/scripts/prettify/lang-css.js create mode 100644 doc/scripts/prettify/prettify.js create mode 100644 doc/styles/prettify-jsdoc.css create mode 100644 doc/styles/prettify-tomorrow.css diff --git a/Makefile b/Makefile index 28e181f4..375c3612 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ help: @echo "test - runs JavaScript unit tests" @echo "example - creates a simple example" @echo "ext-chr-gmail - creates the Google Chrome / Google Mail extension" + @echo "documentation - generates documentation. Requires jsdoc (3.2) in PATH" update: update-me update-deps @@ -35,3 +36,6 @@ minify: test: @echo to be implemented + +documentation: + @jsdoc src -r -d doc diff --git a/doc/global.html b/doc/global.html index b1457442..e78218e7 100644 --- a/doc/global.html +++ b/doc/global.html @@ -4,12 +4,12 @@ JSDoc: Global - - + + - + @@ -43,27 +43,29 @@
- - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +
@@ -82,154 +84,6 @@ -

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

@@ -237,1508 +91,7 @@
-

bin2str

- - -
-
- - -
- convert an array of integers(0.255) to a string -
- - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
[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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
[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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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

+

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

@@ -1750,6 +103,8 @@ using the specified blockcipher to encrypt a message the specified secretMPIs of the private key and the specified algorithm. + + @@ -1784,13 +139,18 @@ the specified secretMPIs of the private key and the specified algorithm. + +Integer + + + - [Integer] Algorithm to be used (See RFC4880 9.1) + Algorithm to be used (See RFC4880 9.1) @@ -1802,13 +162,19 @@ the specified secretMPIs of the private key and the specified algorithm. + +openpgp_type_mpi[] + + + - [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers of the public key part of the private key + Algorithm dependent multiprecision integers +of the public key part of the private key @@ -1820,13 +186,19 @@ the specified secretMPIs of the private key and the specified algorithm. + +openpgp_type_mpi[] + + + - [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers of the private key used + Algorithm dependent multiprecision integers +of the private key used @@ -1838,13 +210,18 @@ the specified secretMPIs of the private key and the specified algorithm. + +openpgp_type_mpi + + + - [openpgp_type_mpi] data to be encrypted as MPI + Data to be encrypted as MPI @@ -1856,34 +233,42 @@ the specified secretMPIs of the private key and the specified algorithm.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9190
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1892,235 +277,20 @@ the specified secretMPIs of the private key and the specified algorithm.
- [BigInteger] returns a big integer containing the decrypted data; otherwise null + 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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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] - +BigInteger + +
@@ -2132,7 +302,356 @@ openpgp_type_mpi is returned; otherwise null
-

openpgp_crypto_generateSessionKey

+

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:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
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:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
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}

@@ -2143,6 +662,8 @@ openpgp_type_mpi is returned; otherwise null Generating a session key for the specified symmetric algorithm + + @@ -2177,13 +698,18 @@ openpgp_type_mpi is returned; otherwise null + +Integer + + + - [Integer] algorithm to use (see RFC4880 9.2) + Algorithm to use (see RFC4880 9.2) @@ -2195,34 +721,42 @@ openpgp_type_mpi is returned; otherwise null
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9273
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -2231,11 +765,23 @@ openpgp_type_mpi is returned; otherwise null
- [String] random bytes as a string to be used as a key + Random bytes as a string to be used as a key
+
+
+ Type +
+
+ +String + + +
+
+ @@ -2244,7 +790,7 @@ openpgp_type_mpi is returned; otherwise null
-

openpgp_crypto_getHashByteLength

+

openpgp_crypto_getHashByteLength(algo) → {Integer}

@@ -2252,9 +798,11 @@ openpgp_type_mpi is returned; otherwise null
- returns the hash size in bytes of the specified hash algorithm type + Returns the hash size in bytes of the specified hash algorithm type
+ + @@ -2289,13 +837,18 @@ openpgp_type_mpi is returned; otherwise null + +Integer + + + - [Integer] hash algorithm type (See RFC4880 9.4) + Hash algorithm type (See RFC4880 9.4) @@ -2307,34 +860,42 @@ openpgp_type_mpi is returned; otherwise null
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9418
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -2343,11 +904,23 @@ openpgp_type_mpi is returned; otherwise null
- [Integer] size in bytes of the resulting hash + Size in bytes of the resulting hash
+
+
+ Type +
+
+ +Integer + + +
+
+ @@ -2356,7 +929,7 @@ openpgp_type_mpi is returned; otherwise null
-

openpgp_crypto_getPrefixRandom

+

openpgp_crypto_getPrefixRandom(algo) → {String}

@@ -2367,6 +940,8 @@ openpgp_type_mpi is returned; otherwise null generate random byte prefix as string for the specified algorithm + + @@ -2401,13 +976,18 @@ openpgp_type_mpi is returned; otherwise null + +Integer + + + - [Integer] algorithm to use (see RFC4880 9.2) + Algorithm to use (see RFC4880 9.2) @@ -2419,34 +999,42 @@ openpgp_type_mpi is returned; otherwise null
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9221
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -2455,12 +1043,24 @@ openpgp_type_mpi is returned; otherwise null
- [String] random bytes with length equal to the block + Random bytes with length equal to the block size of the cipher
+
+
+ Type +
+
+ +String + + +
+
+ @@ -2469,7 +1069,7 @@ size of the cipher
-

openpgp_crypto_getPseudoRandom

+

openpgp_crypto_getPseudoRandom(from, to) → {Integer}

@@ -2477,9 +1077,11 @@ size of the cipher
- return a pseudo-random number in the specified range + Return a pseudo-random number in the specified range
+ + @@ -2514,13 +1116,18 @@ size of the cipher + +Integer + + + - [Integer] min of the random number + Min of the random number @@ -2532,13 +1139,18 @@ size of the cipher + +Integer + + + - [Integer] max of the random number (max 32bit) + Max of the random number (max 32bit) @@ -2550,34 +1162,42 @@ size of the cipher
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9457
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -2586,11 +1206,23 @@ size of the cipher
- [Integer] a pseudo random number + A pseudo random number
+
+
+ Type +
+
+ +Integer + + +
+
+ @@ -2599,7 +1231,7 @@ size of the cipher
-

openpgp_crypto_getRandomBigInteger

+

openpgp_crypto_getRandomBigInteger(bits) → {BigInteger}

@@ -2607,9 +1239,11 @@ size of the cipher
- create a secure random big integer of bits length + Create a secure random big integer of bits length
+ + @@ -2644,13 +1278,18 @@ size of the cipher + +Integer + + + - [Integer] bit length of the MPI to create + Bit length of the MPI to create @@ -2662,34 +1301,42 @@ size of the cipher
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9487
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -2698,11 +1345,23 @@ size of the cipher
- [BigInteger] resulting big integer + Resulting big integer
+
+
+ Type +
+
+ +BigInteger + + +
+
+ @@ -2711,7 +1370,7 @@ size of the cipher
-

openpgp_crypto_getRandomBytes

+

openpgp_crypto_getRandomBytes(length) → {String}

@@ -2719,9 +1378,11 @@ size of the cipher
- retrieve secure random byte string of the specified length + Retrieve secure random byte string of the specified length
+ + @@ -2756,13 +1417,18 @@ size of the cipher + +Integer + + + - [Integer] length in bytes to generate + Length in bytes to generate @@ -2774,34 +1440,42 @@ size of the cipher
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9443
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -2810,11 +1484,23 @@ size of the cipher
- [String] random byte string + Random byte string
+
+
+ Type +
+
+ +String + + +
+
+ @@ -2823,7 +1509,7 @@ size of the cipher
-

openpgp_crypto_getSecureRandom

+

openpgp_crypto_getSecureRandom(from, to) → {Integer}

@@ -2831,9 +1517,11 @@ size of the cipher
- return a secure random number in the specified range + Return a secure random number in the specified range
+ + @@ -2868,13 +1556,18 @@ size of the cipher + +Integer + + + - [Integer] min of the random number + Min of the random number @@ -2886,13 +1579,18 @@ size of the cipher + +Integer + + + - [Integer] max of the random number (max 32bit) + Max of the random number (max 32bit) @@ -2904,34 +1602,42 @@ size of the cipher
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9467
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -2940,11 +1646,23 @@ size of the cipher
- [Integer] a secure random number + A secure random number
+
+
+ Type +
+
+ +Integer + + +
+
+ @@ -2953,7 +1671,7 @@ size of the cipher
-

openpgp_crypto_hashData

+

openpgp_crypto_hashData(algo, data) → {String}

@@ -2961,9 +1679,11 @@ size of the cipher
- create a hash on the specified data using the specified algorithm + Create a hash on the specified data using the specified algorithm
+ + @@ -2998,13 +1718,18 @@ size of the cipher + +Integer + + + - [Integer] hash algorithm type (see RFC4880 9.4) + Hash algorithm type (see RFC4880 9.4) @@ -3016,13 +1741,18 @@ size of the cipher + +String + + + - [String] data to be hashed + Data to be hashed @@ -3034,34 +1764,42 @@ size of the cipher
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9384
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -3070,11 +1808,23 @@ size of the cipher
- [String] hash value + hash value
+
+
+ Type +
+
+ +String + + +
+
+ @@ -3083,7 +1833,7 @@ size of the cipher
-

openpgp_crypto_MDCSystemBytes

+

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

@@ -3094,6 +1844,8 @@ size of the cipher retrieve the MDC prefixed bytes by decrypting them + + @@ -3128,13 +1880,18 @@ size of the cipher + +Integer + + + - [Integer] algorithm to use (see RFC4880 9.2) + Algorithm to use (see RFC4880 9.2) @@ -3146,13 +1903,18 @@ size of the cipher + +String + + + - [String] key as string. length is depending on the algorithm used + Key as string. length is depending on the algorithm used @@ -3164,13 +1926,18 @@ size of the cipher + +String + + + - [String] encrypted data where the prefix is decrypted from + Encrypted data where the prefix is decrypted from @@ -3182,34 +1949,42 @@ size of the cipher
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9244
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -3218,11 +1993,23 @@ size of the cipher
- [String] plain text data of the prefixed data + Plain text data of the prefixed data
+
+
+ Type +
+
+ +String + + +
+
+ @@ -3231,7 +2018,7 @@ size of the cipher
-

openpgp_crypto_signData

+

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

@@ -3242,6 +2029,8 @@ size of the cipher Create a signature on data using the specified algorithm + + @@ -3276,13 +2065,18 @@ size of the cipher + +Integer + + + - [Integer] hash algorithm to use (See RFC4880 9.4) + hash Algorithm to use (See RFC4880 9.4) @@ -3294,13 +2088,18 @@ size of the cipher + +Integer + + + - [Integer] asymmetric cipher algorithm to use (See RFC4880 9.1) + Asymmetric cipher algorithm to use (See RFC4880 9.1) @@ -3312,13 +2111,19 @@ size of the cipher + +openpgp_type_mpi[] + + + - [Array[openpgp_type_mpi]] public key multiprecision integers of the private key + Public key multiprecision integers +of the private key @@ -3330,13 +2135,19 @@ size of the cipher + +openpgp_type_mpi[] + + + - [Array[openpgp_type_mpi]] private key multiprecision integers which is used to sign the data + Private key multiprecision +integers which is used to sign the data @@ -3348,13 +2159,18 @@ size of the cipher + +String + + + - [String] data to be signed + Data to be signed @@ -3366,34 +2182,42 @@ size of the cipher
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9346
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -3401,11 +2225,22 @@ size of the cipher
Returns:
-
- [String or openpgp_type_mpi] -
+
+
+ Type +
+
+ +String +| + +openpgp_type_mpi + + +
+
@@ -3415,17 +2250,14 @@ size of the cipher
-

openpgp_crypto_symmetricDecrypt

+

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

-
- Symmetrically decrypts data using a key with length depending on the -algorithm in openpgp_cfb mode with or without resync (MDC style) -
+ @@ -3461,23 +2293,10 @@ algorithm in openpgp_cfb mode with or without resync (MDC style) - - - - - - - [Integer] algorithm to use (see RFC4880 9.2) - - - - - - - key - - - + +Integer + + @@ -3485,340 +2304,7 @@ algorithm in openpgp_cfb mode with or without resync (MDC style) - [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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -3830,13 +2316,18 @@ to retrieve that string - + @@ -3848,13 +2339,18 @@ to retrieve that string - + @@ -3866,13 +2362,18 @@ to retrieve that string - + @@ -3884,13 +2385,18 @@ to retrieve that string - + @@ -3902,34 +2408,42 @@ to retrieve that string
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9299
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -3943,2275 +2457,153 @@ to retrieve that string - - - - - - - -
-

openpgp_encoding_armor

- - -
-
- - -
- Armor an OpenPGP binary packet block -
- - - - - -
Parameters:
- - -
NameTypeDescription
algo - - [Integer] public key algorithmpublic Key algorithm
+ +Integer + + + [Integer] hash algorithmHash algorithm
+ +openpgp_type_mpi[] + + + [Array[openpgp_type_mpi]] signature multiprecision integersSignature multiprecision integers
+ +openpgp_type_mpi[] + + + [Array[openpgp_type_mpi]] public key multiprecision integersPublic key multiprecision integers
+ +String + + + [String] data on where the signature was computed on.Data on where the signature was computed on.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
messagetype - - type of the message
data - -
partindex - -
parttotal - -
- - - -
- - - - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10834
- - - - - - - -
- - - - - - - -
Returns:
- - -
- Armored text -
- - - -
Type
- string - +Boolean + +
-
- - - -
-

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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeArgumentDescription
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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
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 -
- - - - - -
+

Type Definitions

+ +
+ +
+

openpgp_keypair

+ + +
+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
privateKey + + +openpgp_packet_keymaterial + + + +
publicKey + + +openpgp_packet_keymaterial + + + +
+ + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ @@ -6224,15 +2616,15 @@ are automatically converted to HTML line feeds '
'.
- + diff --git a/doc/index.html b/doc/index.html index abcd7a7e..5f1486f7 100644 --- a/doc/index.html +++ b/doc/index.html @@ -4,12 +4,12 @@ JSDoc: Index - - + + - + @@ -45,99 +45,18 @@ - - -
- -
-

- file:openpgp.js -

- -
- -
-
- - - - -
The openpgp base class should provide all of the functionality -to consume the openpgp.js library. All additional classes are documented -for extending and developing on top of the base library.
- - - -
- - - - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9565
- - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - -
- -
- - - -
- + diff --git a/doc/openpgp.cfb.js.html b/doc/openpgp.cfb.js.html new file mode 100644 index 00000000..106dfb52 --- /dev/null +++ b/doc/openpgp.cfb.js.html @@ -0,0 +1,339 @@ + + + + + JSDoc: Source: openpgp.cfb.js + + + + + + + + + + +
+ +

Source: openpgp.cfb.js

+ + + + + +
+
+
// Modified by Recurity Labs GmbH 
+
+// modified version of http://www.hanewin.net/encrypt/PGdecode.js:
+
+/* OpenPGP encryption using RSA/AES
+ * Copyright 2005-2006 Herbert Hanewinkel, www.haneWIN.de
+ * version 2.0, check www.haneWIN.de for the latest version
+
+ * This software is provided as-is, without express or implied warranty.  
+ * Permission to use, copy, modify, distribute or sell this software, with or
+ * without fee, for any purpose and by any individual or organization, is hereby
+ * granted, provided that the above copyright notice and this paragraph appear 
+ * in all copies. Distribution as a part of an application or binary must
+ * include the above copyright notice in the documentation and/or other
+ * materials provided with the application or distribution.
+ */
+
+/**
+ * An array of bytes, that is integers with values from 0 to 255
+ * @typedef {(Array|Uint8Array)} openpgp_byte_array
+ */
+
+/**
+ * Block cipher function
+ * @callback openpgp_cipher_block_fn
+ * @param {openpgp_byte_array} block A block to perform operations on
+ * @param {openpgp_byte_array} key to use in encryption/decryption
+ * @return {openpgp_byte_array} Encrypted/decrypted block
+ */
+
+
+// --------------------------------------
+/**
+ * This function encrypts a given with the specified prefixrandom 
+ * using the specified blockcipher to encrypt a message
+ * @param {String[]} prefixrandom random bytes of block_size length provided 
+ *  as a string to be used in prefixing the data
+ * @param {openpgp_cipher_block_fn} blockcipherfn the algorithm encrypt function to encrypt
+ *  data in one block_size encryption. 
+ * @param {Integer} block_size the block size in bytes of the algorithm used
+ * @param {String} plaintext data to be encrypted provided as a string
+ * @param {openpgp_byte_array} key key to be used to encrypt the data. This will be passed to the 
+ *  blockcipherfn
+ * @param {Boolean} 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.
+ * @return {String} a string with the encrypted data
+ */
+function openpgp_cfb_encrypt(prefixrandom, blockcipherencryptfn, plaintext, block_size, key, resync) {
+	var FR = new Array(block_size);
+	var FRE = new Array(block_size);
+
+	prefixrandom = prefixrandom + prefixrandom.charAt(block_size-2) +prefixrandom.charAt(block_size-1);
+	util.print_debug("prefixrandom:"+util.hexstrdump(prefixrandom));
+	var ciphertext = "";
+	// 1.  The feedback register (FR) is set to the IV, which is all zeros.
+	for (var i = 0; i < block_size; i++) FR[i] = 0;
+	
+	// 2.  FR is encrypted to produce FRE (FR Encrypted).  This is the
+    //     encryption of an all-zero value.
+	FRE = blockcipherencryptfn(FR, key);
+	// 3.  FRE is xored with the first BS octets of random data prefixed to
+    //     the plaintext to produce C[1] through C[BS], the first BS octets
+    //     of ciphertext.
+	for (var i = 0; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ prefixrandom.charCodeAt(i));
+	
+	// 4.  FR is loaded with C[1] through C[BS].
+	for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i);
+	
+	// 5.  FR is encrypted to produce FRE, the encryption of the first BS
+    // 	   octets of ciphertext.
+	FRE = blockcipherencryptfn(FR, key);
+
+	// 6.  The left two octets of FRE get xored with the next two octets of
+	//     data that were prefixed to the plaintext.  This produces C[BS+1]
+	//     and C[BS+2], the next two octets of ciphertext.
+	ciphertext += String.fromCharCode(FRE[0] ^ prefixrandom.charCodeAt(block_size));
+	ciphertext += String.fromCharCode(FRE[1] ^ prefixrandom.charCodeAt(block_size+1));
+
+	if (resync) {
+		// 7.  (The resync step) FR is loaded with C3-C10.
+		for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i+2);
+	} else {
+		for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(i);
+	}
+	// 8.  FR is encrypted to produce FRE.
+	FRE = blockcipherencryptfn(FR, key);
+	
+	if (resync) {
+		// 9.  FRE is xored with the first 8 octets of the given plaintext, now
+	    //	   that we have finished encrypting the 10 octets of prefixed data.
+	    // 	   This produces C11-C18, the next 8 octets of ciphertext.
+		for (var i = 0; i < block_size; i++)
+			ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(i));
+		for(n=block_size+2; n < plaintext.length; n+=block_size) {
+			// 10. FR is loaded with C11-C18
+			for (var i = 0; i < block_size; i++) FR[i] = ciphertext.charCodeAt(n+i);
+		
+			// 11. FR is encrypted to produce FRE.
+			FRE = blockcipherencryptfn(FR, key);
+		
+			// 12. FRE is xored with the next 8 octets of plaintext, to produce the
+			// next 8 octets of ciphertext.  These are loaded into FR and the
+			// process is repeated until the plaintext is used up.
+			for (var i = 0; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt((n-2)+i));
+		}
+	}
+	else {
+		plaintext = "  "+plaintext;
+		// 9.  FRE is xored with the first 8 octets of the given plaintext, now
+	    //	   that we have finished encrypting the 10 octets of prefixed data.
+	    // 	   This produces C11-C18, the next 8 octets of ciphertext.
+		for (var i = 2; i < block_size; i++) ciphertext += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(i));
+		var tempCiphertext = ciphertext.substring(0,2*block_size).split('');
+		var tempCiphertextString = ciphertext.substring(block_size);
+		for(n=block_size; n<plaintext.length; n+=block_size) {
+			// 10. FR is loaded with C11-C18
+			for (var i = 0; i < block_size; i++) FR[i] = tempCiphertextString.charCodeAt(i);
+			tempCiphertextString='';
+			
+			// 11. FR is encrypted to produce FRE.
+			FRE = blockcipherencryptfn(FR, key);
+			
+			// 12. FRE is xored with the next 8 octets of plaintext, to produce the
+			//     next 8 octets of ciphertext.  These are loaded into FR and the
+			//     process is repeated until the plaintext is used up.
+			for (var i = 0; i < block_size; i++){ tempCiphertext.push(String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(n+i)));
+			tempCiphertextString += String.fromCharCode(FRE[i] ^ plaintext.charCodeAt(n+i));
+			}
+		}
+		ciphertext = tempCiphertext.join('');
+		
+	}
+	return ciphertext;
+}
+
+/**
+ * Decrypts the prefixed data for the Modification Detection Code (MDC) computation
+ * @param {openpgp_block_cipher_fn} blockcipherencryptfn Cipher function to use
+ * @param {Integer} block_size Blocksize of the algorithm
+ * @param {openpgp_byte_array} key The key for encryption
+ * @param {String} ciphertext The encrypted data
+ * @return {String} plaintext Data of D(ciphertext) with blocksize length +2
+ */
+function openpgp_cfb_mdc(blockcipherencryptfn, block_size, key, ciphertext) {
+	var iblock = new Array(block_size);
+	var ablock = new Array(block_size);
+	var i;
+
+	// initialisation vector
+	for(i=0; i < block_size; i++) iblock[i] = 0;
+
+	iblock = blockcipherencryptfn(iblock, key);
+	for(i = 0; i < block_size; i++)
+	{
+		ablock[i] = ciphertext.charCodeAt(i);
+		iblock[i] ^= ablock[i];
+	}
+
+	ablock = blockcipherencryptfn(ablock, key);
+
+	return util.bin2str(iblock)+
+		String.fromCharCode(ablock[0]^ciphertext.charCodeAt(block_size))+
+		String.fromCharCode(ablock[1]^ciphertext.charCodeAt(block_size+1));
+}
+/**
+ * This function decrypts a given plaintext using the specified
+ * blockcipher to decrypt a message
+ * @param {openpgp_cipher_block_fn} blockcipherfn The algorithm _encrypt_ function to encrypt
+ *  data in one block_size encryption.
+ * @param {Integer} block_size the block size in bytes of the algorithm used
+ * @param {String} plaintext ciphertext to be decrypted provided as a string
+ * @param {openpgp_byte_array} key key to be used to decrypt the ciphertext. This will be passed to the 
+ *  blockcipherfn
+ * @param {Boolean} 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.
+ * @return {String} a string with the plaintext data
+ */
+
+function openpgp_cfb_decrypt(blockcipherencryptfn, block_size, key, ciphertext, resync)
+{
+	util.print_debug("resync:"+resync);
+	var iblock = new Array(block_size);
+	var ablock = new Array(block_size);
+	var i, n = '';
+	var text = [];
+
+	// initialisation vector
+	for(i=0; i < block_size; i++) iblock[i] = 0;
+
+	iblock = blockcipherencryptfn(iblock, key);
+	for(i = 0; i < block_size; i++)
+	{
+		ablock[i] = ciphertext.charCodeAt(i);
+		iblock[i] ^= ablock[i];
+	}
+
+	ablock = blockcipherencryptfn(ablock, key);
+
+	util.print_debug("openpgp_cfb_decrypt:\niblock:"+util.hexidump(iblock)+"\nablock:"+util.hexidump(ablock)+"\n");
+	util.print_debug((ablock[0]^ciphertext.charCodeAt(block_size)).toString(16)+(ablock[1]^ciphertext.charCodeAt(block_size+1)).toString(16));
+	
+	// test check octets
+	if(iblock[block_size-2]!=(ablock[0]^ciphertext.charCodeAt(block_size))
+	|| iblock[block_size-1]!=(ablock[1]^ciphertext.charCodeAt(block_size+1)))
+	{
+		util.print_eror("error duding decryption. Symmectric encrypted data not valid.");
+		return text.join('');
+	}
+	
+	/*  RFC4880: Tag 18 and Resync:
+	 *  [...] Unlike the Symmetrically Encrypted Data Packet, no
+   	 *  special CFB resynchronization is done after encrypting this prefix
+     *  data.  See "OpenPGP CFB Mode" below for more details.
+
+	 */
+	
+	if (resync) {
+	    for(i=0; i<block_size; i++) iblock[i] = ciphertext.charCodeAt(i+2);
+		for(n=block_size+2; n<ciphertext.length; n+=block_size)
+		{
+			ablock = blockcipherencryptfn(iblock, key);
+
+			for(i = 0; i<block_size && i+n < ciphertext.length; i++)
+			{
+				iblock[i] = ciphertext.charCodeAt(n+i);
+				text.push(String.fromCharCode(ablock[i]^iblock[i])); 
+			}
+		}
+	} else {
+		for(i=0; i<block_size; i++) iblock[i] = ciphertext.charCodeAt(i);
+		for(n=block_size; n<ciphertext.length; n+=block_size)
+		{
+			ablock = blockcipherencryptfn(iblock, key);
+			for(i = 0; i<block_size && i+n < ciphertext.length; i++)
+			{
+				iblock[i] = ciphertext.charCodeAt(n+i);
+				text.push(String.fromCharCode(ablock[i]^iblock[i])); 
+			}
+		}
+		
+	}
+	
+	return text.join('');
+}
+
+
+function normal_cfb_encrypt(blockcipherencryptfn, block_size, key, plaintext, iv) {
+	var blocki ="";
+	var blockc = "";
+	var pos = 0;
+	var cyphertext = [];
+	var tempBlock = [];
+	blockc = iv.substring(0,block_size);
+	while (plaintext.length > block_size*pos) {
+		var encblock = blockcipherencryptfn(blockc, key);
+		blocki = plaintext.substring((pos*block_size),(pos*block_size)+block_size);
+		for (var i=0; i < blocki.length; i++)
+		    tempBlock.push(String.fromCharCode(blocki.charCodeAt(i) ^ encblock[i]));
+		blockc = tempBlock.join('');
+		tempBlock = [];
+		cyphertext.push(blockc);
+		pos++;
+	}
+	return cyphertext.join('');
+}
+
+function normal_cfb_decrypt(blockcipherencryptfn, block_size, key, ciphertext, iv) { 
+	var blockp ="";
+	var pos = 0;
+	var plaintext = [];
+	var offset = 0;
+	if (iv == null)
+		for (var i = 0; i < block_size; i++) blockp += String.fromCharCode(0);
+	else
+		blockp = iv.substring(0,block_size);
+	while (ciphertext.length > (block_size*pos)) {
+		var decblock = blockcipherencryptfn(blockp, key);
+		blockp = ciphertext.substring((pos*(block_size))+offset,(pos*(block_size))+(block_size)+offset);
+		for (var i=0; i < blockp.length; i++) {
+			plaintext.push(String.fromCharCode(blockp.charCodeAt(i) ^ decblock[i]));
+		}
+		pos++;
+	}
+	
+	return plaintext.join('');
+}
+
+
+
+ + + + +
+ + + +
+ + + + + + diff --git a/doc/openpgp.crypto.js.html b/doc/openpgp.crypto.js.html new file mode 100644 index 00000000..7a80d7b9 --- /dev/null +++ b/doc/openpgp.crypto.js.html @@ -0,0 +1,479 @@ + + + + + JSDoc: Source: openpgp.crypto.js + + + + + + + + + + +
+ +

Source: openpgp.crypto.js

+ + + + + +
+
+
// GPG4Browsers - An OpenPGP implementation in javascript
+// Copyright (C) 2011 Recurity Labs GmbH
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 
+
+// The GPG4Browsers crypto interface
+
+/**
+ * Encrypts data using the specified public key multiprecision integers 
+ * and the specified algorithm.
+ * @param {Integer} algo Algorithm to be used (See RFC4880 9.1)
+ * @param {openpgp_type_mpi[]} publicMPIs Algorithm dependent multiprecision integers
+ * @param {openpgp_type_mpi} data Data to be encrypted as MPI
+ * @return {(openpgp_type_mpi|openpgp_type_mpi[])} if RSA an openpgp_type_mpi; 
+ * if elgamal encryption an array of two openpgp_type_mpi is returned; otherwise null
+ */
+function openpgp_crypto_asymetricEncrypt(algo, publicMPIs, data) {
+	switch(algo) {
+	case 1: // RSA (Encrypt or Sign) [HAC]
+	case 2: // RSA Encrypt-Only [HAC]
+	case 3: // RSA Sign-Only [HAC]
+		var rsa = new RSA();
+		var n = publicMPIs[0].toBigInteger();
+		var e = publicMPIs[1].toBigInteger();
+		var m = data.toBigInteger();
+		return rsa.encrypt(m,e,n).toMPI();
+	case 16: // Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
+		var elgamal = new Elgamal();
+		var p = publicMPIs[0].toBigInteger();
+		var g = publicMPIs[1].toBigInteger();
+		var y = publicMPIs[2].toBigInteger();
+		var m = data.toBigInteger();
+		return elgamal.encrypt(m,g,p,y);
+	default:
+		return null;
+	}
+}
+
+/**
+ * Decrypts data using the specified public key multiprecision integers of the private key,
+ * the specified secretMPIs of the private key and the specified algorithm.
+ * @param {Integer} algo Algorithm to be used (See RFC4880 9.1)
+ * @param {openpgp_type_mpi[]} publicMPIs Algorithm dependent multiprecision integers 
+ * of the public key part of the private key
+ * @param {openpgp_type_mpi[]} secretMPIs Algorithm dependent multiprecision integers 
+ * of the private key used
+ * @param {openpgp_type_mpi} data Data to be encrypted as MPI
+ * @return {BigInteger} returns a big integer containing the decrypted data; otherwise null
+ */
+
+function openpgp_crypto_asymetricDecrypt(algo, publicMPIs, secretMPIs, dataMPIs) {
+	switch(algo) {
+	case 1: // RSA (Encrypt or Sign) [HAC]  
+	case 2: // RSA Encrypt-Only [HAC]
+	case 3: // RSA Sign-Only [HAC]
+		var rsa = new RSA();
+		var d = secretMPIs[0].toBigInteger();
+		var p = secretMPIs[1].toBigInteger();
+		var q = secretMPIs[2].toBigInteger();
+		var u = secretMPIs[3].toBigInteger();
+		var m = dataMPIs[0].toBigInteger();
+		return rsa.decrypt(m, d, p, q, u);
+	case 16: // Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
+		var elgamal = new Elgamal();
+		var x = secretMPIs[0].toBigInteger();
+		var c1 = dataMPIs[0].toBigInteger();
+		var c2 = dataMPIs[1].toBigInteger();
+		var p = publicMPIs[0].toBigInteger();
+		return elgamal.decrypt(c1,c2,p,x);
+	default:
+		return null;
+	}
+	
+}
+
+/**
+ * generate random byte prefix as string for the specified algorithm
+ * @param {Integer} algo Algorithm to use (see RFC4880 9.2)
+ * @return {String} Random bytes with length equal to the block
+ * size of the cipher
+ */
+function openpgp_crypto_getPrefixRandom(algo) {
+	switch(algo) {
+	case 2:
+	case 3:
+	case 4:
+		return openpgp_crypto_getRandomBytes(8);
+	case 7:
+	case 8:
+	case 9:
+	case 10:
+		return openpgp_crypto_getRandomBytes(16);
+	default:
+		return null;
+	}
+}
+
+/**
+ * retrieve the MDC prefixed bytes by decrypting them
+ * @param {Integer} algo Algorithm to use (see RFC4880 9.2)
+ * @param {String} key Key as string. length is depending on the algorithm used
+ * @param {String} data Encrypted data where the prefix is decrypted from
+ * @return {String} Plain text data of the prefixed data
+ */
+function openpgp_crypto_MDCSystemBytes(algo, key, data) {
+	util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nencrypteddata:",data);
+	switch(algo) {
+	case 0: // Plaintext or unencrypted data
+		return data;
+	case 2: // TripleDES (DES-EDE, [SCHNEIER] [HAC] - 168 bit key derived from 192)
+		return openpgp_cfb_mdc(desede, 8, key, data, openpgp_cfb);
+	case 3: // CAST5 (128 bit key, as per [RFC2144])
+		return openpgp_cfb_mdc(cast5_encrypt, 8, key, data);
+	case 4: // Blowfish (128 bit key, 16 rounds) [BLOWFISH]
+		return openpgp_cfb_mdc(BFencrypt, 8, key, data);
+	case 7: // AES with 128-bit key [AES]
+	case 8: // AES with 192-bit key
+	case 9: // AES with 256-bit key
+		return openpgp_cfb_mdc(AESencrypt, 16, keyExpansion(key), data);
+	case 10: 
+		return openpgp_cfb_mdc(TFencrypt, 16, key, data);
+	case 1: // IDEA [IDEA]
+		util.print_error(""+ (algo == 1 ? "IDEA Algorithm not implemented" : "Twofish Algorithm not implemented"));
+		return null;
+	default:
+	}
+	return null;
+}
+/**
+ * Generating a session key for the specified symmetric algorithm
+ * @param {Integer} algo Algorithm to use (see RFC4880 9.2)
+ * @return {String} Random bytes as a string to be used as a key
+ */
+function openpgp_crypto_generateSessionKey(algo) {
+	switch (algo) {
+	case 2: // TripleDES (DES-EDE, [SCHNEIER] [HAC] - 168 bit key derived from 192)
+	case 8: // AES with 192-bit key
+		return openpgp_crypto_getRandomBytes(24); 
+	case 3: // CAST5 (128 bit key, as per [RFC2144])
+	case 4: // Blowfish (128 bit key, 16 rounds) [BLOWFISH]
+	case 7: // AES with 128-bit key [AES]
+		util.print_debug("length = 16:\n"+util.hexstrdump(openpgp_crypto_getRandomBytes(16)));
+		return openpgp_crypto_getRandomBytes(16);
+	case 9: // AES with 256-bit key
+	case 10:// Twofish with 256-bit key [TWOFISH]
+		return openpgp_crypto_getRandomBytes(32);
+	}
+	return null;
+}
+
+/**
+ * 
+ * @param {Integer} algo public Key algorithm
+ * @param {Integer} hash_algo Hash algorithm
+ * @param {openpgp_type_mpi[]} msg_MPIs Signature multiprecision integers
+ * @param {openpgp_type_mpi[]} publickey_MPIs Public key multiprecision integers 
+ * @param {String} data Data on where the signature was computed on.
+ * @return {Boolean} true if signature (sig_data was equal to data over hash)
+ */
+function openpgp_crypto_verifySignature(algo, hash_algo, msg_MPIs, publickey_MPIs, data) {
+	var calc_hash = openpgp_crypto_hashData(hash_algo, data);
+	switch(algo) {
+	case 1: // RSA (Encrypt or Sign) [HAC]  
+	case 2: // RSA Encrypt-Only [HAC]
+	case 3: // RSA Sign-Only [HAC]
+		var rsa = new RSA();
+		var n = publickey_MPIs[0].toBigInteger();
+		var e = publickey_MPIs[1].toBigInteger();
+		var x = msg_MPIs[0].toBigInteger();
+		var dopublic = rsa.verify(x,e,n);
+		var hash  = openpgp_encoding_emsa_pkcs1_decode(hash_algo,dopublic.toMPI().substring(2));
+		if (hash == -1) {
+			util.print_error("PKCS1 padding in message or key incorrect. Aborting...");
+			return false;
+		}
+		return hash == calc_hash;
+		
+	case 16: // Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
+		util.print_error("signing with Elgamal is not defined in the OpenPGP standard.");
+		return null;
+	case 17: // DSA (Digital Signature Algorithm) [FIPS186] [HAC]
+		var dsa = new DSA();
+		var s1 = msg_MPIs[0].toBigInteger();
+		var s2 = msg_MPIs[1].toBigInteger();
+		var p = publickey_MPIs[0].toBigInteger();
+		var q = publickey_MPIs[1].toBigInteger();
+		var g = publickey_MPIs[2].toBigInteger();
+		var y = publickey_MPIs[3].toBigInteger();
+		var m = data;
+		var dopublic = dsa.verify(hash_algo,s1,s2,m,p,q,g,y);
+		return dopublic.compareTo(s1) == 0;
+	default:
+		return null;
+	}
+	
+}
+   
+/**
+ * Create a signature on data using the specified algorithm
+ * @param {Integer} hash_algo hash Algorithm to use (See RFC4880 9.4)
+ * @param {Integer} algo Asymmetric cipher algorithm to use (See RFC4880 9.1)
+ * @param {openpgp_type_mpi[]} publicMPIs Public key multiprecision integers 
+ * of the private key 
+ * @param {openpgp_type_mpi[]} secretMPIs Private key multiprecision 
+ * integers which is used to sign the data
+ * @param {String} data Data to be signed
+ * @return {(String|openpgp_type_mpi)}
+ */
+function openpgp_crypto_signData(hash_algo, algo, publicMPIs, secretMPIs, data) {
+	
+	switch(algo) {
+	case 1: // RSA (Encrypt or Sign) [HAC]  
+	case 2: // RSA Encrypt-Only [HAC]
+	case 3: // RSA Sign-Only [HAC]
+		var rsa = new RSA();
+		var d = secretMPIs[0].toBigInteger();
+		var n = publicMPIs[0].toBigInteger();
+		var m = openpgp_encoding_emsa_pkcs1_encode(hash_algo, data,publicMPIs[0].mpiByteLength);
+		util.print_debug("signing using RSA");
+		return rsa.sign(m, d, n).toMPI();
+	case 17: // DSA (Digital Signature Algorithm) [FIPS186] [HAC]
+		var dsa = new DSA();
+		util.print_debug("DSA Sign: q size in Bytes:"+publicMPIs[1].getByteLength());
+		var p = publicMPIs[0].toBigInteger();
+		var q = publicMPIs[1].toBigInteger();
+		var g = publicMPIs[2].toBigInteger();
+		var y = publicMPIs[3].toBigInteger();
+		var x = secretMPIs[0].toBigInteger();
+		var m = data;
+		var result = dsa.sign(hash_algo,m, g, p, q, x);
+		util.print_debug("signing using DSA\n result:"+util.hexstrdump(result[0])+"|"+util.hexstrdump(result[1]));
+		return result[0]+result[1];
+	case 16: // Elgamal (Encrypt-Only) [ELGAMAL] [HAC]
+			util.print_debug("signing with Elgamal is not defined in the OpenPGP standard.");
+			return null;
+	default:
+		return null;
+	}	
+}
+
+/**
+ * Create a hash on the specified data using the specified algorithm
+ * @param {Integer} algo Hash algorithm type (see RFC4880 9.4)
+ * @param {String} data Data to be hashed
+ * @return {String} hash value
+ */
+function openpgp_crypto_hashData(algo, data) {
+	var hash = null;
+	switch(algo) {
+	case 1: // - MD5 [HAC]
+		hash = MD5(data);
+		break;
+	case 2: // - SHA-1 [FIPS180]
+		hash = str_sha1(data);
+		break;
+	case 3: // - RIPE-MD/160 [HAC]
+		hash = RMDstring(data);
+		break;
+	case 8: // - SHA256 [FIPS180]
+		hash = str_sha256(data);
+		break;
+	case 9: // - SHA384 [FIPS180]
+		hash = str_sha384(data);
+		break;
+	case 10:// - SHA512 [FIPS180]
+		hash = str_sha512(data);
+		break;
+	case 11:// - SHA224 [FIPS180]
+		hash = str_sha224(data);
+	default:
+		break;
+	}
+	return hash;
+}
+
+/**
+ * Returns the hash size in bytes of the specified hash algorithm type
+ * @param {Integer} algo Hash algorithm type (See RFC4880 9.4)
+ * @return {Integer} Size in bytes of the resulting hash
+ */
+function openpgp_crypto_getHashByteLength(algo) {
+	var hash = null;
+	switch(algo) {
+	case 1: // - MD5 [HAC]
+		return 16;
+	case 2: // - SHA-1 [FIPS180]
+	case 3: // - RIPE-MD/160 [HAC]
+		return 20;
+	case 8: // - SHA256 [FIPS180]
+		return 32;
+	case 9: // - SHA384 [FIPS180]
+		return 48
+	case 10:// - SHA512 [FIPS180]
+		return 64;
+	case 11:// - SHA224 [FIPS180]
+		return 28;
+	}
+	return null;
+}
+
+/**
+ * Retrieve secure random byte string of the specified length
+ * @param {Integer} length Length in bytes to generate
+ * @return {String} Random byte string
+ */
+function openpgp_crypto_getRandomBytes(length) {
+	var result = '';
+	for (var i = 0; i < length; i++) {
+		result += String.fromCharCode(openpgp_crypto_getSecureRandomOctet());
+	}
+	return result;
+}
+
+/**
+ * Return a pseudo-random number in the specified range
+ * @param {Integer} from Min of the random number
+ * @param {Integer} to Max of the random number (max 32bit)
+ * @return {Integer} A pseudo random number
+ */
+function openpgp_crypto_getPseudoRandom(from, to) {
+	return Math.round(Math.random()*(to-from))+from;
+}
+
+/**
+ * Return a secure random number in the specified range
+ * @param {Integer} from Min of the random number
+ * @param {Integer} to Max of the random number (max 32bit)
+ * @return {Integer} A secure random number
+ */
+function openpgp_crypto_getSecureRandom(from, to) {
+	var buf = new Uint32Array(1);
+	window.crypto.getRandomValues(buf);
+	var bits = ((to-from)).toString(2).length;
+	while ((buf[0] & (Math.pow(2, bits) -1)) > (to-from))
+		window.crypto.getRandomValues(buf);
+	return from+(Math.abs(buf[0] & (Math.pow(2, bits) -1)));
+}
+
+function openpgp_crypto_getSecureRandomOctet() {
+	var buf = new Uint32Array(1);
+	window.crypto.getRandomValues(buf);
+	return buf[0] & 0xFF;
+}
+
+/**
+ * Create a secure random big integer of bits length
+ * @param {Integer} bits Bit length of the MPI to create
+ * @return {BigInteger} Resulting big integer
+ */
+function openpgp_crypto_getRandomBigInteger(bits) {
+	if (bits < 0)
+	   return null;
+	var numBytes = Math.floor((bits+7)/8);
+
+	var randomBits = openpgp_crypto_getRandomBytes(numBytes);
+	if (bits % 8 > 0) {
+		
+		randomBits = String.fromCharCode(
+						(Math.pow(2,bits % 8)-1) &
+						randomBits.charCodeAt(0)) +
+			randomBits.substring(1);
+	}
+	return new openpgp_type_mpi().create(randomBits).toBigInteger();
+}
+
+function openpgp_crypto_getRandomBigIntegerInRange(min, max) {
+	if (max.compareTo(min) <= 0)
+		return;
+	var range = max.subtract(min);
+	var r = openpgp_crypto_getRandomBigInteger(range.bitLength());
+	while (r > range) {
+		r = openpgp_crypto_getRandomBigInteger(range.bitLength());
+	}
+	return min.add(r);
+}
+
+
+//This is a test method to ensure that encryption/decryption with a given 1024bit RSAKey object functions as intended
+function openpgp_crypto_testRSA(key){
+	debugger;
+    var rsa = new RSA();
+	var mpi = new openpgp_type_mpi();
+	mpi.create(openpgp_encoding_eme_pkcs1_encode('ABABABAB', 128));
+	var msg = rsa.encrypt(mpi.toBigInteger(),key.ee,key.n);
+	var result = rsa.decrypt(msg, key.d, key.p, key.q, key.u);
+}
+
+/**
+ * @typedef {Object} openpgp_keypair
+ * @property {openpgp_packet_keymaterial} privateKey 
+ * @property {openpgp_packet_keymaterial} publicKey
+ */
+
+/**
+ * Calls the necessary crypto functions to generate a keypair. 
+ * Called directly by openpgp.js
+ * @param {Integer} keyType Follows OpenPGP algorithm convention.
+ * @param {Integer} numBits Number of bits to make the key to be generated
+ * @return {openpgp_keypair}
+ */
+function openpgp_crypto_generateKeyPair(keyType, numBits, passphrase, s2kHash, symmetricEncryptionAlgorithm){
+	var privKeyPacket;
+	var publicKeyPacket;
+	var d = new Date();
+	d = d.getTime()/1000;
+	var timePacket = String.fromCharCode(Math.floor(d/0x1000000%0x100)) + String.fromCharCode(Math.floor(d/0x10000%0x100)) + String.fromCharCode(Math.floor(d/0x100%0x100)) + String.fromCharCode(Math.floor(d%0x100));
+	switch(keyType){
+	case 1:
+	    var rsa = new RSA();
+	    var key = rsa.generate(numBits,"10001");
+	    privKeyPacket = new openpgp_packet_keymaterial().write_private_key(keyType, key, passphrase, s2kHash, symmetricEncryptionAlgorithm, timePacket);
+	    publicKeyPacket =  new openpgp_packet_keymaterial().write_public_key(keyType, key, timePacket);
+	    break;
+	default:
+		util.print_error("Unknown keytype "+keyType)
+	}
+	return {privateKey: privKeyPacket, publicKey: publicKeyPacket};
+}
+
+
+
+ + + + +
+ + + +
+ + + + + + diff --git a/doc/scripts/prettify/Apache-License-2.0.txt b/doc/scripts/prettify/Apache-License-2.0.txt new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/doc/scripts/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/doc/scripts/prettify/lang-css.js b/doc/scripts/prettify/lang-css.js new file mode 100644 index 00000000..041e1f59 --- /dev/null +++ b/doc/scripts/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", +/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/doc/scripts/prettify/prettify.js b/doc/scripts/prettify/prettify.js new file mode 100644 index 00000000..eef5ad7e --- /dev/null +++ b/doc/scripts/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p