From 8545feb03d997a7b163a595aec939003420b099e Mon Sep 17 00:00:00 2001 From: Michal Kolodziej Date: Fri, 12 Apr 2013 13:00:09 +0200 Subject: [PATCH 1/4] 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 Date: Fri, 12 Apr 2013 13:04:00 +0200 Subject: [PATCH 2/4] Crypto.sym --- doc/global.html | 2211 +---------------------------- doc/index.html | 4 +- src/ciphers/openpgp.crypto.sym.js | 28 +- 3 files changed, 88 insertions(+), 2155 deletions(-) diff --git a/doc/global.html b/doc/global.html index e78218e7..db1fa8dd 100644 --- a/doc/global.html +++ b/doc/global.html @@ -91,7 +91,7 @@
-

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

+

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

@@ -99,1749 +99,8 @@
- 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:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
algo - - -Integer - - - - Algorithm to be used (See RFC4880 9.1)
publicMPIs - - -openpgp_type_mpi[] - - - - Algorithm dependent multiprecision integers -of the public key part of the private key
secretMPIs - - -openpgp_type_mpi[] - - - - Algorithm dependent multiprecision integers -of the private key used
data - - -openpgp_type_mpi - - - - Data to be encrypted as MPI
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - -
- returns a big integer containing the decrypted data; otherwise null -
- - - -
-
- Type -
-
- -BigInteger - - -
-
- - - - - - - - -
-

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

- - -
-
- - -
- Encrypts data using the specified public key multiprecision integers -and the specified algorithm. -
- - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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}

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

openpgp_crypto_getHashByteLength(algo) → {Integer}

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

openpgp_crypto_getPrefixRandom(algo) → {String}

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

openpgp_crypto_getPseudoRandom(from, to) → {Integer}

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

openpgp_crypto_getRandomBigInteger(bits) → {BigInteger}

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

openpgp_crypto_getRandomBytes(length) → {String}

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

openpgp_crypto_getSecureRandom(from, to) → {Integer}

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

openpgp_crypto_hashData(algo, data) → {String}

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

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

- - -
-
- - -
- retrieve the MDC prefixed bytes by decrypting them + Symmetrically decrypts data using a key with length depending on the +algorithm in openpgp_cfb mode with or without resync (MDC style)
@@ -1937,7 +196,31 @@ size of the cipher - Encrypted data where the prefix is decrypted from + Data to be decrypted + + + + + + + openpgp_cfb + + + + + +Boolean + + + + + + + + + + If true use the resync (for encrypteddata); +otherwise use without the resync (for MDC encrypted data) @@ -1968,7 +251,7 @@ size of the cipher
Source:
@@ -1993,7 +276,7 @@ size of the cipher
- Plain text data of the prefixed data + Plaintext data
@@ -2018,7 +301,7 @@ size of the cipher
-

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

+

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

@@ -2026,7 +309,9 @@ size of the cipher
- Create a signature on data using the specified algorithm + Symmetrically encrypts data using prefixedrandom, a key with length +depending on the algorithm in openpgp_cfb mode with or without resync +(MDC style)
@@ -2060,13 +345,13 @@ size of the cipher - hash_algo + prefixrandom -Integer +String @@ -2076,7 +361,9 @@ size of the cipher - hash Algorithm to use (See RFC4880 9.4) + 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 @@ -2099,20 +386,20 @@ size of the cipher - Asymmetric cipher algorithm to use (See RFC4880 9.1) + Algorithm to use (see RFC4880 9.2) - publicMPIs + key -openpgp_type_mpi[] +String @@ -2122,32 +409,7 @@ size of the cipher - Public key multiprecision integers -of the private key - - - - - - - secretMPIs - - - - - -openpgp_type_mpi[] - - - - - - - - - - Private key multiprecision -integers which is used to sign the data + Key as string. length is depending on the algorithm used @@ -2170,7 +432,30 @@ integers which is used to sign the data - Data to be signed + Data to encrypt + + + + + + + openpgp_cfb + + + + + +Boolean + + + + + + + + + + @@ -2201,233 +486,7 @@ integers which is used to sign the data
Source:
- - - - - - - -
- - - - - - - - - - - -
Returns:
- - - - -
-
- Type -
-
- -String -| - -openpgp_type_mpi - - -
-
- - - - - - - - -
-

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

- - -
-
- - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
algo - - -Integer - - - - public Key algorithm
hash_algo - - -Integer - - - - Hash algorithm
msg_MPIs - - -openpgp_type_mpi[] - - - - Signature multiprecision integers
publickey_MPIs - - -openpgp_type_mpi[] - - - - Public key multiprecision integers
data - - -String - - - - Data on where the signature was computed on.
- - - -
- - - - - - - - - - - - - - - - - - - -
Source:
-
@@ -2452,7 +511,7 @@ integers which is used to sign the data
- true if signature (sig_data was equal to data over hash) + Encrypted data
@@ -2463,7 +522,7 @@ integers which is used to sign the data
-Boolean +String
@@ -2478,132 +537,6 @@ integers which is used to sign the data -

Type Definitions

- -
- -
-

openpgp_keypair

- - -
-
- - - -
- - -
Properties:
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
privateKey - - -openpgp_packet_keymaterial - - - -
publicKey - - -openpgp_packet_keymaterial - - - -
- - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - -
- -
- @@ -2616,13 +549,13 @@ integers which is used to sign the data
- Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 12:58:17 GMT+0200 (CEST) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 13:03:34 GMT+0200 (CEST)
diff --git a/doc/index.html b/doc/index.html index 5f1486f7..b1030897 100644 --- a/doc/index.html +++ b/doc/index.html @@ -48,13 +48,13 @@
- Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 12:58:17 GMT+0200 (CEST) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 13:03:34 GMT+0200 (CEST)
diff --git a/src/ciphers/openpgp.crypto.sym.js b/src/ciphers/openpgp.crypto.sym.js index 5a2be9d6..30879a7d 100644 --- a/src/ciphers/openpgp.crypto.sym.js +++ b/src/ciphers/openpgp.crypto.sym.js @@ -21,14 +21,14 @@ * Symmetrically encrypts data using prefixedrandom, a key with length * depending on the algorithm in openpgp_cfb mode with or without resync * (MDC style) - * @param 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 - * @param algo [Integer] algorithm to use (see RFC4880 9.2) - * @param key [String] key as string. length is depending on the algorithm used - * @param data [String] data to encrypt - * @param openpgp_cfb [boolean] - * @return [String] encrypted data + * @param {String} 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 + * @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 Data to encrypt + * @param {Boolean} openpgp_cfb + * @return {String} Encrypted data */ function openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_cfb) { switch(algo) { @@ -57,12 +57,12 @@ function openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_ /** * Symmetrically decrypts data using a key with length depending on the * algorithm in openpgp_cfb mode with or without resync (MDC style) - * @param algo [Integer] algorithm to use (see RFC4880 9.2) - * @param key [String] key as string. length is depending on the algorithm used - * @param data [String] data to be decrypted - * @param openpgp_cfb [boolean] if true use the resync (for encrypteddata); + * @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 Data to be decrypted + * @param {Boolean} openpgp_cfb If true use the resync (for encrypteddata); * otherwise use without the resync (for MDC encrypted data) - * @return [String] plaintext data + * @return {String} Plaintext data */ function openpgp_crypto_symmetricDecrypt(algo, key, data, openpgp_cfb) { util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+algo+"\nencrypteddata:",data); @@ -91,4 +91,4 @@ function openpgp_crypto_symmetricDecrypt(algo, key, data, openpgp_cfb) { default: } return null; -} \ No newline at end of file +} From 51f8f958077d79a4e053fdb04ac3ab2c12fee742 Mon Sep 17 00:00:00 2001 From: Michal Kolodziej Date: Fri, 12 Apr 2013 14:21:07 +0200 Subject: [PATCH 3/4] Finished changing all the javascript files, the documentation now correctly generates via the use of the makefile. --- doc/JXG.Util.html | 319 +- doc/_openpgp_packet.html | 408 +- doc/global.html | 7568 ++++++++++++++++- doc/index.html | 89 +- doc/openpgp.cfb.js.html | 10 +- doc/openpgp.crypto.js.html | 8 +- doc/openpgp.html | 856 +- doc/openpgp_config.html | 546 +- doc/openpgp_keyring.html | 1006 ++- doc/openpgp_msg_message.html | 302 +- doc/openpgp_msg_privatekey.html | 186 +- doc/openpgp_msg_publickey.html | 304 +- doc/openpgp_packet_compressed.html | 463 +- doc/openpgp_packet_encrypteddata.html | 338 +- ...acket_encryptedintegrityprotecteddata.html | 350 +- doc/openpgp_packet_encryptedsessionkey.html | 533 +- doc/openpgp_packet_keymaterial.html | 1382 +-- doc/openpgp_packet_literaldata.html | 298 +- doc/openpgp_packet_marker.html | 229 +- ...npgp_packet_modificationdetectioncode.html | 220 +- doc/openpgp_packet_onepasssignature.html | 318 +- doc/openpgp_packet_signature.html | 584 +- doc/openpgp_packet_userattribute.html | 310 +- doc/openpgp_packet_userid.html | 575 +- doc/openpgp_type_keyid.html | 225 +- doc/openpgp_type_mpi.html | 500 +- doc/openpgp_type_s2k.html | 293 +- doc/styles/node-dark.css | 150 - resources/openpgp.js | 2078 ++--- resources/openpgp.min.js | 50 +- src/compression/zlib/jsxcompressor.js | 6 +- src/config/openpgp.config.js | 21 +- src/encoding/openpgp.encoding.asciiarmor.js | 39 +- src/encoding/openpgp.encoding.js | 39 +- src/openpgp.js | 46 +- src/openpgp.keyring.js | 18 +- src/openpgp.msg.publickey.js | 2 +- src/packet/openpgp.packet.compressed.js | 29 +- src/packet/openpgp.packet.encrypteddata.js | 28 +- ....packet.encryptedintegrityprotecteddata.js | 31 +- .../openpgp.packet.encryptedsessionkey.js | 53 +- src/packet/openpgp.packet.js | 28 +- src/packet/openpgp.packet.keymaterial.js | 97 +- src/packet/openpgp.packet.literaldata.js | 18 +- src/packet/openpgp.packet.marker.js | 17 +- ...penpgp.packet.modificationdetectioncode.js | 4 +- src/packet/openpgp.packet.onepasssignature.js | 14 +- src/packet/openpgp.packet.signature.js | 16 +- src/packet/openpgp.packet.userattribute.js | 16 +- src/packet/openpgp.packet.userid.js | 22 +- src/type/openpgp.type.keyid.js | 11 +- src/type/openpgp.type.mpi.js | 30 +- src/type/openpgp.type.s2k.js | 18 +- src/util/util.js | 81 +- 54 files changed, 15452 insertions(+), 5730 deletions(-) delete mode 100644 doc/styles/node-dark.css diff --git a/doc/JXG.Util.html b/doc/JXG.Util.html index 1d882d58..19ab8810 100644 --- a/doc/JXG.Util.html +++ b/doc/JXG.Util.html @@ -4,12 +4,12 @@ JSDoc: Class: Util - - + + - + @@ -35,7 +35,9 @@ Class for gunzipping, unzipping and base64 decoding of files. It is used for reading GEONExT, Geogebra and Intergeo files. Only Huffman codes are decoded in gunzip. -The code is based on the source code for gunzip.c by Pasi Ojala +The code is based on the source code for gunzip.c by Pasi Ojala +http://www.cs.tut.fi/~albert/Dev/gunzip/gunzip.c +http://www.cs.tut.fi/~albert @@ -46,13 +48,15 @@ The code is based on the source code for gunzip.c by Pasi Ojala
-

new Util

+

new Util()

+ + @@ -62,43 +66,42 @@ The code is based on the source code for gunzip.c by Pasi Ojala
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10985
- - - -
See:
-
- -
- - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -134,6 +137,7 @@ The code is based on the source code for gunzip.c by Pasi Ojala
Base64 encoding / decoding + http://www.webtoolkit.info/
@@ -141,37 +145,34 @@ The code is based on the source code for gunzip.c by Pasi Ojala
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 11876
- - - -
See:
-
- -
- - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
@@ -187,7 +188,7 @@ The code is based on the source code for gunzip.c by Pasi Ojala
-

<static> genUUID

+

<static> genUUID()

@@ -207,6 +208,8 @@ EXAMPLES: "92329D39-6F5C-4520-ABFC-AAB64544E172" + + @@ -216,34 +219,42 @@ EXAMPLES:
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12152
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -255,7 +266,7 @@ EXAMPLES:
-

<static> Unzip

+

<static> Unzip()

@@ -266,6 +277,8 @@ EXAMPLES: Unzip zip files + + @@ -275,34 +288,42 @@ EXAMPLES:
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10990
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -314,7 +335,7 @@ EXAMPLES:
-

<static> utf8Decode

+

<static> utf8Decode(string) → {String}

@@ -325,6 +346,8 @@ EXAMPLES: Decoding string into utf-8 + + @@ -359,9 +382,11 @@ EXAMPLES: - String - - + +String + + + @@ -380,34 +405,42 @@ EXAMPLES:
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12114
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -421,15 +454,15 @@ EXAMPLES: -
Type
- String - +String + +
@@ -454,15 +487,15 @@ EXAMPLES:
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:26 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:34 GMT+0200 (CEST)
- + diff --git a/doc/_openpgp_packet.html b/doc/_openpgp_packet.html index ef93ab29..3057dac2 100644 --- a/doc/_openpgp_packet.html +++ b/doc/_openpgp_packet.html @@ -4,12 +4,12 @@ JSDoc: Class: _openpgp_packet - - + + - + @@ -30,8 +30,8 @@ _openpgp_packet -
Parent openpgp packet class. Operations focus on determining packet types - and packet header.
+
Parent openpgp packet class. Operations focus on determining +packet types and packet header.
@@ -42,13 +42,15 @@
-

new _openpgp_packet

+

new _openpgp_packet()

+ + @@ -58,34 +60,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2108
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -115,7 +125,7 @@
-

<inner> encode_length

+

<inner> encode_length(length) → {String}

@@ -127,6 +137,8 @@ string + + @@ -161,16 +173,18 @@ string - Integer - - + +Integer + + + - of the length to encode + The length to encode @@ -182,34 +196,42 @@ string
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2116
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -218,20 +240,20 @@ string
- string with openpgp length representation + String with openpgp length representation
-
Type
- string - +String + +
@@ -243,7 +265,7 @@ string
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {Object}

@@ -254,6 +276,8 @@ string Generic static Packet Parser function + + @@ -288,16 +312,18 @@ string - String - - + +String + + + - input stream as string + Input stream as string @@ -309,16 +335,18 @@ string - integer - - + +integer + + + - position to start parsing + Position to start parsing @@ -330,16 +358,18 @@ string - integer - - + +integer + + + - length of the input from position on + Length of the input from position on @@ -351,34 +381,42 @@ string
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2190
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -387,20 +425,20 @@ string
- returns a parsed openpgp_packet + Returns a parsed openpgp_packet
-
Type
- openpgp_packet_* - +Object + +
@@ -412,7 +450,7 @@ string
-

<inner> write_old_packet_header

+

<inner> write_old_packet_header(tag_type, length) → {String}

@@ -424,6 +462,8 @@ string string + + @@ -458,16 +498,18 @@ string - integer - - + +Integer + + + - tag type + Tag type @@ -479,16 +521,18 @@ string - integer - - + +Integer + + + - length of the payload + Length of the payload @@ -500,34 +544,42 @@ string
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2162
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -536,20 +588,20 @@ string
- string of the header + String of the header
-
Type
- string - +String + +
@@ -561,7 +613,7 @@ string
-

<inner> write_packet_header

+

<inner> write_packet_header(tag_type, length) → {String}

@@ -573,6 +625,8 @@ string string + + @@ -607,16 +661,18 @@ string - integer - - + +Integer + + + - tag type + Tag type @@ -628,16 +684,18 @@ string - integer - - + +Integer + + + - length of the payload + Length of the payload @@ -649,34 +707,42 @@ string
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2146
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -685,20 +751,20 @@ string
- string of the header + String of the header
-
Type
- string - +String + +
@@ -723,15 +789,15 @@ string
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:26 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:34 GMT+0200 (CEST)
- + diff --git a/doc/global.html b/doc/global.html index db1fa8dd..0f55353d 100644 --- a/doc/global.html +++ b/doc/global.html @@ -84,12 +84,4188 @@ +

Members

+ +
+ +
+

crc_table

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

hash_headers

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

util

+ + +
+
+ +
+ an instance that should be used. +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+

Methods

+
+

bin2str(bin) → {String}

+ + +
+
+ + +
+ Convert an array of integers(0.255) to a string +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bin + + +Integer[] + + + + An array of (binary) integers to convert
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ The string representation of the array +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

calc_checksum(text) → {Integer}

+ + +
+
+ + +
+ 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:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ An integer containing the sum of all character +codes % 65535 +
+ + + +
+
+ Type +
+
+ +Integer + + +
+
+ + + + +
+ + + +
+

get_hashAlgorithmString() → {String}

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

getCheckSum(data) → {String}

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

getPGPMessageType(text) → {Integer}

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

hex2bin(str) → {String}

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

hexidump(str) → {String}

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

hexstrdump(str) → {String}

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

MD5()

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

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

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

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

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

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

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

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

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

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

+ + +
+
+ + +
+ Encrypts data using the specified public key multiprecision integers +and the specified algorithm. +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
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}

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

openpgp_crypto_getHashByteLength(algo) → {Integer}

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

openpgp_crypto_getPrefixRandom(algo) → {String}

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

openpgp_crypto_getPseudoRandom(from, to) → {Integer}

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

openpgp_crypto_getRandomBigInteger(bits) → {BigInteger}

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

openpgp_crypto_getRandomBytes(length) → {String}

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

openpgp_crypto_getSecureRandom(from, to) → {Integer}

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

openpgp_crypto_hashData(algo, data) → {String}

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

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

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

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

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

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

@@ -251,7 +4427,7 @@ otherwise use without the resync (for MDC encrypted data)
Source:
@@ -486,7 +4662,7 @@ openpgp_crypto_getPrefixRandom(algo) to retrieve that string
Source:
@@ -531,12 +4707,3396 @@ openpgp_crypto_getPrefixRandom(algo) to retrieve that string +
+ + + +
+

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

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

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

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

openpgp_encoding_armor_addheader() → {String}

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

openpgp_encoding_base64_decode(message) → {String}

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

openpgp_encoding_base64_encode(message) → {String}

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

openpgp_encoding_deArmor(text) → {String|Object}

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

openpgp_encoding_eme_pkcs1_decode(message) → {String}

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

openpgp_encoding_eme_pkcs1_encode(message, length) → {String}

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

openpgp_encoding_emsa_pkcs1_decode(data) → {String}

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

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

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

openpgp_encoding_html_encode(message) → {String}

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

shiftRight(value, bitcount) → {String}

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

str2bin(str) → {Integer[]}

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

str2Uint8Array(str) → {Uint8Array}

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

Uint8Array2str(bin) → {String}

+ + +
+
+ + +
+ Convert a Uint8Array to a string. This currently functions +the same as bin2str. +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
bin + + +Uint8Array + + + + An array of (binary) integers to convert
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ String representation of the array +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

verifyCheckSum(data, checksum) → {Boolean}

+ + +
+
+ + +
+ 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:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ True if the given checksum is correct; otherwise false +
+ + + +
+
+ Type +
+
+ +Boolean + + +
+
+ + + +
+

Type Definitions

+ +
+ +
+

openpgp_byte_array

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

openpgp_cipher_block_fn(block, key) → {openpgp_byte_array}

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

openpgp_keypair

+ + +
+
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
privateKey + + +openpgp_packet_keymaterial + + + +
publicKey + + +openpgp_packet_keymaterial + + + +
+ + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ +
+ @@ -549,13 +8109,13 @@ openpgp_crypto_getPrefixRandom(algo) to retrieve that string
- Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 13:03:34 GMT+0200 (CEST) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST)
diff --git a/doc/index.html b/doc/index.html index b1030897..e32350ac 100644 --- a/doc/index.html +++ b/doc/index.html @@ -45,16 +45,101 @@ + + +
+ +
+

+ src/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:
+
+ + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + +
- Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 13:03:34 GMT+0200 (CEST) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:34 GMT+0200 (CEST)
diff --git a/doc/openpgp.cfb.js.html b/doc/openpgp.cfb.js.html index 106dfb52..f9613e13 100644 --- a/doc/openpgp.cfb.js.html +++ b/doc/openpgp.cfb.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: openpgp.cfb.js + JSDoc: Source: ciphers/openpgp.cfb.js @@ -17,7 +17,7 @@
-

Source: openpgp.cfb.js

+

Source: ciphers/openpgp.cfb.js

@@ -60,7 +60,7 @@ /** * 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 + * @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. @@ -325,13 +325,13 @@ function normal_cfb_decrypt(blockcipherencryptfn, block_size, key, ciphertext, i

- Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 12:38:54 GMT+0200 (CEST) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST)
diff --git a/doc/openpgp.crypto.js.html b/doc/openpgp.crypto.js.html index 7a80d7b9..3a6d889e 100644 --- a/doc/openpgp.crypto.js.html +++ b/doc/openpgp.crypto.js.html @@ -2,7 +2,7 @@ - JSDoc: Source: openpgp.crypto.js + JSDoc: Source: ciphers/openpgp.crypto.js @@ -17,7 +17,7 @@
-

Source: openpgp.crypto.js

+

Source: ciphers/openpgp.crypto.js

@@ -465,13 +465,13 @@ function openpgp_crypto_generateKeyPair(keyType, numBits, passphrase, s2kHash, s

- Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 12:58:17 GMT+0200 (CEST) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST)
diff --git a/doc/openpgp.html b/doc/openpgp.html index 5cec5ebe..f5e389de 100644 --- a/doc/openpgp.html +++ b/doc/openpgp.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp - - + + - + @@ -41,7 +41,7 @@
-

new openpgp

+

new openpgp()

@@ -53,6 +53,8 @@ from the beginning. To use this library call "openpgp.init()" + + @@ -62,34 +64,42 @@ from the beginning. To use this library call "openpgp.init()"
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9578
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -119,7 +129,7 @@ from the beginning. To use this library call "openpgp.init()"
-

<inner> generate_key_pair

+

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

@@ -127,9 +137,12 @@ from the beginning. To use this library call "openpgp.init()"
- generates a new key pair for openpgp. Beta stage. Currently only supports RSA keys, and no subkeys. + generates a new key pair for openpgp. Beta stage. Currently only +supports RSA keys, and no subkeys.
+ + @@ -164,16 +177,19 @@ from the beginning. To use this library call "openpgp.init()" - int - - + +Integer + + + - to indicate what type of key to make. RSA is 1. Follows algorithms outlined in OpenPGP. + to indicate what type of key to make. +RSA is 1. Follows algorithms outlined in OpenPGP. @@ -185,16 +201,19 @@ from the beginning. To use this library call "openpgp.init()" - int - - + +Integer + + + - number of bits for the key creation. (should be 1024+, generally) + number of bits for the key creation. (should +be 1024+, generally) @@ -206,16 +225,19 @@ from the beginning. To use this library call "openpgp.init()" - string - - + +String + + + - assumes already in form of "User Name " + assumes already in form of "User Name +" @@ -227,34 +249,42 @@ from the beginning. To use this library call "openpgp.init()"
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9925
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -262,6 +292,10 @@ from the beginning. To use this library call "openpgp.init()"
Returns:
+
+ {privateKey: [openpgp_msg_privatekey], +privateKeyArmored: [string], publicKeyArmored: [string]} +
@@ -271,8 +305,9 @@ from the beginning. To use this library call "openpgp.init()"
- privateKey: [openpgp_msg_privatekey], privateKeyArmored: [string], publicKeyArmored: [string] - +Object + +
@@ -284,7 +319,7 @@ from the beginning. To use this library call "openpgp.init()"
-

<inner> init

+

<inner> init()

@@ -297,6 +332,8 @@ from the beginning. To use this library call "openpgp.init()" - reading the config from local storage + + @@ -306,48 +343,46 @@ from the beginning. To use this library call "openpgp.init()"
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9587
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
- - - - -
Returns:
- - -
- [void] -
+ - - + + + + +
@@ -355,7 +390,7 @@ from the beginning. To use this library call "openpgp.init()"
-

<inner> read_message

+

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

@@ -367,6 +402,8 @@ from the beginning. To use this library call "openpgp.init()" returns an array of message objects + + @@ -401,9 +438,11 @@ returns an array of message objects - String - - + +String + + + @@ -422,34 +461,42 @@ returns an array of message objects
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9678
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -464,15 +511,15 @@ returns null -
Type
- Array[openpgp_msg_message] - +openpgp_msg_message[] + +
@@ -484,7 +531,150 @@ returns null
-

<inner> read_privateKey

+

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

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

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

@@ -496,6 +686,8 @@ returns null representation an returns openpgp_msg_privatekey objects + + @@ -530,9 +722,11 @@ representation an returns openpgp_msg_privatekey objects - String - - + +String + + + @@ -552,34 +746,42 @@ the private key(s)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9648
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -594,15 +796,15 @@ returns null -
Type
- Array[openpgp_msg_privatekey] - +openpgp_msg_privatekey[] + +
@@ -614,7 +816,7 @@ returns null
-

<inner> read_publicKey

+

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

@@ -626,6 +828,8 @@ returns null representation an returns openpgp_msg_publickey packets + + @@ -660,9 +864,11 @@ representation an returns openpgp_msg_publickey packets - String - - + +String + + + @@ -682,34 +888,42 @@ the public key(s)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9602
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -724,15 +938,15 @@ returns null -
Type
- Array[openpgp_msg_publickey] - +openpgp_msg_publickey[] + +
@@ -744,7 +958,7 @@ returns null
-

<inner> write_encrypted_message

+

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

@@ -756,6 +970,8 @@ returns null The message will be encrypted with the public keys specified + + @@ -790,17 +1006,19 @@ The message will be encrypted with the public keys specified - Array {obj: [openpgp_msg_publickey]} - - + +Object[] + + + - public -keys to be used to encrypt the message + An array of {obj: [openpgp_msg_publickey]} +-public keys to be used to encrypt the message @@ -812,9 +1030,11 @@ keys to be used to encrypt the message - String - - + +String + + + @@ -833,34 +1053,42 @@ keys to be used to encrypt the message
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9869
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -875,15 +1103,15 @@ which can be OpenPGP armored -
Type
- String - +String + +
@@ -895,7 +1123,7 @@ which can be OpenPGP armored
-

<inner> write_signed_and_encrypted_message

+

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

@@ -908,6 +1136,8 @@ The message will be encrypted with the public keys specified and signed with the specified private key. + + @@ -942,16 +1172,19 @@ with the specified private key. - obj: [openpgp_msg_privatekey] - - + +Object + + + - private key to be used to sign the message + {obj: [openpgp_msg_privatekey]} Private key +to be used to sign the message @@ -963,16 +1196,19 @@ with the specified private key. - Array {obj: [openpgp_msg_publickey]} - - + +Object[] + + + - public keys to be used to encrypt the message + An arraf of {obj: [openpgp_msg_publickey]} +- public keys to be used to encrypt the message @@ -984,9 +1220,11 @@ with the specified private key. - String - - + +String + + + @@ -1005,34 +1243,42 @@ with the specified private key.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9812
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1041,20 +1287,21 @@ with the specified private key.
- a binary string representation of the message which can be OpenPGP armored + a binary string representation of the message which +can be OpenPGP armored
-
Type
- String - +String + +
@@ -1066,7 +1313,7 @@ with the specified private key.
-

<inner> write_signed_message

+

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

@@ -1078,6 +1325,8 @@ with the specified private key. The message will be signed with the specified private key. + + @@ -1112,17 +1361,19 @@ The message will be signed with the specified private key. - obj: [openpgp_msg_privatekey] - - + +Object + + + - private -key to be used to sign the message + {obj: [openpgp_msg_privatekey]} +- the private key to be used to sign the message @@ -1134,9 +1385,11 @@ key to be used to sign the message - String - - + +String + + + @@ -1155,34 +1408,42 @@ key to be used to sign the message
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9912
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1191,22 +1452,23 @@ key to be used to sign the message
- , openpgp: {String} a binary + {Object: text [String]}, openpgp: {String} a binary string representation of the message which can be OpenPGP - armored(openpgp) and a text representation of the message (text). This can be directly used to OpenPGP armor the message + armored(openpgp) and a text representation of the message (text). +This can be directly used to OpenPGP armor the message
-
Type
- Object: text [String] - +Object + +
@@ -1231,15 +1493,15 @@ key to be used to sign the message
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:26 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:34 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_config.html b/doc/openpgp_config.html index ee08b0d8..b831a797 100644 --- a/doc/openpgp_config.html +++ b/doc/openpgp_config.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_config - - + + - + @@ -41,7 +41,7 @@
-

new openpgp_config

+

new openpgp_config()

@@ -58,6 +58,8 @@ Stored config parameters can be accessed using openpgp.config.config + + @@ -67,34 +69,42 @@ openpgp.config.config
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10250
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -122,14 +132,14 @@ openpgp.config.config
-

debug

+

config

- if enabled, debug messages will be printed + The variable with the actual configuration
@@ -137,30 +147,298 @@ openpgp.config.config
+
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -
Source:
-
  • openpgp.js, line 10289
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
prefer_hash_algorithm + + +Integer + + + +
encryption_cipher + + +Integer + + + +
compression + + +Integer + + + +
show_version + + +Boolean + + + +
show_comment + + +Boolean + + + +
integrity_protect + + +Boolean + + + +
composition_behavior + + +Integer + + + +
keyserver + + +String + + + +
+ + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + +
+ + + +
+

debug

+ + +
+
+ +
+ If enabled, debug messages will be printed +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + - - - -
@@ -177,7 +455,7 @@ openpgp.config.config
- the default config object which is used if no + The default config object which is used if no configuration was in place
@@ -186,30 +464,34 @@ configuration was in place
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10257
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
@@ -225,7 +507,7 @@ configuration was in place
-

<inner> read

+

<inner> read()

@@ -233,11 +515,13 @@ configuration was in place
- reads the config out of the HTML5 local storage + Reads the config out of the HTML5 local storage and initializes the object config. if config is null the default config will be used
+ + @@ -247,48 +531,46 @@ if config is null the default config will be used
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10276
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
- - - - -
Returns:
- - -
- [void] -
+ - - + + + + +
@@ -296,7 +578,7 @@ if config is null the default config will be used
-

<inner> write

+

<inner> write()

@@ -304,9 +586,11 @@ if config is null the default config will be used
- writes the config to HTML5 local storage + Writes the config to HTML5 local storage
+ + @@ -316,48 +600,46 @@ if config is null the default config will be used
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10295
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
- - - - -
Returns:
- - -
- [void] -
+ - - + + + + + @@ -378,15 +660,15 @@ if config is null the default config will be used
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:26 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:34 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_keyring.html b/doc/openpgp_keyring.html index 50359e18..e577d36b 100644 --- a/doc/openpgp_keyring.html +++ b/doc/openpgp_keyring.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_keyring - - + + - + @@ -41,13 +41,15 @@
-

new openpgp_keyring

+

new openpgp_keyring()

+ + @@ -57,34 +59,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12660
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -114,7 +124,7 @@
-

<inner> exportPrivateKey

+

<inner> exportPrivateKey(index) → {openpgp_msg_privatekey}

@@ -125,6 +135,8 @@ returns the openpgp_msg_privatekey representation of the private key at private key ring index + + @@ -159,9 +171,11 @@ - Integer - - + +Integer + + + @@ -180,34 +194,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12876
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -221,15 +243,15 @@ -
Type
- openpgp_msg_privatekey - +openpgp_msg_privatekey + +
@@ -241,7 +263,7 @@
-

<inner> exportPublicKey

+

<inner> exportPublicKey(index) → {openpgp_msg_privatekey}

@@ -252,6 +274,8 @@ returns the openpgp_msg_privatekey representation of the public key at public key ring index + + @@ -286,9 +310,11 @@ - Integer - - + +Integer + + + @@ -307,34 +333,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12853
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -348,15 +382,15 @@ -
Type
- openpgp_msg_privatekey - +openpgp_msg_privatekey + +
@@ -368,7 +402,7 @@
-

<inner> getPrivateKeyForAddress

+

<inner> getPrivateKeyForAddress(email_address) → {openpgp_msg_privatekey[]}

@@ -379,6 +413,8 @@ Searches the keyring for a private key containing the specified email address + + @@ -413,9 +449,11 @@ - String - - + +String + + + @@ -434,34 +472,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12757
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -475,15 +521,15 @@ -
Type
- Array[openpgp_msg_privatekey - +openpgp_msg_privatekey[] + +
@@ -495,7 +541,7 @@
-

<inner> getPrivateKeyForKeyId

+

<inner> getPrivateKeyForKeyId(keyId) → {openpgp_msg_privatekey[]}

@@ -506,6 +552,8 @@ Searches the keyring for private keys having the specified key id + + @@ -540,9 +588,11 @@ - String - - + +String + + + @@ -561,34 +611,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12799
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -602,15 +660,15 @@ -
Type
- Array[openpgp_msg_privatekey] - +openpgp_msg_privatekey[] + +
@@ -622,7 +680,7 @@
-

<inner> getPublicKeyForAddress

+

<inner> getPublicKeyForAddress(email_address) → {openpgp_msg_publickey[]}

@@ -633,6 +691,8 @@ searches all public keys in the keyring matching the address or address part of the user ids + + @@ -667,6 +727,11 @@ + +String + + + @@ -685,34 +750,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12729
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -721,20 +794,20 @@
- the public keys associated with provided email address. + The public keys associated with provided email address.
-
Type
- array[openpgp_msg_publickey] - +openpgp_msg_publickey[] + +
@@ -746,7 +819,7 @@
-

<inner> getPublicKeysForKeyId

+

<inner> getPublicKeysForKeyId(keyId) → {openpgp_msg_privatekey[]}

@@ -757,6 +830,8 @@ Searches the keyring for public keys having the specified key id + + @@ -791,6 +866,11 @@ + +String + + + @@ -809,34 +889,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12785
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -850,15 +938,15 @@ -
Type
- Array[openpgp_msg_privatekey] - +openpgp_msg_privatekey[] + +
@@ -870,7 +958,7 @@
-

<inner> hasPrivateKey

+

<inner> hasPrivateKey() → {Boolean}

@@ -881,6 +969,8 @@ Checks if at least one private key is in the keyring + + @@ -890,34 +980,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12701
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -931,15 +1029,15 @@ -
Type
- boolean - +Boolean + +
@@ -951,7 +1049,7 @@
-

<inner> importPrivateKey

+

<inner> importPrivateKey(armored_text)

@@ -962,6 +1060,8 @@ Imports a private key from an exported ascii armored message + + @@ -996,9 +1096,11 @@ - String - - + +String + + + @@ -1017,60 +1119,46 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12835
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + -
Returns:
- -
- nothing -
- - - - -
-
- Type -
-
- - null - -
-
- -
@@ -1078,7 +1166,7 @@
-

<inner> importPublicKey

+

<inner> importPublicKey(armored_text)

@@ -1089,6 +1177,8 @@ Imports a public key from an exported ascii armored message + + @@ -1123,9 +1213,11 @@ - String - - + +String + + + @@ -1144,60 +1236,46 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12822
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + -
Returns:
- -
- nothing -
- - - - -
-
- Type -
-
- - null - -
-
- - @@ -1205,7 +1283,7 @@
-

<inner> init

+

<inner> init()

@@ -1218,6 +1296,8 @@ keyring from HTML5 local storage and initializes this instance. This method is called by openpgp.init(). + + @@ -1227,60 +1307,46 @@ This method is called by openpgp.init().
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12668
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + -
Returns:
- -
- undefined -
- - - - -
-
- Type -
-
- - null - -
-
- - @@ -1288,7 +1354,7 @@ This method is called by openpgp.init().
-

<inner> removePrivateKey

+

<inner> removePrivateKey(index) → {openpgp_msg_privatekey}

@@ -1299,6 +1365,8 @@ This method is called by openpgp.init(). Removes a private key from the private key keyring at the specified index + + @@ -1333,9 +1401,11 @@ This method is called by openpgp.init(). - Integer - - + +Integer + + + @@ -1354,34 +1424,42 @@ This method is called by openpgp.init().
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12886
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1395,15 +1473,15 @@ This method is called by openpgp.init(). -
Type
- openpgp_msg_privatekey - +openpgp_msg_privatekey + +
@@ -1415,7 +1493,7 @@ This method is called by openpgp.init().
-

<inner> removePublicKey

+

<inner> removePublicKey(index) → {openpgp_msg_privatekey}

@@ -1426,6 +1504,8 @@ This method is called by openpgp.init(). Removes a public key from the public key keyring at the specified index + + @@ -1460,9 +1540,11 @@ This method is called by openpgp.init(). - Integer - - + +Integer + + + @@ -1481,34 +1563,42 @@ This method is called by openpgp.init().
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12864
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1522,15 +1612,15 @@ This method is called by openpgp.init(). -
Type
- openpgp_msg_privatekey - +openpgp_msg_privatekey + +
@@ -1542,7 +1632,7 @@ This method is called by openpgp.init().
-

<inner> store

+

<inner> store()

@@ -1554,6 +1644,8 @@ This method is called by openpgp.init(). The privateKeys array and publicKeys array gets Stringified using JSON + + @@ -1563,60 +1655,46 @@ The privateKeys array and publicKeys array gets Stringified using JSON
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12711
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + -
Returns:
- -
- undefined -
- - - - -
-
- Type -
-
- - null - -
-
- - @@ -1637,15 +1715,15 @@ The privateKeys array and publicKeys array gets Stringified using JSON
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:26 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:34 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_msg_message.html b/doc/openpgp_msg_message.html index 50c9f6e6..cdf458d9 100644 --- a/doc/openpgp_msg_message.html +++ b/doc/openpgp_msg_message.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_msg_message - - + + - + @@ -41,13 +41,15 @@
-

<protected> new openpgp_msg_message

+

<protected> new openpgp_msg_message()

+ + @@ -57,34 +59,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12196
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -114,7 +124,7 @@
-

<inner> decrypt

+

<inner> decrypt(private_key, sessionkey) → {String}

@@ -126,6 +136,8 @@ MDC will be verified as well as message signatures + + @@ -160,9 +172,11 @@ MDC will be verified as well as message signatures - openpgp_msg_privatekey - - + +openpgp_msg_privatekey + + + @@ -181,9 +195,11 @@ MDC will be verified as well as message signatures - openpgp_packet_encryptedsessionkey - - + +openpgp_packet_encryptedsessionkey + + + @@ -202,34 +218,42 @@ MDC will be verified as well as message signatures
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12211
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -243,15 +267,15 @@ MDC will be verified as well as message signatures -
Type
- String - +String + +
@@ -263,7 +287,7 @@ MDC will be verified as well as message signatures
-

<inner> decryptAndVerifySignature

+

<inner> decryptAndVerifySignature(private_key, sessionkey, pubkey) → {String}

@@ -275,6 +299,8 @@ MDC will be verified as well as message signatures MDC will be verified as well as message signatures + + @@ -309,9 +335,11 @@ MDC will be verified as well as message signatures - openpgp_msg_privatekey - - + +openpgp_msg_privatekey + + + @@ -330,9 +358,11 @@ MDC will be verified as well as message signatures - openpgp_packet_encryptedsessionkey - - + +openpgp_packet_encryptedsessionkey + + + @@ -351,9 +381,11 @@ MDC will be verified as well as message signatures - openpgp_msg_publickey - - + +openpgp_msg_publickey + + + @@ -372,34 +404,42 @@ MDC will be verified as well as message signatures
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12223
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -413,15 +453,15 @@ MDC will be verified as well as message signatures -
Type
- String - +String + +
@@ -433,7 +473,7 @@ MDC will be verified as well as message signatures
-

<inner> verifySignature

+

<inner> verifySignature(pubkey) → {boolean}

@@ -444,6 +484,8 @@ MDC will be verified as well as message signatures Verifies a message signature. This function can be called after read_message if the message was signed only. + + @@ -478,9 +520,11 @@ MDC will be verified as well as message signatures - openpgp_msg_publickey - - + +openpgp_msg_publickey + + + @@ -499,34 +543,42 @@ MDC will be verified as well as message signatures
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12282
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -540,15 +592,15 @@ MDC will be verified as well as message signatures -
Type
- boolean - +boolean + +
@@ -573,15 +625,15 @@ MDC will be verified as well as message signatures
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_msg_privatekey.html b/doc/openpgp_msg_privatekey.html index e2e5441a..55edc36e 100644 --- a/doc/openpgp_msg_privatekey.html +++ b/doc/openpgp_msg_privatekey.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_msg_privatekey - - + + - + @@ -41,13 +41,15 @@
-

new openpgp_msg_privatekey

+

new openpgp_msg_privatekey()

+ + @@ -57,34 +59,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10324
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -114,7 +124,7 @@
-

<inner> extractPublicKey

+

<inner> extractPublicKey() → {String}

@@ -125,6 +135,8 @@ extracts the public key part + + @@ -134,34 +146,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10448
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -176,15 +196,15 @@ -
Type
- String - +String + +
@@ -196,13 +216,15 @@
-

<inner> read_nodes

+

<inner> read_nodes()

+ + @@ -212,34 +234,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10336
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -274,15 +304,15 @@
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_msg_publickey.html b/doc/openpgp_msg_publickey.html index 2c2f38dd..3c5fe904 100644 --- a/doc/openpgp_msg_publickey.html +++ b/doc/openpgp_msg_publickey.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_msg_publickey - - + + - + @@ -41,13 +41,15 @@
-

new openpgp_msg_publickey

+

new openpgp_msg_publickey()

+ + @@ -57,34 +59,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 9986
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -114,7 +124,7 @@
-

<inner> getEncryptionKey

+

<inner> getEncryptionKey()

@@ -125,6 +135,8 @@ finds an encryption key for this public key + + @@ -134,34 +146,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10183
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -183,13 +203,15 @@
-

<inner> read_nodes

+

<inner> read_nodes()

+ + @@ -199,34 +221,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10003
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -248,7 +278,7 @@
-

<inner> verifyBasicSignatures

+

<inner> verifyBasicSignatures() → {Boolean}

@@ -264,6 +294,8 @@ This is useful for validating the key + + @@ -273,34 +305,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10124
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -314,6 +354,18 @@ +
+
+ Type +
+
+ +Boolean + + +
+
+ @@ -322,7 +374,7 @@
-

<inner> verifyCertificationSignatures

+

<inner> verifyCertificationSignatures()

@@ -333,6 +385,8 @@ verifies all signatures + + @@ -342,34 +396,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 10106
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -404,15 +466,15 @@
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_compressed.html b/doc/openpgp_packet_compressed.html index 456ff6db..251d24b3 100644 --- a/doc/openpgp_packet_compressed.html +++ b/doc/openpgp_packet_compressed.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_compressed - - + + - + @@ -47,13 +47,15 @@ packet.
-

new openpgp_packet_compressed

+

new openpgp_packet_compressed()

+ + @@ -63,34 +65,42 @@ packet.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2519
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -120,7 +130,7 @@ packet.
-

<inner> compress

+

<inner> compress(type, data) → {String}

@@ -131,6 +141,8 @@ packet. Compress the packet data (member decompressedData) + + @@ -165,16 +177,18 @@ packet. - integer - - + +Integer + + + - algorithm to be used // See RFC 4880 9.3 + Algorithm to be used // See RFC 4880 9.3 @@ -186,16 +200,18 @@ packet. - String - - + +String + + + - data to be compressed + Data to be compressed @@ -207,34 +223,42 @@ packet.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2599
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -248,15 +272,15 @@ packet. -
Type
- String - +String + +
@@ -268,7 +292,7 @@ packet.
-

<inner> decompress

+

<inner> decompress() → {String}

@@ -276,10 +300,12 @@ packet.
- decompression method for decompressing the compressed data + Decompression method for decompressing the compressed data read by read_packet
+ + @@ -289,34 +315,42 @@ read by read_packet
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2543
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -325,20 +359,20 @@ read by read_packet
- the decompressed data + The decompressed data
-
Type
- String - +String + +
@@ -350,7 +384,7 @@ read by read_packet
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_compressed}

@@ -358,9 +392,11 @@ read by read_packet
- parsing function for the packet. + Parsing function for the packet.
+ + @@ -395,16 +431,18 @@ read by read_packet - string - - + +String + + + - payload of a tag 8 packet + Payload of a tag 8 packet @@ -416,16 +454,18 @@ read by read_packet - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input string @@ -437,16 +477,19 @@ read by read_packet - integer - - + +Integer + + + - length of the packet or the remaining length of input at position + Length of the packet or the remaining length of +input at position @@ -458,34 +501,42 @@ read by read_packet
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2529
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -494,20 +545,20 @@ read by read_packet
- object representation + Object representation
-
Type
- openpgp_packet_compressed - +openpgp_packet_compressed + +
@@ -519,7 +570,7 @@ read by read_packet
-

<inner> toString

+

<inner> toString() → {String}

@@ -527,9 +578,11 @@ read by read_packet
- pretty printing the packet (useful for debug purposes) + Pretty printing the packet (useful for debug purposes)
+ + @@ -539,34 +592,42 @@ read by read_packet
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2644
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -576,15 +637,15 @@ read by read_packet -
Type
- String - +String + +
@@ -596,7 +657,7 @@ read by read_packet
-

<inner> write_packet

+

<inner> write_packet(algorithm, data) → {String}

@@ -604,9 +665,11 @@ read by read_packet
- creates a string representation of the packet + Creates a string representation of the packet
+ + @@ -641,16 +704,18 @@ read by read_packet - integer - - + +Integer + + + - algorithm to be used // See RFC 4880 9.3 + Algorithm to be used // See RFC 4880 9.3 @@ -662,16 +727,18 @@ read by read_packet - String - - + +String + + + - data to be compressed + Data to be compressed @@ -683,34 +750,42 @@ read by read_packet
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2631
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -719,20 +794,20 @@ read by read_packet
- string-representation of the packet + String-representation of the packet
-
Type
- String - +String + +
@@ -757,15 +832,15 @@ read by read_packet
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_encrypteddata.html b/doc/openpgp_packet_encrypteddata.html index 93ba2c04..60049e41 100644 --- a/doc/openpgp_packet_encrypteddata.html +++ b/doc/openpgp_packet_encrypteddata.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_encrypteddata - - + + - + @@ -47,13 +47,15 @@ that form whole OpenPGP messages).
-

new openpgp_packet_encrypteddata

+

new openpgp_packet_encrypteddata()

+ + @@ -63,34 +65,42 @@ that form whole OpenPGP messages).
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1860
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -120,7 +130,7 @@ that form whole OpenPGP messages).
-

<inner> decrypt_sym

+

<inner> decrypt_sym(symmetric_algorithm_type, key)

@@ -128,9 +138,11 @@ that form whole OpenPGP messages).
- symmetrically decrypt the packet data + Symmetrically decrypt the packet data
+ + @@ -165,16 +177,18 @@ that form whole OpenPGP messages). - integer - - + +Integer + + + - symmetric key algorithm to use // See RFC4880 9.2 + Symmetric key algorithm to use // See RFC4880 9.2 @@ -186,16 +200,18 @@ that form whole OpenPGP messages). - String - - + +String + + + - key as string with the corresponding length to the + Key as string with the corresponding length to the algorithm @@ -208,34 +224,42 @@ that form whole OpenPGP messages).
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1894
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -244,7 +268,7 @@ that form whole OpenPGP messages).
- the decrypted data; + The decrypted data;
@@ -257,7 +281,7 @@ that form whole OpenPGP messages).
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -265,9 +289,11 @@ that form whole OpenPGP messages).
- parsing function for the packet. + Parsing function for the packet.
+ + @@ -302,16 +328,18 @@ that form whole OpenPGP messages). - string - - + +String + + + - payload of a tag 9 packet + Payload of a tag 9 packet @@ -323,16 +351,18 @@ that form whole OpenPGP messages). - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input string @@ -344,16 +374,18 @@ that form whole OpenPGP messages). - integer - - + +Integer + + + - length of the packet or the remaining length of + Length of the packet or the remaining length of input at position @@ -366,34 +398,42 @@ that form whole OpenPGP messages).
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1875
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -402,20 +442,20 @@ that form whole OpenPGP messages).
- object representation + Object representation
-
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -427,7 +467,7 @@ that form whole OpenPGP messages).
-

<inner> write_packet

+

<inner> write_packet(algo, key, data) → {String}

@@ -438,6 +478,8 @@ that form whole OpenPGP messages). Creates a string representation of the packet + + @@ -472,16 +514,18 @@ that form whole OpenPGP messages). - Integer - - + +Integer + + + - symmetric key algorithm to use // See RFC4880 9.2 + Symmetric key algorithm to use // See RFC4880 9.2 @@ -493,16 +537,18 @@ that form whole OpenPGP messages). - String - - + +String + + + - key as string with the corresponding length to the + Key as string with the corresponding length to the algorithm @@ -515,16 +561,18 @@ that form whole OpenPGP messages). - String - - + +String + + + - data to be + Data to be @@ -536,34 +584,42 @@ that form whole OpenPGP messages).
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1911
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -572,20 +628,20 @@ that form whole OpenPGP messages).
- string-representation of the packet + String-representation of the packet
-
Type
- String - +String + +
@@ -610,15 +666,15 @@ that form whole OpenPGP messages).
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_encryptedintegrityprotecteddata.html b/doc/openpgp_packet_encryptedintegrityprotecteddata.html index 7fc78d6e..6711c584 100644 --- a/doc/openpgp_packet_encryptedintegrityprotecteddata.html +++ b/doc/openpgp_packet_encryptedintegrityprotecteddata.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_encryptedintegrityprotecteddata - - + + - + @@ -30,7 +30,8 @@ openpgp_packet_encryptedintegrityprotecteddata -
Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18) +
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 @@ -47,13 +48,15 @@ packet.
-

new openpgp_packet_encryptedintegrityprotecteddata

+

new openpgp_packet_encryptedintegrityprotecteddata()

+ + @@ -63,34 +66,42 @@ packet.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 968
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -120,7 +131,7 @@ packet.
-

<inner> decrypt

+

<inner> decrypt(symmetric_algorithm_type, key) → {String}

@@ -132,6 +143,8 @@ packet. have been called before + + @@ -166,16 +179,18 @@ have been called before - integer - - + +Integer + + + - the selected symmetric encryption algorithm to be used + The selected symmetric encryption algorithm to be used @@ -187,16 +202,18 @@ have been called before - String - - + +String + + + - the key of cipher blocksize length to be used + The key of cipher blocksize length to be used @@ -208,34 +225,42 @@ have been called before
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1054
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -244,11 +269,23 @@ have been called before
- the decrypted data of this packet + The decrypted data of this packet
+
+
+ Type +
+
+ +String + + +
+
+ @@ -257,7 +294,7 @@ have been called before
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encryptedintegrityprotecteddata}

@@ -265,9 +302,11 @@ have been called before
- parsing function for the packet. + Parsing function for the packet.
+ + @@ -302,16 +341,18 @@ have been called before - string - - + +String + + + - payload of a tag 18 packet + Payload of a tag 18 packet @@ -323,9 +364,11 @@ have been called before - integer - - + +Integer + + + @@ -344,16 +387,18 @@ have been called before - integer - - + +Integer + + + - length of the packet or the remaining length of + Length of the packet or the remaining length of input at position @@ -366,34 +411,42 @@ have been called before
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 986
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -408,15 +461,15 @@ have been called before -
Type
- openpgp_packet_encryptedintegrityprotecteddata - +openpgp_packet_encryptedintegrityprotecteddata + +
@@ -428,7 +481,7 @@ have been called before
-

<inner> write_packet

+

<inner> write_packet(symmetric_algorithm, key, data) → {String}

@@ -440,6 +493,8 @@ have been called before Data Packet (tag 18) (see RFC4880 5.13) + + @@ -474,16 +529,18 @@ Data Packet (tag 18) (see RFC4880 5.13) - integer - - + +Integer + + + - the selected symmetric encryption algorithm to be used + The selected symmetric encryption algorithm to be used @@ -495,16 +552,18 @@ Data Packet (tag 18) (see RFC4880 5.13) - String - - + +String + + + - the key of cipher blocksize length to be used + The key of cipher blocksize length to be used @@ -516,13 +575,18 @@ Data Packet (tag 18) (see RFC4880 5.13) + +String + + + - plaintext data to be encrypted within the packet + Plaintext data to be encrypted within the packet @@ -534,34 +598,42 @@ Data Packet (tag 18) (see RFC4880 5.13)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1021
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -570,11 +642,23 @@ Data Packet (tag 18) (see RFC4880 5.13)
- a string representation of the packet + A string representation of the packet
+
+
+ Type +
+
+ +String + + +
+
+ @@ -596,15 +680,15 @@ Data Packet (tag 18) (see RFC4880 5.13)
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_encryptedsessionkey.html b/doc/openpgp_packet_encryptedsessionkey.html index 37923a22..1f3076ae 100644 --- a/doc/openpgp_packet_encryptedsessionkey.html +++ b/doc/openpgp_packet_encryptedsessionkey.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_encryptedsessionkey - - + + - + @@ -53,13 +53,15 @@ decrypt the message.
-

new openpgp_packet_encryptedsessionkey

+

new openpgp_packet_encryptedsessionkey()

+ + @@ -69,34 +71,42 @@ decrypt the message.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1542
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -126,7 +136,7 @@ decrypt the message.
-

<inner> decrypt

+

<inner> decrypt(msg, key) → {String}

@@ -138,6 +148,8 @@ decrypt the message. packets (tag 1) + + @@ -172,16 +184,18 @@ packets (tag 1) - openpgp_msg_message - - + +openpgp_msg_message + + + - the message object (with member encryptedData + The message object (with member encryptedData @@ -193,16 +207,18 @@ packets (tag 1) - openpgp_msg_privatekey - - + +openpgp_msg_privatekey + + + - private key with secMPIs unlocked + Private key with secMPIs unlocked @@ -214,34 +230,42 @@ packets (tag 1)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1673
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -250,20 +274,20 @@ packets (tag 1)
- the unencrypted session key + The unencrypted session key
-
Type
- String - +String + +
@@ -275,7 +299,7 @@ packets (tag 1)
-

<inner> read_pub_key_packet

+

<inner> read_pub_key_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -283,9 +307,11 @@ packets (tag 1)
- parsing function for a publickey encrypted session key packet (tag 1). + Parsing function for a publickey encrypted session key packet (tag 1).
+ + @@ -320,16 +346,18 @@ packets (tag 1) - string - - + +String + + + - payload of a tag 1 packet + Payload of a tag 1 packet @@ -341,16 +369,18 @@ packets (tag 1) - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input string @@ -362,16 +392,18 @@ packets (tag 1) - integer - - + +Integer + + + - length of the packet or the remaining length of + Length of the packet or the remaining length of input at position @@ -384,34 +416,42 @@ packets (tag 1)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1553
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -420,20 +460,20 @@ packets (tag 1)
- object representation + Object representation
-
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -445,7 +485,7 @@ packets (tag 1)
-

<inner> read_symmetric_key_packet

+

<inner> read_symmetric_key_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -453,9 +493,11 @@ packets (tag 1)
- parsing function for a symmetric encrypted session key packet (tag 3). + Parsing function for a symmetric encrypted session key packet (tag 3).
+ + @@ -490,16 +532,18 @@ packets (tag 1) - string - - + +String + + + - payload of a tag 1 packet + Payload of a tag 1 packet @@ -511,16 +555,18 @@ packets (tag 1) - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input string @@ -532,16 +578,18 @@ packets (tag 1) - integer - - + +Integer + + + - length of the packet or the remaining length of + Length of the packet or the remaining length of input at position @@ -554,34 +602,42 @@ packets (tag 1)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1641
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -590,20 +646,20 @@ packets (tag 1)
- object representation + Object representation
-
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -615,7 +671,7 @@ packets (tag 1)
-

<inner> toString

+

<inner> toString() → {String}

@@ -627,6 +683,8 @@ packets (tag 1) purposes) + + @@ -636,34 +694,42 @@ purposes)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1700
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -672,11 +738,23 @@ purposes)
- the string containing a openpgp description + The string containing a openpgp description
+
+
+ Type +
+
+ +String + + +
+
+ @@ -685,7 +763,7 @@ purposes)
-

<inner> write_pub_key_packet

+

<inner> write_pub_key_packet(publicKeyId, publicMPIs, pubalgo, symmalgo, sessionkey) → {String}

@@ -693,9 +771,11 @@ purposes)
- create a string representation of a tag 1 packet + Create a string representation of a tag 1 packet
+ + @@ -730,16 +810,18 @@ purposes) - String - - + +String + + + - the public key id corresponding to publicMPIs key as string + The public key id corresponding to publicMPIs key as string @@ -751,16 +833,18 @@ purposes) - Array[openpgp_type_mpi] - - + +openpgp_type_mpi[] + + + - multiprecision integer objects describing the public key + Multiprecision integer objects describing the public key @@ -772,16 +856,18 @@ purposes) - integer - - + +Integer + + + - the corresponding public key algorithm // See RFC4880 9.1 + The corresponding public key algorithm // See RFC4880 9.1 @@ -793,17 +879,20 @@ purposes) - integer - - + +Integer + + + - the symmetric cipher algorithm used to encrypt the data within - an encrypteddatapacket or encryptedintegrityprotecteddatapacket + The symmetric cipher algorithm used to encrypt the data + within an encrypteddatapacket or encryptedintegrity- + protecteddatapacket following this packet //See RFC4880 9.2 @@ -816,16 +905,18 @@ purposes) - String - - + +String + + + - a string of randombytes representing the session key + A string of randombytes representing the session key @@ -837,34 +928,42 @@ purposes)
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1610
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -873,20 +972,20 @@ purposes)
- the string representation + The string representation
-
Type
- String - +String + +
@@ -911,15 +1010,15 @@ purposes)
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_keymaterial.html b/doc/openpgp_packet_keymaterial.html index c64e2485..c9f16cf7 100644 --- a/doc/openpgp_packet_keymaterial.html +++ b/doc/openpgp_packet_keymaterial.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_keymaterial - - + + - + @@ -46,13 +46,15 @@ major versions. Consequently, this section is complex.
-

new openpgp_packet_keymaterial

+

new openpgp_packet_keymaterial()

+ + @@ -62,34 +64,42 @@ major versions. Consequently, this section is complex.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2683
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -119,7 +129,7 @@ major versions. Consequently, this section is complex.
-

<inner> decryptSecretMPIs

+

<inner> decryptSecretMPIs(str_passphrase) → {Boolean}

@@ -128,10 +138,13 @@ major versions. Consequently, this section is complex.
Decrypts the private key MPIs which are needed to use the key. -openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be false otherwise +openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be +false otherwise a call to this function is not needed
+ + @@ -166,13 +179,19 @@ a call to this function is not needed + +String + + + - the passphrase for this private key as string + The passphrase for this private key +as string @@ -184,34 +203,42 @@ a call to this function is not needed
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 3024
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -220,89 +247,20 @@ a call to this function is not needed
- true if the passphrase was correct; false if not + True if the passphrase was correct; false if not
- - - -
- - - -
-

<inner> getFingerprint

- - -
-
- - -
- calculates the fingerprint of the key -
- - - - - - - -
- - - - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 3334
- - - - - - - -
- - - - - - - -
Returns:
- - -
- a string containing the fingerprint -
- - - -
Type
- String - +Boolean + +
@@ -314,7 +272,7 @@ a call to this function is not needed
-

<inner> getKeyId

+

<inner> getFingerprint() → {String}

@@ -322,9 +280,11 @@ a call to this function is not needed
- calculates the key id of they key + Calculates the fingerprint of the key
+ + @@ -334,34 +294,42 @@ a call to this function is not needed
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 3319
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -370,20 +338,20 @@ a call to this function is not needed
- a 8 byte key id + A string containing the fingerprint
-
Type
- String - +String + +
@@ -395,7 +363,98 @@ a call to this function is not needed
-

<inner> read_nodes

+

<inner> getKeyId() → {String}

+ + +
+
+ + +
+ Calculates the key id of they key +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + +
+ A 8 byte key id +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + +
+ + + +
+

<inner> read_nodes(parent_node, input, position, len) → {Integer}

@@ -406,6 +465,8 @@ a call to this function is not needed Continue parsing packets belonging to the key material such as signatures + + @@ -440,16 +501,18 @@ a call to this function is not needed - openpgp_* - - + +Object + + + - the parent object + The parent object @@ -461,16 +524,18 @@ a call to this function is not needed - String - - + +String + + + - input string to read the packet(s) from + Input string to read the packet(s) from @@ -482,16 +547,18 @@ a call to this function is not needed - integer - - + +Integer + + + - start position for the parser + Start position for the parser @@ -503,16 +570,18 @@ a call to this function is not needed - integer - - + +Integer + + + - length of the packet(s) or remaining length of input + Length of the packet(s) or remaining length of input @@ -524,34 +593,42 @@ a call to this function is not needed
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 3211
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -560,20 +637,20 @@ a call to this function is not needed
- length of nodes read + Length of nodes read
-
Type
- integer - +Integer + +
@@ -585,7 +662,7 @@ a call to this function is not needed
-

<inner> read_priv_key

+

<inner> read_priv_key(input, position, len) → {Object}

@@ -596,6 +673,8 @@ a call to this function is not needed Internal parser for private keys as specified in RFC 4880 section 5.5.3 + + @@ -630,13 +709,18 @@ a call to this function is not needed + +String + + + - input string to read the packet from + Input string to read the packet from @@ -648,13 +732,18 @@ a call to this function is not needed + +Integer + + + - start position for the parser + Start position for the parser @@ -666,13 +755,18 @@ a call to this function is not needed + +Integer + + + - length of the packet or remaining length of input + Length of the packet or remaining length of input @@ -684,34 +778,42 @@ a call to this function is not needed
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2890
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -720,11 +822,23 @@ a call to this function is not needed
- this object with attributes set by the parser + This object with attributes set by the parser
+
+
+ Type +
+
+ +Object + + +
+
+ @@ -733,7 +847,7 @@ a call to this function is not needed
-

<inner> read_pub_key

+

<inner> read_pub_key(input, position, len) → {Object}

@@ -741,158 +855,12 @@ a call to this function is not needed
- Internal Parser for public keys as specified in RFC 4880 section 5.5.2 Public-Key Packet Formats + Internal Parser for public keys as specified in RFC 4880 section +5.5.2 Public-Key Packet Formats called by read_tag<num>
- - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
input - - input string to read the packet from
position - - start position for the parser
len - - length of the packet or remaining length of input
- - - -
- - - - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2780
- - - - - - - -
- - - - - - - -
Returns:
- - -
- this object with attributes set by the parser -
- - - - - - -
- - - -
-

<inner> read_tag14

- - -
-
- - -
- This function reads the payload of a public key sub packet (Tag 14) -and initializes the openpgp_packet_keymaterial -
@@ -928,13 +896,18 @@ and initializes the openpgp_packet_keymaterial + +String + + + - input string to read the packet from + Input string to read the packet from @@ -946,13 +919,18 @@ and initializes the openpgp_packet_keymaterial + +Integer + + + - start position for the parser + Start position for the parser @@ -964,13 +942,18 @@ and initializes the openpgp_packet_keymaterial + +Integer + + + - length of the packet or remaining length of input + Length of the packet or remaining length of input @@ -982,34 +965,42 @@ and initializes the openpgp_packet_keymaterial
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2763
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1018,11 +1009,23 @@ and initializes the openpgp_packet_keymaterial
- openpgp_packet_keymaterial object + This object with attributes set by the parser
+
+
+ Type +
+
+ +Object + + +
+
+ @@ -1031,7 +1034,7 @@ and initializes the openpgp_packet_keymaterial
-

<inner> read_tag5

+

<inner> read_tag5(input, position, len) → {openpgp_packet_keymaterial}

@@ -1043,6 +1046,8 @@ and initializes the openpgp_packet_keymaterial and initializes the openpgp_packet_keymaterial + + @@ -1077,13 +1082,18 @@ and initializes the openpgp_packet_keymaterial + +String + + + - input string to read the packet from + Input string to read the packet from @@ -1095,13 +1105,18 @@ and initializes the openpgp_packet_keymaterial + +Integer + + + - start position for the parser + Start position for the parser @@ -1113,13 +1128,18 @@ and initializes the openpgp_packet_keymaterial + +Intefer + + + - length of the packet or remaining length of input + Length of the packet or remaining length of input @@ -1131,34 +1151,42 @@ and initializes the openpgp_packet_keymaterial
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2714
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1166,11 +1194,19 @@ and initializes the openpgp_packet_keymaterial
Returns:
-
- openpgp_packet_keymaterial object -
+
+
+ Type +
+
+ +openpgp_packet_keymaterial + + +
+
@@ -1180,7 +1216,7 @@ and initializes the openpgp_packet_keymaterial
-

<inner> read_tag6

+

<inner> read_tag6(input, position, len) → {openpgp_packet_keymaterial}

@@ -1192,6 +1228,8 @@ and initializes the openpgp_packet_keymaterial and initializes the openpgp_packet_keymaterial + + @@ -1226,13 +1264,18 @@ and initializes the openpgp_packet_keymaterial + +String + + + - input string to read the packet from + Input string to read the packet from @@ -1244,13 +1287,18 @@ and initializes the openpgp_packet_keymaterial + +Integer + + + - start position for the parser + Start position for the parser @@ -1262,13 +1310,18 @@ and initializes the openpgp_packet_keymaterial + +Integer + + + - length of the packet or remaining length of input + Length of the packet or remaining length of input @@ -1280,34 +1333,42 @@ and initializes the openpgp_packet_keymaterial
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2729
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1315,11 +1376,19 @@ and initializes the openpgp_packet_keymaterial
Returns:
-
- openpgp_packet_keymaterial object -
+
+
+ Type +
+
+ +openpgp_packet_keymaterial + + +
+
@@ -1329,7 +1398,7 @@ and initializes the openpgp_packet_keymaterial
-

<inner> read_tag7

+

<inner> read_tag7(input, position, len) → {openpgp_packet_keymaterial}

@@ -1341,6 +1410,8 @@ and initializes the openpgp_packet_keymaterial and initializes the openpgp_packet_keymaterial + + @@ -1375,13 +1446,18 @@ and initializes the openpgp_packet_keymaterial + +String + + + - input string to read the packet from + Input string to read the packet from @@ -1393,13 +1469,18 @@ and initializes the openpgp_packet_keymaterial + +Integer + + + - start position for the parser + Start position for the parser @@ -1411,13 +1492,18 @@ and initializes the openpgp_packet_keymaterial + +Integer + + + - length of the packet or remaining length of input + Length of the packet or remaining length of input @@ -1429,34 +1515,42 @@ and initializes the openpgp_packet_keymaterial
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2748
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1464,11 +1558,19 @@ and initializes the openpgp_packet_keymaterial
Returns:
-
- openpgp_packet_keymaterial object -
+
+
+ Type +
+
+ +openpgp_packet_keymaterial + + +
+
@@ -1478,7 +1580,189 @@ and initializes the openpgp_packet_keymaterial
-

<inner> toString

+

<inner> read_tag14(input, position, len) → {openpgp_packet_keymaterial}

+ + +
+
+ + +
+ This function reads the payload of a public key sub packet (Tag 14) +and initializes the openpgp_packet_keymaterial +
+ + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
input + + +String + + + + Input string to read the packet from
position + + +Integer + + + + Start position for the parser
len + + +Integer + + + + Length of the packet or remaining length of input
+ + + +
+ + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +openpgp_packet_keymaterial + + +
+
+ + + + +
+ + + +
+

<inner> toString()

@@ -1489,6 +1773,8 @@ and initializes the openpgp_packet_keymaterial Generates Debug output + + @@ -1498,34 +1784,42 @@ and initializes the openpgp_packet_keymaterial
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 3138
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1547,7 +1841,7 @@ and initializes the openpgp_packet_keymaterial
-

<inner> verifyKey

+

<inner> verifyKey() → {Integer}

@@ -1558,6 +1852,8 @@ and initializes the openpgp_packet_keymaterial Checks the validity for usage of this (sub)key + + @@ -1567,34 +1863,42 @@ and initializes the openpgp_packet_keymaterial
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 3288
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -1608,6 +1912,18 @@ and initializes the openpgp_packet_keymaterial +
+
+ Type +
+
+ +Integer + + +
+
+ @@ -1629,15 +1945,15 @@ and initializes the openpgp_packet_keymaterial
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_literaldata.html b/doc/openpgp_packet_literaldata.html index 2ad78e2f..5478d758 100644 --- a/doc/openpgp_packet_literaldata.html +++ b/doc/openpgp_packet_literaldata.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_literaldata - - + + - + @@ -44,13 +44,15 @@ is not to be further interpreted.
-

new openpgp_packet_literaldata

+

new openpgp_packet_literaldata()

+ + @@ -60,34 +62,42 @@ is not to be further interpreted.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1758
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -117,7 +127,7 @@ is not to be further interpreted.
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -125,9 +135,11 @@ is not to be further interpreted.
- parsing function for a literal data packet (tag 11). + Parsing function for a literal data packet (tag 11).
+ + @@ -162,16 +174,18 @@ is not to be further interpreted. - string - - + +String + + + - payload of a tag 11 packet + Payload of a tag 11 packet @@ -183,16 +197,18 @@ is not to be further interpreted. - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input string @@ -204,16 +220,18 @@ is not to be further interpreted. - integer - - + +Integer + + + - length of the packet or the remaining length of + Length of the packet or the remaining length of input at position @@ -226,34 +244,42 @@ is not to be further interpreted.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1772
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -267,15 +293,15 @@ is not to be further interpreted. -
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -287,7 +313,7 @@ is not to be further interpreted.
-

<inner> toString

+

<inner> toString() → {String}

@@ -295,9 +321,11 @@ is not to be further interpreted.
- generates debug output (pretty print) + Generates debug output (pretty print)
+ + @@ -307,34 +335,42 @@ is not to be further interpreted.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1820
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -348,15 +384,15 @@ is not to be further interpreted. -
Type
- string - +String + +
@@ -368,7 +404,7 @@ is not to be further interpreted.
-

<inner> write_packet

+

<inner> write_packet(data) → {String}

@@ -379,6 +415,8 @@ is not to be further interpreted. Creates a string representation of the packet + + @@ -413,16 +451,18 @@ is not to be further interpreted. - String - - + +String + + + - the data to be inserted as body + The data to be inserted as body @@ -434,34 +474,42 @@ is not to be further interpreted.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1792
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -475,15 +523,15 @@ is not to be further interpreted. -
Type
- String - +String + +
@@ -508,15 +556,15 @@ is not to be further interpreted.
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_marker.html b/doc/openpgp_packet_marker.html index 5e615422..4bd2a4e2 100644 --- a/doc/openpgp_packet_marker.html +++ b/doc/openpgp_packet_marker.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_marker - - + + - + @@ -48,13 +48,15 @@ Such a packet MUST be ignored when received.
-

new openpgp_packet_marker

+

new openpgp_packet_marker()

+ + @@ -64,34 +66,42 @@ Such a packet MUST be ignored when received.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 148
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -121,7 +131,7 @@ Such a packet MUST be ignored when received.
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -129,9 +139,11 @@ Such a packet MUST be ignored when received.
- parsing function for a literal data packet (tag 10). + Parsing function for a literal data packet (tag 10).
+ + @@ -166,16 +178,18 @@ Such a packet MUST be ignored when received. - string - - + +String + + + - payload of a tag 10 packet + Payload of a tag 10 packet @@ -187,16 +201,18 @@ Such a packet MUST be ignored when received. - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input string @@ -208,16 +224,18 @@ Such a packet MUST be ignored when received. - integer - - + +Integer + + + - length of the packet or the remaining length of + Length of the packet or the remaining length of input at position @@ -230,34 +248,42 @@ Such a packet MUST be ignored when received.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 161
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -266,20 +292,20 @@ Such a packet MUST be ignored when received.
- object representation + Object representation
-
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -291,7 +317,7 @@ Such a packet MUST be ignored when received.
-

<inner> toString

+

<inner> toString() → {String}

@@ -302,6 +328,8 @@ Such a packet MUST be ignored when received. Generates Debug output + + @@ -311,34 +339,42 @@ Such a packet MUST be ignored when received.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 176
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -347,20 +383,21 @@ Such a packet MUST be ignored when received.
- String which gives some information about the keymaterial + String which gives some information about the +keymaterial
-
Type
- string - +String + +
@@ -385,15 +422,15 @@ Such a packet MUST be ignored when received.
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_modificationdetectioncode.html b/doc/openpgp_packet_modificationdetectioncode.html index 2f23b379..3eaddaea 100644 --- a/doc/openpgp_packet_modificationdetectioncode.html +++ b/doc/openpgp_packet_modificationdetectioncode.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_modificationdetectioncode - - + + - + @@ -48,13 +48,15 @@ Data packet, and MUST appear in no other place.
-

new openpgp_packet_modificationdetectioncode

+

new openpgp_packet_modificationdetectioncode()

+ + @@ -64,34 +66,42 @@ Data packet, and MUST appear in no other place.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1123
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -121,7 +131,7 @@ Data packet, and MUST appear in no other place.
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -132,6 +142,8 @@ Data packet, and MUST appear in no other place. parsing function for a modification detection code packet (tag 19). + + @@ -166,9 +178,11 @@ Data packet, and MUST appear in no other place. - String - - + +String + + + @@ -187,9 +201,11 @@ Data packet, and MUST appear in no other place. - Integer - - + +Integer + + + @@ -208,9 +224,11 @@ Data packet, and MUST appear in no other place. - Integer - - + +Integer + + + @@ -230,34 +248,42 @@ Data packet, and MUST appear in no other place.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1137
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -271,15 +297,15 @@ Data packet, and MUST appear in no other place. -
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -291,7 +317,7 @@ Data packet, and MUST appear in no other place.
-

<inner> toString

+

<inner> toString() → {String}

@@ -302,6 +328,8 @@ Data packet, and MUST appear in no other place. generates debug output (pretty print) + + @@ -311,34 +339,42 @@ Data packet, and MUST appear in no other place.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1166
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -347,21 +383,21 @@ Data packet, and MUST appear in no other place.
- String which gives some information about the modification - detection code + String which gives some information about the +modification detection code
-
Type
- string - +String + +
@@ -386,15 +422,15 @@ Data packet, and MUST appear in no other place.
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_onepasssignature.html b/doc/openpgp_packet_onepasssignature.html index e962a9c3..e5be7319 100644 --- a/doc/openpgp_packet_onepasssignature.html +++ b/doc/openpgp_packet_onepasssignature.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_onepasssignature - - + + - + @@ -48,13 +48,15 @@ can compute the entire signed message in one pass.
-

new openpgp_packet_onepasssignature

+

new openpgp_packet_onepasssignature()

+ + @@ -64,34 +66,42 @@ can compute the entire signed message in one pass.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 29
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -121,7 +131,7 @@ can compute the entire signed message in one pass.
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -132,6 +142,8 @@ can compute the entire signed message in one pass. parsing function for a one-pass signature packet (tag 4). + + @@ -166,9 +178,11 @@ can compute the entire signed message in one pass. - string - - + +String + + + @@ -187,9 +201,11 @@ can compute the entire signed message in one pass. - integer - - + +Integer + + + @@ -208,9 +224,11 @@ can compute the entire signed message in one pass. - integer - - + +Integer + + + @@ -229,34 +247,42 @@ can compute the entire signed message in one pass.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 45
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -270,15 +296,15 @@ can compute the entire signed message in one pass. -
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -290,7 +316,7 @@ can compute the entire signed message in one pass.
-

<inner> toString

+

<inner> toString() → {String}

@@ -301,6 +327,8 @@ can compute the entire signed message in one pass. generates debug output (pretty print) + + @@ -310,34 +338,42 @@ can compute the entire signed message in one pass.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 105
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -351,15 +387,15 @@ can compute the entire signed message in one pass. -
Type
- string - +String + +
@@ -371,7 +407,7 @@ can compute the entire signed message in one pass.
-

<inner> write_packet

+

<inner> write_packet(type, hashalgorithm, privatekey, length, nested) → {String}

@@ -382,6 +418,8 @@ can compute the entire signed message in one pass. creates a string representation of a one-pass signature packet + + @@ -416,9 +454,11 @@ can compute the entire signed message in one pass. - integer - - + +Integer + + + @@ -437,9 +477,11 @@ can compute the entire signed message in one pass. - integer - - + +Integer + + + @@ -458,9 +500,11 @@ can compute the entire signed message in one pass. - openpgp_msg_privatekey - - + +openpgp_msg_privatekey + + + @@ -479,9 +523,11 @@ can compute the entire signed message in one pass. - integer - - + +Integer + + + @@ -500,9 +546,11 @@ can compute the entire signed message in one pass. - boolean - - + +boolean + + + @@ -523,34 +571,42 @@ can compute the entire signed message in one pass.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 84
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -564,15 +620,15 @@ can compute the entire signed message in one pass. -
Type
- String - +String + +
@@ -597,15 +653,15 @@ can compute the entire signed message in one pass.
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:35 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_signature.html b/doc/openpgp_packet_signature.html index ead5abf2..61d62fb2 100644 --- a/doc/openpgp_packet_signature.html +++ b/doc/openpgp_packet_signature.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_signature - - + + - + @@ -46,13 +46,15 @@ block of text, and a signature that is a certification of a User ID.
-

new openpgp_packet_signature

+

new openpgp_packet_signature()

+ + @@ -62,34 +64,42 @@ block of text, and a signature that is a certification of a User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 210
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -119,7 +129,7 @@ block of text, and a signature that is a certification of a User ID.
-

<inner> getIssuer

+

<inner> getIssuer() → {String}

@@ -130,6 +140,8 @@ block of text, and a signature that is a certification of a User ID. gets the issuer key id of this signature + + @@ -139,34 +151,42 @@ block of text, and a signature that is a certification of a User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 910
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -180,15 +200,15 @@ block of text, and a signature that is a certification of a User ID. -
Type
- String - +String + +
@@ -200,7 +220,7 @@ block of text, and a signature that is a certification of a User ID.
-

<inner> getIssuerKey

+

<inner> getIssuerKey() → {Object}

@@ -211,6 +231,8 @@ block of text, and a signature that is a certification of a User ID. Tries to get the corresponding public key out of the public keyring for the issuer created this signature + + @@ -220,34 +242,42 @@ block of text, and a signature that is a certification of a User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 922
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -256,20 +286,20 @@ block of text, and a signature that is a certification of a User ID.
- if found the public key will be returned. null otherwise + {obj: [openpgp_msg_publickey], text: [String]} if found the public key will be returned. null otherwise
-
Type
- obj: [openpgp_msg_publickey], text: [String] - +Object + +
@@ -281,7 +311,7 @@ block of text, and a signature that is a certification of a User ID.
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -292,6 +322,8 @@ block of text, and a signature that is a certification of a User ID. parsing function for a signature packet (tag 2). + + @@ -326,9 +358,11 @@ block of text, and a signature that is a certification of a User ID. - string - - + +String + + + @@ -347,9 +381,11 @@ block of text, and a signature that is a certification of a User ID. - integer - - + +Integer + + + @@ -368,9 +404,11 @@ block of text, and a signature that is a certification of a User ID. - integer - - + +Integer + + + @@ -389,34 +427,42 @@ block of text, and a signature that is a certification of a User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 260
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -430,15 +476,15 @@ block of text, and a signature that is a certification of a User ID. -
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -450,7 +496,7 @@ block of text, and a signature that is a certification of a User ID.
-

<inner> toString

+

<inner> toString() → {String}

@@ -461,6 +507,8 @@ block of text, and a signature that is a certification of a User ID. generates debug output (pretty print) + + @@ -470,34 +518,42 @@ block of text, and a signature that is a certification of a User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 852
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -511,15 +567,15 @@ block of text, and a signature that is a certification of a User ID. -
Type
- string - +String + +
@@ -531,7 +587,7 @@ block of text, and a signature that is a certification of a User ID.
-

<inner> verify

+

<inner> verify(data, key) → {boolean}

@@ -542,6 +598,8 @@ block of text, and a signature that is a certification of a User ID. verifys the signature packet. Note: not signature types are implemented + + @@ -576,9 +634,11 @@ block of text, and a signature that is a certification of a User ID. - String - - + +String + + + @@ -597,9 +657,11 @@ block of text, and a signature that is a certification of a User ID. - openpgp_msg_privatekey - - + +openpgp_msg_privatekey + + + @@ -618,34 +680,42 @@ block of text, and a signature that is a certification of a User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 668
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -659,15 +729,15 @@ block of text, and a signature that is a certification of a User ID. -
Type
- boolean - +boolean + +
@@ -679,7 +749,7 @@ block of text, and a signature that is a certification of a User ID.
-

<inner> write_message_signature

+

<inner> write_message_signature(signature_type, data, privatekey) → {String}

@@ -691,6 +761,8 @@ block of text, and a signature that is a certification of a User ID. This can be only used on text data + + @@ -725,9 +797,11 @@ This can be only used on text data - integer - - + +Integer + + + @@ -746,9 +820,11 @@ This can be only used on text data - String - - + +String + + + @@ -767,9 +843,11 @@ This can be only used on text data - openpgp_msg_privatekey - - + +openpgp_msg_privatekey + + + @@ -788,34 +866,42 @@ This can be only used on text data
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 400
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -829,15 +915,15 @@ This can be only used on text data -
Type
- string - +String + +
@@ -849,7 +935,7 @@ This can be only used on text data
-

<inner> write_sub_signature_packet

+

<inner> write_sub_signature_packet(type, data) → {String}

@@ -860,6 +946,8 @@ This can be only used on text data creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) + + @@ -894,9 +982,11 @@ This can be only used on text data - integer - - + +Integer + + + @@ -915,9 +1005,11 @@ This can be only used on text data - String - - + +String + + + @@ -936,34 +1028,42 @@ This can be only used on text data
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 445
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -977,15 +1077,15 @@ This can be only used on text data -
Type
- String - +String + +
@@ -1010,15 +1110,15 @@ This can be only used on text data
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:36 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_userattribute.html b/doc/openpgp_packet_userattribute.html index 49e583de..50b06340 100644 --- a/doc/openpgp_packet_userattribute.html +++ b/doc/openpgp_packet_userattribute.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_userattribute - - + + - + @@ -54,13 +54,15 @@
-

new openpgp_packet_userattribute

+

new openpgp_packet_userattribute()

+ + @@ -70,34 +72,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1965
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -127,7 +137,7 @@
-

<inner> read_nodes

+

<inner> read_nodes(parent_node, input, position, len) → {Integer}

@@ -138,6 +148,8 @@ Continue parsing packets belonging to the user attribute packet such as signatures + + @@ -172,9 +184,11 @@ - openpgp_* - - + +Object + + + @@ -193,9 +207,11 @@ - String - - + +String + + + @@ -214,9 +230,11 @@ - integer - - + +Integer + + + @@ -235,9 +253,11 @@ - integer - - + +Integer + + + @@ -256,34 +276,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2041
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -297,15 +325,15 @@ -
Type
- integer - +Integer + +
@@ -317,7 +345,7 @@
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -328,6 +356,8 @@ parsing function for a user attribute packet (tag 17). + + @@ -362,9 +392,11 @@ - string - - + +String + + + @@ -383,9 +415,11 @@ - integer - - + +Integer + + + @@ -404,9 +438,11 @@ - integer - - + +Integer + + + @@ -425,34 +461,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1979
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -466,15 +510,15 @@ -
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -486,7 +530,7 @@
-

<inner> toString

+

<inner> toString() → {String}

@@ -497,6 +541,8 @@ generates debug output (pretty print) + + @@ -506,34 +552,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 2024
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -547,15 +601,15 @@ -
Type
- string - +String + +
@@ -580,15 +634,15 @@
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:36 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_packet_userid.html b/doc/openpgp_packet_userid.html index 74057b4b..cfdc374d 100644 --- a/doc/openpgp_packet_userid.html +++ b/doc/openpgp_packet_userid.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_packet_userid - - + + - + @@ -46,13 +46,15 @@ specifies the length of the User ID.
-

new openpgp_packet_userid

+

new openpgp_packet_userid()

+ + @@ -62,34 +64,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1200
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -119,7 +129,7 @@ specifies the length of the User ID.
-

<inner> hasCertificationRevocationSignature

+

<inner> hasCertificationRevocationSignature(keyId)

@@ -130,6 +140,8 @@ specifies the length of the User ID. lookup function to find certification revocation signatures + + @@ -164,9 +176,11 @@ specifies the length of the User ID. - string - - + +String + + + @@ -185,34 +199,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1344
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -234,7 +256,7 @@ specifies the length of the User ID.
-

<inner> read_nodes

+

<inner> read_nodes(parent_node, input, position, len) → {Integer}

@@ -245,6 +267,8 @@ specifies the length of the User ID. Continue parsing packets belonging to the userid packet such as signatures + + @@ -279,9 +303,11 @@ specifies the length of the User ID. - openpgp_* - - + +Object + + + @@ -300,9 +326,11 @@ specifies the length of the User ID. - String - - + +String + + + @@ -321,9 +349,11 @@ specifies the length of the User ID. - integer - - + +Integer + + + @@ -342,9 +372,11 @@ specifies the length of the User ID. - integer - - + +Integer + + + @@ -363,34 +395,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1244
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -404,15 +444,15 @@ specifies the length of the User ID. -
Type
- integer - +Integer + +
@@ -424,7 +464,7 @@ specifies the length of the User ID.
-

<inner> read_packet

+

<inner> read_packet(input, position, len) → {openpgp_packet_encrypteddata}

@@ -435,6 +475,8 @@ specifies the length of the User ID. parsing function for a user id packet (tag 13). + + @@ -469,9 +511,11 @@ specifies the length of the User ID. - string - - + +String + + + @@ -490,9 +534,11 @@ specifies the length of the User ID. - integer - - + +Integer + + + @@ -511,9 +557,11 @@ specifies the length of the User ID. - integer - - + +Integer + + + @@ -532,34 +580,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1214
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -573,15 +629,15 @@ specifies the length of the User ID. -
Type
- openpgp_packet_encrypteddata - +openpgp_packet_encrypteddata + +
@@ -593,7 +649,7 @@ specifies the length of the User ID.
-

<inner> toString

+

<inner> toString() → {String}

@@ -604,6 +660,8 @@ specifies the length of the User ID. generates debug output (pretty print) + + @@ -613,34 +671,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1324
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -654,15 +720,15 @@ specifies the length of the User ID. -
Type
- string - +String + +
@@ -674,7 +740,7 @@ specifies the length of the User ID.
-

<inner> verify

+

<inner> verify()

@@ -685,6 +751,8 @@ specifies the length of the User ID. verifies the signatures of the user id + + @@ -694,34 +762,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1482
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -743,7 +819,7 @@ specifies the length of the User ID.
-

<inner> verifyCertificationSignatures

+

<inner> verifyCertificationSignatures(publicKeyPacket) → {Integer[]}

@@ -754,6 +830,8 @@ specifies the length of the User ID. Verifies all certification signatures. This method does not consider possible revocation signatures. + + @@ -788,6 +866,11 @@ specifies the length of the User ID. + +Object + + + @@ -806,34 +889,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1367
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -842,7 +933,7 @@ specifies the length of the User ID.
- an array of integers corresponding to the array of certification signatures. The meaning of each integer is the following: + An array of integers corresponding to the array of certification signatures. The meaning of each integer is the following: 0 = bad signature 1 = signature expired 2 = issuer key not available @@ -854,6 +945,18 @@ specifies the length of the User ID.
+
+
+ Type +
+
+ +Integer[] + + +
+
+ @@ -862,7 +965,7 @@ specifies the length of the User ID.
-

<inner> write_packet

+

<inner> write_packet(user_id) → {String}

@@ -873,6 +976,8 @@ specifies the length of the User ID. creates a string representation of the user id packet + + @@ -907,9 +1012,11 @@ specifies the length of the User ID. - String - - + +String + + + @@ -928,34 +1035,42 @@ specifies the length of the User ID.
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 1229
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -969,15 +1084,15 @@ specifies the length of the User ID. -
Type
- String - +String + +
@@ -1002,15 +1117,15 @@ specifies the length of the User ID.
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:36 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_type_keyid.html b/doc/openpgp_type_keyid.html index 5c3f5061..f2edcc5e 100644 --- a/doc/openpgp_type_keyid.html +++ b/doc/openpgp_type_keyid.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_type_keyid - - + + - + @@ -45,13 +45,15 @@
-

new openpgp_type_keyid

+

new openpgp_type_keyid()

+ + @@ -61,34 +63,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12495
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -118,7 +128,7 @@
-

<inner> read_packet

+

<inner> read_packet(input, position) → {openpgp_type_keyid}

@@ -126,9 +136,11 @@
- parsing method for a key id + Parsing method for a key id
+ + @@ -163,16 +175,18 @@ - String - - + +String + + + - input to read the key id from + Input to read the key id from @@ -184,16 +198,19 @@ - integer - - + +integer + + + - position where to start reading the key id from input + Position where to start reading the key +id from input @@ -205,34 +222,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12502
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -241,11 +266,23 @@
- this object + This object
+
+
+ Type +
+
+ +openpgp_type_keyid + + +
+
+ @@ -254,7 +291,7 @@
-

<inner> toString

+

<inner> toString() → {String}

@@ -262,9 +299,11 @@
- generates debug output (pretty print) + Generates debug output (pretty print)
+ + @@ -274,34 +313,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12511
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -315,15 +362,15 @@ -
Type
- String - +String + +
@@ -348,15 +395,15 @@
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:36 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_type_mpi.html b/doc/openpgp_type_mpi.html index 8fe53dbe..72a53519 100644 --- a/doc/openpgp_type_mpi.html +++ b/doc/openpgp_type_mpi.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_type_mpi - - + + - + @@ -39,13 +39,15 @@
-

new openpgp_type_mpi

+

new openpgp_type_mpi()

+ + @@ -55,34 +57,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12369
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -112,7 +122,7 @@
-

<inner> create

+

<inner> create(data) → {openpgp_type_mpi}

@@ -120,9 +130,11 @@
- creates an mpi from the specified string + Creates an mpi from the specified string
+ + @@ -157,16 +169,18 @@ - String - - + +String + + + - data to read the mpi from + Data to read the mpi from @@ -178,34 +192,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12444
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -215,15 +237,15 @@ -
Type
- openpgp_type_mpi - +openpgp_type_mpi + +
@@ -235,7 +257,7 @@
-

<inner> getBigInteger

+

<inner> getBigInteger() → {BigInteger}

@@ -243,9 +265,11 @@
- converts the mpi to an BigInteger object + Converts the mpi to an BigInteger object
+ + @@ -255,34 +279,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12420
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -292,15 +324,15 @@ -
Type
- BigInteger - +BigInteger + +
@@ -312,7 +344,7 @@
-

<inner> getByteLength

+

<inner> getByteLength() → {Integer}

@@ -320,9 +352,11 @@
- gets the length of the mpi in bytes + Gets the length of the mpi in bytes
+ + @@ -332,34 +366,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12435
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -368,20 +410,20 @@
- mpi byte length + Mpi byte length
-
Type
- integer - +Integer + +
@@ -393,7 +435,7 @@
-

<inner> read

+

<inner> read(input, position, len) → {openpgp_type_mpi}

@@ -401,9 +443,11 @@
- parsing function for a mpi (RFC 4880 3.2). + Parsing function for a mpi (RFC 4880 3.2).
+ + @@ -438,16 +482,18 @@ - string - - + +String + + + - payload of mpi data + Payload of mpi data @@ -459,16 +505,19 @@ - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input +string @@ -480,16 +529,19 @@ - integer - - + +Integer + + + - length of the packet or the remaining length of input at position + Length of the packet or the remaining length of +input at position @@ -501,34 +553,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12381
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -537,20 +597,20 @@
- object representation + Object representation
-
Type
- openpgp_type_mpi - +openpgp_type_mpi + +
@@ -562,7 +622,7 @@
-

<inner> toBin

+

<inner> toBin() → {String}

@@ -570,9 +630,11 @@
- converts the mpi object to a string as specified in RFC4880 3.2 + Converts the mpi object to a string as specified in RFC4880 3.2
+ + @@ -582,34 +644,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12455
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -618,20 +688,20 @@
- mpi byte representation + mpi Byte representation
-
Type
- String - +String + +
@@ -643,7 +713,7 @@
-

<inner> toString

+

<inner> toString() → {String}

@@ -651,9 +721,11 @@
- generates debug output (pretty print) + Generates debug output (pretty print)
+ + @@ -663,34 +735,42 @@
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12410
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -704,15 +784,15 @@ -
Type
- string - +String + +
@@ -737,15 +817,15 @@
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:36 GMT+0200 (CEST)
- + diff --git a/doc/openpgp_type_s2k.html b/doc/openpgp_type_s2k.html index 51ff8b47..a353ec02 100644 --- a/doc/openpgp_type_s2k.html +++ b/doc/openpgp_type_s2k.html @@ -4,12 +4,12 @@ JSDoc: Class: openpgp_type_s2k - - + + - + @@ -46,13 +46,15 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
-

new openpgp_type_s2k

+

new openpgp_type_s2k()

+ + @@ -62,34 +64,42 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12544
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -119,7 +129,7 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
-

<inner> produce_key

+

<inner> produce_key(passphrase) → {String}

@@ -127,9 +137,12 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- produces a key using the specified passphrase and the defined hashAlgorithm + Produces a key using the specified passphrase and the defined +hashAlgorithm
+ + @@ -164,13 +177,18 @@ String-to-key (S2K) specifiers are used to convert passphrase strings + +String + + + - {String} passphrase containing user input + Passphrase containing user input @@ -182,34 +200,42 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12614
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -218,20 +244,21 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- produced key with a length corresponding to hashAlgorithm hash length + Produced key with a length corresponding to +hashAlgorithm hash length
-
Type
- String - +String + +
@@ -243,7 +270,7 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
-

<inner> read

+

<inner> read(input, position) → {openpgp_type_s2k}

@@ -251,9 +278,11 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- parsing function for a string-to-key specifier (RFC 4880 3.7). + Parsing function for a string-to-key specifier (RFC 4880 3.7).
+ + @@ -288,16 +317,18 @@ String-to-key (S2K) specifiers are used to convert passphrase strings - string - - + +String + + + - payload of string-to-key specifier + Payload of string-to-key specifier @@ -309,16 +340,18 @@ String-to-key (S2K) specifiers are used to convert passphrase strings - integer - - + +Integer + + + - position to start reading from the input string + Position to start reading from the input string @@ -330,34 +363,42 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12551
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -366,20 +407,20 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- object representation + Object representation
-
Type
- openpgp_type_s2k - +openpgp_type_s2k + +
@@ -391,7 +432,7 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
-

<inner> write

+

<inner> write() → {String}

@@ -402,6 +443,8 @@ String-to-key (S2K) specifiers are used to convert passphrase strings writes an s2k hash based on the inputs. + + @@ -411,34 +454,42 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- - - - - - - - - - - - - - - -
Source:
-
  • openpgp.js, line 12599
- - - - - + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + +
+ + + + @@ -447,20 +498,20 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- produced key of hashAlgorithm hash length + Produced key of hashAlgorithm hash length
-
Type
- String - +String + +
@@ -485,15 +536,15 @@ String-to-key (S2K) specifiers are used to convert passphrase strings
- Documentation generated by JSDoc 3 on Tue Sep 11 2012 21:45:27 GMT-0400 (EDT) + Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:36 GMT+0200 (CEST)
- + diff --git a/doc/styles/node-dark.css b/doc/styles/node-dark.css deleted file mode 100644 index 5849e234..00000000 --- a/doc/styles/node-dark.css +++ /dev/null @@ -1,150 +0,0 @@ - .sh_sourceCode { - background-color: #ffffff; - color: #000000; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_keyword { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_type { - color: #a52a2a; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_string { - color: #006400; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_regexp { - color: #006400; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_specialchar { - color: #2e8b57; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_comment { - color: #000000; - font-weight: normal; - font-style: italic; -} - - .sh_sourceCode .sh_number { - color: #006400; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_preproc { - color: #27408b; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_symbol { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_function { - color: #000000; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_cbracket { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_url { - color: #006400; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_date { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_time { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_file { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_ip { - color: #006400; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_name { - color: #006400; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_variable { - color: #dda0dd; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_oldfile { - color: #2e8b57; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_newfile { - color: #006400; - font-weight: normal; - font-style: normal; -} - - .sh_sourceCode .sh_difflines { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_selector { - color: #dda0dd; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_property { - color: #000000; - font-weight: bold; - font-style: normal; -} - - .sh_sourceCode .sh_value { - color: #006400; - font-weight: normal; - font-style: normal; -} diff --git a/resources/openpgp.js b/resources/openpgp.js index d2b1647a..941635f3 100644 --- a/resources/openpgp.js +++ b/resources/openpgp.js @@ -197,595 +197,6 @@ function Elgamal() { this.encrypt = encrypt; this.decrypt = decrypt; }/* - * Copyright (c) 2003-2005 Tom Wu (tjw@cs.Stanford.EDU) - * All Rights Reserved. - * - * Modified by Recurity Labs GmbH - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF - * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * In addition, the following condition applies: - * - * All redistributions must retain an intact copy of this copyright notice - * and disclaimer. - */ - -// Basic JavaScript BN library - subset useful for RSA encryption. - -// Bits per digit -var dbits; - -// JavaScript engine analysis -var canary = 0xdeadbeefcafe; -var j_lm = ((canary&0xffffff)==0xefcafe); - -// (public) Constructor -function BigInteger(a,b,c) { - if(a != null) - if("number" == typeof a) this.fromNumber(a,b,c); - else if(b == null && "string" != typeof a) this.fromString(a,256); - else this.fromString(a,b); -} - -// return new, unset BigInteger -function nbi() { return new BigInteger(null); } - -// am: Compute w_j += (x*this_i), propagate carries, -// c is initial carry, returns final carry. -// c < 3*dvalue, x < 2*dvalue, this_i < dvalue -// We need to select the fastest one that works in this environment. - -// am1: use a single mult and divide to get the high bits, -// max digit bits should be 26 because -// max internal value = 2*dvalue^2-2*dvalue (< 2^53) -function am1(i,x,w,j,c,n) { - while(--n >= 0) { - var v = x*this[i++]+w[j]+c; - c = Math.floor(v/0x4000000); - w[j++] = v&0x3ffffff; - } - return c; -} -// am2 avoids a big mult-and-extract completely. -// Max digit bits should be <= 30 because we do bitwise ops -// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) -function am2(i,x,w,j,c,n) { - var xl = x&0x7fff, xh = x>>15; - while(--n >= 0) { - var l = this[i]&0x7fff; - var h = this[i++]>>15; - var m = xh*l+h*xl; - l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff); - c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); - w[j++] = l&0x3fffffff; - } - return c; -} -// Alternately, set max digit bits to 28 since some -// browsers slow down when dealing with 32-bit numbers. -function am3(i,x,w,j,c,n) { - var xl = x&0x3fff, xh = x>>14; - while(--n >= 0) { - var l = this[i]&0x3fff; - var h = this[i++]>>14; - var m = xh*l+h*xl; - l = xl*l+((m&0x3fff)<<14)+w[j]+c; - c = (l>>28)+(m>>14)+xh*h; - w[j++] = l&0xfffffff; - } - return c; -} -if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) { - BigInteger.prototype.am = am2; - dbits = 30; -} -else if(j_lm && (navigator.appName != "Netscape")) { - BigInteger.prototype.am = am1; - dbits = 26; -} -else { // Mozilla/Netscape seems to prefer am3 - BigInteger.prototype.am = am3; - dbits = 28; -} - -BigInteger.prototype.DB = dbits; -BigInteger.prototype.DM = ((1<= 0; --i) r[i] = this[i]; - r.t = this.t; - r.s = this.s; -} - -// (protected) set from integer value x, -DV <= x < DV -function bnpFromInt(x) { - this.t = 1; - this.s = (x<0)?-1:0; - if(x > 0) this[0] = x; - else if(x < -1) this[0] = x+DV; - else this.t = 0; -} - -// return bigint initialized to value -function nbv(i) { var r = nbi(); r.fromInt(i); return r; } - -// (protected) set from string and radix -function bnpFromString(s,b) { - var k; - if(b == 16) k = 4; - else if(b == 8) k = 3; - else if(b == 256) k = 8; // byte array - else if(b == 2) k = 1; - else if(b == 32) k = 5; - else if(b == 4) k = 2; - else { this.fromRadix(s,b); return; } - this.t = 0; - this.s = 0; - var i = s.length, mi = false, sh = 0; - while(--i >= 0) { - var x = (k==8)?s[i]&0xff:intAt(s,i); - if(x < 0) { - if(s.charAt(i) == "-") mi = true; - continue; - } - mi = false; - if(sh == 0) - this[this.t++] = x; - else if(sh+k > this.DB) { - this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<>(this.DB-sh)); - } - else - this[this.t-1] |= x<= this.DB) sh -= this.DB; - } - if(k == 8 && (s[0]&0x80) != 0) { - this.s = -1; - if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)< 0 && this[this.t-1] == c) --this.t; -} - -// (public) return string representation in given radix -function bnToString(b) { - if(this.s < 0) return "-"+this.negate().toString(b); - var k; - if(b == 16) k = 4; - else if(b == 8) k = 3; - else if(b == 2) k = 1; - else if(b == 32) k = 5; - else if(b == 4) k = 2; - else return this.toRadix(b); - var km = (1< 0) { - if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); } - while(i >= 0) { - if(p < k) { - d = (this[i]&((1<>(p+=this.DB-k); - } - else { - d = (this[i]>>(p-=k))&km; - if(p <= 0) { p += this.DB; --i; } - } - if(d > 0) m = true; - if(m) r += int2char(d); - } - } - return m?r:"0"; -} - -// (public) -this -function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } - -// (public) |this| -function bnAbs() { return (this.s<0)?this.negate():this; } - -// (public) return + if this > a, - if this < a, 0 if equal -function bnCompareTo(a) { - var r = this.s-a.s; - if(r != 0) return r; - var i = this.t; - r = i-a.t; - if(r != 0) return r; - while(--i >= 0) if((r=this[i]-a[i]) != 0) return r; - return 0; -} - -// returns bit length of the integer x -function nbits(x) { - var r = 1, t; - if((t=x>>>16) != 0) { x = t; r += 16; } - if((t=x>>8) != 0) { x = t; r += 8; } - if((t=x>>4) != 0) { x = t; r += 4; } - if((t=x>>2) != 0) { x = t; r += 2; } - if((t=x>>1) != 0) { x = t; r += 1; } - return r; -} - -// (public) return the number of bits in "this" -function bnBitLength() { - if(this.t <= 0) return 0; - return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM)); -} - -// (protected) r = this << n*DB -function bnpDLShiftTo(n,r) { - var i; - for(i = this.t-1; i >= 0; --i) r[i+n] = this[i]; - for(i = n-1; i >= 0; --i) r[i] = 0; - r.t = this.t+n; - r.s = this.s; -} - -// (protected) r = this >> n*DB -function bnpDRShiftTo(n,r) { - for(var i = n; i < this.t; ++i) r[i-n] = this[i]; - r.t = Math.max(this.t-n,0); - r.s = this.s; -} - -// (protected) r = this << n -function bnpLShiftTo(n,r) { - var bs = n%this.DB; - var cbs = this.DB-bs; - var bm = (1<= 0; --i) { - r[i+ds+1] = (this[i]>>cbs)|c; - c = (this[i]&bm)<= 0; --i) r[i] = 0; - r[ds] = c; - r.t = this.t+ds+1; - r.s = this.s; - r.clamp(); -} - -// (protected) r = this >> n -function bnpRShiftTo(n,r) { - r.s = this.s; - var ds = Math.floor(n/this.DB); - if(ds >= this.t) { r.t = 0; return; } - var bs = n%this.DB; - var cbs = this.DB-bs; - var bm = (1<>bs; - for(var i = ds+1; i < this.t; ++i) { - r[i-ds-1] |= (this[i]&bm)<>bs; - } - if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<>= this.DB; - } - if(a.t < this.t) { - c -= a.s; - while(i < this.t) { - c += this[i]; - r[i++] = c&this.DM; - c >>= this.DB; - } - c += this.s; - } - else { - c += this.s; - while(i < a.t) { - c -= a[i]; - r[i++] = c&this.DM; - c >>= this.DB; - } - c -= a.s; - } - r.s = (c<0)?-1:0; - if(c < -1) r[i++] = this.DV+c; - else if(c > 0) r[i++] = c; - r.t = i; - r.clamp(); -} - -// (protected) r = this * a, r != this,a (HAC 14.12) -// "this" should be the larger one if appropriate. -function bnpMultiplyTo(a,r) { - var x = this.abs(), y = a.abs(); - var i = x.t; - r.t = i+y.t; - while(--i >= 0) r[i] = 0; - for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t); - r.s = 0; - r.clamp(); - if(this.s != a.s) BigInteger.ZERO.subTo(r,r); -} - -// (protected) r = this^2, r != this (HAC 14.16) -function bnpSquareTo(r) { - var x = this.abs(); - var i = r.t = 2*x.t; - while(--i >= 0) r[i] = 0; - for(i = 0; i < x.t-1; ++i) { - var c = x.am(i,x[i],r,2*i,0,1); - if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) { - r[i+x.t] -= x.DV; - r[i+x.t+1] = 1; - } - } - if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1); - r.s = 0; - r.clamp(); -} - -// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) -// r != q, this != m. q or r may be null. -function bnpDivRemTo(m,q,r) { - var pm = m.abs(); - if(pm.t <= 0) return; - var pt = this.abs(); - if(pt.t < pm.t) { - if(q != null) q.fromInt(0); - if(r != null) this.copyTo(r); - return; - } - if(r == null) r = nbi(); - var y = nbi(), ts = this.s, ms = m.s; - var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus - if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } - else { pm.copyTo(y); pt.copyTo(r); } - var ys = y.t; - var y0 = y[ys-1]; - if(y0 == 0) return; - var yt = y0*(1<1)?y[ys-2]>>this.F2:0); - var d1 = this.FV/yt, d2 = (1<= 0) { - r[r.t++] = 1; - r.subTo(t,r); - } - BigInteger.ONE.dlShiftTo(ys,t); - t.subTo(y,y); // "negative" y so we can replace sub with am later - while(y.t < ys) y[y.t++] = 0; - while(--j >= 0) { - // Estimate quotient digit - var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2); - if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out - y.dlShiftTo(j,t); - r.subTo(t,r); - while(r[i] < --qd) r.subTo(t,r); - } - } - if(q != null) { - r.drShiftTo(ys,q); - if(ts != ms) BigInteger.ZERO.subTo(q,q); - } - r.t = ys; - r.clamp(); - if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder - if(ts < 0) BigInteger.ZERO.subTo(r,r); -} - -// (public) this mod a -function bnMod(a) { - var r = nbi(); - this.abs().divRemTo(a,null,r); - if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); - return r; -} - -// Modular reduction using "classic" algorithm -function Classic(m) { this.m = m; } -function cConvert(x) { - if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); - else return x; -} -function cRevert(x) { return x; } -function cReduce(x) { x.divRemTo(this.m,null,x); } -function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } -function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } - -Classic.prototype.convert = cConvert; -Classic.prototype.revert = cRevert; -Classic.prototype.reduce = cReduce; -Classic.prototype.mulTo = cMulTo; -Classic.prototype.sqrTo = cSqrTo; - -// (protected) return "-1/this % 2^DB"; useful for Mont. reduction -// justification: -// xy == 1 (mod m) -// xy = 1+km -// xy(2-xy) = (1+km)(1-km) -// x[y(2-xy)] = 1-k^2m^2 -// x[y(2-xy)] == 1 (mod m^2) -// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 -// should reduce x and y(2-xy) by m^2 at each step to keep size bounded. -// JS multiply "overflows" differently from C/C++, so care is needed here. -function bnpInvDigit() { - if(this.t < 1) return 0; - var x = this[0]; - if((x&1) == 0) return 0; - var y = x&3; // y == 1/x mod 2^2 - y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 - y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 - y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 - // last step - calculate inverse mod DV directly; - // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints - y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits - // we really want the negative inverse, and -DV < y < DV - return (y>0)?this.DV-y:-y; -} - -// Montgomery reduction -function Montgomery(m) { - this.m = m; - this.mp = m.invDigit(); - this.mpl = this.mp&0x7fff; - this.mph = this.mp>>15; - this.um = (1<<(m.DB-15))-1; - this.mt2 = 2*m.t; -} - -// xR mod m -function montConvert(x) { - var r = nbi(); - x.abs().dlShiftTo(this.m.t,r); - r.divRemTo(this.m,null,r); - if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); - return r; -} - -// x/R mod m -function montRevert(x) { - var r = nbi(); - x.copyTo(r); - this.reduce(r); - return r; -} - -// x = x/R mod m (HAC 14.32) -function montReduce(x) { - while(x.t <= this.mt2) // pad x so am has enough room later - x[x.t++] = 0; - for(var i = 0; i < this.m.t; ++i) { - // faster way of calculating u0 = x[i]*mp mod DV - var j = x[i]&0x7fff; - var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM; - // use am to combine the multiply-shift-add into one call - j = i+this.m.t; - x[j] += this.m.am(0,u0,x,i,0,this.m.t); - // propagate carry - while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; } - } - x.clamp(); - x.drShiftTo(this.m.t,x); - if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); -} - -// r = "x^2/R mod m"; x != r -function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } - -// r = "xy/R mod m"; x,y != r -function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } - -Montgomery.prototype.convert = montConvert; -Montgomery.prototype.revert = montRevert; -Montgomery.prototype.reduce = montReduce; -Montgomery.prototype.mulTo = montMulTo; -Montgomery.prototype.sqrTo = montSqrTo; - -// (protected) true iff this is even -function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; } - -// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) -function bnpExp(e,z) { - if(e > 0xffffffff || e < 1) return BigInteger.ONE; - var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; - g.copyTo(r); - while(--i >= 0) { - z.sqrTo(r,r2); - if((e&(1< 0) z.mulTo(r2,g,r); - else { var t = r; r = r2; r2 = t; } - } - return z.revert(r); -} - -// (public) this^e % m, 0 <= e < 2^32 -function bnModPowInt(e,m) { - var z; - if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); - return this.exp(e,z); -} - -// protected -BigInteger.prototype.copyTo = bnpCopyTo; -BigInteger.prototype.fromInt = bnpFromInt; -BigInteger.prototype.fromString = bnpFromString; -BigInteger.prototype.clamp = bnpClamp; -BigInteger.prototype.dlShiftTo = bnpDLShiftTo; -BigInteger.prototype.drShiftTo = bnpDRShiftTo; -BigInteger.prototype.lShiftTo = bnpLShiftTo; -BigInteger.prototype.rShiftTo = bnpRShiftTo; -BigInteger.prototype.subTo = bnpSubTo; -BigInteger.prototype.multiplyTo = bnpMultiplyTo; -BigInteger.prototype.squareTo = bnpSquareTo; -BigInteger.prototype.divRemTo = bnpDivRemTo; -BigInteger.prototype.invDigit = bnpInvDigit; -BigInteger.prototype.isEven = bnpIsEven; -BigInteger.prototype.exp = bnpExp; - -// public -BigInteger.prototype.toString = bnToString; -BigInteger.prototype.negate = bnNegate; -BigInteger.prototype.abs = bnAbs; -BigInteger.prototype.compareTo = bnCompareTo; -BigInteger.prototype.bitLength = bnBitLength; -BigInteger.prototype.mod = bnMod; -BigInteger.prototype.modPowInt = bnModPowInt; - -// "constants" -BigInteger.ZERO = nbv(0); -BigInteger.ONE = nbv(1); - -/* * Copyright (c) 2003-2005 Tom Wu (tjw@cs.Stanford.EDU) * All Rights Reserved. * @@ -1499,6 +910,595 @@ BigInteger.prototype.toMPI = bnToMPI; // JSBN-specific extension BigInteger.prototype.square = bnSquare; +/* + * Copyright (c) 2003-2005 Tom Wu (tjw@cs.Stanford.EDU) + * All Rights Reserved. + * + * Modified by Recurity Labs GmbH + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF + * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * In addition, the following condition applies: + * + * All redistributions must retain an intact copy of this copyright notice + * and disclaimer. + */ + +// Basic JavaScript BN library - subset useful for RSA encryption. + +// Bits per digit +var dbits; + +// JavaScript engine analysis +var canary = 0xdeadbeefcafe; +var j_lm = ((canary&0xffffff)==0xefcafe); + +// (public) Constructor +function BigInteger(a,b,c) { + if(a != null) + if("number" == typeof a) this.fromNumber(a,b,c); + else if(b == null && "string" != typeof a) this.fromString(a,256); + else this.fromString(a,b); +} + +// return new, unset BigInteger +function nbi() { return new BigInteger(null); } + +// am: Compute w_j += (x*this_i), propagate carries, +// c is initial carry, returns final carry. +// c < 3*dvalue, x < 2*dvalue, this_i < dvalue +// We need to select the fastest one that works in this environment. + +// am1: use a single mult and divide to get the high bits, +// max digit bits should be 26 because +// max internal value = 2*dvalue^2-2*dvalue (< 2^53) +function am1(i,x,w,j,c,n) { + while(--n >= 0) { + var v = x*this[i++]+w[j]+c; + c = Math.floor(v/0x4000000); + w[j++] = v&0x3ffffff; + } + return c; +} +// am2 avoids a big mult-and-extract completely. +// Max digit bits should be <= 30 because we do bitwise ops +// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) +function am2(i,x,w,j,c,n) { + var xl = x&0x7fff, xh = x>>15; + while(--n >= 0) { + var l = this[i]&0x7fff; + var h = this[i++]>>15; + var m = xh*l+h*xl; + l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff); + c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); + w[j++] = l&0x3fffffff; + } + return c; +} +// Alternately, set max digit bits to 28 since some +// browsers slow down when dealing with 32-bit numbers. +function am3(i,x,w,j,c,n) { + var xl = x&0x3fff, xh = x>>14; + while(--n >= 0) { + var l = this[i]&0x3fff; + var h = this[i++]>>14; + var m = xh*l+h*xl; + l = xl*l+((m&0x3fff)<<14)+w[j]+c; + c = (l>>28)+(m>>14)+xh*h; + w[j++] = l&0xfffffff; + } + return c; +} +if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) { + BigInteger.prototype.am = am2; + dbits = 30; +} +else if(j_lm && (navigator.appName != "Netscape")) { + BigInteger.prototype.am = am1; + dbits = 26; +} +else { // Mozilla/Netscape seems to prefer am3 + BigInteger.prototype.am = am3; + dbits = 28; +} + +BigInteger.prototype.DB = dbits; +BigInteger.prototype.DM = ((1<= 0; --i) r[i] = this[i]; + r.t = this.t; + r.s = this.s; +} + +// (protected) set from integer value x, -DV <= x < DV +function bnpFromInt(x) { + this.t = 1; + this.s = (x<0)?-1:0; + if(x > 0) this[0] = x; + else if(x < -1) this[0] = x+DV; + else this.t = 0; +} + +// return bigint initialized to value +function nbv(i) { var r = nbi(); r.fromInt(i); return r; } + +// (protected) set from string and radix +function bnpFromString(s,b) { + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 256) k = 8; // byte array + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else { this.fromRadix(s,b); return; } + this.t = 0; + this.s = 0; + var i = s.length, mi = false, sh = 0; + while(--i >= 0) { + var x = (k==8)?s[i]&0xff:intAt(s,i); + if(x < 0) { + if(s.charAt(i) == "-") mi = true; + continue; + } + mi = false; + if(sh == 0) + this[this.t++] = x; + else if(sh+k > this.DB) { + this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<>(this.DB-sh)); + } + else + this[this.t-1] |= x<= this.DB) sh -= this.DB; + } + if(k == 8 && (s[0]&0x80) != 0) { + this.s = -1; + if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)< 0 && this[this.t-1] == c) --this.t; +} + +// (public) return string representation in given radix +function bnToString(b) { + if(this.s < 0) return "-"+this.negate().toString(b); + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else return this.toRadix(b); + var km = (1< 0) { + if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); } + while(i >= 0) { + if(p < k) { + d = (this[i]&((1<>(p+=this.DB-k); + } + else { + d = (this[i]>>(p-=k))&km; + if(p <= 0) { p += this.DB; --i; } + } + if(d > 0) m = true; + if(m) r += int2char(d); + } + } + return m?r:"0"; +} + +// (public) -this +function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } + +// (public) |this| +function bnAbs() { return (this.s<0)?this.negate():this; } + +// (public) return + if this > a, - if this < a, 0 if equal +function bnCompareTo(a) { + var r = this.s-a.s; + if(r != 0) return r; + var i = this.t; + r = i-a.t; + if(r != 0) return r; + while(--i >= 0) if((r=this[i]-a[i]) != 0) return r; + return 0; +} + +// returns bit length of the integer x +function nbits(x) { + var r = 1, t; + if((t=x>>>16) != 0) { x = t; r += 16; } + if((t=x>>8) != 0) { x = t; r += 8; } + if((t=x>>4) != 0) { x = t; r += 4; } + if((t=x>>2) != 0) { x = t; r += 2; } + if((t=x>>1) != 0) { x = t; r += 1; } + return r; +} + +// (public) return the number of bits in "this" +function bnBitLength() { + if(this.t <= 0) return 0; + return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM)); +} + +// (protected) r = this << n*DB +function bnpDLShiftTo(n,r) { + var i; + for(i = this.t-1; i >= 0; --i) r[i+n] = this[i]; + for(i = n-1; i >= 0; --i) r[i] = 0; + r.t = this.t+n; + r.s = this.s; +} + +// (protected) r = this >> n*DB +function bnpDRShiftTo(n,r) { + for(var i = n; i < this.t; ++i) r[i-n] = this[i]; + r.t = Math.max(this.t-n,0); + r.s = this.s; +} + +// (protected) r = this << n +function bnpLShiftTo(n,r) { + var bs = n%this.DB; + var cbs = this.DB-bs; + var bm = (1<= 0; --i) { + r[i+ds+1] = (this[i]>>cbs)|c; + c = (this[i]&bm)<= 0; --i) r[i] = 0; + r[ds] = c; + r.t = this.t+ds+1; + r.s = this.s; + r.clamp(); +} + +// (protected) r = this >> n +function bnpRShiftTo(n,r) { + r.s = this.s; + var ds = Math.floor(n/this.DB); + if(ds >= this.t) { r.t = 0; return; } + var bs = n%this.DB; + var cbs = this.DB-bs; + var bm = (1<>bs; + for(var i = ds+1; i < this.t; ++i) { + r[i-ds-1] |= (this[i]&bm)<>bs; + } + if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<>= this.DB; + } + if(a.t < this.t) { + c -= a.s; + while(i < this.t) { + c += this[i]; + r[i++] = c&this.DM; + c >>= this.DB; + } + c += this.s; + } + else { + c += this.s; + while(i < a.t) { + c -= a[i]; + r[i++] = c&this.DM; + c >>= this.DB; + } + c -= a.s; + } + r.s = (c<0)?-1:0; + if(c < -1) r[i++] = this.DV+c; + else if(c > 0) r[i++] = c; + r.t = i; + r.clamp(); +} + +// (protected) r = this * a, r != this,a (HAC 14.12) +// "this" should be the larger one if appropriate. +function bnpMultiplyTo(a,r) { + var x = this.abs(), y = a.abs(); + var i = x.t; + r.t = i+y.t; + while(--i >= 0) r[i] = 0; + for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t); + r.s = 0; + r.clamp(); + if(this.s != a.s) BigInteger.ZERO.subTo(r,r); +} + +// (protected) r = this^2, r != this (HAC 14.16) +function bnpSquareTo(r) { + var x = this.abs(); + var i = r.t = 2*x.t; + while(--i >= 0) r[i] = 0; + for(i = 0; i < x.t-1; ++i) { + var c = x.am(i,x[i],r,2*i,0,1); + if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) { + r[i+x.t] -= x.DV; + r[i+x.t+1] = 1; + } + } + if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1); + r.s = 0; + r.clamp(); +} + +// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) +// r != q, this != m. q or r may be null. +function bnpDivRemTo(m,q,r) { + var pm = m.abs(); + if(pm.t <= 0) return; + var pt = this.abs(); + if(pt.t < pm.t) { + if(q != null) q.fromInt(0); + if(r != null) this.copyTo(r); + return; + } + if(r == null) r = nbi(); + var y = nbi(), ts = this.s, ms = m.s; + var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus + if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } + else { pm.copyTo(y); pt.copyTo(r); } + var ys = y.t; + var y0 = y[ys-1]; + if(y0 == 0) return; + var yt = y0*(1<1)?y[ys-2]>>this.F2:0); + var d1 = this.FV/yt, d2 = (1<= 0) { + r[r.t++] = 1; + r.subTo(t,r); + } + BigInteger.ONE.dlShiftTo(ys,t); + t.subTo(y,y); // "negative" y so we can replace sub with am later + while(y.t < ys) y[y.t++] = 0; + while(--j >= 0) { + // Estimate quotient digit + var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2); + if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out + y.dlShiftTo(j,t); + r.subTo(t,r); + while(r[i] < --qd) r.subTo(t,r); + } + } + if(q != null) { + r.drShiftTo(ys,q); + if(ts != ms) BigInteger.ZERO.subTo(q,q); + } + r.t = ys; + r.clamp(); + if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder + if(ts < 0) BigInteger.ZERO.subTo(r,r); +} + +// (public) this mod a +function bnMod(a) { + var r = nbi(); + this.abs().divRemTo(a,null,r); + if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); + return r; +} + +// Modular reduction using "classic" algorithm +function Classic(m) { this.m = m; } +function cConvert(x) { + if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); + else return x; +} +function cRevert(x) { return x; } +function cReduce(x) { x.divRemTo(this.m,null,x); } +function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } +function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +Classic.prototype.convert = cConvert; +Classic.prototype.revert = cRevert; +Classic.prototype.reduce = cReduce; +Classic.prototype.mulTo = cMulTo; +Classic.prototype.sqrTo = cSqrTo; + +// (protected) return "-1/this % 2^DB"; useful for Mont. reduction +// justification: +// xy == 1 (mod m) +// xy = 1+km +// xy(2-xy) = (1+km)(1-km) +// x[y(2-xy)] = 1-k^2m^2 +// x[y(2-xy)] == 1 (mod m^2) +// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 +// should reduce x and y(2-xy) by m^2 at each step to keep size bounded. +// JS multiply "overflows" differently from C/C++, so care is needed here. +function bnpInvDigit() { + if(this.t < 1) return 0; + var x = this[0]; + if((x&1) == 0) return 0; + var y = x&3; // y == 1/x mod 2^2 + y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 + y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 + y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 + // last step - calculate inverse mod DV directly; + // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints + y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits + // we really want the negative inverse, and -DV < y < DV + return (y>0)?this.DV-y:-y; +} + +// Montgomery reduction +function Montgomery(m) { + this.m = m; + this.mp = m.invDigit(); + this.mpl = this.mp&0x7fff; + this.mph = this.mp>>15; + this.um = (1<<(m.DB-15))-1; + this.mt2 = 2*m.t; +} + +// xR mod m +function montConvert(x) { + var r = nbi(); + x.abs().dlShiftTo(this.m.t,r); + r.divRemTo(this.m,null,r); + if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); + return r; +} + +// x/R mod m +function montRevert(x) { + var r = nbi(); + x.copyTo(r); + this.reduce(r); + return r; +} + +// x = x/R mod m (HAC 14.32) +function montReduce(x) { + while(x.t <= this.mt2) // pad x so am has enough room later + x[x.t++] = 0; + for(var i = 0; i < this.m.t; ++i) { + // faster way of calculating u0 = x[i]*mp mod DV + var j = x[i]&0x7fff; + var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM; + // use am to combine the multiply-shift-add into one call + j = i+this.m.t; + x[j] += this.m.am(0,u0,x,i,0,this.m.t); + // propagate carry + while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; } + } + x.clamp(); + x.drShiftTo(this.m.t,x); + if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); +} + +// r = "x^2/R mod m"; x != r +function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + +// r = "xy/R mod m"; x,y != r +function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + +Montgomery.prototype.convert = montConvert; +Montgomery.prototype.revert = montRevert; +Montgomery.prototype.reduce = montReduce; +Montgomery.prototype.mulTo = montMulTo; +Montgomery.prototype.sqrTo = montSqrTo; + +// (protected) true iff this is even +function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; } + +// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) +function bnpExp(e,z) { + if(e > 0xffffffff || e < 1) return BigInteger.ONE; + var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; + g.copyTo(r); + while(--i >= 0) { + z.sqrTo(r,r2); + if((e&(1< 0) z.mulTo(r2,g,r); + else { var t = r; r = r2; r2 = t; } + } + return z.revert(r); +} + +// (public) this^e % m, 0 <= e < 2^32 +function bnModPowInt(e,m) { + var z; + if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); + return this.exp(e,z); +} + +// protected +BigInteger.prototype.copyTo = bnpCopyTo; +BigInteger.prototype.fromInt = bnpFromInt; +BigInteger.prototype.fromString = bnpFromString; +BigInteger.prototype.clamp = bnpClamp; +BigInteger.prototype.dlShiftTo = bnpDLShiftTo; +BigInteger.prototype.drShiftTo = bnpDRShiftTo; +BigInteger.prototype.lShiftTo = bnpLShiftTo; +BigInteger.prototype.rShiftTo = bnpRShiftTo; +BigInteger.prototype.subTo = bnpSubTo; +BigInteger.prototype.multiplyTo = bnpMultiplyTo; +BigInteger.prototype.squareTo = bnpSquareTo; +BigInteger.prototype.divRemTo = bnpDivRemTo; +BigInteger.prototype.invDigit = bnpInvDigit; +BigInteger.prototype.isEven = bnpIsEven; +BigInteger.prototype.exp = bnpExp; + +// public +BigInteger.prototype.toString = bnToString; +BigInteger.prototype.negate = bnNegate; +BigInteger.prototype.abs = bnAbs; +BigInteger.prototype.compareTo = bnCompareTo; +BigInteger.prototype.bitLength = bnBitLength; +BigInteger.prototype.mod = bnMod; +BigInteger.prototype.modPowInt = bnModPowInt; + +// "constants" +BigInteger.ZERO = nbv(0); +BigInteger.ONE = nbv(1); + // GPG4Browsers - An OpenPGP implementation in javascript // Copyright (C) 2011 Recurity Labs GmbH // @@ -3368,27 +3368,37 @@ function str_sha512(str) { * 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 prefixrandom random bytes of block_size length provided + * @param {String} prefixrandom random bytes of block_size length provided * as a string to be used in prefixing the data - * @param 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) - * @param block_size the block size in bytes of the algorithm used - * @param plaintext data to be encrypted provided as a string - * @param key key to be used to encrypt the data as - * integer_array(integers 0..255)]. This will be passed to the + * @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 resync a boolean value specifying if a resync of the + * @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 a string with the encrypted data + * @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); @@ -3479,12 +3489,12 @@ function openpgp_cfb_encrypt(prefixrandom, blockcipherencryptfn, plaintext, bloc } /** - * decrypts the prefixed data for the Modification Detection Code (MDC) computation - * @param blockcipherencryptfn cipher function to use - * @param block_size blocksize of the algorithm - * @param key the key for encryption - * @param ciphertext the encrypted data - * @return plaintext data of D(ciphertext) with blocksize length +2 + * 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); @@ -3510,21 +3520,17 @@ function openpgp_cfb_mdc(blockcipherencryptfn, block_size, key, ciphertext) { /** * This function decrypts a given plaintext using the specified * blockcipher to decrypt a message - * @param 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) - * @param block_size the block size in bytes of the algorithm used - * @param plaintext ciphertext to be decrypted provided as a string - * @param key key to be used to decrypt the ciphertext as - * integer_array(integers 0..255)]. This will be passed to the + * @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 resync a boolean value specifying if a resync of the + * @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 a string with the plaintext data + * @return {String} a string with the plaintext data */ function openpgp_cfb_decrypt(blockcipherencryptfn, block_size, key, ciphertext, resync) @@ -3657,11 +3663,11 @@ function normal_cfb_decrypt(blockcipherencryptfn, block_size, key, ciphertext, i /** * Encrypts data using the specified public key multiprecision integers * and the specified algorithm. - * @param algo [Integer] Algorithm to be used (See RFC4880 9.1) - * @param publicMPIs [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers - * @param data [openpgp_type_mpi] data to be encrypted as MPI - * @return [Object] if RSA an openpgp_type_mpi; if elgamal encryption an array of two - * openpgp_type_mpi is returned; otherwise null + * @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) { @@ -3688,11 +3694,13 @@ function openpgp_crypto_asymetricEncrypt(algo, publicMPIs, data) { /** * 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 algo [Integer] Algorithm to be used (See RFC4880 9.1) - * @param publicMPIs [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers of the public key part of the private key - * @param secretMPIs [Array[openpgp_type_mpi]] algorithm dependent multiprecision integers of the private key used - * @param data [openpgp_type_mpi] data to be encrypted as MPI - * @return [BigInteger] returns a big integer containing the decrypted data; otherwise null + * @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) { @@ -3722,8 +3730,8 @@ function openpgp_crypto_asymetricDecrypt(algo, publicMPIs, secretMPIs, dataMPIs) /** * generate random byte prefix as string for the specified algorithm - * @param algo [Integer] algorithm to use (see RFC4880 9.2) - * @return [String] random bytes with length equal to the block + * @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) { @@ -3744,10 +3752,10 @@ function openpgp_crypto_getPrefixRandom(algo) { /** * retrieve the MDC prefixed bytes by decrypting them - * @param algo [Integer] algorithm to use (see RFC4880 9.2) - * @param key [String] key as string. length is depending on the algorithm used - * @param data [String] encrypted data where the prefix is decrypted from - * @return [String] plain text data of the prefixed data + * @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); @@ -3775,8 +3783,8 @@ function openpgp_crypto_MDCSystemBytes(algo, key, data) { } /** * Generating a session key for the specified symmetric algorithm - * @param algo [Integer] algorithm to use (see RFC4880 9.2) - * @return [String] random bytes as a string to be used as a key + * @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) { @@ -3797,12 +3805,12 @@ function openpgp_crypto_generateSessionKey(algo) { /** * - * @param algo [Integer] public key algorithm - * @param hash_algo [Integer] hash algorithm - * @param msg_MPIs [Array[openpgp_type_mpi]] signature multiprecision integers - * @param publickey_MPIs [Array[openpgp_type_mpi]] public key multiprecision integers - * @param data [String] data on where the signature was computed on. - * @return true if signature (sig_data was equal to data over hash) + * @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); @@ -3844,12 +3852,14 @@ function openpgp_crypto_verifySignature(algo, hash_algo, msg_MPIs, publickey_MPI /** * Create a signature on data using the specified algorithm - * @param hash_algo [Integer] hash algorithm to use (See RFC4880 9.4) - * @param algo [Integer] asymmetric cipher algorithm to use (See RFC4880 9.1) - * @param publicMPIs [Array[openpgp_type_mpi]] public key multiprecision integers of the private key - * @param secretMPIs [Array[openpgp_type_mpi]] private key multiprecision integers which is used to sign the data - * @param data [String] data to be signed - * @return [String or openpgp_type_mpi] + * @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) { @@ -3884,10 +3894,10 @@ function openpgp_crypto_signData(hash_algo, algo, publicMPIs, secretMPIs, data) } /** - * create a hash on the specified data using the specified algorithm - * @param algo [Integer] hash algorithm type (see RFC4880 9.4) - * @param data [String] data to be hashed - * @return [String] hash value + * 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; @@ -3919,9 +3929,9 @@ function openpgp_crypto_hashData(algo, data) { } /** - * returns the hash size in bytes of the specified hash algorithm type - * @param algo [Integer] hash algorithm type (See RFC4880 9.4) - * @return [Integer] size in bytes of the resulting 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; @@ -3944,9 +3954,9 @@ function openpgp_crypto_getHashByteLength(algo) { } /** - * retrieve secure random byte string of the specified length - * @param length [Integer] length in bytes to generate - * @return [String] random byte string + * 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 = ''; @@ -3957,20 +3967,20 @@ function openpgp_crypto_getRandomBytes(length) { } /** - * return a pseudo-random number in the specified range - * @param from [Integer] min of the random number - * @param to [Integer] max of the random number (max 32bit) - * @return [Integer] a pseudo random number + * 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 from [Integer] min of the random number - * @param to [Integer] max of the random number (max 32bit) - * @return [Integer] a secure random number + * 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); @@ -3988,9 +3998,9 @@ function openpgp_crypto_getSecureRandomOctet() { } /** - * create a secure random big integer of bits length - * @param bits [Integer] bit length of the MPI to create - * @return [BigInteger] resulting big integer + * 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) @@ -4029,11 +4039,19 @@ function openpgp_crypto_testRSA(key){ var msg = rsa.encrypt(mpi.toBigInteger(),key.ee,key.n); var result = rsa.decrypt(msg, key.d, key.p, key.q, key.u); } + /** - * calls the necessary crypto functions to generate a keypair. Called directly by openpgp.js - * @keyType [int] follows OpenPGP algorithm convention. - * @numBits [int] number of bits to make the key to be generated - * @return {privateKey: [openpgp_packet_keymaterial] , publicKey: [openpgp_packet_keymaterial]} + * @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; @@ -4076,14 +4094,14 @@ function openpgp_crypto_generateKeyPair(keyType, numBits, passphrase, s2kHash, s * Symmetrically encrypts data using prefixedrandom, a key with length * depending on the algorithm in openpgp_cfb mode with or without resync * (MDC style) - * @param 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 - * @param algo [Integer] algorithm to use (see RFC4880 9.2) - * @param key [String] key as string. length is depending on the algorithm used - * @param data [String] data to encrypt - * @param openpgp_cfb [boolean] - * @return [String] encrypted data + * @param {String} 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 + * @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 Data to encrypt + * @param {Boolean} openpgp_cfb + * @return {String} Encrypted data */ function openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_cfb) { switch(algo) { @@ -4112,12 +4130,12 @@ function openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_ /** * Symmetrically decrypts data using a key with length depending on the * algorithm in openpgp_cfb mode with or without resync (MDC style) - * @param algo [Integer] algorithm to use (see RFC4880 9.2) - * @param key [String] key as string. length is depending on the algorithm used - * @param data [String] data to be decrypted - * @param openpgp_cfb [boolean] if true use the resync (for encrypteddata); + * @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 Data to be decrypted + * @param {Boolean} openpgp_cfb If true use the resync (for encrypteddata); * otherwise use without the resync (for MDC encrypted data) - * @return [String] plaintext data + * @return {String} Plaintext data */ function openpgp_crypto_symmetricDecrypt(algo, key, data, openpgp_cfb) { util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+algo+"\nencrypteddata:",data); @@ -4147,6 +4165,7 @@ function openpgp_crypto_symmetricDecrypt(algo, key, data, openpgp_cfb) { } return null; } + /* Rijndael (AES) Encryption * Copyright 2005 Herbert Hanewinkel, www.haneWIN.de * version 1.1, check www.haneWIN.de for the latest version @@ -6111,8 +6130,8 @@ JXG.decompress = function(str) {return unescape((new JXG.Util.Unzip(JXG.Util.Bas * * Only Huffman codes are decoded in gunzip. * The code is based on the source code for gunzip.c by Pasi Ojala - * @see http://www.cs.tut.fi/~albert/Dev/gunzip/gunzip.c - * @see http://www.cs.tut.fi/~albert + * {@link http://www.cs.tut.fi/~albert/Dev/gunzip/gunzip.c} + * {@link http://www.cs.tut.fi/~albert} */ JXG.Util = {}; @@ -7007,7 +7026,7 @@ function skipdir(){ /** * Base64 encoding / decoding -* @see http://www.webtoolkit.info/ +* {@link http://www.webtoolkit.info/} */ JXG.Util.Base64 = { @@ -7336,10 +7355,21 @@ JXG.Util.genUUID = function() { * @classdesc Implementation of the GPG4Browsers config object */ function openpgp_config() { + /** + * The variable with the actual configuration + * @property {Integer} prefer_hash_algorithm + * @property {Integer} encryption_cipher + * @property {Integer} compression + * @property {Boolean} show_version + * @property {Boolean} show_comment + * @property {Boolean} integrity_protect + * @property {Integer} composition_behavior + * @property {String} keyserver + */ this.config = null; /** - * the default config object which is used if no + * The default config object which is used if no * configuration was in place */ this.default_config = { @@ -7353,13 +7383,12 @@ function openpgp_config() { keyserver: "keyserver.linux.it" // "pgp.mit.edu:11371" }; - this.versionstring ="OpenPGP.js v.1.20130306"; + this.versionstring ="OpenPGP.js v.1.20130412"; this.commentstring ="http://openpgpjs.org"; /** - * reads the config out of the HTML5 local storage + * Reads the config out of the HTML5 local storage * and initializes the object config. * if config is null the default config will be used - * @return [void] */ function read() { var cf = JSON.parse(window.localStorage.getItem("config")); @@ -7372,13 +7401,12 @@ function openpgp_config() { } /** - * if enabled, debug messages will be printed + * If enabled, debug messages will be printed */ this.debug = false; /** - * writes the config to HTML5 local storage - * @return [void] + * Writes the config to HTML5 local storage */ function write() { window.localStorage.setItem("config",JSON.stringify(this.config)); @@ -7481,9 +7509,11 @@ function r2s(t) { // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /** - * DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes - * @text [String] OpenPGP armored message - * @return either the bytes of the decoded message or an object with attribute "text" containing the message text + * DeArmor an OpenPGP armored message; verify the checksum and return + * the encoded bytes + * @param {String} text OpenPGP armored message + * @returns {(String|Object)} Either the bytes of the decoded message + * or an object with attribute "text" containing the message text * and an attribute "openpgp" containing the bytes. */ function openpgp_encoding_deArmor(text) { @@ -7510,8 +7540,8 @@ function openpgp_encoding_deArmor(text) { /** * Finds out which Ascii Armoring type is used. This is an internal function - * @param text [String] ascii armored text - * @return 0 = MESSAGE PART n of m + * @param {String} text [String] ascii armored text + * @returns {Integer} 0 = MESSAGE PART n of m * 1 = MESSAGE PART n * 2 = SIGNED MESSAGE * 3 = PGP MESSAGE @@ -7567,7 +7597,7 @@ function getPGPMessageType(text) { * packet block. * @author Alex * @version 2011-12-16 - * @return The header information + * @returns {String} The header information */ function openpgp_encoding_armor_addheader() { var result = ""; @@ -7583,11 +7613,11 @@ function openpgp_encoding_armor_addheader() { /** * Armor an OpenPGP binary packet block - * @param messagetype type of the message + * @param {Integer} messagetype type of the message * @param data - * @param partindex - * @param parttotal - * @return {string} Armored text + * @param {Integer} partindex + * @param {Integer} parttotal + * @returns {String} Armored text */ function openpgp_encoding_armor(messagetype, data, partindex, parttotal) { var result = ""; @@ -7643,8 +7673,8 @@ function openpgp_encoding_armor(messagetype, data, partindex, parttotal) { /** * Calculates a checksum over the given data and returns it base64 encoded - * @param data [String] data to create a CRC-24 checksum for - * @return [String] base64 encoded checksum + * @param {String} data Data to create a CRC-24 checksum for + * @return {String} Base64 encoded checksum */ function getCheckSum(data) { var c = createcrc24(data); @@ -7655,10 +7685,11 @@ function getCheckSum(data) { } /** - * Calculates the checksum over the given data and compares it with the given base64 encoded checksum - * @param data [String] data to create a CRC-24 checksum for - * @param checksum [String] base64 encoded checksum - * @return true if the given checksum is correct; otherwise false + * Calculates the checksum over the given data and compares it with the + * given base64 encoded checksum + * @param {String} data Data to create a CRC-24 checksum for + * @param {String} checksum Base64 encoded checksum + * @return {Boolean} True if the given checksum is correct; otherwise false */ function verifyCheckSum(data, checksum) { var c = getCheckSum(data); @@ -7667,8 +7698,8 @@ function verifyCheckSum(data, checksum) { } /** * Internal function to calculate a CRC-24 checksum over a given string (data) - * @param data [String] data to create a CRC-24 checksum for - * @return [Integer] the CRC-24 checksum as number + * @param {String} data Data to create a CRC-24 checksum for + * @return {Integer} The CRC-24 checksum as number */ var crc_table = [ 0x00000000, 0x00864cfb, 0x018ad50d, 0x010c99f6, 0x0393e6e1, 0x0315aa1a, 0x021933ec, 0x029f7f17, 0x07a18139, 0x0727cdc2, 0x062b5434, 0x06ad18cf, 0x043267d8, 0x04b42b23, 0x05b8b2d5, 0x053efe2e, 0x0fc54e89, 0x0f430272, 0x0e4f9b84, 0x0ec9d77f, 0x0c56a868, 0x0cd0e493, 0x0ddc7d65, 0x0d5a319e, 0x0864cfb0, 0x08e2834b, 0x09ee1abd, 0x09685646, 0x0bf72951, 0x0b7165aa, 0x0a7dfc5c, 0x0afbb0a7, 0x1f0cd1e9, 0x1f8a9d12, 0x1e8604e4, 0x1e00481f, 0x1c9f3708, 0x1c197bf3, 0x1d15e205, 0x1d93aefe, 0x18ad50d0, 0x182b1c2b, 0x192785dd, 0x19a1c926, 0x1b3eb631, 0x1bb8faca, 0x1ab4633c, 0x1a322fc7, 0x10c99f60, 0x104fd39b, 0x11434a6d, 0x11c50696, 0x135a7981, 0x13dc357a, 0x12d0ac8c, 0x1256e077, 0x17681e59, 0x17ee52a2, 0x16e2cb54, 0x166487af, 0x14fbf8b8, 0x147db443, 0x15712db5, 0x15f7614e, 0x3e19a3d2, 0x3e9fef29, 0x3f9376df, 0x3f153a24, 0x3d8a4533, 0x3d0c09c8, 0x3c00903e, 0x3c86dcc5, 0x39b822eb, 0x393e6e10, 0x3832f7e6, 0x38b4bb1d, 0x3a2bc40a, 0x3aad88f1, 0x3ba11107, 0x3b275dfc, 0x31dced5b, 0x315aa1a0, @@ -7726,8 +7757,8 @@ function createcrc24(input) { /** * Wrapper function for the base64 codec. * This function encodes a String (message) in base64 (radix-64) - * @param message [String] the message to encode - * @return [String] the base64 encoded data + * @param {String} message The message to encode + * @return {String} The base64 encoded data */ function openpgp_encoding_base64_encode(message) { return s2r(message); @@ -7737,8 +7768,8 @@ function openpgp_encoding_base64_encode(message) { /** * Wrapper function for the base64 codec. * This function decodes a String(message) in base64 (radix-64) - * @param message [String] base64 encoded data - * @return [String] raw data after decoding + * @param {String} message Base64 encoded data + * @return {String} Raw data after decoding */ function openpgp_encoding_base64_decode(message) { return r2s(message); @@ -7746,9 +7777,10 @@ function openpgp_encoding_base64_decode(message) { /** * Wrapper function for jquery library. - * This function escapes HTML characters within a string. This is used to prevent XSS. - * @param message [String] message to escape - * @return [String] html encoded string + * This function escapes HTML characters within a string. This is used + * to prevent XSS. + * @param {String} message Message to escape + * @return {String} Html encoded string */ function openpgp_encoding_html_encode(message) { if (message == null) @@ -7758,9 +7790,9 @@ function openpgp_encoding_html_encode(message) { /** * create a EME-PKCS1-v1_5 padding (See RFC4880 13.1.1) - * @param message [String] message to be padded - * @param length [Integer] length to the resulting message - * @return [String] EME-PKCS1 padded message + * @param {String} message message to be padded + * @param {Integer} length Length to the resulting message + * @return {String} EME-PKCS1 padded message */ function openpgp_encoding_eme_pkcs1_encode(message, length) { if (message.length > length-11) @@ -7778,8 +7810,8 @@ function openpgp_encoding_eme_pkcs1_encode(message, length) { /** * decodes a EME-PKCS1-v1_5 padding (See RFC4880 13.1.2) - * @param message [String] EME-PKCS1 padded message - * @return [String] decoded message + * @param {String} message EME-PKCS1 padded message + * @return {String} decoded message */ function openpgp_encoding_eme_pkcs1_decode(message, len) { if (message.length < len) @@ -7805,10 +7837,10 @@ hash_headers[11] = [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03, /** * create a EMSA-PKCS1-v1_5 padding (See RFC4880 13.1.3) - * @param algo [Integer] hash algorithm type used - * @param data [String] data to be hashed - * @param keylength [Integer] key size of the public mpi in bytes - * @return the [String] hashcode with pkcs1padding as string + * @param {Integer} algo Hash algorithm type used + * @param {String} data Data to be hashed + * @param {Integer} keylength Key size of the public mpi in bytes + * @returns {String} Hashcode with pkcs1padding as string */ function openpgp_encoding_emsa_pkcs1_encode(algo, data, keylength) { var data2 = ""; @@ -7827,8 +7859,8 @@ function openpgp_encoding_emsa_pkcs1_encode(algo, data, keylength) { /** * extract the hash out of an EMSA-PKCS1-v1.5 padding (See RFC4880 13.1.3) - * @param data [String] hash in pkcs1 encoding - * @return the hash as string + * @param {String} data Hash in pkcs1 encoding + * @returns {String} The hash as string */ function openpgp_encoding_emsa_pkcs1_decode(algo, data) { var i = 0; @@ -7845,7 +7877,8 @@ function openpgp_encoding_emsa_pkcs1_decode(algo, data) { i+= j; if (data.substring(i).length < openpgp_crypto_getHashByteLength(algo)) return -1; return data.substring(i); -}// GPG4Browsers - An OpenPGP implementation in javascript +} +// GPG4Browsers - An OpenPGP implementation in javascript // Copyright (C) 2011 Recurity Labs GmbH // // This library is free software; you can redistribute it and/or @@ -7882,7 +7915,6 @@ function _openpgp () { * initializes the library: * - reading the keyring from local storage * - reading the config from local storage - * @return [void] */ function init() { this.config = new openpgp_config(); @@ -7896,7 +7928,7 @@ function _openpgp () { * representation an returns openpgp_msg_publickey packets * @param {String} armoredText OpenPGP armored text containing * the public key(s) - * @return {Array[openpgp_msg_publickey]} on error the function + * @return {openpgp_msg_publickey[]} on error the function * returns null */ function read_publicKey(armoredText) { @@ -7942,7 +7974,7 @@ function _openpgp () { * representation an returns openpgp_msg_privatekey objects * @param {String} armoredText OpenPGP armored text containing * the private key(s) - * @return {Array[openpgp_msg_privatekey]} on error the function + * @return {openpgp_msg_privatekey[]} on error the function * returns null */ function read_privateKey(armoredText) { @@ -7972,7 +8004,7 @@ function _openpgp () { * reads message packets out of an OpenPGP armored text and * returns an array of message objects * @param {String} armoredText text to be parsed - * @return {Array[openpgp_msg_message]} on error the function + * @return {openpgp_msg_message[]} on error the function * returns null */ function read_message(armoredText) { @@ -7993,7 +8025,7 @@ function _openpgp () { * External call will parse a de-armored messaged and return messages found. * Internal will be called to read packets wrapped in other packets (i.e. compressed) * @param {String} input dearmored text of OpenPGP packets, to be parsed - * @return {Array[openpgp_msg_message]} on error the function + * @return {openpgp_msg_message[]} on error the function * returns null */ function read_messages_dearmored(input){ @@ -8138,10 +8170,13 @@ function _openpgp () { * creates a binary string representation of an encrypted and signed message. * The message will be encrypted with the public keys specified and signed * with the specified private key. - * @param {obj: [openpgp_msg_privatekey]} privatekey private key to be used to sign the message - * @param {Array {obj: [openpgp_msg_publickey]}} publickeys public keys to be used to encrypt the message + * @param {Object} privatekey {obj: [openpgp_msg_privatekey]} Private key + * to be used to sign the message + * @param {Object[]} publickeys An arraf of {obj: [openpgp_msg_publickey]} + * - public keys to be used to encrypt the message * @param {String} messagetext message text to encrypt and sign - * @return {String} a binary string representation of the message which can be OpenPGP armored + * @return {String} a binary string representation of the message which + * can be OpenPGP armored */ function write_signed_and_encrypted_message(privatekey, publickeys, messagetext) { var result = ""; @@ -8194,8 +8229,8 @@ function _openpgp () { /** * creates a binary string representation of an encrypted message. * The message will be encrypted with the public keys specified - * @param {Array {obj: [openpgp_msg_publickey]}} publickeys public - * keys to be used to encrypt the message + * @param {Object[]} publickeys An array of {obj: [openpgp_msg_publickey]} + * -public keys to be used to encrypt the message * @param {String} messagetext message text to encrypt * @return {String} a binary string representation of the message * which can be OpenPGP armored @@ -8236,12 +8271,13 @@ function _openpgp () { /** * creates a binary string representation a signed message. * The message will be signed with the specified private key. - * @param {obj: [openpgp_msg_privatekey]} privatekey private - * key to be used to sign the message + * @param {Object} privatekey {obj: [openpgp_msg_privatekey]} + * - the private key to be used to sign the message * @param {String} messagetext message text to sign - * @return {Object: text [String]}, openpgp: {String} a binary + * @return {Object} {Object: text [String]}, openpgp: {String} a binary * string representation of the message which can be OpenPGP - * armored(openpgp) and a text representation of the message (text). This can be directly used to OpenPGP armor the message + * armored(openpgp) and a text representation of the message (text). + * This can be directly used to OpenPGP armor the message */ function write_signed_message(privatekey, messagetext) { var sig = new openpgp_packet_signature().write_message_signature(1, messagetext.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"), privatekey); @@ -8250,11 +8286,16 @@ function _openpgp () { } /** - * generates a new key pair for openpgp. Beta stage. Currently only supports RSA keys, and no subkeys. - * @param {int} keyType to indicate what type of key to make. RSA is 1. Follows algorithms outlined in OpenPGP. - * @param {int} numBits number of bits for the key creation. (should be 1024+, generally) - * @param {string} userId assumes already in form of "User Name " - * @return {privateKey: [openpgp_msg_privatekey], privateKeyArmored: [string], publicKeyArmored: [string]} + * generates a new key pair for openpgp. Beta stage. Currently only + * supports RSA keys, and no subkeys. + * @param {Integer} keyType to indicate what type of key to make. + * RSA is 1. Follows algorithms outlined in OpenPGP. + * @param {Integer} numBits number of bits for the key creation. (should + * be 1024+, generally) + * @param {String} userId assumes already in form of "User Name + * " + * @return {Object} {privateKey: [openpgp_msg_privatekey], + * privateKeyArmored: [string], publicKeyArmored: [string]} */ function generate_key_pair(keyType, numBits, userId, passphrase){ var userIdPacket = new openpgp_packet_userid(); @@ -8324,7 +8365,6 @@ function openpgp_keyring() { * Initialization routine for the keyring. This method reads the * keyring from HTML5 local storage and initializes this instance. * This method is called by openpgp.init(). - * @return {null} undefined */ function init() { var sprivatekeys = JSON.parse(window.localStorage.getItem("privatekeys")); @@ -8357,7 +8397,7 @@ function openpgp_keyring() { /** * Checks if at least one private key is in the keyring - * @return {boolean} True if there are private keys, else false. + * @return {Boolean} True if there are private keys, else false. */ function hasPrivateKey() { return this.privateKeys.length > 0; @@ -8367,7 +8407,6 @@ function openpgp_keyring() { /** * Saves the current state of the keyring to HTML5 local storage. * The privateKeys array and publicKeys array gets Stringified using JSON - * @return {null} undefined */ function store() { var priv = new Array(); @@ -8384,8 +8423,8 @@ function openpgp_keyring() { this.store = store; /** * searches all public keys in the keyring matching the address or address part of the user ids - * @param email_address - * @return {array[openpgp_msg_publickey]} the public keys associated with provided email address. + * @param {String} email_address + * @return {openpgp_msg_publickey[]} The public keys associated with provided email address. */ function getPublicKeyForAddress(email_address) { var results = new Array(); @@ -8413,7 +8452,7 @@ function openpgp_keyring() { /** * Searches the keyring for a private key containing the specified email address * @param {String} email_address email address to search for - * @return {Array[openpgp_msg_privatekey} private keys found + * @return {openpgp_msg_privatekey[]} private keys found */ function getPrivateKeyForAddress(email_address) { var results = new Array(); @@ -8440,8 +8479,8 @@ function openpgp_keyring() { this.getPrivateKeyForAddress = getPrivateKeyForAddress; /** * Searches the keyring for public keys having the specified key id - * @param keyId provided as string of hex number (lowercase) - * @return {Array[openpgp_msg_privatekey]} public keys found + * @param {String} keyId provided as string of hex number (lowercase) + * @return {openpgp_msg_privatekey[]} public keys found */ function getPublicKeysForKeyId(keyId) { var result = new Array(); @@ -8468,7 +8507,7 @@ function openpgp_keyring() { /** * Searches the keyring for private keys having the specified key id * @param {String} keyId 8 bytes as string containing the key id to look for - * @return {Array[openpgp_msg_privatekey]} private keys found + * @return {openpgp_msg_privatekey[]} private keys found */ function getPrivateKeyForKeyId(keyId) { var result = new Array(); @@ -8491,7 +8530,6 @@ function openpgp_keyring() { /** * Imports a public key from an exported ascii armored message * @param {String} armored_text PUBLIC KEY BLOCK message to read the public key from - * @return {null} nothing */ function importPublicKey (armored_text) { var result = openpgp.read_publicKey(armored_text); @@ -8504,7 +8542,6 @@ function openpgp_keyring() { /** * Imports a private key from an exported ascii armored message * @param {String} armored_text PRIVATE KEY BLOCK message to read the private key from - * @return {null} nothing */ function importPrivateKey (armored_text, password) { var result = openpgp.read_privateKey(armored_text); @@ -9049,7 +9086,7 @@ function openpgp_msg_publickey() { * - subkey binding and revocation certificates * * This is useful for validating the key - * @returns true if the basic signatures are all valid + * @returns {Boolean} true if the basic signatures are all valid */ function verifyBasicSignatures() { for (var i = 0; i < this.revocationSignatures.length; i++) { @@ -9192,11 +9229,12 @@ function openpgp_packet_compressed() { this.decompressedData = null; /** - * parsing function for the packet. - * @param {string} input payload of a tag 8 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position - * @return {openpgp_packet_compressed} object representation + * Parsing function for the packet. + * @param {String} input Payload of a tag 8 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len Length of the packet or the remaining length of + * input at position + * @return {openpgp_packet_compressed} Object representation */ function read_packet (input, position, len) { this.packetLength = len; @@ -9208,9 +9246,9 @@ function openpgp_packet_compressed() { return this; } /** - * decompression method for decompressing the compressed data + * Decompression method for decompressing the compressed data * read by read_packet - * @return {String} the decompressed data + * @return {String} The decompressed data */ function decompress() { if (this.decompressedData != null) @@ -9261,8 +9299,8 @@ function openpgp_packet_compressed() { /** * Compress the packet data (member decompressedData) - * @param {integer} type algorithm to be used // See RFC 4880 9.3 - * @param {String} data data to be compressed + * @param {Integer} type Algorithm to be used // See RFC 4880 9.3 + * @param {String} data Data to be compressed * @return {String} The compressed data stored in attribute compressedData */ function compress(type, data) { @@ -9292,10 +9330,10 @@ function openpgp_packet_compressed() { } /** - * creates a string representation of the packet - * @param {integer} algorithm algorithm to be used // See RFC 4880 9.3 - * @param {String} data data to be compressed - * @return {String} string-representation of the packet + * Creates a string representation of the packet + * @param {Integer} algorithm Algorithm to be used // See RFC 4880 9.3 + * @param {String} data Data to be compressed + * @return {String} String-representation of the packet */ function write_packet(algorithm, data) { this.decompressedData = data; @@ -9307,7 +9345,7 @@ function openpgp_packet_compressed() { } /** - * pretty printing the packet (useful for debug purposes) + * Pretty printing the packet (useful for debug purposes) * @return {String} */ function toString() { @@ -9358,13 +9396,13 @@ function openpgp_packet_encrypteddata() { this.decryptedData = null; /** - * parsing function for the packet. + * Parsing function for the packet. * - * @param {string} input payload of a tag 9 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of + * @param {String} input Payload of a tag 9 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_packet(input, position, len) { var mypos = position; @@ -9376,14 +9414,14 @@ function openpgp_packet_encrypteddata() { } /** - * symmetrically decrypt the packet data + * Symmetrically decrypt the packet data * - * @param {integer} symmetric_algorithm_type - * symmetric key algorithm to use // See RFC4880 9.2 + * @param {Integer} symmetric_algorithm_type + * Symmetric key algorithm to use // See RFC4880 9.2 * @param {String} key - * key as string with the corresponding length to the + * Key as string with the corresponding length to the * algorithm - * @return the decrypted data; + * @return The decrypted data; */ function decrypt_sym(symmetric_algorithm_type, key) { this.decryptedData = openpgp_crypto_symmetricDecrypt( @@ -9396,11 +9434,11 @@ function openpgp_packet_encrypteddata() { /** * Creates a string representation of the packet * - * @param {Integer} algo symmetric key algorithm to use // See RFC4880 9.2 - * @param {String} key key as string with the corresponding length to the + * @param {Integer} algo Symmetric key algorithm to use // See RFC4880 9.2 + * @param {String} key Key as string with the corresponding length to the * algorithm - * @param {String} data data to be - * @return {String} string-representation of the packet + * @param {String} data Data to be + * @return {String} String-representation of the packet */ function write_packet(algo, key, data) { var result = ""; @@ -9441,7 +9479,8 @@ function openpgp_packet_encrypteddata() { /** * @class - * @classdesc Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18) + * @classdesc 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 @@ -9458,12 +9497,12 @@ function openpgp_packet_encryptedintegrityprotecteddata() { this.decrytpedData = null; // string this.hash = null; // string /** - * parsing function for the packet. + * Parsing function for the packet. * - * @param {string} input payload of a tag 18 packet - * @param {integer} position + * @param {String} input Payload of a tag 18 packet + * @param {Integer} position * position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of + * @param {Integer} len Length of the packet or the remaining length of * input at position * @return {openpgp_packet_encryptedintegrityprotecteddata} object * representation @@ -9496,12 +9535,12 @@ function openpgp_packet_encryptedintegrityprotecteddata() { * Creates a string representation of a Sym. Encrypted Integrity Protected * Data Packet (tag 18) (see RFC4880 5.13) * - * @param {integer} symmetric_algorithm - * the selected symmetric encryption algorithm to be used - * @param {String} key the key of cipher blocksize length to be used - * @param data - * plaintext data to be encrypted within the packet - * @return a string representation of the packet + * @param {Integer} symmetric_algorithm + * The selected symmetric encryption algorithm to be used + * @param {String} key The key of cipher blocksize length to be used + * @param {String} data + * Plaintext data to be encrypted within the packet + * @return {String} A string representation of the packet */ function write_packet(symmetric_algorithm, key, data) { @@ -9531,10 +9570,10 @@ function openpgp_packet_encryptedintegrityprotecteddata() { * Decrypts the encrypted data contained in this object read_packet must * have been called before * - * @param {integer} symmetric_algorithm_type - * the selected symmetric encryption algorithm to be used - * @param {String} key the key of cipher blocksize length to be used - * @return the decrypted data of this packet + * @param {Integer} symmetric_algorithm_type + * The selected symmetric encryption algorithm to be used + * @param {String} key The key of cipher blocksize length to be used + * @return {String} The decrypted data of this packet */ function decrypt(symmetric_algorithm_type, key) { this.decryptedData = openpgp_crypto_symmetricDecrypt( @@ -9612,13 +9651,13 @@ function openpgp_packet_encryptedintegrityprotecteddata() { function openpgp_packet_encryptedsessionkey() { /** - * parsing function for a publickey encrypted session key packet (tag 1). + * Parsing function for a publickey encrypted session key packet (tag 1). * - * @param {string} input payload of a tag 1 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of + * @param {String} input Payload of a tag 1 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_pub_key_packet(input, position, len) { this.tagType = 1; @@ -9661,21 +9700,22 @@ function openpgp_packet_encryptedsessionkey() { } /** - * create a string representation of a tag 1 packet + * Create a string representation of a tag 1 packet * * @param {String} publicKeyId - * the public key id corresponding to publicMPIs key as string - * @param {Array[openpgp_type_mpi]} publicMPIs - * multiprecision integer objects describing the public key - * @param {integer} pubalgo - * the corresponding public key algorithm // See RFC4880 9.1 - * @param {integer} symmalgo - * the symmetric cipher algorithm used to encrypt the data within - * an encrypteddatapacket or encryptedintegrityprotecteddatapacket + * The public key id corresponding to publicMPIs key as string + * @param {openpgp_type_mpi[]} publicMPIs + * Multiprecision integer objects describing the public key + * @param {Integer} pubalgo + * The corresponding public key algorithm // See RFC4880 9.1 + * @param {Integer} symmalgo + * The symmetric cipher algorithm used to encrypt the data + * within an encrypteddatapacket or encryptedintegrity- + * protecteddatapacket * following this packet //See RFC4880 9.2 * @param {String} sessionkey - * a string of randombytes representing the session key - * @return {String} the string representation + * A string of randombytes representing the session key + * @return {String} The string representation */ function write_pub_key_packet(publicKeyId, publicMPIs, pubalgo, symmalgo, sessionkey) { @@ -9699,14 +9739,14 @@ function openpgp_packet_encryptedsessionkey() { } /** - * parsing function for a symmetric encrypted session key packet (tag 3). + * Parsing function for a symmetric encrypted session key packet (tag 3). * - * @param {string} input payload of a tag 1 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len - * length of the packet or the remaining length of + * @param {String} input Payload of a tag 1 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len + * Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_symmetric_key_packet(input, position, len) { this.tagType = 3; @@ -9735,10 +9775,10 @@ function openpgp_packet_encryptedsessionkey() { * packets (tag 1) * * @param {openpgp_msg_message} msg - * the message object (with member encryptedData + * The message object (with member encryptedData * @param {openpgp_msg_privatekey} key - * private key with secMPIs unlocked - * @return {String} the unencrypted session key + * Private key with secMPIs unlocked + * @return {String} The unencrypted session key */ function decrypt(msg, key) { if (this.tagType == 1) { @@ -9765,7 +9805,7 @@ function openpgp_packet_encryptedsessionkey() { * Creates a string representation of this object (useful for debug * purposes) * - * @return the string containing a openpgp description + * @return {String} The string containing a openpgp description */ function toString() { if (this.tagType == 1) { @@ -9820,16 +9860,16 @@ function openpgp_packet_encryptedsessionkey() { /** * @class - * @classdesc Parent openpgp packet class. Operations focus on determining packet types - * and packet header. + * @classdesc Parent openpgp packet class. Operations focus on determining + * packet types and packet header. */ function _openpgp_packet() { /** * Encodes a given integer of length to the openpgp length specifier to a * string * - * @param {Integer} length of the length to encode - * @return {string} string with openpgp length representation + * @param {Integer} length The length to encode + * @return {String} String with openpgp length representation */ function encode_length(length) { result = ""; @@ -9857,9 +9897,9 @@ function _openpgp_packet() { * Writes a packet header version 4 with the given tag_type and length to a * string * - * @param {integer} tag_type tag type - * @param {integer} length length of the payload - * @return {string} string of the header + * @param {Integer} tag_type Tag type + * @param {Integer} length Length of the payload + * @return {String} String of the header */ function write_packet_header(tag_type, length) { /* we're only generating v4 packet headers here */ @@ -9873,9 +9913,9 @@ function _openpgp_packet() { * Writes a packet header Version 3 with the given tag_type and length to a * string * - * @param {integer} tag_type tag type - * @param {integer} length length of the payload - * @return {string} string of the header + * @param {Integer} tag_type Tag type + * @param {Integer} length Length of the payload + * @return {String} String of the header */ function write_old_packet_header(tag_type, length) { var result = ""; @@ -9900,10 +9940,10 @@ function _openpgp_packet() { /** * Generic static Packet Parser function * - * @param {String} input input stream as string - * @param {integer} position position to start parsing - * @param {integer} len length of the input from position on - * @return {openpgp_packet_*} returns a parsed openpgp_packet + * @param {String} input Input stream as string + * @param {integer} position Position to start parsing + * @param {integer} len Length of the input from position on + * @return {Object} Returns a parsed openpgp_packet */ function read_packet(input, position, len) { // some sanity checks @@ -10260,10 +10300,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a secret key packet (Tag 5) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Intefer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag5(input, position, len) { this.tagType = 5; @@ -10275,10 +10315,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a public key packet (Tag 6) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag6(input, position, len) { // A Public-Key packet starts a series of packets that forms an OpenPGP @@ -10294,10 +10334,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a secret key sub packet (Tag 7) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag7(input, position, len) { this.tagType = 7; @@ -10309,10 +10349,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a public key sub packet (Tag 14) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag14(input, position, len) { this.subKeySignature = null; @@ -10324,12 +10364,13 @@ function openpgp_packet_keymaterial() { } /** - * Internal Parser for public keys as specified in RFC 4880 section 5.5.2 Public-Key Packet Formats + * Internal Parser for public keys as specified in RFC 4880 section + * 5.5.2 Public-Key Packet Formats * called by read_tag<num> - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return this object with attributes set by the parser + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {Object} This object with attributes set by the parser */ function read_pub_key(input, position, len) { var mypos = position; @@ -10436,10 +10477,10 @@ function openpgp_packet_keymaterial() { /** * Internal parser for private keys as specified in RFC 4880 section 5.5.3 - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return this object with attributes set by the parser + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {Object} This object with attributes set by the parser */ function read_priv_key(input,position, len) { // - A Public-Key or Public-Subkey packet, as described above. @@ -10572,11 +10613,13 @@ function openpgp_packet_keymaterial() { /** * Decrypts the private key MPIs which are needed to use the key. - * openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be false otherwise + * openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be + * false otherwise * a call to this function is not needed * - * @param str_passphrase the passphrase for this private key as string - * @return true if the passphrase was correct; false if not + * @param {String} str_passphrase The passphrase for this private key + * as string + * @return {Boolean} True if the passphrase was correct; false if not */ function decryptSecretMPIs(str_passphrase) { if (this.hasUnencryptedSecretKeyData) @@ -10759,11 +10802,11 @@ function openpgp_packet_keymaterial() { /** * Continue parsing packets belonging to the key material such as signatures - * @param {openpgp_*} parent_node the parent object - * @param {String} input input string to read the packet(s) from - * @param {integer} position start position for the parser - * @param {integer} len length of the packet(s) or remaining length of input - * @return {integer} length of nodes read + * @param {Object} parent_node The parent object + * @param {String} input Input string to read the packet(s) from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet(s) or remaining length of input + * @return {Integer} Length of nodes read */ function read_nodes(parent_node, input, position, len) { this.parentNode = parent_node; @@ -10840,7 +10883,7 @@ function openpgp_packet_keymaterial() { /** * Checks the validity for usage of this (sub)key - * @return 0 = bad key, 1 = expired, 2 = revoked, 3 = valid + * @return {Integer} 0 = bad key, 1 = expired, 2 = revoked, 3 = valid */ function verifyKey() { if (this.tagType == 14) { @@ -10868,8 +10911,8 @@ function openpgp_packet_keymaterial() { } /** - * calculates the key id of they key - * @return {String} a 8 byte key id + * Calculates the key id of they key + * @return {String} A 8 byte key id */ function getKeyId() { if (this.version == 4) { @@ -10883,8 +10926,8 @@ function openpgp_packet_keymaterial() { } /** - * calculates the fingerprint of the key - * @return {String} a string containing the fingerprint + * Calculates the fingerprint of the key + * @return {String} A string containing the fingerprint */ function getFingerprint() { if (this.version == 4) { @@ -10898,14 +10941,17 @@ function openpgp_packet_keymaterial() { } /* - * creates an OpenPGP key packet for the given key. much TODO in regards to s2k, subkeys. - * @param {int} keyType follows the OpenPGP algorithm standard, IE 1 corresponds to RSA. + * Creates an OpenPGP key packet for the given key. much + * TODO in regards to s2k, subkeys. + * @param {Integer} keyType Follows the OpenPGP algorithm standard, + * IE 1 corresponds to RSA. * @param {RSA.keyObject} key * @param password * @param s2kHash * @param symmetricEncryptionAlgorithm * @param timePacket - * @return {body: [string]OpenPGP packet body contents, header: [string] OpenPGP packet header, string: [string] header+body} + * @return {Object} {body: [string]OpenPGP packet body contents, + header: [string] OpenPGP packet header, string: [string] header+body} */ function write_private_key(keyType, key, password, s2kHash, symmetricEncryptionAlgorithm, timePacket){ this.symmetricEncryptionAlgorithm = symmetricEncryptionAlgorithm; @@ -10979,11 +11025,14 @@ function openpgp_packet_keymaterial() { } /* - * same as write_private_key, but has less information because of public key. - * @param {int} keyType follows the OpenPGP algorithm standard, IE 1 corresponds to RSA. + * Same as write_private_key, but has less information because of + * public key. + * @param {Integer} keyType Follows the OpenPGP algorithm standard, + * IE 1 corresponds to RSA. * @param {RSA.keyObject} key * @param timePacket - * @return {body: [string]OpenPGP packet body contents, header: [string] OpenPGP packet header, string: [string] header+body} + * @return {Object} {body: [string]OpenPGP packet body contents, + * header: [string] OpenPGP packet header, string: [string] header+body} */ function write_public_key(keyType, key, timePacket){ var tag = 6; @@ -11046,13 +11095,13 @@ function openpgp_packet_literaldata() { this.tagType = 11; /** - * parsing function for a literal data packet (tag 11). + * Parsing function for a literal data packet (tag 11). * - * @param {string} input payload of a tag 11 packet - * @param {integer} position - * position to start reading from the input string - * @param {integer} len - * length of the packet or the remaining length of + * @param {String} input Payload of a tag 11 packet + * @param {Integer} position + * Position to start reading from the input string + * @param {Integer} len + * Length of the packet or the remaining length of * input at position * @return {openpgp_packet_encrypteddata} object representation */ @@ -11073,7 +11122,7 @@ function openpgp_packet_literaldata() { /** * Creates a string representation of the packet * - * @param {String} data the data to be inserted as body + * @param {String} data The data to be inserted as body * @return {String} string-representation of the packet */ function write_packet(data) { @@ -11100,9 +11149,9 @@ function openpgp_packet_literaldata() { } /** - * generates debug output (pretty print) + * Generates debug output (pretty print) * - * @return {string} String which gives some information about the keymaterial + * @return {String} String which gives some information about the keymaterial */ function toString() { return '5.9. Literal Data Packet (Tag 11)\n' + ' length: ' @@ -11147,15 +11196,15 @@ function openpgp_packet_literaldata() { function openpgp_packet_marker() { this.tagType = 10; /** - * parsing function for a literal data packet (tag 10). + * Parsing function for a literal data packet (tag 10). * - * @param {string} input payload of a tag 10 packet - * @param {integer} position - * position to start reading from the input string - * @param {integer} len - * length of the packet or the remaining length of + * @param {String} input Payload of a tag 10 packet + * @param {Integer} position + * Position to start reading from the input string + * @param {Integer} len + * Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_packet(input, position, len) { this.packetLength = 3; @@ -11170,7 +11219,8 @@ function openpgp_packet_marker() { /** * Generates Debug output * - * @return {string} String which gives some information about the keymaterial + * @return {String} String which gives some information about the + * keymaterial */ function toString() { return "5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)\n" @@ -11249,8 +11299,8 @@ function openpgp_packet_modificationdetectioncode() { /** * generates debug output (pretty print) * - * @return {string} String which gives some information about the modification - * detection code + * @return {String} String which gives some information about the + * modification detection code */ function toString() { return '5.14 Modification detection code packet\n' + ' bytes (' @@ -11298,9 +11348,9 @@ function openpgp_packet_onepasssignature() { /** * parsing function for a one-pass signature packet (tag 4). - * @param {string} input payload of a tag 4 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 4 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet(input, position, len) { @@ -11333,10 +11383,10 @@ function openpgp_packet_onepasssignature() { /** * creates a string representation of a one-pass signature packet - * @param {integer} type Signature types as described in RFC4880 Section 5.2.1. - * @param {integer} hashalgorithm the hash algorithm used within the signature + * @param {Integer} type Signature types as described in RFC4880 Section 5.2.1. + * @param {Integer} hashalgorithm the hash algorithm used within the signature * @param {openpgp_msg_privatekey} privatekey the private key used to generate the signature - * @param {integer} length length of data to be signed + * @param {Integer} length length of data to be signed * @param {boolean} nested boolean showing whether the signature is nested. * "true" indicates that the next packet is another One-Pass Signature packet * that describes another signature to be applied to the same message data. @@ -11361,7 +11411,7 @@ function openpgp_packet_onepasssignature() { /** * generates debug output (pretty print) - * @return {string} String which gives some information about the one-pass signature packet + * @return {String} String which gives some information about the one-pass signature packet */ function toString() { return '5.4. One-Pass Signature Packets (Tag 4)\n'+ @@ -11450,9 +11500,9 @@ function openpgp_packet_signature() { /** * parsing function for a signature packet (tag 2). - * @param {string} input payload of a tag 2 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 2 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet(input, position, len) { @@ -11590,10 +11640,10 @@ function openpgp_packet_signature() { /** * creates a string representation of a message signature packet (tag 2). * This can be only used on text data - * @param {integer} signature_type should be 1 (one) + * @param {Integer} signature_type should be 1 (one) * @param {String} data data to be signed * @param {openpgp_msg_privatekey} privatekey private key used to sign the message. (secMPIs MUST be unlocked) - * @return {string} string representation of a signature packet + * @return {String} string representation of a signature packet */ function write_message_signature(signature_type, data, privatekey) { var publickey = privatekey.privateKeyPacket.publicKey; @@ -11636,7 +11686,7 @@ function openpgp_packet_signature() { } /** * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) - * @param {integer} type subpacket signature type. Signature types as described in RFC4880 Section 5.2.3.2 + * @param {Integer} type subpacket signature type. Signature types as described in RFC4880 Section 5.2.3.2 * @param {String} data data to be included * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) */ @@ -12016,7 +12066,7 @@ function openpgp_packet_signature() { } /** * generates debug output (pretty print) - * @return {string} String which gives some information about the signature packet + * @return {String} String which gives some information about the signature packet */ function toString () { @@ -12087,7 +12137,7 @@ function openpgp_packet_signature() { /** * Tries to get the corresponding public key out of the public keyring for the issuer created this signature - * @return {obj: [openpgp_msg_publickey], text: [String]} if found the public key will be returned. null otherwise + * @return {Object} {obj: [openpgp_msg_publickey], text: [String]} if found the public key will be returned. null otherwise */ function getIssuerKey() { var result = null; @@ -12150,9 +12200,9 @@ function openpgp_packet_userattribute() { /** * parsing function for a user attribute packet (tag 17). - * @param {string} input payload of a tag 17 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 17 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet (input, position, len) { @@ -12198,7 +12248,7 @@ function openpgp_packet_userattribute() { /** * generates debug output (pretty print) - * @return {string} String which gives some information about the user attribute packet + * @return {String} String which gives some information about the user attribute packet */ function toString() { var result = '5.12. User Attribute Packet (Tag 17)\n'+ @@ -12211,11 +12261,11 @@ function openpgp_packet_userattribute() { /** * Continue parsing packets belonging to the user attribute packet such as signatures - * @param {openpgp_*} parent_node the parent object + * @param {Object} parent_node the parent object * @param {String} input input string to read the packet(s) from - * @param {integer} position start position for the parser - * @param {integer} len length of the packet(s) or remaining length of input - * @return {integer} length of nodes read + * @param {Integer} position start position for the parser + * @param {Integer} len length of the packet(s) or remaining length of input + * @return {Integer} length of nodes read */ function read_nodes(parent_node, input, position, len) { @@ -12298,9 +12348,9 @@ function openpgp_packet_userid() { /** * parsing function for a user id packet (tag 13). - * @param {string} input payload of a tag 13 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 13 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet(input, position, len) { @@ -12327,11 +12377,11 @@ function openpgp_packet_userid() { /** * Continue parsing packets belonging to the userid packet such as signatures - * @param {openpgp_*} parent_node the parent object + * @param {Object} parent_node the parent object * @param {String} input input string to read the packet(s) from - * @param {integer} position start position for the parser - * @param {integer} len length of the packet(s) or remaining length of input - * @return {integer} length of nodes read + * @param {Integer} position start position for the parser + * @param {Integer} len length of the packet(s) or remaining length of input + * @return {Integer} length of nodes read */ function read_nodes(parent_node, input, position, len) { if (parent_node.tagType == 6) { // public key @@ -12411,7 +12461,7 @@ function openpgp_packet_userid() { /** * generates debug output (pretty print) - * @return {string} String which gives some information about the user id packet + * @return {String} String which gives some information about the user id packet */ function toString() { var result = ' 5.11. User ID Packet (Tag 13)\n' + ' text (' @@ -12430,7 +12480,7 @@ function openpgp_packet_userid() { /** * lookup function to find certification revocation signatures - * @param {string} keyId string containing the key id of the issuer of this signature + * @param {String} keyId string containing the key id of the issuer of this signature * @return a CertificationRevocationSignature if found; otherwise null */ function hasCertificationRevocationSignature(keyId) { @@ -12446,8 +12496,8 @@ function openpgp_packet_userid() { /** * Verifies all certification signatures. This method does not consider possible revocation signatures. - * @param publicKeyPacket the top level key material - * @return an array of integers corresponding to the array of certification signatures. The meaning of each integer is the following: + * @param {Object} publicKeyPacket the top level key material + * @return {Integer[]} An array of integers corresponding to the array of certification signatures. The meaning of each integer is the following: * 0 = bad signature * 1 = signature expired * 2 = issuer key not available @@ -12625,10 +12675,11 @@ function openpgp_packet_userid() { */ function openpgp_type_keyid() { /** - * parsing method for a key id - * @param {String} input input to read the key id from - * @param {integer} position position where to start reading the key id from input - * @return this object + * Parsing method for a key id + * @param {String} input Input to read the key id from + * @param {integer} position Position where to start reading the key + * id from input + * @return {openpgp_type_keyid} This object */ function read_packet(input, position) { this.bytes = input.substring(position, position+8); @@ -12636,7 +12687,7 @@ function openpgp_type_keyid() { } /** - * generates debug output (pretty print) + * Generates debug output (pretty print) * @return {String} Key Id as hexadecimal string */ function toString() { @@ -12684,11 +12735,13 @@ function openpgp_type_mpi() { this.mpiByteLength = null; this.data = null; /** - * parsing function for a mpi (RFC 4880 3.2). - * @param {string} input payload of mpi data - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position - * @return {openpgp_type_mpi} object representation + * Parsing function for a mpi (RFC 4880 3.2). + * @param {String} input Payload of mpi data + * @param {Integer} position Position to start reading from the input + * string + * @param {Integer} len Length of the packet or the remaining length of + * input at position + * @return {openpgp_type_mpi} Object representation */ function read(input, position, len) { var mypos = position; @@ -12716,8 +12769,8 @@ function openpgp_type_mpi() { } /** - * generates debug output (pretty print) - * @return {string} String which gives some information about the mpi + * Generates debug output (pretty print) + * @return {String} String which gives some information about the mpi */ function toString() { var r = " MPI("+this.mpiBitLength+"b/"+this.mpiByteLength+"B) : 0x"; @@ -12726,7 +12779,7 @@ function openpgp_type_mpi() { } /** - * converts the mpi to an BigInteger object + * Converts the mpi to an BigInteger object * @return {BigInteger} */ function getBigInteger() { @@ -12741,16 +12794,16 @@ function openpgp_type_mpi() { } /** - * gets the length of the mpi in bytes - * @return {integer} mpi byte length + * Gets the length of the mpi in bytes + * @return {Integer} Mpi byte length */ function getByteLength() { return this.mpiByteLength; } /** - * creates an mpi from the specified string - * @param {String} data data to read the mpi from + * Creates an mpi from the specified string + * @param {String} data Data to read the mpi from * @return {openpgp_type_mpi} */ function create(data) { @@ -12761,8 +12814,8 @@ function openpgp_type_mpi() { } /** - * converts the mpi object to a string as specified in RFC4880 3.2 - * @return {String} mpi byte representation + * Converts the mpi object to a string as specified in RFC4880 3.2 + * @return {String} mpi Byte representation */ function toBin() { var result = String.fromCharCode((this.mpiBitLength >> 8) & 0xFF); @@ -12807,10 +12860,10 @@ function openpgp_type_mpi() { */ function openpgp_type_s2k() { /** - * parsing function for a string-to-key specifier (RFC 4880 3.7). - * @param {string} input payload of string-to-key specifier - * @param {integer} position position to start reading from the input string - * @return {openpgp_type_s2k} object representation + * Parsing function for a string-to-key specifier (RFC 4880 3.7). + * @param {String} input Payload of string-to-key specifier + * @param {Integer} position Position to start reading from the input string + * @return {openpgp_type_s2k} Object representation */ function read(input, position) { var mypos = position; @@ -12875,7 +12928,7 @@ function openpgp_type_s2k() { /** * writes an s2k hash based on the inputs. - * @return {String} produced key of hashAlgorithm hash length + * @return {String} Produced key of hashAlgorithm hash length */ function write(type, hash, passphrase, salt, c){ this.type = type; @@ -12888,9 +12941,11 @@ function openpgp_type_s2k() { } /** - * produces a key using the specified passphrase and the defined hashAlgorithm - * @param passphrase {String} passphrase containing user input - * @return {String} produced key with a length corresponding to hashAlgorithm hash length + * Produces a key using the specified passphrase and the defined + * hashAlgorithm + * @param {String} passphrase Passphrase containing user input + * @return {String} Produced key with a length corresponding to + * hashAlgorithm hash length */ function produce_key(passphrase, numBytes) { if (this.type == 0) { @@ -12956,9 +13011,9 @@ var Util = function() { }; /** - * create hexstring from a binary - * @param str [String] string to convert - * @return [String] string containing the hexadecimal values + * Create hexstring from a binary + * @param {String} str String to convert + * @return {String} String containing the hexadecimal values */ this.hexstrdump = function(str) { if (str == null) @@ -12976,9 +13031,9 @@ var Util = function() { }; /** - * create binary string from a hex encoded string - * @param str [String] hex string to convert - * @return [String] string containing the binary values + * Create binary string from a hex encoded string + * @param {String} str Hex string to convert + * @return {String} String containing the binary values */ this.hex2bin = function(hex) { var str = ''; @@ -12988,9 +13043,9 @@ var Util = function() { }; /** - * creating a hex string from an binary array of integers (0..255) - * @param [Array[integer 0..255]] array to convert - * @return [String] hexadecimal representation of the array + * Creating a hex string from an binary array of integers (0..255) + * @param {String} str Array of bytes to convert + * @return {String} Hexadecimal representation of the array */ this.hexidump = function(str) { var r=[]; @@ -13006,9 +13061,9 @@ var Util = function() { }; /** - * convert a string to an array of integers(0.255) - * @param [String] string to convert - * @return [Array [Integer 0..255]] array of (binary) integers + * Convert a string to an array of integers(0.255) + * @param {String} str String to convert + * @return {Integer[]} An array of (binary) integers */ this.str2bin = function(str) { var result = new Array(); @@ -13020,9 +13075,9 @@ var Util = function() { }; /** - * convert an array of integers(0.255) to a string - * @param [Array [Integer 0..255]] array of (binary) integers to convert - * @return [String] string representation of the array + * Convert an array of integers(0.255) to a string + * @param {Integer[]} bin An array of (binary) integers to convert + * @return {String} The string representation of the array */ this.bin2str = function(bin) { var result = []; @@ -13033,9 +13088,9 @@ var Util = function() { }; /** - * convert a string to a Uint8Array - * @param [String] string to convert - * @return [Uint8Array] array of (binary) integers + * Convert a string to a Uint8Array + * @param {String} str String to convert + * @return {Uint8Array} The array of (binary) integers */ this.str2Uint8Array = function(str){ var uintArray = new Uint8Array(new ArrayBuffer(str.length)); @@ -13046,9 +13101,10 @@ var Util = function() { }; /** - * convert a Uint8Array to a string. This currently functions the same as bin2str. - * @param [Uint8Array] array of (binary) integers to convert - * @return [String] string representation of the array + * Convert a Uint8Array to a string. This currently functions + * the same as bin2str. + * @param {Uint8Array} bin An array of (binary) integers to convert + * @return {String} String representation of the array */ this.Uint8Array2str = function(bin) { var result = []; @@ -13059,9 +13115,11 @@ var Util = function() { }; /** - * calculates a 16bit sum of a string by adding each character codes modulus 65535 - * @param text [String] string to create a sum of - * @return [Integer] an integer containing the sum of all character codes % 65535 + * Calculates a 16bit sum of a string by adding each character + * codes modulus 65535 + * @param {String} text String to create a sum of + * @return {Integer} An integer containing the sum of all character + * codes % 65535 */ this.calc_checksum = function(text) { var checksum = { s: 0, add: function (sadd) { this.s = (this.s + sadd) % 65536; }}; @@ -13078,8 +13136,9 @@ var Util = function() { * Javascript context MUST define * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
' - * @param str [String] string of the debug message - * @return [String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in. + * @param {String} str String of the debug message + * @return {String} An HTML tt entity containing a paragraph with a + * style attribute where the debug message is HTMLencoded in. */ this.print_debug = function(str) { if (openpgp.config.debug) { @@ -13096,8 +13155,9 @@ var Util = function() { * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
' * Different than print_debug because will call hexstrdump iff necessary. - * @param str [String] string of the debug message - * @return [String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in. + * @param {String} str String of the debug message + * @return {String} An HTML tt entity containing a paragraph with a + * style attribute where the debug message is HTMLencoded in. */ this.print_debug_hexstr_dump = function(str,strToHex) { if (openpgp.config.debug) { @@ -13112,8 +13172,9 @@ var Util = function() { * The calling Javascript context MUST define * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
' - * @param str [String] string of the error message - * @return [String] a HTML paragraph entity with a style attribute containing the HTML encoded error message + * @param {String} str String of the error message + * @return {String} A HTML paragraph entity with a style attribute + * containing the HTML encoded error message */ this.print_error = function(str) { str = openpgp_encoding_html_encode(str); @@ -13125,8 +13186,9 @@ var Util = function() { * The calling Javascript context MUST define * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
'. - * @param str [String] string of the info message - * @return [String] a HTML paragraph entity with a style attribute containing the HTML encoded info message + * @param {String} str String of the info message + * @return {String} A HTML paragraph entity with a style attribute + * containing the HTML encoded info message */ this.print_info = function(str) { str = openpgp_encoding_html_encode(str); @@ -13146,11 +13208,13 @@ var Util = function() { var result = string.substring(0, bytes); return this.shiftRight(result, 8-rest); // +String.fromCharCode(string.charCodeAt(bytes -1) << (8-rest) & 0xFF); }; + /** * Shifting a string to n bits right - * @param value [String] the string to shift - * @param bitcount [Integer] amount of bits to shift (MUST be smaller than 9) - * @return [String] resulting string. + * @param {String} value The string to shift + * @param {Integer} bitcount Amount of bits to shift (MUST be smaller + * than 9) + * @return {String} Resulting string. */ this.shiftRight = function(value, bitcount) { var temp = util.str2bin(value); @@ -13168,7 +13232,7 @@ var Util = function() { /** * Return the algorithm type as string - * @return [String] String representing the message type + * @return {String} String representing the message type */ this.get_hashAlgorithmString = function(algo) { switch(algo) { diff --git a/resources/openpgp.min.js b/resources/openpgp.min.js index 32c6ab37..8402d094 100644 --- a/resources/openpgp.min.js +++ b/resources/openpgp.min.js @@ -2,29 +2,7 @@ function DSA(){this.select_hash_algorithm=function(b){var a=openpgp.config.confi e.subtract(BigInteger.ONE));c=c.modPow(a,d).mod(e);e=a.modInverse(e).multiply(b.add(f.multiply(c))).mod(e);f=[];f[0]=c.toMPI();f[1]=e.toMPI();return f};this.verify=function(b,a,c,d,e,f,g,h){b=util.getLeftNBits(openpgp_crypto_hashData(b,d),f.bitLength());b=new BigInteger(util.hexstrdump(b),16);if(0>15;0<=--f;){var h=this[b]&32767,j=this[b++]>>15,k=a*h+j*g,h=g*h+((k&32767)<<15)+c[d]+(e&1073741823),e=(h>>>30)+(k>>>15)+a*j+(e>>>30);c[d++]=h&1073741823}return e}function am3(b,a,c,d,e,f){for(var g=a&16383,a=a>>14;0<=--f;){var h=this[b]&16383,j=this[b++]>>14,k=a*h+j*g,h=g*h+((k&16383)<<14)+c[d]+e,e=(h>>28)+(k>>14)+a*j;c[d++]=h&268435455}return e} -j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28);BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=vv;++vv)BI_RC[rr++]=vv;rr=97;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;rr=65;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;function int2char(b){return BI_RM.charAt(b)}function intAt(b,a){var c=BI_RC[b.charCodeAt(a)];return null==c?-1:c}function bnpCopyTo(b){for(var a=this.t-1;0<=a;--a)b[a]=this[a];b.t=this.t;b.s=this.s}function bnpFromInt(b){this.t=1;this.s=0>b?-1:0;0b?this[0]=b+DV:this.t=0}function nbv(b){var a=nbi();a.fromInt(b);return a} -function bnpFromString(b,a){var c;if(16==a)c=4;else if(8==a)c=3;else if(256==a)c=8;else if(2==a)c=1;else if(32==a)c=5;else if(4==a)c=2;else{this.fromRadix(b,a);return}this.s=this.t=0;for(var d=b.length,e=!1,f=0;0<=--d;){var g=8==c?b[d]&255:intAt(b,d);0>g?"-"==b.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<>this.DB-f):this[this.t-1]|=g<=this.DB&&(f-=this.DB))}if(8==c&&0!=(b[0]&128))this.s=-1,0this.s)return"-"+this.negate().toString(b);if(16==b)b=4;else if(8==b)b=3;else if(2==b)b=1;else if(32==b)b=5;else if(4==b)b=2;else return this.toRadix(b);var a=(1<>g))d=!0,e=int2char(c);for(;0<=f;)g>(g+=this.DB-b)):(c=this[f]>>(g-=b)&a,0>=g&&(g+=this.DB,--f)),0this.s?this.negate():this}function bnCompareTo(b){var a=this.s-b.s;if(0!=a)return a;var c=this.t,a=c-b.t;if(0!=a)return a;for(;0<=--c;)if(0!=(a=this[c]-b[c]))return a;return 0}function nbits(b){var a=1,c;if(0!=(c=b>>>16))b=c,a+=16;if(0!=(c=b>>8))b=c,a+=8;if(0!=(c=b>>4))b=c,a+=4;if(0!=(c=b>>2))b=c,a+=2;0!=b>>1&&(a+=1);return a} -function bnBitLength(){return 0>=this.t?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(b,a){var c;for(c=this.t-1;0<=c;--c)a[c+b]=this[c];for(c=b-1;0<=c;--c)a[c]=0;a.t=this.t+b;a.s=this.s}function bnpDRShiftTo(b,a){for(var c=b;c>d|g,g=(this[h]&e)<=this.t)a.t=0;else{var d=b%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;0>=this.DB;if(b.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=b.s}a.s=0>d?-1:0;-1>d?a[c++]=this.DV+d:0=a.DV)b[c+a.t]-=a.DV,b[c+a.t+1]=1}0=d.t)){var e=this.abs();if(e.t>this.F2:0),k=this.FV/j,j=(1<g&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(b){var a=nbi();this.abs().divRemTo(b,null,a);0>this.s&&0b.s||0<=b.compareTo(this.m)?b.mod(this.m):b}function cRevert(b){return b}function cReduce(b){b.divRemTo(this.m,null,b)}function cMulTo(b,a,c){b.multiplyTo(a,c);this.reduce(c)}function cSqrTo(b,a){b.squareTo(a);this.reduce(a)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo; -function bnpInvDigit(){if(1>this.t)return 0;var b=this[0];if(0==(b&1))return 0;var a=b&3,a=a*(2-(b&15)*a)&15,a=a*(2-(b&255)*a)&255,a=a*(2-((b&65535)*a&65535))&65535,a=a*(2-b*a%this.DV)%this.DV;return 0>15;this.um=(1<b.s&&0>15)*this.mpl&this.um)<<15)&b.DM,c=a+this.m.t;for(b[c]+=this.m.am(0,d,b,a,0,this.m.t);b[c]>=b.DV;)b[c]-=b.DV,b[++c]++}b.clamp();b.drShiftTo(this.m.t,b);0<=b.compareTo(this.m)&&b.subTo(this.m,b)}function montSqrTo(b,a){b.squareTo(a);this.reduce(a)}function montMulTo(b,a,c){b.multiplyTo(a,c);this.reduce(c)}Montgomery.prototype.convert=montConvert; -Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return 0==(0b)return BigInteger.ONE;var c=nbi(),d=nbi(),e=a.convert(this),f=nbits(b)-1;for(e.copyTo(c);0<=--f;)if(a.sqrTo(c,d),0<(b&1<b||a.isEven()?new Classic(a):new Montgomery(a);return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo; -BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt; -BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function bnClone(){var b=nbi();this.copyTo(b);return b}function bnIntValue(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(b){return Math.floor(Math.LN2*this.DB/Math.log(b))} +c).modInverse(c).multiply(a).mod(c)}}function bnClone(){var b=nbi();this.copyTo(b);return b}function bnIntValue(){if(0>this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(b){return Math.floor(Math.LN2*this.DB/Math.log(b))} function bnSigNum(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1}function bnpToRadix(b){null==b&&(b=10);if(0==this.signum()||2>b||36j?"-"==b.charAt(h)&&0==this.signum()&&(e=!0):(g=a*g+j,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),g=f=0))}0b)this.fromInt(1);else{this.fromNumber(b,c);this.testBit(b-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(b-1),op_or,this);for(this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(a);)this.dAddOffset(2,0),this.bitLength()>b&&this.subTo(BigInteger.ONE.shiftLeft(b-1),this)}else{var c=[],d=b&7;c.length=(b>>3)+1;a.nextBytes(c);c[0]=0>15;0<=--f;){var h=this[b]&32767,j=this[b++]>>15,k=a*h+j*g,h=g*h+((k&32767)<<15)+c[d]+(e&1073741823),e=(h>>>30)+(k>>>15)+a*j+(e>>>30);c[d++]=h&1073741823}return e}function am3(b,a,c,d,e,f){for(var g=a&16383,a=a>>14;0<=--f;){var h=this[b]&16383,j=this[b++]>>14,k=a*h+j*g,h=g*h+((k&16383)<<14)+c[d]+e,e=(h>>28)+(k>>14)+a*j;c[d++]=h&268435455}return e} +j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28);BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=vv;++vv)BI_RC[rr++]=vv;rr=97;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;rr=65;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;function int2char(b){return BI_RM.charAt(b)}function intAt(b,a){var c=BI_RC[b.charCodeAt(a)];return null==c?-1:c}function bnpCopyTo(b){for(var a=this.t-1;0<=a;--a)b[a]=this[a];b.t=this.t;b.s=this.s}function bnpFromInt(b){this.t=1;this.s=0>b?-1:0;0b?this[0]=b+DV:this.t=0}function nbv(b){var a=nbi();a.fromInt(b);return a} +function bnpFromString(b,a){var c;if(16==a)c=4;else if(8==a)c=3;else if(256==a)c=8;else if(2==a)c=1;else if(32==a)c=5;else if(4==a)c=2;else{this.fromRadix(b,a);return}this.s=this.t=0;for(var d=b.length,e=!1,f=0;0<=--d;){var g=8==c?b[d]&255:intAt(b,d);0>g?"-"==b.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<>this.DB-f):this[this.t-1]|=g<=this.DB&&(f-=this.DB))}if(8==c&&0!=(b[0]&128))this.s=-1,0this.s)return"-"+this.negate().toString(b);if(16==b)b=4;else if(8==b)b=3;else if(2==b)b=1;else if(32==b)b=5;else if(4==b)b=2;else return this.toRadix(b);var a=(1<>g))d=!0,e=int2char(c);for(;0<=f;)g>(g+=this.DB-b)):(c=this[f]>>(g-=b)&a,0>=g&&(g+=this.DB,--f)),0this.s?this.negate():this}function bnCompareTo(b){var a=this.s-b.s;if(0!=a)return a;var c=this.t,a=c-b.t;if(0!=a)return a;for(;0<=--c;)if(0!=(a=this[c]-b[c]))return a;return 0}function nbits(b){var a=1,c;if(0!=(c=b>>>16))b=c,a+=16;if(0!=(c=b>>8))b=c,a+=8;if(0!=(c=b>>4))b=c,a+=4;if(0!=(c=b>>2))b=c,a+=2;0!=b>>1&&(a+=1);return a} +function bnBitLength(){return 0>=this.t?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(b,a){var c;for(c=this.t-1;0<=c;--c)a[c+b]=this[c];for(c=b-1;0<=c;--c)a[c]=0;a.t=this.t+b;a.s=this.s}function bnpDRShiftTo(b,a){for(var c=b;c>d|g,g=(this[h]&e)<=this.t)a.t=0;else{var d=b%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;0>=this.DB;if(b.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=b.s}a.s=0>d?-1:0;-1>d?a[c++]=this.DV+d:0=a.DV)b[c+a.t]-=a.DV,b[c+a.t+1]=1}0=d.t)){var e=this.abs();if(e.t>this.F2:0),k=this.FV/j,j=(1<g&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(b){var a=nbi();this.abs().divRemTo(b,null,a);0>this.s&&0b.s||0<=b.compareTo(this.m)?b.mod(this.m):b}function cRevert(b){return b}function cReduce(b){b.divRemTo(this.m,null,b)}function cMulTo(b,a,c){b.multiplyTo(a,c);this.reduce(c)}function cSqrTo(b,a){b.squareTo(a);this.reduce(a)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo; +function bnpInvDigit(){if(1>this.t)return 0;var b=this[0];if(0==(b&1))return 0;var a=b&3,a=a*(2-(b&15)*a)&15,a=a*(2-(b&255)*a)&255,a=a*(2-((b&65535)*a&65535))&65535,a=a*(2-b*a%this.DV)%this.DV;return 0>15;this.um=(1<b.s&&0>15)*this.mpl&this.um)<<15)&b.DM,c=a+this.m.t;for(b[c]+=this.m.am(0,d,b,a,0,this.m.t);b[c]>=b.DV;)b[c]-=b.DV,b[++c]++}b.clamp();b.drShiftTo(this.m.t,b);0<=b.compareTo(this.m)&&b.subTo(this.m,b)}function montSqrTo(b,a){b.squareTo(a);this.reduce(a)}function montMulTo(b,a,c){b.multiplyTo(a,c);this.reduce(c)}Montgomery.prototype.convert=montConvert; +Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return 0==(0b)return BigInteger.ONE;var c=nbi(),d=nbi(),e=a.convert(this),f=nbits(b)-1;for(e.copyTo(c);0<=--f;)if(a.sqrTo(c,d),0<(b&1<b||a.isEven()?new Classic(a):new Montgomery(a);return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo; +BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt; +BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function SecureRandom(){this.nextBytes=function(b){for(var a=0;a>1;d.e=parseInt(c,16);for(d.ee=new BigInteger(c,16);;){for(;!(d.p=new BigInteger(a-f,1,e),0==d.p.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.p.isProbablePrime(10)););for(;!(d.q=new BigInteger(f,1,e),0==d.q.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.q.isProbablePrime(10));); if(0>=d.p.compareTo(d.q)){var g=d.p;d.p=d.q;d.q=g}var g=d.p.subtract(BigInteger.ONE),h=d.q.subtract(BigInteger.ONE),j=g.multiply(h);if(0==j.gcd(d.ee).compareTo(BigInteger.ONE)){d.n=d.p.multiply(d.q);d.d=d.ee.modInverse(j);d.dmp1=d.d.mod(g);d.dmq1=d.d.mod(h);d.u=d.p.modInverse(d.q);break}}return d};this.keyObject=b}function MD5(b){b=md5(b);return util.hex2bin(b)} @@ -285,7 +285,7 @@ JXG.Util.asciiCharCodeAt=function(b,a){var c=b.charCodeAt(a);if(255d?(a.push(String.fromCharCode(d)),c++):191d?(e=b.charCodeAt(c+1),a.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=b.charCodeAt(c+1),f=b.charCodeAt(c+2),a.push(String.fromCharCode((d&15)<<12|(e&63)<<6|f&63)),c+=3);return a.join("")}; JXG.Util.genUUID=function(){for(var b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),a=Array(36),c=0,d,e=0;36>e;e++)8==e||13==e||18==e||23==e?a[e]="-":14==e?a[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,a[e]=b[19==e?d&3|8:d]);return a.join("")}; -function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:2,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20130306";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var b=JSON.parse(window.localStorage.getItem("config"));null==b?(this.config=this.default_config,this.write()):this.config=b};this.write=function(){window.localStorage.setItem("config", +function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:2,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20130412";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var b=JSON.parse(window.localStorage.getItem("config"));null==b?(this.config=this.default_config,this.write()):this.config=b};this.write=function(){window.localStorage.setItem("config", JSON.stringify(this.config))}}var b64s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function s2r(b){var a,c,d,e="",f=0,g=0,h=b.length;for(d=0;d>2&63),a=(c&3)<<4):1==g?(e+=b64s.charAt(a|c>>4&15),a=(c&15)<<2):2==g&&(e+=b64s.charAt(a|c>>6&3),f+=1,0==f%60&&(e+="\n"),e+=b64s.charAt(c&63)),f+=1,0==f%60&&(e+="\n"),g+=1,3==g&&(g=0);0>6-e&255)),e=e+2&7,f=a<http://www.cs.tut.fi/~albert/Dev/gunzip/gunzip.c - * @see http://www.cs.tut.fi/~albert + * {@link http://www.cs.tut.fi/~albert/Dev/gunzip/gunzip.c} + * {@link http://www.cs.tut.fi/~albert} */ JXG.Util = {}; @@ -925,7 +925,7 @@ function skipdir(){ /** * Base64 encoding / decoding -* @see http://www.webtoolkit.info/ +* {@link http://www.webtoolkit.info/} */ JXG.Util.Base64 = { diff --git a/src/config/openpgp.config.js b/src/config/openpgp.config.js index a97188b7..1e655448 100644 --- a/src/config/openpgp.config.js +++ b/src/config/openpgp.config.js @@ -28,10 +28,21 @@ * @classdesc Implementation of the GPG4Browsers config object */ function openpgp_config() { + /** + * The variable with the actual configuration + * @property {Integer} prefer_hash_algorithm + * @property {Integer} encryption_cipher + * @property {Integer} compression + * @property {Boolean} show_version + * @property {Boolean} show_comment + * @property {Boolean} integrity_protect + * @property {Integer} composition_behavior + * @property {String} keyserver + */ this.config = null; /** - * the default config object which is used if no + * The default config object which is used if no * configuration was in place */ this.default_config = { @@ -48,10 +59,9 @@ function openpgp_config() { this.versionstring ="OpenPGP.js VERSION"; this.commentstring ="http://openpgpjs.org"; /** - * reads the config out of the HTML5 local storage + * Reads the config out of the HTML5 local storage * and initializes the object config. * if config is null the default config will be used - * @return [void] */ function read() { var cf = JSON.parse(window.localStorage.getItem("config")); @@ -64,13 +74,12 @@ function openpgp_config() { } /** - * if enabled, debug messages will be printed + * If enabled, debug messages will be printed */ this.debug = false; /** - * writes the config to HTML5 local storage - * @return [void] + * Writes the config to HTML5 local storage */ function write() { window.localStorage.setItem("config",JSON.stringify(this.config)); diff --git a/src/encoding/openpgp.encoding.asciiarmor.js b/src/encoding/openpgp.encoding.asciiarmor.js index 768131f6..40460ba2 100644 --- a/src/encoding/openpgp.encoding.asciiarmor.js +++ b/src/encoding/openpgp.encoding.asciiarmor.js @@ -16,9 +16,11 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /** - * DeArmor an OpenPGP armored message; verify the checksum and return the encoded bytes - * @text [String] OpenPGP armored message - * @return either the bytes of the decoded message or an object with attribute "text" containing the message text + * DeArmor an OpenPGP armored message; verify the checksum and return + * the encoded bytes + * @param {String} text OpenPGP armored message + * @returns {(String|Object)} Either the bytes of the decoded message + * or an object with attribute "text" containing the message text * and an attribute "openpgp" containing the bytes. */ function openpgp_encoding_deArmor(text) { @@ -45,8 +47,8 @@ function openpgp_encoding_deArmor(text) { /** * Finds out which Ascii Armoring type is used. This is an internal function - * @param text [String] ascii armored text - * @return 0 = MESSAGE PART n of m + * @param {String} text [String] ascii armored text + * @returns {Integer} 0 = MESSAGE PART n of m * 1 = MESSAGE PART n * 2 = SIGNED MESSAGE * 3 = PGP MESSAGE @@ -102,7 +104,7 @@ function getPGPMessageType(text) { * packet block. * @author Alex * @version 2011-12-16 - * @return The header information + * @returns {String} The header information */ function openpgp_encoding_armor_addheader() { var result = ""; @@ -118,11 +120,11 @@ function openpgp_encoding_armor_addheader() { /** * Armor an OpenPGP binary packet block - * @param messagetype type of the message + * @param {Integer} messagetype type of the message * @param data - * @param partindex - * @param parttotal - * @return {string} Armored text + * @param {Integer} partindex + * @param {Integer} parttotal + * @returns {String} Armored text */ function openpgp_encoding_armor(messagetype, data, partindex, parttotal) { var result = ""; @@ -178,8 +180,8 @@ function openpgp_encoding_armor(messagetype, data, partindex, parttotal) { /** * Calculates a checksum over the given data and returns it base64 encoded - * @param data [String] data to create a CRC-24 checksum for - * @return [String] base64 encoded checksum + * @param {String} data Data to create a CRC-24 checksum for + * @return {String} Base64 encoded checksum */ function getCheckSum(data) { var c = createcrc24(data); @@ -190,10 +192,11 @@ function getCheckSum(data) { } /** - * Calculates the checksum over the given data and compares it with the given base64 encoded checksum - * @param data [String] data to create a CRC-24 checksum for - * @param checksum [String] base64 encoded checksum - * @return true if the given checksum is correct; otherwise false + * Calculates the checksum over the given data and compares it with the + * given base64 encoded checksum + * @param {String} data Data to create a CRC-24 checksum for + * @param {String} checksum Base64 encoded checksum + * @return {Boolean} True if the given checksum is correct; otherwise false */ function verifyCheckSum(data, checksum) { var c = getCheckSum(data); @@ -202,8 +205,8 @@ function verifyCheckSum(data, checksum) { } /** * Internal function to calculate a CRC-24 checksum over a given string (data) - * @param data [String] data to create a CRC-24 checksum for - * @return [Integer] the CRC-24 checksum as number + * @param {String} data Data to create a CRC-24 checksum for + * @return {Integer} The CRC-24 checksum as number */ var crc_table = [ 0x00000000, 0x00864cfb, 0x018ad50d, 0x010c99f6, 0x0393e6e1, 0x0315aa1a, 0x021933ec, 0x029f7f17, 0x07a18139, 0x0727cdc2, 0x062b5434, 0x06ad18cf, 0x043267d8, 0x04b42b23, 0x05b8b2d5, 0x053efe2e, 0x0fc54e89, 0x0f430272, 0x0e4f9b84, 0x0ec9d77f, 0x0c56a868, 0x0cd0e493, 0x0ddc7d65, 0x0d5a319e, 0x0864cfb0, 0x08e2834b, 0x09ee1abd, 0x09685646, 0x0bf72951, 0x0b7165aa, 0x0a7dfc5c, 0x0afbb0a7, 0x1f0cd1e9, 0x1f8a9d12, 0x1e8604e4, 0x1e00481f, 0x1c9f3708, 0x1c197bf3, 0x1d15e205, 0x1d93aefe, 0x18ad50d0, 0x182b1c2b, 0x192785dd, 0x19a1c926, 0x1b3eb631, 0x1bb8faca, 0x1ab4633c, 0x1a322fc7, 0x10c99f60, 0x104fd39b, 0x11434a6d, 0x11c50696, 0x135a7981, 0x13dc357a, 0x12d0ac8c, 0x1256e077, 0x17681e59, 0x17ee52a2, 0x16e2cb54, 0x166487af, 0x14fbf8b8, 0x147db443, 0x15712db5, 0x15f7614e, 0x3e19a3d2, 0x3e9fef29, 0x3f9376df, 0x3f153a24, 0x3d8a4533, 0x3d0c09c8, 0x3c00903e, 0x3c86dcc5, 0x39b822eb, 0x393e6e10, 0x3832f7e6, 0x38b4bb1d, 0x3a2bc40a, 0x3aad88f1, 0x3ba11107, 0x3b275dfc, 0x31dced5b, 0x315aa1a0, diff --git a/src/encoding/openpgp.encoding.js b/src/encoding/openpgp.encoding.js index e68dd3f9..ca61448d 100644 --- a/src/encoding/openpgp.encoding.js +++ b/src/encoding/openpgp.encoding.js @@ -18,8 +18,8 @@ /** * Wrapper function for the base64 codec. * This function encodes a String (message) in base64 (radix-64) - * @param message [String] the message to encode - * @return [String] the base64 encoded data + * @param {String} message The message to encode + * @return {String} The base64 encoded data */ function openpgp_encoding_base64_encode(message) { return s2r(message); @@ -29,8 +29,8 @@ function openpgp_encoding_base64_encode(message) { /** * Wrapper function for the base64 codec. * This function decodes a String(message) in base64 (radix-64) - * @param message [String] base64 encoded data - * @return [String] raw data after decoding + * @param {String} message Base64 encoded data + * @return {String} Raw data after decoding */ function openpgp_encoding_base64_decode(message) { return r2s(message); @@ -38,9 +38,10 @@ function openpgp_encoding_base64_decode(message) { /** * Wrapper function for jquery library. - * This function escapes HTML characters within a string. This is used to prevent XSS. - * @param message [String] message to escape - * @return [String] html encoded string + * This function escapes HTML characters within a string. This is used + * to prevent XSS. + * @param {String} message Message to escape + * @return {String} Html encoded string */ function openpgp_encoding_html_encode(message) { if (message == null) @@ -50,9 +51,9 @@ function openpgp_encoding_html_encode(message) { /** * create a EME-PKCS1-v1_5 padding (See RFC4880 13.1.1) - * @param message [String] message to be padded - * @param length [Integer] length to the resulting message - * @return [String] EME-PKCS1 padded message + * @param {String} message message to be padded + * @param {Integer} length Length to the resulting message + * @return {String} EME-PKCS1 padded message */ function openpgp_encoding_eme_pkcs1_encode(message, length) { if (message.length > length-11) @@ -70,8 +71,8 @@ function openpgp_encoding_eme_pkcs1_encode(message, length) { /** * decodes a EME-PKCS1-v1_5 padding (See RFC4880 13.1.2) - * @param message [String] EME-PKCS1 padded message - * @return [String] decoded message + * @param {String} message EME-PKCS1 padded message + * @return {String} decoded message */ function openpgp_encoding_eme_pkcs1_decode(message, len) { if (message.length < len) @@ -97,10 +98,10 @@ hash_headers[11] = [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03, /** * create a EMSA-PKCS1-v1_5 padding (See RFC4880 13.1.3) - * @param algo [Integer] hash algorithm type used - * @param data [String] data to be hashed - * @param keylength [Integer] key size of the public mpi in bytes - * @return the [String] hashcode with pkcs1padding as string + * @param {Integer} algo Hash algorithm type used + * @param {String} data Data to be hashed + * @param {Integer} keylength Key size of the public mpi in bytes + * @returns {String} Hashcode with pkcs1padding as string */ function openpgp_encoding_emsa_pkcs1_encode(algo, data, keylength) { var data2 = ""; @@ -119,8 +120,8 @@ function openpgp_encoding_emsa_pkcs1_encode(algo, data, keylength) { /** * extract the hash out of an EMSA-PKCS1-v1.5 padding (See RFC4880 13.1.3) - * @param data [String] hash in pkcs1 encoding - * @return the hash as string + * @param {String} data Hash in pkcs1 encoding + * @returns {String} The hash as string */ function openpgp_encoding_emsa_pkcs1_decode(algo, data) { var i = 0; @@ -137,4 +138,4 @@ function openpgp_encoding_emsa_pkcs1_decode(algo, data) { i+= j; if (data.substring(i).length < openpgp_crypto_getHashByteLength(algo)) return -1; return data.substring(i); -} \ No newline at end of file +} diff --git a/src/openpgp.js b/src/openpgp.js index b5a56286..6f64cf23 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -35,7 +35,6 @@ function _openpgp () { * initializes the library: * - reading the keyring from local storage * - reading the config from local storage - * @return [void] */ function init() { this.config = new openpgp_config(); @@ -49,7 +48,7 @@ function _openpgp () { * representation an returns openpgp_msg_publickey packets * @param {String} armoredText OpenPGP armored text containing * the public key(s) - * @return {Array[openpgp_msg_publickey]} on error the function + * @return {openpgp_msg_publickey[]} on error the function * returns null */ function read_publicKey(armoredText) { @@ -95,7 +94,7 @@ function _openpgp () { * representation an returns openpgp_msg_privatekey objects * @param {String} armoredText OpenPGP armored text containing * the private key(s) - * @return {Array[openpgp_msg_privatekey]} on error the function + * @return {openpgp_msg_privatekey[]} on error the function * returns null */ function read_privateKey(armoredText) { @@ -125,7 +124,7 @@ function _openpgp () { * reads message packets out of an OpenPGP armored text and * returns an array of message objects * @param {String} armoredText text to be parsed - * @return {Array[openpgp_msg_message]} on error the function + * @return {openpgp_msg_message[]} on error the function * returns null */ function read_message(armoredText) { @@ -146,7 +145,7 @@ function _openpgp () { * External call will parse a de-armored messaged and return messages found. * Internal will be called to read packets wrapped in other packets (i.e. compressed) * @param {String} input dearmored text of OpenPGP packets, to be parsed - * @return {Array[openpgp_msg_message]} on error the function + * @return {openpgp_msg_message[]} on error the function * returns null */ function read_messages_dearmored(input){ @@ -291,10 +290,13 @@ function _openpgp () { * creates a binary string representation of an encrypted and signed message. * The message will be encrypted with the public keys specified and signed * with the specified private key. - * @param {obj: [openpgp_msg_privatekey]} privatekey private key to be used to sign the message - * @param {Array {obj: [openpgp_msg_publickey]}} publickeys public keys to be used to encrypt the message + * @param {Object} privatekey {obj: [openpgp_msg_privatekey]} Private key + * to be used to sign the message + * @param {Object[]} publickeys An arraf of {obj: [openpgp_msg_publickey]} + * - public keys to be used to encrypt the message * @param {String} messagetext message text to encrypt and sign - * @return {String} a binary string representation of the message which can be OpenPGP armored + * @return {String} a binary string representation of the message which + * can be OpenPGP armored */ function write_signed_and_encrypted_message(privatekey, publickeys, messagetext) { var result = ""; @@ -347,8 +349,8 @@ function _openpgp () { /** * creates a binary string representation of an encrypted message. * The message will be encrypted with the public keys specified - * @param {Array {obj: [openpgp_msg_publickey]}} publickeys public - * keys to be used to encrypt the message + * @param {Object[]} publickeys An array of {obj: [openpgp_msg_publickey]} + * -public keys to be used to encrypt the message * @param {String} messagetext message text to encrypt * @return {String} a binary string representation of the message * which can be OpenPGP armored @@ -389,12 +391,13 @@ function _openpgp () { /** * creates a binary string representation a signed message. * The message will be signed with the specified private key. - * @param {obj: [openpgp_msg_privatekey]} privatekey private - * key to be used to sign the message + * @param {Object} privatekey {obj: [openpgp_msg_privatekey]} + * - the private key to be used to sign the message * @param {String} messagetext message text to sign - * @return {Object: text [String]}, openpgp: {String} a binary + * @return {Object} {Object: text [String]}, openpgp: {String} a binary * string representation of the message which can be OpenPGP - * armored(openpgp) and a text representation of the message (text). This can be directly used to OpenPGP armor the message + * armored(openpgp) and a text representation of the message (text). + * This can be directly used to OpenPGP armor the message */ function write_signed_message(privatekey, messagetext) { var sig = new openpgp_packet_signature().write_message_signature(1, messagetext.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"), privatekey); @@ -403,11 +406,16 @@ function _openpgp () { } /** - * generates a new key pair for openpgp. Beta stage. Currently only supports RSA keys, and no subkeys. - * @param {int} keyType to indicate what type of key to make. RSA is 1. Follows algorithms outlined in OpenPGP. - * @param {int} numBits number of bits for the key creation. (should be 1024+, generally) - * @param {string} userId assumes already in form of "User Name " - * @return {privateKey: [openpgp_msg_privatekey], privateKeyArmored: [string], publicKeyArmored: [string]} + * generates a new key pair for openpgp. Beta stage. Currently only + * supports RSA keys, and no subkeys. + * @param {Integer} keyType to indicate what type of key to make. + * RSA is 1. Follows algorithms outlined in OpenPGP. + * @param {Integer} numBits number of bits for the key creation. (should + * be 1024+, generally) + * @param {String} userId assumes already in form of "User Name + * " + * @return {Object} {privateKey: [openpgp_msg_privatekey], + * privateKeyArmored: [string], publicKeyArmored: [string]} */ function generate_key_pair(keyType, numBits, userId, passphrase){ var userIdPacket = new openpgp_packet_userid(); diff --git a/src/openpgp.keyring.js b/src/openpgp.keyring.js index d30e28d9..92c953bc 100644 --- a/src/openpgp.keyring.js +++ b/src/openpgp.keyring.js @@ -25,7 +25,6 @@ function openpgp_keyring() { * Initialization routine for the keyring. This method reads the * keyring from HTML5 local storage and initializes this instance. * This method is called by openpgp.init(). - * @return {null} undefined */ function init() { var sprivatekeys = JSON.parse(window.localStorage.getItem("privatekeys")); @@ -58,7 +57,7 @@ function openpgp_keyring() { /** * Checks if at least one private key is in the keyring - * @return {boolean} True if there are private keys, else false. + * @return {Boolean} True if there are private keys, else false. */ function hasPrivateKey() { return this.privateKeys.length > 0; @@ -68,7 +67,6 @@ function openpgp_keyring() { /** * Saves the current state of the keyring to HTML5 local storage. * The privateKeys array and publicKeys array gets Stringified using JSON - * @return {null} undefined */ function store() { var priv = new Array(); @@ -85,8 +83,8 @@ function openpgp_keyring() { this.store = store; /** * searches all public keys in the keyring matching the address or address part of the user ids - * @param email_address - * @return {array[openpgp_msg_publickey]} the public keys associated with provided email address. + * @param {String} email_address + * @return {openpgp_msg_publickey[]} The public keys associated with provided email address. */ function getPublicKeyForAddress(email_address) { var results = new Array(); @@ -114,7 +112,7 @@ function openpgp_keyring() { /** * Searches the keyring for a private key containing the specified email address * @param {String} email_address email address to search for - * @return {Array[openpgp_msg_privatekey} private keys found + * @return {openpgp_msg_privatekey[]} private keys found */ function getPrivateKeyForAddress(email_address) { var results = new Array(); @@ -141,8 +139,8 @@ function openpgp_keyring() { this.getPrivateKeyForAddress = getPrivateKeyForAddress; /** * Searches the keyring for public keys having the specified key id - * @param keyId provided as string of hex number (lowercase) - * @return {Array[openpgp_msg_privatekey]} public keys found + * @param {String} keyId provided as string of hex number (lowercase) + * @return {openpgp_msg_privatekey[]} public keys found */ function getPublicKeysForKeyId(keyId) { var result = new Array(); @@ -169,7 +167,7 @@ function openpgp_keyring() { /** * Searches the keyring for private keys having the specified key id * @param {String} keyId 8 bytes as string containing the key id to look for - * @return {Array[openpgp_msg_privatekey]} private keys found + * @return {openpgp_msg_privatekey[]} private keys found */ function getPrivateKeyForKeyId(keyId) { var result = new Array(); @@ -192,7 +190,6 @@ function openpgp_keyring() { /** * Imports a public key from an exported ascii armored message * @param {String} armored_text PUBLIC KEY BLOCK message to read the public key from - * @return {null} nothing */ function importPublicKey (armored_text) { var result = openpgp.read_publicKey(armored_text); @@ -205,7 +202,6 @@ function openpgp_keyring() { /** * Imports a private key from an exported ascii armored message * @param {String} armored_text PRIVATE KEY BLOCK message to read the private key from - * @return {null} nothing */ function importPrivateKey (armored_text, password) { var result = openpgp.read_privateKey(armored_text); diff --git a/src/openpgp.msg.publickey.js b/src/openpgp.msg.publickey.js index 6d729152..8293707d 100644 --- a/src/openpgp.msg.publickey.js +++ b/src/openpgp.msg.publickey.js @@ -155,7 +155,7 @@ function openpgp_msg_publickey() { * - subkey binding and revocation certificates * * This is useful for validating the key - * @returns true if the basic signatures are all valid + * @returns {Boolean} true if the basic signatures are all valid */ function verifyBasicSignatures() { for (var i = 0; i < this.revocationSignatures.length; i++) { diff --git a/src/packet/openpgp.packet.compressed.js b/src/packet/openpgp.packet.compressed.js index 11fadb7d..e02ee4da 100644 --- a/src/packet/openpgp.packet.compressed.js +++ b/src/packet/openpgp.packet.compressed.js @@ -30,11 +30,12 @@ function openpgp_packet_compressed() { this.decompressedData = null; /** - * parsing function for the packet. - * @param {string} input payload of a tag 8 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position - * @return {openpgp_packet_compressed} object representation + * Parsing function for the packet. + * @param {String} input Payload of a tag 8 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len Length of the packet or the remaining length of + * input at position + * @return {openpgp_packet_compressed} Object representation */ function read_packet (input, position, len) { this.packetLength = len; @@ -46,9 +47,9 @@ function openpgp_packet_compressed() { return this; } /** - * decompression method for decompressing the compressed data + * Decompression method for decompressing the compressed data * read by read_packet - * @return {String} the decompressed data + * @return {String} The decompressed data */ function decompress() { if (this.decompressedData != null) @@ -99,8 +100,8 @@ function openpgp_packet_compressed() { /** * Compress the packet data (member decompressedData) - * @param {integer} type algorithm to be used // See RFC 4880 9.3 - * @param {String} data data to be compressed + * @param {Integer} type Algorithm to be used // See RFC 4880 9.3 + * @param {String} data Data to be compressed * @return {String} The compressed data stored in attribute compressedData */ function compress(type, data) { @@ -130,10 +131,10 @@ function openpgp_packet_compressed() { } /** - * creates a string representation of the packet - * @param {integer} algorithm algorithm to be used // See RFC 4880 9.3 - * @param {String} data data to be compressed - * @return {String} string-representation of the packet + * Creates a string representation of the packet + * @param {Integer} algorithm Algorithm to be used // See RFC 4880 9.3 + * @param {String} data Data to be compressed + * @return {String} String-representation of the packet */ function write_packet(algorithm, data) { this.decompressedData = data; @@ -145,7 +146,7 @@ function openpgp_packet_compressed() { } /** - * pretty printing the packet (useful for debug purposes) + * Pretty printing the packet (useful for debug purposes) * @return {String} */ function toString() { diff --git a/src/packet/openpgp.packet.encrypteddata.js b/src/packet/openpgp.packet.encrypteddata.js index bb47cc9f..be31467e 100644 --- a/src/packet/openpgp.packet.encrypteddata.js +++ b/src/packet/openpgp.packet.encrypteddata.js @@ -33,13 +33,13 @@ function openpgp_packet_encrypteddata() { this.decryptedData = null; /** - * parsing function for the packet. + * Parsing function for the packet. * - * @param {string} input payload of a tag 9 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of + * @param {String} input Payload of a tag 9 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_packet(input, position, len) { var mypos = position; @@ -51,14 +51,14 @@ function openpgp_packet_encrypteddata() { } /** - * symmetrically decrypt the packet data + * Symmetrically decrypt the packet data * - * @param {integer} symmetric_algorithm_type - * symmetric key algorithm to use // See RFC4880 9.2 + * @param {Integer} symmetric_algorithm_type + * Symmetric key algorithm to use // See RFC4880 9.2 * @param {String} key - * key as string with the corresponding length to the + * Key as string with the corresponding length to the * algorithm - * @return the decrypted data; + * @return The decrypted data; */ function decrypt_sym(symmetric_algorithm_type, key) { this.decryptedData = openpgp_crypto_symmetricDecrypt( @@ -71,11 +71,11 @@ function openpgp_packet_encrypteddata() { /** * Creates a string representation of the packet * - * @param {Integer} algo symmetric key algorithm to use // See RFC4880 9.2 - * @param {String} key key as string with the corresponding length to the + * @param {Integer} algo Symmetric key algorithm to use // See RFC4880 9.2 + * @param {String} key Key as string with the corresponding length to the * algorithm - * @param {String} data data to be - * @return {String} string-representation of the packet + * @param {String} data Data to be + * @return {String} String-representation of the packet */ function write_packet(algo, key, data) { var result = ""; diff --git a/src/packet/openpgp.packet.encryptedintegrityprotecteddata.js b/src/packet/openpgp.packet.encryptedintegrityprotecteddata.js index cbd5fc85..c1bcdca5 100644 --- a/src/packet/openpgp.packet.encryptedintegrityprotecteddata.js +++ b/src/packet/openpgp.packet.encryptedintegrityprotecteddata.js @@ -17,7 +17,8 @@ /** * @class - * @classdesc Implementation of the Sym. Encrypted Integrity Protected Data Packet (Tag 18) + * @classdesc 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 @@ -34,12 +35,12 @@ function openpgp_packet_encryptedintegrityprotecteddata() { this.decrytpedData = null; // string this.hash = null; // string /** - * parsing function for the packet. + * Parsing function for the packet. * - * @param {string} input payload of a tag 18 packet - * @param {integer} position + * @param {String} input Payload of a tag 18 packet + * @param {Integer} position * position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of + * @param {Integer} len Length of the packet or the remaining length of * input at position * @return {openpgp_packet_encryptedintegrityprotecteddata} object * representation @@ -72,12 +73,12 @@ function openpgp_packet_encryptedintegrityprotecteddata() { * Creates a string representation of a Sym. Encrypted Integrity Protected * Data Packet (tag 18) (see RFC4880 5.13) * - * @param {integer} symmetric_algorithm - * the selected symmetric encryption algorithm to be used - * @param {String} key the key of cipher blocksize length to be used - * @param data - * plaintext data to be encrypted within the packet - * @return a string representation of the packet + * @param {Integer} symmetric_algorithm + * The selected symmetric encryption algorithm to be used + * @param {String} key The key of cipher blocksize length to be used + * @param {String} data + * Plaintext data to be encrypted within the packet + * @return {String} A string representation of the packet */ function write_packet(symmetric_algorithm, key, data) { @@ -107,10 +108,10 @@ function openpgp_packet_encryptedintegrityprotecteddata() { * Decrypts the encrypted data contained in this object read_packet must * have been called before * - * @param {integer} symmetric_algorithm_type - * the selected symmetric encryption algorithm to be used - * @param {String} key the key of cipher blocksize length to be used - * @return the decrypted data of this packet + * @param {Integer} symmetric_algorithm_type + * The selected symmetric encryption algorithm to be used + * @param {String} key The key of cipher blocksize length to be used + * @return {String} The decrypted data of this packet */ function decrypt(symmetric_algorithm_type, key) { this.decryptedData = openpgp_crypto_symmetricDecrypt( diff --git a/src/packet/openpgp.packet.encryptedsessionkey.js b/src/packet/openpgp.packet.encryptedsessionkey.js index 6bdc5446..24a4961c 100644 --- a/src/packet/openpgp.packet.encryptedsessionkey.js +++ b/src/packet/openpgp.packet.encryptedsessionkey.js @@ -34,13 +34,13 @@ function openpgp_packet_encryptedsessionkey() { /** - * parsing function for a publickey encrypted session key packet (tag 1). + * Parsing function for a publickey encrypted session key packet (tag 1). * - * @param {string} input payload of a tag 1 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of + * @param {String} input Payload of a tag 1 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_pub_key_packet(input, position, len) { this.tagType = 1; @@ -83,21 +83,22 @@ function openpgp_packet_encryptedsessionkey() { } /** - * create a string representation of a tag 1 packet + * Create a string representation of a tag 1 packet * * @param {String} publicKeyId - * the public key id corresponding to publicMPIs key as string - * @param {Array[openpgp_type_mpi]} publicMPIs - * multiprecision integer objects describing the public key - * @param {integer} pubalgo - * the corresponding public key algorithm // See RFC4880 9.1 - * @param {integer} symmalgo - * the symmetric cipher algorithm used to encrypt the data within - * an encrypteddatapacket or encryptedintegrityprotecteddatapacket + * The public key id corresponding to publicMPIs key as string + * @param {openpgp_type_mpi[]} publicMPIs + * Multiprecision integer objects describing the public key + * @param {Integer} pubalgo + * The corresponding public key algorithm // See RFC4880 9.1 + * @param {Integer} symmalgo + * The symmetric cipher algorithm used to encrypt the data + * within an encrypteddatapacket or encryptedintegrity- + * protecteddatapacket * following this packet //See RFC4880 9.2 * @param {String} sessionkey - * a string of randombytes representing the session key - * @return {String} the string representation + * A string of randombytes representing the session key + * @return {String} The string representation */ function write_pub_key_packet(publicKeyId, publicMPIs, pubalgo, symmalgo, sessionkey) { @@ -121,14 +122,14 @@ function openpgp_packet_encryptedsessionkey() { } /** - * parsing function for a symmetric encrypted session key packet (tag 3). + * Parsing function for a symmetric encrypted session key packet (tag 3). * - * @param {string} input payload of a tag 1 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len - * length of the packet or the remaining length of + * @param {String} input Payload of a tag 1 packet + * @param {Integer} position Position to start reading from the input string + * @param {Integer} len + * Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_symmetric_key_packet(input, position, len) { this.tagType = 3; @@ -157,10 +158,10 @@ function openpgp_packet_encryptedsessionkey() { * packets (tag 1) * * @param {openpgp_msg_message} msg - * the message object (with member encryptedData + * The message object (with member encryptedData * @param {openpgp_msg_privatekey} key - * private key with secMPIs unlocked - * @return {String} the unencrypted session key + * Private key with secMPIs unlocked + * @return {String} The unencrypted session key */ function decrypt(msg, key) { if (this.tagType == 1) { @@ -187,7 +188,7 @@ function openpgp_packet_encryptedsessionkey() { * Creates a string representation of this object (useful for debug * purposes) * - * @return the string containing a openpgp description + * @return {String} The string containing a openpgp description */ function toString() { if (this.tagType == 1) { diff --git a/src/packet/openpgp.packet.js b/src/packet/openpgp.packet.js index e0a37a7a..cefb838e 100644 --- a/src/packet/openpgp.packet.js +++ b/src/packet/openpgp.packet.js @@ -17,16 +17,16 @@ /** * @class - * @classdesc Parent openpgp packet class. Operations focus on determining packet types - * and packet header. + * @classdesc Parent openpgp packet class. Operations focus on determining + * packet types and packet header. */ function _openpgp_packet() { /** * Encodes a given integer of length to the openpgp length specifier to a * string * - * @param {Integer} length of the length to encode - * @return {string} string with openpgp length representation + * @param {Integer} length The length to encode + * @return {String} String with openpgp length representation */ function encode_length(length) { result = ""; @@ -54,9 +54,9 @@ function _openpgp_packet() { * Writes a packet header version 4 with the given tag_type and length to a * string * - * @param {integer} tag_type tag type - * @param {integer} length length of the payload - * @return {string} string of the header + * @param {Integer} tag_type Tag type + * @param {Integer} length Length of the payload + * @return {String} String of the header */ function write_packet_header(tag_type, length) { /* we're only generating v4 packet headers here */ @@ -70,9 +70,9 @@ function _openpgp_packet() { * Writes a packet header Version 3 with the given tag_type and length to a * string * - * @param {integer} tag_type tag type - * @param {integer} length length of the payload - * @return {string} string of the header + * @param {Integer} tag_type Tag type + * @param {Integer} length Length of the payload + * @return {String} String of the header */ function write_old_packet_header(tag_type, length) { var result = ""; @@ -97,10 +97,10 @@ function _openpgp_packet() { /** * Generic static Packet Parser function * - * @param {String} input input stream as string - * @param {integer} position position to start parsing - * @param {integer} len length of the input from position on - * @return {openpgp_packet_*} returns a parsed openpgp_packet + * @param {String} input Input stream as string + * @param {integer} position Position to start parsing + * @param {integer} len Length of the input from position on + * @return {Object} Returns a parsed openpgp_packet */ function read_packet(input, position, len) { // some sanity checks diff --git a/src/packet/openpgp.packet.keymaterial.js b/src/packet/openpgp.packet.keymaterial.js index 077096e8..e52fb879 100644 --- a/src/packet/openpgp.packet.keymaterial.js +++ b/src/packet/openpgp.packet.keymaterial.js @@ -50,10 +50,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a secret key packet (Tag 5) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Intefer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag5(input, position, len) { this.tagType = 5; @@ -65,10 +65,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a public key packet (Tag 6) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag6(input, position, len) { // A Public-Key packet starts a series of packets that forms an OpenPGP @@ -84,10 +84,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a secret key sub packet (Tag 7) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag7(input, position, len) { this.tagType = 7; @@ -99,10 +99,10 @@ function openpgp_packet_keymaterial() { /** * This function reads the payload of a public key sub packet (Tag 14) * and initializes the openpgp_packet_keymaterial - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return openpgp_packet_keymaterial object + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {openpgp_packet_keymaterial} */ function read_tag14(input, position, len) { this.subKeySignature = null; @@ -114,12 +114,13 @@ function openpgp_packet_keymaterial() { } /** - * Internal Parser for public keys as specified in RFC 4880 section 5.5.2 Public-Key Packet Formats + * Internal Parser for public keys as specified in RFC 4880 section + * 5.5.2 Public-Key Packet Formats * called by read_tag<num> - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return this object with attributes set by the parser + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {Object} This object with attributes set by the parser */ function read_pub_key(input, position, len) { var mypos = position; @@ -226,10 +227,10 @@ function openpgp_packet_keymaterial() { /** * Internal parser for private keys as specified in RFC 4880 section 5.5.3 - * @param input input string to read the packet from - * @param position start position for the parser - * @param len length of the packet or remaining length of input - * @return this object with attributes set by the parser + * @param {String} input Input string to read the packet from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet or remaining length of input + * @return {Object} This object with attributes set by the parser */ function read_priv_key(input,position, len) { // - A Public-Key or Public-Subkey packet, as described above. @@ -362,11 +363,13 @@ function openpgp_packet_keymaterial() { /** * Decrypts the private key MPIs which are needed to use the key. - * openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be false otherwise + * openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be + * false otherwise * a call to this function is not needed * - * @param str_passphrase the passphrase for this private key as string - * @return true if the passphrase was correct; false if not + * @param {String} str_passphrase The passphrase for this private key + * as string + * @return {Boolean} True if the passphrase was correct; false if not */ function decryptSecretMPIs(str_passphrase) { if (this.hasUnencryptedSecretKeyData) @@ -549,11 +552,11 @@ function openpgp_packet_keymaterial() { /** * Continue parsing packets belonging to the key material such as signatures - * @param {openpgp_*} parent_node the parent object - * @param {String} input input string to read the packet(s) from - * @param {integer} position start position for the parser - * @param {integer} len length of the packet(s) or remaining length of input - * @return {integer} length of nodes read + * @param {Object} parent_node The parent object + * @param {String} input Input string to read the packet(s) from + * @param {Integer} position Start position for the parser + * @param {Integer} len Length of the packet(s) or remaining length of input + * @return {Integer} Length of nodes read */ function read_nodes(parent_node, input, position, len) { this.parentNode = parent_node; @@ -630,7 +633,7 @@ function openpgp_packet_keymaterial() { /** * Checks the validity for usage of this (sub)key - * @return 0 = bad key, 1 = expired, 2 = revoked, 3 = valid + * @return {Integer} 0 = bad key, 1 = expired, 2 = revoked, 3 = valid */ function verifyKey() { if (this.tagType == 14) { @@ -658,8 +661,8 @@ function openpgp_packet_keymaterial() { } /** - * calculates the key id of they key - * @return {String} a 8 byte key id + * Calculates the key id of they key + * @return {String} A 8 byte key id */ function getKeyId() { if (this.version == 4) { @@ -673,8 +676,8 @@ function openpgp_packet_keymaterial() { } /** - * calculates the fingerprint of the key - * @return {String} a string containing the fingerprint + * Calculates the fingerprint of the key + * @return {String} A string containing the fingerprint */ function getFingerprint() { if (this.version == 4) { @@ -688,14 +691,17 @@ function openpgp_packet_keymaterial() { } /* - * creates an OpenPGP key packet for the given key. much TODO in regards to s2k, subkeys. - * @param {int} keyType follows the OpenPGP algorithm standard, IE 1 corresponds to RSA. + * Creates an OpenPGP key packet for the given key. much + * TODO in regards to s2k, subkeys. + * @param {Integer} keyType Follows the OpenPGP algorithm standard, + * IE 1 corresponds to RSA. * @param {RSA.keyObject} key * @param password * @param s2kHash * @param symmetricEncryptionAlgorithm * @param timePacket - * @return {body: [string]OpenPGP packet body contents, header: [string] OpenPGP packet header, string: [string] header+body} + * @return {Object} {body: [string]OpenPGP packet body contents, + header: [string] OpenPGP packet header, string: [string] header+body} */ function write_private_key(keyType, key, password, s2kHash, symmetricEncryptionAlgorithm, timePacket){ this.symmetricEncryptionAlgorithm = symmetricEncryptionAlgorithm; @@ -769,11 +775,14 @@ function openpgp_packet_keymaterial() { } /* - * same as write_private_key, but has less information because of public key. - * @param {int} keyType follows the OpenPGP algorithm standard, IE 1 corresponds to RSA. + * Same as write_private_key, but has less information because of + * public key. + * @param {Integer} keyType Follows the OpenPGP algorithm standard, + * IE 1 corresponds to RSA. * @param {RSA.keyObject} key * @param timePacket - * @return {body: [string]OpenPGP packet body contents, header: [string] OpenPGP packet header, string: [string] header+body} + * @return {Object} {body: [string]OpenPGP packet body contents, + * header: [string] OpenPGP packet header, string: [string] header+body} */ function write_public_key(keyType, key, timePacket){ var tag = 6; diff --git a/src/packet/openpgp.packet.literaldata.js b/src/packet/openpgp.packet.literaldata.js index 179eb95c..1deaa88e 100644 --- a/src/packet/openpgp.packet.literaldata.js +++ b/src/packet/openpgp.packet.literaldata.js @@ -26,13 +26,13 @@ function openpgp_packet_literaldata() { this.tagType = 11; /** - * parsing function for a literal data packet (tag 11). + * Parsing function for a literal data packet (tag 11). * - * @param {string} input payload of a tag 11 packet - * @param {integer} position - * position to start reading from the input string - * @param {integer} len - * length of the packet or the remaining length of + * @param {String} input Payload of a tag 11 packet + * @param {Integer} position + * Position to start reading from the input string + * @param {Integer} len + * Length of the packet or the remaining length of * input at position * @return {openpgp_packet_encrypteddata} object representation */ @@ -53,7 +53,7 @@ function openpgp_packet_literaldata() { /** * Creates a string representation of the packet * - * @param {String} data the data to be inserted as body + * @param {String} data The data to be inserted as body * @return {String} string-representation of the packet */ function write_packet(data) { @@ -80,9 +80,9 @@ function openpgp_packet_literaldata() { } /** - * generates debug output (pretty print) + * Generates debug output (pretty print) * - * @return {string} String which gives some information about the keymaterial + * @return {String} String which gives some information about the keymaterial */ function toString() { return '5.9. Literal Data Packet (Tag 11)\n' + ' length: ' diff --git a/src/packet/openpgp.packet.marker.js b/src/packet/openpgp.packet.marker.js index 5f3ab5af..848f746a 100644 --- a/src/packet/openpgp.packet.marker.js +++ b/src/packet/openpgp.packet.marker.js @@ -29,15 +29,15 @@ function openpgp_packet_marker() { this.tagType = 10; /** - * parsing function for a literal data packet (tag 10). + * Parsing function for a literal data packet (tag 10). * - * @param {string} input payload of a tag 10 packet - * @param {integer} position - * position to start reading from the input string - * @param {integer} len - * length of the packet or the remaining length of + * @param {String} input Payload of a tag 10 packet + * @param {Integer} position + * Position to start reading from the input string + * @param {Integer} len + * Length of the packet or the remaining length of * input at position - * @return {openpgp_packet_encrypteddata} object representation + * @return {openpgp_packet_encrypteddata} Object representation */ function read_packet(input, position, len) { this.packetLength = 3; @@ -52,7 +52,8 @@ function openpgp_packet_marker() { /** * Generates Debug output * - * @return {string} String which gives some information about the keymaterial + * @return {String} String which gives some information about the + * keymaterial */ function toString() { return "5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)\n" diff --git a/src/packet/openpgp.packet.modificationdetectioncode.js b/src/packet/openpgp.packet.modificationdetectioncode.js index 37a53701..36e4a2c6 100644 --- a/src/packet/openpgp.packet.modificationdetectioncode.js +++ b/src/packet/openpgp.packet.modificationdetectioncode.js @@ -67,8 +67,8 @@ function openpgp_packet_modificationdetectioncode() { /** * generates debug output (pretty print) * - * @return {string} String which gives some information about the modification - * detection code + * @return {String} String which gives some information about the + * modification detection code */ function toString() { return '5.14 Modification detection code packet\n' + ' bytes (' diff --git a/src/packet/openpgp.packet.onepasssignature.js b/src/packet/openpgp.packet.onepasssignature.js index f1ff9a60..d6b61944 100644 --- a/src/packet/openpgp.packet.onepasssignature.js +++ b/src/packet/openpgp.packet.onepasssignature.js @@ -37,9 +37,9 @@ function openpgp_packet_onepasssignature() { /** * parsing function for a one-pass signature packet (tag 4). - * @param {string} input payload of a tag 4 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 4 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet(input, position, len) { @@ -72,10 +72,10 @@ function openpgp_packet_onepasssignature() { /** * creates a string representation of a one-pass signature packet - * @param {integer} type Signature types as described in RFC4880 Section 5.2.1. - * @param {integer} hashalgorithm the hash algorithm used within the signature + * @param {Integer} type Signature types as described in RFC4880 Section 5.2.1. + * @param {Integer} hashalgorithm the hash algorithm used within the signature * @param {openpgp_msg_privatekey} privatekey the private key used to generate the signature - * @param {integer} length length of data to be signed + * @param {Integer} length length of data to be signed * @param {boolean} nested boolean showing whether the signature is nested. * "true" indicates that the next packet is another One-Pass Signature packet * that describes another signature to be applied to the same message data. @@ -100,7 +100,7 @@ function openpgp_packet_onepasssignature() { /** * generates debug output (pretty print) - * @return {string} String which gives some information about the one-pass signature packet + * @return {String} String which gives some information about the one-pass signature packet */ function toString() { return '5.4. One-Pass Signature Packets (Tag 4)\n'+ diff --git a/src/packet/openpgp.packet.signature.js b/src/packet/openpgp.packet.signature.js index 865d29fb..7f19e3a5 100644 --- a/src/packet/openpgp.packet.signature.js +++ b/src/packet/openpgp.packet.signature.js @@ -70,9 +70,9 @@ function openpgp_packet_signature() { /** * parsing function for a signature packet (tag 2). - * @param {string} input payload of a tag 2 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 2 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet(input, position, len) { @@ -210,10 +210,10 @@ function openpgp_packet_signature() { /** * creates a string representation of a message signature packet (tag 2). * This can be only used on text data - * @param {integer} signature_type should be 1 (one) + * @param {Integer} signature_type should be 1 (one) * @param {String} data data to be signed * @param {openpgp_msg_privatekey} privatekey private key used to sign the message. (secMPIs MUST be unlocked) - * @return {string} string representation of a signature packet + * @return {String} string representation of a signature packet */ function write_message_signature(signature_type, data, privatekey) { var publickey = privatekey.privateKeyPacket.publicKey; @@ -256,7 +256,7 @@ function openpgp_packet_signature() { } /** * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1) - * @param {integer} type subpacket signature type. Signature types as described in RFC4880 Section 5.2.3.2 + * @param {Integer} type subpacket signature type. Signature types as described in RFC4880 Section 5.2.3.2 * @param {String} data data to be included * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1) */ @@ -636,7 +636,7 @@ function openpgp_packet_signature() { } /** * generates debug output (pretty print) - * @return {string} String which gives some information about the signature packet + * @return {String} String which gives some information about the signature packet */ function toString () { @@ -707,7 +707,7 @@ function openpgp_packet_signature() { /** * Tries to get the corresponding public key out of the public keyring for the issuer created this signature - * @return {obj: [openpgp_msg_publickey], text: [String]} if found the public key will be returned. null otherwise + * @return {Object} {obj: [openpgp_msg_publickey], text: [String]} if found the public key will be returned. null otherwise */ function getIssuerKey() { var result = null; diff --git a/src/packet/openpgp.packet.userattribute.js b/src/packet/openpgp.packet.userattribute.js index 1acb34e2..9ccdfd17 100644 --- a/src/packet/openpgp.packet.userattribute.js +++ b/src/packet/openpgp.packet.userattribute.js @@ -41,9 +41,9 @@ function openpgp_packet_userattribute() { /** * parsing function for a user attribute packet (tag 17). - * @param {string} input payload of a tag 17 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 17 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet (input, position, len) { @@ -89,7 +89,7 @@ function openpgp_packet_userattribute() { /** * generates debug output (pretty print) - * @return {string} String which gives some information about the user attribute packet + * @return {String} String which gives some information about the user attribute packet */ function toString() { var result = '5.12. User Attribute Packet (Tag 17)\n'+ @@ -102,11 +102,11 @@ function openpgp_packet_userattribute() { /** * Continue parsing packets belonging to the user attribute packet such as signatures - * @param {openpgp_*} parent_node the parent object + * @param {Object} parent_node the parent object * @param {String} input input string to read the packet(s) from - * @param {integer} position start position for the parser - * @param {integer} len length of the packet(s) or remaining length of input - * @return {integer} length of nodes read + * @param {Integer} position start position for the parser + * @param {Integer} len length of the packet(s) or remaining length of input + * @return {Integer} length of nodes read */ function read_nodes(parent_node, input, position, len) { diff --git a/src/packet/openpgp.packet.userid.js b/src/packet/openpgp.packet.userid.js index be1814f9..e7a0b7aa 100644 --- a/src/packet/openpgp.packet.userid.js +++ b/src/packet/openpgp.packet.userid.js @@ -34,9 +34,9 @@ function openpgp_packet_userid() { /** * parsing function for a user id packet (tag 13). - * @param {string} input payload of a tag 13 packet - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position + * @param {String} input payload of a tag 13 packet + * @param {Integer} position position to start reading from the input string + * @param {Integer} len length of the packet or the remaining length of input at position * @return {openpgp_packet_encrypteddata} object representation */ function read_packet(input, position, len) { @@ -63,11 +63,11 @@ function openpgp_packet_userid() { /** * Continue parsing packets belonging to the userid packet such as signatures - * @param {openpgp_*} parent_node the parent object + * @param {Object} parent_node the parent object * @param {String} input input string to read the packet(s) from - * @param {integer} position start position for the parser - * @param {integer} len length of the packet(s) or remaining length of input - * @return {integer} length of nodes read + * @param {Integer} position start position for the parser + * @param {Integer} len length of the packet(s) or remaining length of input + * @return {Integer} length of nodes read */ function read_nodes(parent_node, input, position, len) { if (parent_node.tagType == 6) { // public key @@ -147,7 +147,7 @@ function openpgp_packet_userid() { /** * generates debug output (pretty print) - * @return {string} String which gives some information about the user id packet + * @return {String} String which gives some information about the user id packet */ function toString() { var result = ' 5.11. User ID Packet (Tag 13)\n' + ' text (' @@ -166,7 +166,7 @@ function openpgp_packet_userid() { /** * lookup function to find certification revocation signatures - * @param {string} keyId string containing the key id of the issuer of this signature + * @param {String} keyId string containing the key id of the issuer of this signature * @return a CertificationRevocationSignature if found; otherwise null */ function hasCertificationRevocationSignature(keyId) { @@ -182,8 +182,8 @@ function openpgp_packet_userid() { /** * Verifies all certification signatures. This method does not consider possible revocation signatures. - * @param publicKeyPacket the top level key material - * @return an array of integers corresponding to the array of certification signatures. The meaning of each integer is the following: + * @param {Object} publicKeyPacket the top level key material + * @return {Integer[]} An array of integers corresponding to the array of certification signatures. The meaning of each integer is the following: * 0 = bad signature * 1 = signature expired * 2 = issuer key not available diff --git a/src/type/openpgp.type.keyid.js b/src/type/openpgp.type.keyid.js index e91f1d4e..d8c1ac7a 100644 --- a/src/type/openpgp.type.keyid.js +++ b/src/type/openpgp.type.keyid.js @@ -25,10 +25,11 @@ */ function openpgp_type_keyid() { /** - * parsing method for a key id - * @param {String} input input to read the key id from - * @param {integer} position position where to start reading the key id from input - * @return this object + * Parsing method for a key id + * @param {String} input Input to read the key id from + * @param {integer} position Position where to start reading the key + * id from input + * @return {openpgp_type_keyid} This object */ function read_packet(input, position) { this.bytes = input.substring(position, position+8); @@ -36,7 +37,7 @@ function openpgp_type_keyid() { } /** - * generates debug output (pretty print) + * Generates debug output (pretty print) * @return {String} Key Id as hexadecimal string */ function toString() { diff --git a/src/type/openpgp.type.mpi.js b/src/type/openpgp.type.mpi.js index bee4c439..82f56690 100644 --- a/src/type/openpgp.type.mpi.js +++ b/src/type/openpgp.type.mpi.js @@ -36,11 +36,13 @@ function openpgp_type_mpi() { this.mpiByteLength = null; this.data = null; /** - * parsing function for a mpi (RFC 4880 3.2). - * @param {string} input payload of mpi data - * @param {integer} position position to start reading from the input string - * @param {integer} len length of the packet or the remaining length of input at position - * @return {openpgp_type_mpi} object representation + * Parsing function for a mpi (RFC 4880 3.2). + * @param {String} input Payload of mpi data + * @param {Integer} position Position to start reading from the input + * string + * @param {Integer} len Length of the packet or the remaining length of + * input at position + * @return {openpgp_type_mpi} Object representation */ function read(input, position, len) { var mypos = position; @@ -68,8 +70,8 @@ function openpgp_type_mpi() { } /** - * generates debug output (pretty print) - * @return {string} String which gives some information about the mpi + * Generates debug output (pretty print) + * @return {String} String which gives some information about the mpi */ function toString() { var r = " MPI("+this.mpiBitLength+"b/"+this.mpiByteLength+"B) : 0x"; @@ -78,7 +80,7 @@ function openpgp_type_mpi() { } /** - * converts the mpi to an BigInteger object + * Converts the mpi to an BigInteger object * @return {BigInteger} */ function getBigInteger() { @@ -93,16 +95,16 @@ function openpgp_type_mpi() { } /** - * gets the length of the mpi in bytes - * @return {integer} mpi byte length + * Gets the length of the mpi in bytes + * @return {Integer} Mpi byte length */ function getByteLength() { return this.mpiByteLength; } /** - * creates an mpi from the specified string - * @param {String} data data to read the mpi from + * Creates an mpi from the specified string + * @param {String} data Data to read the mpi from * @return {openpgp_type_mpi} */ function create(data) { @@ -113,8 +115,8 @@ function openpgp_type_mpi() { } /** - * converts the mpi object to a string as specified in RFC4880 3.2 - * @return {String} mpi byte representation + * Converts the mpi object to a string as specified in RFC4880 3.2 + * @return {String} mpi Byte representation */ function toBin() { var result = String.fromCharCode((this.mpiBitLength >> 8) & 0xFF); diff --git a/src/type/openpgp.type.s2k.js b/src/type/openpgp.type.s2k.js index 82b759c2..3147a8bb 100644 --- a/src/type/openpgp.type.s2k.js +++ b/src/type/openpgp.type.s2k.js @@ -26,10 +26,10 @@ */ function openpgp_type_s2k() { /** - * parsing function for a string-to-key specifier (RFC 4880 3.7). - * @param {string} input payload of string-to-key specifier - * @param {integer} position position to start reading from the input string - * @return {openpgp_type_s2k} object representation + * Parsing function for a string-to-key specifier (RFC 4880 3.7). + * @param {String} input Payload of string-to-key specifier + * @param {Integer} position Position to start reading from the input string + * @return {openpgp_type_s2k} Object representation */ function read(input, position) { var mypos = position; @@ -94,7 +94,7 @@ function openpgp_type_s2k() { /** * writes an s2k hash based on the inputs. - * @return {String} produced key of hashAlgorithm hash length + * @return {String} Produced key of hashAlgorithm hash length */ function write(type, hash, passphrase, salt, c){ this.type = type; @@ -107,9 +107,11 @@ function openpgp_type_s2k() { } /** - * produces a key using the specified passphrase and the defined hashAlgorithm - * @param passphrase {String} passphrase containing user input - * @return {String} produced key with a length corresponding to hashAlgorithm hash length + * Produces a key using the specified passphrase and the defined + * hashAlgorithm + * @param {String} passphrase Passphrase containing user input + * @return {String} Produced key with a length corresponding to + * hashAlgorithm hash length */ function produce_key(passphrase, numBytes) { if (this.type == 0) { diff --git a/src/util/util.js b/src/util/util.js index e62475a6..9d6e3f6d 100644 --- a/src/util/util.js +++ b/src/util/util.js @@ -37,9 +37,9 @@ var Util = function() { }; /** - * create hexstring from a binary - * @param str [String] string to convert - * @return [String] string containing the hexadecimal values + * Create hexstring from a binary + * @param {String} str String to convert + * @return {String} String containing the hexadecimal values */ this.hexstrdump = function(str) { if (str == null) @@ -57,9 +57,9 @@ var Util = function() { }; /** - * create binary string from a hex encoded string - * @param str [String] hex string to convert - * @return [String] string containing the binary values + * Create binary string from a hex encoded string + * @param {String} str Hex string to convert + * @return {String} String containing the binary values */ this.hex2bin = function(hex) { var str = ''; @@ -69,9 +69,9 @@ var Util = function() { }; /** - * creating a hex string from an binary array of integers (0..255) - * @param [Array[integer 0..255]] array to convert - * @return [String] hexadecimal representation of the array + * Creating a hex string from an binary array of integers (0..255) + * @param {String} str Array of bytes to convert + * @return {String} Hexadecimal representation of the array */ this.hexidump = function(str) { var r=[]; @@ -87,9 +87,9 @@ var Util = function() { }; /** - * convert a string to an array of integers(0.255) - * @param [String] string to convert - * @return [Array [Integer 0..255]] array of (binary) integers + * Convert a string to an array of integers(0.255) + * @param {String} str String to convert + * @return {Integer[]} An array of (binary) integers */ this.str2bin = function(str) { var result = new Array(); @@ -101,9 +101,9 @@ var Util = function() { }; /** - * convert an array of integers(0.255) to a string - * @param [Array [Integer 0..255]] array of (binary) integers to convert - * @return [String] string representation of the array + * Convert an array of integers(0.255) to a string + * @param {Integer[]} bin An array of (binary) integers to convert + * @return {String} The string representation of the array */ this.bin2str = function(bin) { var result = []; @@ -114,9 +114,9 @@ var Util = function() { }; /** - * convert a string to a Uint8Array - * @param [String] string to convert - * @return [Uint8Array] array of (binary) integers + * Convert a string to a Uint8Array + * @param {String} str String to convert + * @return {Uint8Array} The array of (binary) integers */ this.str2Uint8Array = function(str){ var uintArray = new Uint8Array(new ArrayBuffer(str.length)); @@ -127,9 +127,10 @@ var Util = function() { }; /** - * convert a Uint8Array to a string. This currently functions the same as bin2str. - * @param [Uint8Array] array of (binary) integers to convert - * @return [String] string representation of the array + * Convert a Uint8Array to a string. This currently functions + * the same as bin2str. + * @param {Uint8Array} bin An array of (binary) integers to convert + * @return {String} String representation of the array */ this.Uint8Array2str = function(bin) { var result = []; @@ -140,9 +141,11 @@ var Util = function() { }; /** - * calculates a 16bit sum of a string by adding each character codes modulus 65535 - * @param text [String] string to create a sum of - * @return [Integer] an integer containing the sum of all character codes % 65535 + * Calculates a 16bit sum of a string by adding each character + * codes modulus 65535 + * @param {String} text String to create a sum of + * @return {Integer} An integer containing the sum of all character + * codes % 65535 */ this.calc_checksum = function(text) { var checksum = { s: 0, add: function (sadd) { this.s = (this.s + sadd) % 65536; }}; @@ -159,8 +162,9 @@ var Util = function() { * Javascript context MUST define * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
' - * @param str [String] string of the debug message - * @return [String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in. + * @param {String} str String of the debug message + * @return {String} An HTML tt entity containing a paragraph with a + * style attribute where the debug message is HTMLencoded in. */ this.print_debug = function(str) { if (openpgp.config.debug) { @@ -177,8 +181,9 @@ var Util = function() { * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
' * Different than print_debug because will call hexstrdump iff necessary. - * @param str [String] string of the debug message - * @return [String] an HTML tt entity containing a paragraph with a style attribute where the debug message is HTMLencoded in. + * @param {String} str String of the debug message + * @return {String} An HTML tt entity containing a paragraph with a + * style attribute where the debug message is HTMLencoded in. */ this.print_debug_hexstr_dump = function(str,strToHex) { if (openpgp.config.debug) { @@ -193,8 +198,9 @@ var Util = function() { * The calling Javascript context MUST define * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
' - * @param str [String] string of the error message - * @return [String] a HTML paragraph entity with a style attribute containing the HTML encoded error message + * @param {String} str String of the error message + * @return {String} A HTML paragraph entity with a style attribute + * containing the HTML encoded error message */ this.print_error = function(str) { str = openpgp_encoding_html_encode(str); @@ -206,8 +212,9 @@ var Util = function() { * The calling Javascript context MUST define * a "showMessages(text)" function. Line feeds ('\n') * are automatically converted to HTML line feeds '
'. - * @param str [String] string of the info message - * @return [String] a HTML paragraph entity with a style attribute containing the HTML encoded info message + * @param {String} str String of the info message + * @return {String} A HTML paragraph entity with a style attribute + * containing the HTML encoded info message */ this.print_info = function(str) { str = openpgp_encoding_html_encode(str); @@ -227,11 +234,13 @@ var Util = function() { var result = string.substring(0, bytes); return this.shiftRight(result, 8-rest); // +String.fromCharCode(string.charCodeAt(bytes -1) << (8-rest) & 0xFF); }; + /** * Shifting a string to n bits right - * @param value [String] the string to shift - * @param bitcount [Integer] amount of bits to shift (MUST be smaller than 9) - * @return [String] resulting string. + * @param {String} value The string to shift + * @param {Integer} bitcount Amount of bits to shift (MUST be smaller + * than 9) + * @return {String} Resulting string. */ this.shiftRight = function(value, bitcount) { var temp = util.str2bin(value); @@ -249,7 +258,7 @@ var Util = function() { /** * Return the algorithm type as string - * @return [String] String representing the message type + * @return {String} String representing the message type */ this.get_hashAlgorithmString = function(algo) { switch(algo) { From f06900542e0f9bd47d1a0ea33ddcb0def58a4c72 Mon Sep 17 00:00:00 2001 From: Michal Kolodziej Date: Fri, 12 Apr 2013 15:11:34 +0200 Subject: [PATCH 4/4] Forgot to add the generated documentation. --- doc/jsxcompressor.js.html | 1275 +++++++++++++++++ doc/md5.js.html | 253 ++++ doc/openpgp.config.js.html | 139 ++ doc/openpgp.crypto.sym.js.html | 143 ++ doc/openpgp.encoding.asciiarmor.js.html | 295 ++++ doc/openpgp.encoding.js.html | 190 +++ doc/openpgp.js.html | 509 +++++++ doc/openpgp.keyring.js.html | 313 ++++ doc/openpgp.msg.message.js.html | 185 +++ doc/openpgp.msg.privatekey.js.html | 240 ++++ doc/openpgp.msg.publickey.js.html | 317 ++++ doc/openpgp.packet.compressed.js.html | 213 +++ doc/openpgp.packet.encrypteddata.js.html | 148 ++ ...et.encryptedintegrityprotecteddata.js.html | 204 +++ ...openpgp.packet.encryptedsessionkey.js.html | 275 ++++ doc/openpgp.packet.js.html | 456 ++++++ doc/openpgp.packet.keymaterial.js.html | 868 +++++++++++ doc/openpgp.packet.literaldata.js.html | 147 ++ doc/openpgp.packet.marker.js.html | 114 ++ ...p.packet.modificationdetectioncode.js.html | 128 ++ doc/openpgp.packet.onepasssignature.js.html | 168 +++ doc/openpgp.packet.signature.js.html | 778 ++++++++++ doc/openpgp.packet.userattribute.js.html | 204 +++ doc/openpgp.packet.userid.js.html | 385 +++++ doc/openpgp.type.keyid.js.html | 98 ++ doc/openpgp.type.mpi.js.html | 184 +++ doc/openpgp.type.s2k.js.html | 189 +++ doc/rsa.js.html | 184 +++ doc/util.js.html | 336 +++++ 29 files changed, 8938 insertions(+) create mode 100644 doc/jsxcompressor.js.html create mode 100644 doc/md5.js.html create mode 100644 doc/openpgp.config.js.html create mode 100644 doc/openpgp.crypto.sym.js.html create mode 100644 doc/openpgp.encoding.asciiarmor.js.html create mode 100644 doc/openpgp.encoding.js.html create mode 100644 doc/openpgp.js.html create mode 100644 doc/openpgp.keyring.js.html create mode 100644 doc/openpgp.msg.message.js.html create mode 100644 doc/openpgp.msg.privatekey.js.html create mode 100644 doc/openpgp.msg.publickey.js.html create mode 100644 doc/openpgp.packet.compressed.js.html create mode 100644 doc/openpgp.packet.encrypteddata.js.html create mode 100644 doc/openpgp.packet.encryptedintegrityprotecteddata.js.html create mode 100644 doc/openpgp.packet.encryptedsessionkey.js.html create mode 100644 doc/openpgp.packet.js.html create mode 100644 doc/openpgp.packet.keymaterial.js.html create mode 100644 doc/openpgp.packet.literaldata.js.html create mode 100644 doc/openpgp.packet.marker.js.html create mode 100644 doc/openpgp.packet.modificationdetectioncode.js.html create mode 100644 doc/openpgp.packet.onepasssignature.js.html create mode 100644 doc/openpgp.packet.signature.js.html create mode 100644 doc/openpgp.packet.userattribute.js.html create mode 100644 doc/openpgp.packet.userid.js.html create mode 100644 doc/openpgp.type.keyid.js.html create mode 100644 doc/openpgp.type.mpi.js.html create mode 100644 doc/openpgp.type.s2k.js.html create mode 100644 doc/rsa.js.html create mode 100644 doc/util.js.html diff --git a/doc/jsxcompressor.js.html b/doc/jsxcompressor.js.html new file mode 100644 index 00000000..c505c58f --- /dev/null +++ b/doc/jsxcompressor.js.html @@ -0,0 +1,1275 @@ + + + + + JSDoc: Source: compression/zlib/jsxcompressor.js + + + + + + + + + + +
+ +

Source: compression/zlib/jsxcompressor.js

+ + + + + +
+
+
JXG = {exists: (function(undefined){return function(v){return !(v===undefined || v===null);}})()};
+JXG.decompress = function(str) {return unescape((new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(str))).unzip()[0][0]);};
+/*
+    Copyright 2008-2012
+        Matthias Ehmann,
+        Michael Gerhaeuser,
+        Carsten Miller,
+        Bianca Valentin,
+        Alfred Wassermann,
+        Peter Wilfahrt
+
+    This file is part of JSXGraph.
+    
+    Dual licensed under the Apache License Version 2.0, or LGPL Version 3 licenses.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with JSXCompressor.  If not, see <http://www.gnu.org/licenses/>.
+    
+    You should have received a copy of the Apache License along with JSXCompressor.  
+    If not, see <http://www.apache.org/licenses/>.
+
+*/
+
+/**
+  * @class Util class
+  * @classdesc Utilities for uncompressing and base64 decoding
+  * Class for gunzipping, unzipping and base64 decoding of files.
+  * It is used for reading GEONExT, Geogebra and Intergeo files.
+  *
+  * Only Huffman codes are decoded in gunzip.
+  * The code is based on the source code for gunzip.c by Pasi Ojala 
+  * {@link http://www.cs.tut.fi/~albert/Dev/gunzip/gunzip.c}
+  * {@link http://www.cs.tut.fi/~albert}
+  */
+JXG.Util = {};
+                                 
+/**
+ * Unzip zip files
+ */
+JXG.Util.Unzip = function (barray){
+    var outputArr = [],
+        output = "",
+        debug = false,
+        gpflags,
+        files = 0,
+        unzipped = [],
+        crc,
+        buf32k = new Array(32768),
+        bIdx = 0,
+        modeZIP=false,
+
+        CRC, SIZE,
+    
+        bitReverse = [
+        0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+        0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+        0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+        0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+        0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+        0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+        0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+        0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+        0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+        0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+        0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+        0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+        0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+        0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+        0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+        0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+        0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+        0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+        0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+        0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+        0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+        0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+        0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+        0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+        0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+        0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+        0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+        0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+        0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+        0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+        0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+        0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+    ],
+    
+    cplens = [
+        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
+    ],
+
+    cplext = [
+        0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99
+    ], /* 99==invalid */
+
+    cpdist = [
+        0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0007, 0x0009, 0x000d,
+        0x0011, 0x0019, 0x0021, 0x0031, 0x0041, 0x0061, 0x0081, 0x00c1,
+        0x0101, 0x0181, 0x0201, 0x0301, 0x0401, 0x0601, 0x0801, 0x0c01,
+        0x1001, 0x1801, 0x2001, 0x3001, 0x4001, 0x6001
+    ],
+
+    cpdext = [
+        0,  0,  0,  0,  1,  1,  2,  2,
+        3,  3,  4,  4,  5,  5,  6,  6,
+        7,  7,  8,  8,  9,  9, 10, 10,
+        11, 11, 12, 12, 13, 13
+    ],
+    
+    border = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15],
+    
+    bA = barray,
+
+    bytepos=0,
+    bitpos=0,
+    bb = 1,
+    bits=0,
+    
+    NAMEMAX = 256,
+    
+    nameBuf = [],
+    
+    fileout;
+    
+    function readByte(){
+        bits+=8;
+        if (bytepos<bA.length){
+            //if (debug)
+            //    document.write(bytepos+": "+bA[bytepos]+"<br>");
+            return bA[bytepos++];
+        } else
+            return -1;
+    };
+
+    function byteAlign(){
+        bb = 1;
+    };
+    
+    function readBit(){
+        var carry;
+        bits++;
+        carry = (bb & 1);
+        bb >>= 1;
+        if (bb==0){
+            bb = readByte();
+            carry = (bb & 1);
+            bb = (bb>>1) | 0x80;
+        }
+        return carry;
+    };
+
+    function readBits(a) {
+        var res = 0,
+            i = a;
+    
+        while(i--) {
+            res = (res<<1) | readBit();
+        }
+        if(a) {
+            res = bitReverse[res]>>(8-a);
+        }
+        return res;
+    };
+        
+    function flushBuffer(){
+        //document.write('FLUSHBUFFER:'+buf32k);
+        bIdx = 0;
+    };
+    function addBuffer(a){
+        SIZE++;
+        //CRC=updcrc(a,crc);
+        buf32k[bIdx++] = a;
+        outputArr.push(String.fromCharCode(a));
+        //output+=String.fromCharCode(a);
+        if(bIdx==0x8000){
+            //document.write('ADDBUFFER:'+buf32k);
+            bIdx=0;
+        }
+    };
+    
+    function HufNode() {
+        this.b0=0;
+        this.b1=0;
+        this.jump = null;
+        this.jumppos = -1;
+    };
+
+    var LITERALS = 288;
+    
+    var literalTree = new Array(LITERALS);
+    var distanceTree = new Array(32);
+    var treepos=0;
+    var Places = null;
+    var Places2 = null;
+    
+    var impDistanceTree = new Array(64);
+    var impLengthTree = new Array(64);
+    
+    var len = 0;
+    var fpos = new Array(17);
+    fpos[0]=0;
+    var flens;
+    var fmax;
+    
+    function IsPat() {
+        while (1) {
+            if (fpos[len] >= fmax)
+                return -1;
+            if (flens[fpos[len]] == len)
+                return fpos[len]++;
+            fpos[len]++;
+        }
+    };
+
+    function Rec() {
+        var curplace = Places[treepos];
+        var tmp;
+        if (debug)
+    		document.write("<br>len:"+len+" treepos:"+treepos);
+        if(len==17) { //war 17
+            return -1;
+        }
+        treepos++;
+        len++;
+    	
+        tmp = IsPat();
+        if (debug)
+        	document.write("<br>IsPat "+tmp);
+        if(tmp >= 0) {
+            curplace.b0 = tmp;    /* leaf cell for 0-bit */
+            if (debug)
+            	document.write("<br>b0 "+curplace.b0);
+        } else {
+        /* Not a Leaf cell */
+        curplace.b0 = 0x8000;
+        if (debug)
+        	document.write("<br>b0 "+curplace.b0);
+        if(Rec())
+            return -1;
+        }
+        tmp = IsPat();
+        if(tmp >= 0) {
+            curplace.b1 = tmp;    /* leaf cell for 1-bit */
+            if (debug)
+            	document.write("<br>b1 "+curplace.b1);
+            curplace.jump = null;    /* Just for the display routine */
+        } else {
+            /* Not a Leaf cell */
+            curplace.b1 = 0x8000;
+            if (debug)
+            	document.write("<br>b1 "+curplace.b1);
+            curplace.jump = Places[treepos];
+            curplace.jumppos = treepos;
+            if(Rec())
+                return -1;
+        }
+        len--;
+        return 0;
+    };
+
+    function CreateTree(currentTree, numval, lengths, show) {
+        var i;
+        /* Create the Huffman decode tree/table */
+        //document.write("<br>createtree<br>");
+        if (debug)
+        	document.write("currentTree "+currentTree+" numval "+numval+" lengths "+lengths+" show "+show);
+        Places = currentTree;
+        treepos=0;
+        flens = lengths;
+        fmax  = numval;
+        for (i=0;i<17;i++)
+            fpos[i] = 0;
+        len = 0;
+        if(Rec()) {
+            //fprintf(stderr, "invalid huffman tree\n");
+            if (debug)
+            	alert("invalid huffman tree\n");
+            return -1;
+        }
+        if (debug){
+        	document.write('<br>Tree: '+Places.length);
+        	for (var a=0;a<32;a++){
+            	document.write("Places["+a+"].b0="+Places[a].b0+"<br>");
+            	document.write("Places["+a+"].b1="+Places[a].b1+"<br>");
+        	}
+        }
+    
+        /*if(show) {
+            var tmp;
+            for(tmp=currentTree;tmp<Places;tmp++) {
+                fprintf(stdout, "0x%03x  0x%03x (0x%04x)",tmp-currentTree, tmp->jump?tmp->jump-currentTree:0,(tmp->jump?tmp->jump-currentTree:0)*6+0xcf0);
+                if(!(tmp.b0 & 0x8000)) {
+                    //fprintf(stdout, "  0x%03x (%c)", tmp->b0,(tmp->b0<256 && isprint(tmp->b0))?tmp->b0:'�');
+                }
+                if(!(tmp.b1 & 0x8000)) {
+                    if((tmp.b0 & 0x8000))
+                        fprintf(stdout, "           ");
+                    fprintf(stdout, "  0x%03x (%c)", tmp->b1,(tmp->b1<256 && isprint(tmp->b1))?tmp->b1:'�');
+                }
+                fprintf(stdout, "\n");
+            }
+        }*/
+        return 0;
+    };
+    
+    function DecodeValue(currentTree) {
+        var len, i,
+            xtreepos=0,
+            X = currentTree[xtreepos],
+            b;
+
+        /* decode one symbol of the data */
+        while(1) {
+            b=readBit();
+            if (debug)
+            	document.write("b="+b);
+            if(b) {
+                if(!(X.b1 & 0x8000)){
+                	if (debug)
+                    	document.write("ret1");
+                    return X.b1;    /* If leaf node, return data */
+                }
+                X = X.jump;
+                len = currentTree.length;
+                for (i=0;i<len;i++){
+                    if (currentTree[i]===X){
+                        xtreepos=i;
+                        break;
+                    }
+                }
+                //xtreepos++;
+            } else {
+                if(!(X.b0 & 0x8000)){
+                	if (debug)
+                    	document.write("ret2");
+                    return X.b0;    /* If leaf node, return data */
+                }
+                //X++; //??????????????????
+                xtreepos++;
+                X = currentTree[xtreepos];
+            }
+        }
+        if (debug)
+        	document.write("ret3");
+        return -1;
+    };
+    
+    function DeflateLoop() {
+    var last, c, type, i, len;
+
+    do {
+        /*if((last = readBit())){
+            fprintf(errfp, "Last Block: ");
+        } else {
+            fprintf(errfp, "Not Last Block: ");
+        }*/
+        last = readBit();
+        type = readBits(2);
+        switch(type) {
+            case 0:
+            	if (debug)
+                	alert("Stored\n");
+                break;
+            case 1:
+            	if (debug)
+                	alert("Fixed Huffman codes\n");
+                break;
+            case 2:
+            	if (debug)
+                	alert("Dynamic Huffman codes\n");
+                break;
+            case 3:
+            	if (debug)
+                	alert("Reserved block type!!\n");
+                break;
+            default:
+            	if (debug)
+                	alert("Unexpected value %d!\n", type);
+                break;
+        }
+
+        if(type==0) {
+            var blockLen, cSum;
+
+            // Stored 
+            byteAlign();
+            blockLen = readByte();
+            blockLen |= (readByte()<<8);
+
+            cSum = readByte();
+            cSum |= (readByte()<<8);
+
+            if(((blockLen ^ ~cSum) & 0xffff)) {
+                document.write("BlockLen checksum mismatch\n");
+            }
+            while(blockLen--) {
+                c = readByte();
+                addBuffer(c);
+            }
+        } else if(type==1) {
+            var j;
+
+            /* Fixed Huffman tables -- fixed decode routine */
+            while(1) {
+            /*
+                256    0000000        0
+                :   :     :
+                279    0010111        23
+                0   00110000    48
+                :    :      :
+                143    10111111    191
+                280 11000000    192
+                :    :      :
+                287 11000111    199
+                144    110010000    400
+                :    :       :
+                255    111111111    511
+    
+                Note the bit order!
+                */
+
+            j = (bitReverse[readBits(7)]>>1);
+            if(j > 23) {
+                j = (j<<1) | readBit();    /* 48..255 */
+
+                if(j > 199) {    /* 200..255 */
+                    j -= 128;    /*  72..127 */
+                    j = (j<<1) | readBit();        /* 144..255 << */
+                } else {        /*  48..199 */
+                    j -= 48;    /*   0..151 */
+                    if(j > 143) {
+                        j = j+136;    /* 280..287 << */
+                        /*   0..143 << */
+                    }
+                }
+            } else {    /*   0..23 */
+                j += 256;    /* 256..279 << */
+            }
+            if(j < 256) {
+                addBuffer(j);
+                //document.write("out:"+String.fromCharCode(j));
+                /*fprintf(errfp, "@%d %02x\n", SIZE, j);*/
+            } else if(j == 256) {
+                /* EOF */
+                break;
+            } else {
+                var len, dist;
+
+                j -= 256 + 1;    /* bytes + EOF */
+                len = readBits(cplext[j]) + cplens[j];
+
+                j = bitReverse[readBits(5)]>>3;
+                if(cpdext[j] > 8) {
+                    dist = readBits(8);
+                    dist |= (readBits(cpdext[j]-8)<<8);
+                } else {
+                    dist = readBits(cpdext[j]);
+                }
+                dist += cpdist[j];
+
+                /*fprintf(errfp, "@%d (l%02x,d%04x)\n", SIZE, len, dist);*/
+                for(j=0;j<len;j++) {
+                    var c = buf32k[(bIdx - dist) & 0x7fff];
+                    addBuffer(c);
+                }
+            }
+            } // while
+        } else if(type==2) {
+            var j, n, literalCodes, distCodes, lenCodes;
+            var ll = new Array(288+32);    // "static" just to preserve stack
+    
+            // Dynamic Huffman tables 
+    
+            literalCodes = 257 + readBits(5);
+            distCodes = 1 + readBits(5);
+            lenCodes = 4 + readBits(4);
+            //document.write("<br>param: "+literalCodes+" "+distCodes+" "+lenCodes+"<br>");
+            for(j=0; j<19; j++) {
+                ll[j] = 0;
+            }
+    
+            // Get the decode tree code lengths
+    
+            //document.write("<br>");
+            for(j=0; j<lenCodes; j++) {
+                ll[border[j]] = readBits(3);
+                //document.write(ll[border[j]]+" ");
+            }
+            //fprintf(errfp, "\n");
+            //document.write('<br>ll:'+ll);
+            len = distanceTree.length;
+            for (i=0; i<len; i++)
+                distanceTree[i]=new HufNode();
+            if(CreateTree(distanceTree, 19, ll, 0)) {
+                flushBuffer();
+                return 1;
+            }
+            if (debug){
+            	document.write("<br>distanceTree");
+            	for(var a=0;a<distanceTree.length;a++){
+                	document.write("<br>"+distanceTree[a].b0+" "+distanceTree[a].b1+" "+distanceTree[a].jump+" "+distanceTree[a].jumppos);
+                	/*if (distanceTree[a].jumppos!=-1)
+                    	document.write(" "+distanceTree[a].jump.b0+" "+distanceTree[a].jump.b1);
+                	*/
+            	}
+            }
+            //document.write('<BR>tree created');
+    
+            //read in literal and distance code lengths
+            n = literalCodes + distCodes;
+            i = 0;
+            var z=-1;
+            if (debug)
+            	document.write("<br>n="+n+" bits: "+bits+"<br>");
+            while(i < n) {
+                z++;
+                j = DecodeValue(distanceTree);
+                if (debug)
+                	document.write("<br>"+z+" i:"+i+" decode: "+j+"    bits "+bits+"<br>");
+                if(j<16) {    // length of code in bits (0..15)
+                       ll[i++] = j;
+                } else if(j==16) {    // repeat last length 3 to 6 times 
+                       var l;
+                    j = 3 + readBits(2);
+                    if(i+j > n) {
+                        flushBuffer();
+                        return 1;
+                    }
+                    l = i ? ll[i-1] : 0;
+                    while(j--) {
+                        ll[i++] = l;
+                    }
+                } else {
+                    if(j==17) {        // 3 to 10 zero length codes
+                        j = 3 + readBits(3);
+                    } else {        // j == 18: 11 to 138 zero length codes 
+                        j = 11 + readBits(7);
+                    }
+                    if(i+j > n) {
+                        flushBuffer();
+                        return 1;
+                    }
+                    while(j--) {
+                        ll[i++] = 0;
+                    }
+                }
+            }
+            /*for(j=0; j<literalCodes+distCodes; j++) {
+                //fprintf(errfp, "%d ", ll[j]);
+                if ((j&7)==7)
+                    fprintf(errfp, "\n");
+            }
+            fprintf(errfp, "\n");*/
+            // Can overwrite tree decode tree as it is not used anymore
+            len = literalTree.length;
+            for (i=0; i<len; i++)
+                literalTree[i]=new HufNode();
+            if(CreateTree(literalTree, literalCodes, ll, 0)) {
+                flushBuffer();
+                return 1;
+            }
+            len = literalTree.length;
+            for (i=0; i<len; i++)
+                distanceTree[i]=new HufNode();
+            var ll2 = new Array();
+            for (i=literalCodes; i <ll.length; i++){
+                ll2[i-literalCodes]=ll[i];
+            }    
+            if(CreateTree(distanceTree, distCodes, ll2, 0)) {
+                flushBuffer();
+                return 1;
+            }
+            if (debug)
+           		document.write("<br>literalTree");
+            outer:
+            while(1) {
+                j = DecodeValue(literalTree);
+                if(j >= 256) {        // In C64: if carry set
+                    var len, dist;
+                    j -= 256;
+                    if(j == 0) {
+                        // EOF
+                        break;
+                    }
+                    j--;
+                    len = readBits(cplext[j]) + cplens[j];
+    
+                    j = DecodeValue(distanceTree);
+                    if(cpdext[j] > 8) {
+                        dist = readBits(8);
+                        dist |= (readBits(cpdext[j]-8)<<8);
+                    } else {
+                        dist = readBits(cpdext[j]);
+                    }
+                    dist += cpdist[j];
+                    while(len--) {
+                        if(bIdx - dist < 0) {
+                            break outer;
+                        }
+                        var c = buf32k[(bIdx - dist) & 0x7fff];
+                        addBuffer(c);
+                    }
+                } else {
+                    addBuffer(j);
+                }
+            }
+        }
+    } while(!last);
+    flushBuffer();
+
+    byteAlign();
+    return 0;
+};
+
+JXG.Util.Unzip.prototype.unzipFile = function(name) {
+    var i;
+	this.unzip();
+	//alert(unzipped[0][1]);
+	for (i=0;i<unzipped.length;i++){
+		if(unzipped[i][1]==name) {
+			return unzipped[i][0];
+		}
+	}
+	
+  };
+
+JXG.Util.Unzip.prototype.deflate = function() {
+    outputArr = [];
+    var tmp = [];
+    modeZIP = false;
+    DeflateLoop();
+    if (debug)
+        alert(outputArr.join(''));
+    unzipped[files] = new Array(2);
+    unzipped[files][0] = outputArr.join('');
+    unzipped[files][1] = "DEFLATE";
+    files++;
+    return unzipped;
+}    
+    
+JXG.Util.Unzip.prototype.unzip = function() {
+	//convertToByteArray(input);
+	if (debug)
+		alert(bA);
+	/*for (i=0;i<bA.length*8;i++){
+		document.write(readBit());
+		if ((i+1)%8==0)
+			document.write(" ");
+	}*/
+	/*for (i=0;i<bA.length;i++){
+		document.write(readByte()+" ");
+		if ((i+1)%8==0)
+			document.write(" ");
+	}
+	for (i=0;i<bA.length;i++){
+		document.write(bA[i]+" ");
+		if ((i+1)%16==0)
+			document.write("<br>");
+	}	
+	*/
+	//alert(bA);
+	nextFile();
+	return unzipped;
+  };
+    
+ function nextFile(){
+ 	if (debug)
+ 		alert("NEXTFILE");
+ 	outputArr = [];
+ 	var tmp = [];
+ 	modeZIP = false;
+	tmp[0] = readByte();
+	tmp[1] = readByte();
+	if (debug)
+		alert("type: "+tmp[0]+" "+tmp[1]);
+	if (tmp[0] == parseInt("78",16) && tmp[1] == parseInt("da",16)){ //GZIP
+		if (debug)
+			alert("GEONExT-GZIP");
+		DeflateLoop();
+		if (debug)
+			alert(outputArr.join(''));
+		unzipped[files] = new Array(2);
+    	unzipped[files][0] = outputArr.join('');
+    	unzipped[files][1] = "geonext.gxt";
+    	files++;
+	}
+	if (tmp[0] == parseInt("78",16) && tmp[1] == parseInt("9c",16)){ //ZLIB
+		if (debug)
+			alert("ZLIB");
+		DeflateLoop();
+		if (debug)
+			alert(outputArr.join(''));
+		unzipped[files] = new Array(2);
+    	unzipped[files][0] = outputArr.join('');
+    	unzipped[files][1] = "ZLIB";
+    	files++;
+	}
+	if (tmp[0] == parseInt("1f",16) && tmp[1] == parseInt("8b",16)){ //GZIP
+		if (debug)
+			alert("GZIP");
+		//DeflateLoop();
+		skipdir();
+		if (debug)
+			alert(outputArr.join(''));
+		unzipped[files] = new Array(2);
+    	unzipped[files][0] = outputArr.join('');
+    	unzipped[files][1] = "file";
+    	files++;
+	}
+	if (tmp[0] == parseInt("50",16) && tmp[1] == parseInt("4b",16)){ //ZIP
+		modeZIP = true;
+		tmp[2] = readByte();
+		tmp[3] = readByte();
+		if (tmp[2] == parseInt("3",16) && tmp[3] == parseInt("4",16)){
+			//MODE_ZIP
+			tmp[0] = readByte();
+			tmp[1] = readByte();
+			if (debug)
+				alert("ZIP-Version: "+tmp[1]+" "+tmp[0]/10+"."+tmp[0]%10);
+			
+			gpflags = readByte();
+			gpflags |= (readByte()<<8);
+			if (debug)
+				alert("gpflags: "+gpflags);
+			
+			var method = readByte();
+			method |= (readByte()<<8);
+			if (debug)
+				alert("method: "+method);
+			
+			readByte();
+			readByte();
+			readByte();
+			readByte();
+			
+			var crc = readByte();
+			crc |= (readByte()<<8);
+			crc |= (readByte()<<16);
+			crc |= (readByte()<<24);
+			
+			var compSize = readByte();
+			compSize |= (readByte()<<8);
+			compSize |= (readByte()<<16);
+			compSize |= (readByte()<<24);
+			
+			var size = readByte();
+			size |= (readByte()<<8);
+			size |= (readByte()<<16);
+			size |= (readByte()<<24);
+			
+			if (debug)
+				alert("local CRC: "+crc+"\nlocal Size: "+size+"\nlocal CompSize: "+compSize);
+			
+			var filelen = readByte();
+			filelen |= (readByte()<<8);
+			
+			var extralen = readByte();
+			extralen |= (readByte()<<8);
+			
+			if (debug)
+				alert("filelen "+filelen);
+			i = 0;
+			nameBuf = [];
+			while (filelen--){ 
+				var c = readByte();
+				if (c == "/" | c ==":"){
+					i = 0;
+				} else if (i < NAMEMAX-1)
+					nameBuf[i++] = String.fromCharCode(c);
+			}
+			if (debug)
+				alert("nameBuf: "+nameBuf);
+			
+			//nameBuf[i] = "\0";
+			if (!fileout)
+				fileout = nameBuf;
+			
+			var i = 0;
+			while (i < extralen){
+				c = readByte();
+				i++;
+			}
+				
+			CRC = 0xffffffff;
+			SIZE = 0;
+			
+			if (size = 0 && fileOut.charAt(fileout.length-1)=="/"){
+				//skipdir
+				if (debug)
+					alert("skipdir");
+			}
+			if (method == 8){
+				DeflateLoop();
+				if (debug)
+					alert(outputArr.join(''));
+				unzipped[files] = new Array(2);
+				unzipped[files][0] = outputArr.join('');
+    			unzipped[files][1] = nameBuf.join('');
+    			files++;
+				//return outputArr.join('');
+			}
+			skipdir();
+		}
+	}
+ };
+	
+function skipdir(){
+    var crc, 
+        tmp = [],
+        compSize, size, os, i, c;
+    
+	if ((gpflags & 8)) {
+		tmp[0] = readByte();
+		tmp[1] = readByte();
+		tmp[2] = readByte();
+		tmp[3] = readByte();
+		
+		if (tmp[0] == parseInt("50",16) && 
+            tmp[1] == parseInt("4b",16) && 
+            tmp[2] == parseInt("07",16) && 
+            tmp[3] == parseInt("08",16))
+        {
+            crc = readByte();
+            crc |= (readByte()<<8);
+            crc |= (readByte()<<16);
+            crc |= (readByte()<<24);
+		} else {
+			crc = tmp[0] | (tmp[1]<<8) | (tmp[2]<<16) | (tmp[3]<<24);
+		}
+		
+		compSize = readByte();
+		compSize |= (readByte()<<8);
+		compSize |= (readByte()<<16);
+		compSize |= (readByte()<<24);
+		
+		size = readByte();
+		size |= (readByte()<<8);
+		size |= (readByte()<<16);
+		size |= (readByte()<<24);
+		
+		if (debug)
+			alert("CRC:");
+	}
+
+	if (modeZIP)
+		nextFile();
+	
+	tmp[0] = readByte();
+	if (tmp[0] != 8) {
+		if (debug)
+			alert("Unknown compression method!");
+        return 0;	
+	}
+	
+	gpflags = readByte();
+	if (debug){
+		if ((gpflags & ~(parseInt("1f",16))))
+			alert("Unknown flags set!");
+	}
+	
+	readByte();
+	readByte();
+	readByte();
+	readByte();
+	
+	readByte();
+	os = readByte();
+	
+	if ((gpflags & 4)){
+		tmp[0] = readByte();
+		tmp[2] = readByte();
+		len = tmp[0] + 256*tmp[1];
+		if (debug)
+			alert("Extra field size: "+len);
+		for (i=0;i<len;i++)
+			readByte();
+	}
+	
+	if ((gpflags & 8)){
+		i=0;
+		nameBuf=[];
+		while (c=readByte()){
+			if(c == "7" || c == ":")
+				i=0;
+			if (i<NAMEMAX-1)
+				nameBuf[i++] = c;
+		}
+		//nameBuf[i] = "\0";
+		if (debug)
+			alert("original file name: "+nameBuf);
+	}
+		
+	if ((gpflags & 16)){
+		while (c=readByte()){
+			//FILE COMMENT
+		}
+	}
+	
+	if ((gpflags & 2)){
+		readByte();
+		readByte();
+	}
+	
+	DeflateLoop();
+	
+	crc = readByte();
+	crc |= (readByte()<<8);
+	crc |= (readByte()<<16);
+	crc |= (readByte()<<24);
+	
+	size = readByte();
+	size |= (readByte()<<8);
+	size |= (readByte()<<16);
+	size |= (readByte()<<24);
+	
+	if (modeZIP)
+		nextFile();
+	
+};
+
+};
+
+/**
+*  Base64 encoding / decoding
+*  {@link http://www.webtoolkit.info/}
+*/
+JXG.Util.Base64 = {
+
+    // private property
+    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
+
+    // public method for encoding
+    encode : function (input) {
+        var output = [],
+            chr1, chr2, chr3, enc1, enc2, enc3, enc4,
+            i = 0;
+
+        input = JXG.Util.Base64._utf8_encode(input);
+
+        while (i < input.length) {
+
+            chr1 = input.charCodeAt(i++);
+            chr2 = input.charCodeAt(i++);
+            chr3 = input.charCodeAt(i++);
+
+            enc1 = chr1 >> 2;
+            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
+            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
+            enc4 = chr3 & 63;
+
+            if (isNaN(chr2)) {
+                enc3 = enc4 = 64;
+            } else if (isNaN(chr3)) {
+                enc4 = 64;
+            }
+
+            output.push([this._keyStr.charAt(enc1),
+                         this._keyStr.charAt(enc2),
+                         this._keyStr.charAt(enc3),
+                         this._keyStr.charAt(enc4)].join(''));
+        }
+
+        return output.join('');
+    },
+
+    // public method for decoding
+    decode : function (input, utf8) {
+        var output = [],
+            chr1, chr2, chr3,
+            enc1, enc2, enc3, enc4,
+            i = 0;
+
+        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
+
+        while (i < input.length) {
+
+            enc1 = this._keyStr.indexOf(input.charAt(i++));
+            enc2 = this._keyStr.indexOf(input.charAt(i++));
+            enc3 = this._keyStr.indexOf(input.charAt(i++));
+            enc4 = this._keyStr.indexOf(input.charAt(i++));
+
+            chr1 = (enc1 << 2) | (enc2 >> 4);
+            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
+            chr3 = ((enc3 & 3) << 6) | enc4;
+
+            output.push(String.fromCharCode(chr1));
+
+            if (enc3 != 64) {
+                output.push(String.fromCharCode(chr2));
+            }
+            if (enc4 != 64) {
+                output.push(String.fromCharCode(chr3));
+            }
+        }
+        
+        output = output.join(''); 
+        
+        if (utf8) {
+            output = JXG.Util.Base64._utf8_decode(output);
+        }
+        return output;
+
+    },
+
+    // private method for UTF-8 encoding
+    _utf8_encode : function (string) {
+        string = string.replace(/\r\n/g,"\n");
+        var utftext = "";
+
+        for (var n = 0; n < string.length; n++) {
+
+            var c = string.charCodeAt(n);
+
+            if (c < 128) {
+                utftext += String.fromCharCode(c);
+            }
+            else if((c > 127) && (c < 2048)) {
+                utftext += String.fromCharCode((c >> 6) | 192);
+                utftext += String.fromCharCode((c & 63) | 128);
+            }
+            else {
+                utftext += String.fromCharCode((c >> 12) | 224);
+                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
+                utftext += String.fromCharCode((c & 63) | 128);
+            }
+
+        }
+
+        return utftext;
+    },
+
+    // private method for UTF-8 decoding
+    _utf8_decode : function (utftext) {
+        var string = [],
+            i = 0,
+            c = 0, c2 = 0, c3 = 0;
+
+        while ( i < utftext.length ) {
+            c = utftext.charCodeAt(i);
+            if (c < 128) {
+                string.push(String.fromCharCode(c));
+                i++;
+            }
+            else if((c > 191) && (c < 224)) {
+                c2 = utftext.charCodeAt(i+1);
+                string.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
+                i += 2;
+            }
+            else {
+                c2 = utftext.charCodeAt(i+1);
+                c3 = utftext.charCodeAt(i+2);
+                string.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
+                i += 3;
+            }
+        }
+        return string.join('');
+    },
+    
+    _destrip: function (stripped, wrap){
+        var lines = [], lineno, i,
+            destripped = [];
+        
+        if (wrap==null) 
+            wrap = 76;
+            
+        stripped.replace(/ /g, "");
+        lineno = stripped.length / wrap;
+        for (i = 0; i < lineno; i++)
+            lines[i]=stripped.substr(i * wrap, wrap);
+        if (lineno != stripped.length / wrap)
+            lines[lines.length]=stripped.substr(lineno * wrap, stripped.length-(lineno * wrap));
+            
+        for (i = 0; i < lines.length; i++)
+            destripped.push(lines[i]);
+        return destripped.join('\n');
+    },
+    
+    decodeAsArray: function (input){
+        var dec = this.decode(input),
+            ar = [], i;
+        for (i=0;i<dec.length;i++){
+            ar[i]=dec.charCodeAt(i);
+        }
+        return ar;
+    },
+    
+    decodeGEONExT : function (input) {
+        return decodeAsArray(destrip(input),false);
+    }
+};
+
+/**
+ * @private
+ */
+JXG.Util.asciiCharCodeAt = function(str,i){
+	var c = str.charCodeAt(i);
+	if (c>255){
+    	switch (c) {
+			case 8364: c=128;
+	    	break;
+	    	case 8218: c=130;
+	    	break;
+	    	case 402: c=131;
+	    	break;
+	    	case 8222: c=132;
+	    	break;
+	    	case 8230: c=133;
+	    	break;
+	    	case 8224: c=134;
+	    	break;
+	    	case 8225: c=135;
+	    	break;
+	    	case 710: c=136;
+	    	break;
+	    	case 8240: c=137;
+	    	break;
+	    	case 352: c=138;
+	    	break;
+	    	case 8249: c=139;
+	    	break;
+	    	case 338: c=140;
+	    	break;
+	    	case 381: c=142;
+	    	break;
+	    	case 8216: c=145;
+	    	break;
+	    	case 8217: c=146;
+	    	break;
+	    	case 8220: c=147;
+	    	break;
+	    	case 8221: c=148;
+	    	break;
+	    	case 8226: c=149;
+	    	break;
+	    	case 8211: c=150;
+	    	break;
+	    	case 8212: c=151;
+	    	break;
+	    	case 732: c=152;
+	    	break;
+	    	case 8482: c=153;
+	    	break;
+	    	case 353: c=154;
+	    	break;
+	    	case 8250: c=155;
+	    	break;
+	    	case 339: c=156;
+	    	break;
+	    	case 382: c=158;
+	    	break;
+	    	case 376: c=159;
+	    	break;
+	    	default:
+	    	break;
+	    }
+	}
+	return c;
+};
+
+/**
+ * Decoding string into utf-8
+ * @param {String} string to decode
+ * @return {String} utf8 decoded string
+ */
+JXG.Util.utf8Decode = function(utftext) {
+  var string = [];
+  var i = 0;
+  var c = 0, c1 = 0, c2 = 0, c3;
+  if (!JXG.exists(utftext)) return '';
+  
+  while ( i < utftext.length ) {
+    c = utftext.charCodeAt(i);
+
+    if (c < 128) {
+      string.push(String.fromCharCode(c));
+      i++;
+    } else if((c > 191) && (c < 224)) {
+      c2 = utftext.charCodeAt(i+1);
+      string.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
+      i += 2;
+    } else {
+      c2 = utftext.charCodeAt(i+1);
+      c3 = utftext.charCodeAt(i+2);
+      string.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
+      i += 3;
+    }
+  };
+  return string.join('');
+};
+
+/**
+ * Generate a random uuid.
+ * http://www.broofa.com
+ * mailto:robert@broofa.com
+ *
+ * Copyright (c) 2010 Robert Kieffer
+ * Dual licensed under the MIT and GPL licenses.
+ *
+ * EXAMPLES:
+ *   >>> Math.uuid()
+ *   "92329D39-6F5C-4520-ABFC-AAB64544E172"
+ */
+JXG.Util.genUUID = function() {
+    // Private array of chars to use
+    var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),
+        uuid = new Array(36), rnd=0, r;
+
+    for (var i = 0; i < 36; i++) {
+      if (i==8 || i==13 ||  i==18 || i==23) {
+        uuid[i] = '-';
+      } else if (i==14) {
+        uuid[i] = '4';
+      } else {
+        if (rnd <= 0x02) rnd = 0x2000000 + (Math.random()*0x1000000)|0;
+        r = rnd & 0xf;
+        rnd = rnd >> 4;
+        uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
+      }
+    }
+
+    return uuid.join('');
+};
+
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/md5.js.html b/doc/md5.js.html new file mode 100644 index 00000000..92594e93 --- /dev/null +++ b/doc/md5.js.html @@ -0,0 +1,253 @@ + + + + + JSDoc: Source: ciphers/hash/md5.js + + + + + + + + + + +
+ +

Source: ciphers/hash/md5.js

+ + + + + +
+
+
/**
+ * 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.
+ */
+
+function MD5(entree) {
+	var hex = md5(entree);
+	var bin = util.hex2bin(hex);
+	return bin;
+}
+
+function md5cycle(x, k) {
+var a = x[0], b = x[1], c = x[2], d = x[3];
+
+a = ff(a, b, c, d, k[0], 7, -680876936);
+d = ff(d, a, b, c, k[1], 12, -389564586);
+c = ff(c, d, a, b, k[2], 17,  606105819);
+b = ff(b, c, d, a, k[3], 22, -1044525330);
+a = ff(a, b, c, d, k[4], 7, -176418897);
+d = ff(d, a, b, c, k[5], 12,  1200080426);
+c = ff(c, d, a, b, k[6], 17, -1473231341);
+b = ff(b, c, d, a, k[7], 22, -45705983);
+a = ff(a, b, c, d, k[8], 7,  1770035416);
+d = ff(d, a, b, c, k[9], 12, -1958414417);
+c = ff(c, d, a, b, k[10], 17, -42063);
+b = ff(b, c, d, a, k[11], 22, -1990404162);
+a = ff(a, b, c, d, k[12], 7,  1804603682);
+d = ff(d, a, b, c, k[13], 12, -40341101);
+c = ff(c, d, a, b, k[14], 17, -1502002290);
+b = ff(b, c, d, a, k[15], 22,  1236535329);
+
+a = gg(a, b, c, d, k[1], 5, -165796510);
+d = gg(d, a, b, c, k[6], 9, -1069501632);
+c = gg(c, d, a, b, k[11], 14,  643717713);
+b = gg(b, c, d, a, k[0], 20, -373897302);
+a = gg(a, b, c, d, k[5], 5, -701558691);
+d = gg(d, a, b, c, k[10], 9,  38016083);
+c = gg(c, d, a, b, k[15], 14, -660478335);
+b = gg(b, c, d, a, k[4], 20, -405537848);
+a = gg(a, b, c, d, k[9], 5,  568446438);
+d = gg(d, a, b, c, k[14], 9, -1019803690);
+c = gg(c, d, a, b, k[3], 14, -187363961);
+b = gg(b, c, d, a, k[8], 20,  1163531501);
+a = gg(a, b, c, d, k[13], 5, -1444681467);
+d = gg(d, a, b, c, k[2], 9, -51403784);
+c = gg(c, d, a, b, k[7], 14,  1735328473);
+b = gg(b, c, d, a, k[12], 20, -1926607734);
+
+a = hh(a, b, c, d, k[5], 4, -378558);
+d = hh(d, a, b, c, k[8], 11, -2022574463);
+c = hh(c, d, a, b, k[11], 16,  1839030562);
+b = hh(b, c, d, a, k[14], 23, -35309556);
+a = hh(a, b, c, d, k[1], 4, -1530992060);
+d = hh(d, a, b, c, k[4], 11,  1272893353);
+c = hh(c, d, a, b, k[7], 16, -155497632);
+b = hh(b, c, d, a, k[10], 23, -1094730640);
+a = hh(a, b, c, d, k[13], 4,  681279174);
+d = hh(d, a, b, c, k[0], 11, -358537222);
+c = hh(c, d, a, b, k[3], 16, -722521979);
+b = hh(b, c, d, a, k[6], 23,  76029189);
+a = hh(a, b, c, d, k[9], 4, -640364487);
+d = hh(d, a, b, c, k[12], 11, -421815835);
+c = hh(c, d, a, b, k[15], 16,  530742520);
+b = hh(b, c, d, a, k[2], 23, -995338651);
+
+a = ii(a, b, c, d, k[0], 6, -198630844);
+d = ii(d, a, b, c, k[7], 10,  1126891415);
+c = ii(c, d, a, b, k[14], 15, -1416354905);
+b = ii(b, c, d, a, k[5], 21, -57434055);
+a = ii(a, b, c, d, k[12], 6,  1700485571);
+d = ii(d, a, b, c, k[3], 10, -1894986606);
+c = ii(c, d, a, b, k[10], 15, -1051523);
+b = ii(b, c, d, a, k[1], 21, -2054922799);
+a = ii(a, b, c, d, k[8], 6,  1873313359);
+d = ii(d, a, b, c, k[15], 10, -30611744);
+c = ii(c, d, a, b, k[6], 15, -1560198380);
+b = ii(b, c, d, a, k[13], 21,  1309151649);
+a = ii(a, b, c, d, k[4], 6, -145523070);
+d = ii(d, a, b, c, k[11], 10, -1120210379);
+c = ii(c, d, a, b, k[2], 15,  718787259);
+b = ii(b, c, d, a, k[9], 21, -343485551);
+
+x[0] = add32(a, x[0]);
+x[1] = add32(b, x[1]);
+x[2] = add32(c, x[2]);
+x[3] = add32(d, x[3]);
+
+}
+
+function cmn(q, a, b, x, s, t) {
+a = add32(add32(a, q), add32(x, t));
+return add32((a << s) | (a >>> (32 - s)), b);
+}
+
+function ff(a, b, c, d, x, s, t) {
+return cmn((b & c) | ((~b) & d), a, b, x, s, t);
+}
+
+function gg(a, b, c, d, x, s, t) {
+return cmn((b & d) | (c & (~d)), a, b, x, s, t);
+}
+
+function hh(a, b, c, d, x, s, t) {
+return cmn(b ^ c ^ d, a, b, x, s, t);
+}
+
+function ii(a, b, c, d, x, s, t) {
+return cmn(c ^ (b | (~d)), a, b, x, s, t);
+}
+
+function md51(s) {
+txt = '';
+var n = s.length,
+state = [1732584193, -271733879, -1732584194, 271733878], i;
+for (i=64; i<=s.length; i+=64) {
+md5cycle(state, md5blk(s.substring(i-64, i)));
+}
+s = s.substring(i-64);
+var tail = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0];
+for (i=0; i<s.length; i++)
+tail[i>>2] |= s.charCodeAt(i) << ((i%4) << 3);
+tail[i>>2] |= 0x80 << ((i%4) << 3);
+if (i > 55) {
+md5cycle(state, tail);
+for (i=0; i<16; i++) tail[i] = 0;
+}
+tail[14] = n*8;
+md5cycle(state, tail);
+return state;
+}
+
+/* there needs to be support for Unicode here,
+ * unless we pretend that we can redefine the MD-5
+ * algorithm for multi-byte characters (perhaps
+ * by adding every four 16-bit characters and
+ * shortening the sum to 32 bits). Otherwise
+ * I suggest performing MD-5 as if every character
+ * was two bytes--e.g., 0040 0025 = @%--but then
+ * how will an ordinary MD-5 sum be matched?
+ * There is no way to standardize text to something
+ * like UTF-8 before transformation; speed cost is
+ * utterly prohibitive. The JavaScript standard
+ * itself needs to look at this: it should start
+ * providing access to strings as preformed UTF-8
+ * 8-bit unsigned value arrays.
+ */
+function md5blk(s) { /* I figured global was faster.   */
+var md5blks = [], i; /* Andy King said do it this way. */
+for (i=0; i<64; i+=4) {
+md5blks[i>>2] = s.charCodeAt(i)
++ (s.charCodeAt(i+1) << 8)
++ (s.charCodeAt(i+2) << 16)
++ (s.charCodeAt(i+3) << 24);
+}
+return md5blks;
+}
+
+var hex_chr = '0123456789abcdef'.split('');
+
+function rhex(n)
+{
+var s='', j=0;
+for(; j<4; j++)
+s += hex_chr[(n >> (j * 8 + 4)) & 0x0F]
++ hex_chr[(n >> (j * 8)) & 0x0F];
+return s;
+}
+
+function hex(x) {
+for (var i=0; i<x.length; i++)
+x[i] = rhex(x[i]);
+return x.join('');
+}
+
+function md5(s) {
+return hex(md51(s));
+}
+
+/* this function is much faster,
+so if possible we use it. Some IEs
+are the only ones I know of that
+need the idiotic second function,
+generated by an if clause.  */
+
+function add32(a, b) {
+return (a + b) & 0xFFFFFFFF;
+}
+
+if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
+function add32(x, y) {
+var lsw = (x & 0xFFFF) + (y & 0xFFFF),
+msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+return (msw << 16) | (lsw & 0xFFFF);
+}
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.config.js.html b/doc/openpgp.config.js.html new file mode 100644 index 00000000..8c29fc92 --- /dev/null +++ b/doc/openpgp.config.js.html @@ -0,0 +1,139 @@ + + + + + JSDoc: Source: config/openpgp.config.js + + + + + + + + + + +
+ +

Source: config/openpgp.config.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
+
+/**
+ *
+ * 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
+ * @class
+ * @classdesc Implementation of the GPG4Browsers config object
+ */
+function openpgp_config() {
+	/**
+	 * The variable with the actual configuration
+	 * @property {Integer} prefer_hash_algorithm
+	 * @property {Integer} encryption_cipher
+	 * @property {Integer} compression
+	 * @property {Boolean} show_version
+	 * @property {Boolean} show_comment
+	 * @property {Boolean} integrity_protect
+	 * @property {Integer} composition_behavior
+	 * @property {String} keyserver
+	 */
+	this.config = null;
+
+	/**
+	 * The default config object which is used if no
+	 * configuration was in place
+	 */
+	this.default_config = {
+			prefer_hash_algorithm: 2,
+			encryption_cipher: 9,
+			compression: 1,
+			show_version: true,
+			show_comment: true,
+			integrity_protect: true,
+			composition_behavior: 0,
+			keyserver: "keyserver.linux.it" // "pgp.mit.edu:11371"
+	};
+
+	this.versionstring ="OpenPGP.js VERSION";
+	this.commentstring ="http://openpgpjs.org";
+	/**
+	 * Reads the config out of the HTML5 local storage
+	 * and initializes the object config.
+	 * if config is null the default config will be used
+	 */
+	function read() {
+		var cf = JSON.parse(window.localStorage.getItem("config"));
+		if (cf == null) {
+			this.config = this.default_config;
+			this.write();
+		}
+		else
+			this.config = cf;
+	}
+
+	/**
+	 * If enabled, debug messages will be printed
+	 */
+	this.debug = false;
+
+	/**
+	 * Writes the config to HTML5 local storage
+	 */
+	function write() {
+		window.localStorage.setItem("config",JSON.stringify(this.config));
+	}
+
+	this.read = read;
+	this.write = write;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.crypto.sym.js.html b/doc/openpgp.crypto.sym.js.html new file mode 100644 index 00000000..8f3018b4 --- /dev/null +++ b/doc/openpgp.crypto.sym.js.html @@ -0,0 +1,143 @@ + + + + + JSDoc: Source: ciphers/openpgp.crypto.sym.js + + + + + + + + + + +
+ +

Source: ciphers/openpgp.crypto.sym.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 symmetric crypto interface
+
+/**
+ * Symmetrically encrypts data using prefixedrandom, a key with length 
+ * depending on the algorithm in openpgp_cfb mode with or without resync
+ * (MDC style)
+ * @param {String} 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
+ * @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 Data to encrypt
+ * @param {Boolean} openpgp_cfb
+ * @return {String} Encrypted data
+ */
+function openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_cfb) {
+	switch(algo) {
+		case 0: // Plaintext or unencrypted data
+			return data; // blockcipherencryptfn, plaintext, block_size, key
+		case 2: // TripleDES (DES-EDE, [SCHNEIER] [HAC] - 168 bit key derived from 192)
+			return openpgp_cfb_encrypt(prefixrandom, desede, data,8,key, openpgp_cfb).substring(0, data.length + 10);
+		case 3: // CAST5 (128 bit key, as per [RFC2144])
+			return openpgp_cfb_encrypt(prefixrandom, cast5_encrypt, data,8,key, openpgp_cfb).substring(0, data.length + 10);
+		case 4: // Blowfish (128 bit key, 16 rounds) [BLOWFISH]
+			return openpgp_cfb_encrypt(prefixrandom, BFencrypt, data,8,key, openpgp_cfb).substring(0, data.length + 10);
+		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_encrypt(prefixrandom, AESencrypt, data, 16, keyExpansion(key), openpgp_cfb).substring(0, data.length + 18);
+		case 10: // Twofish with 256-bit key [TWOFISH]
+			return openpgp_cfb_encrypt(prefixrandom, TFencrypt, data,16, key, openpgp_cfb).substring(0, data.length + 18);
+		case 1: // IDEA [IDEA]
+			util.print_error("IDEA Algorithm not implemented");
+			return null;
+		default:
+			return null;
+	}
+}
+
+/**
+ * Symmetrically decrypts data using a key with length depending on the
+ * algorithm in openpgp_cfb mode with or without resync (MDC style)
+ * @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 Data to be decrypted
+ * @param {Boolean} openpgp_cfb If true use the resync (for encrypteddata); 
+ * otherwise use without the resync (for MDC encrypted data)
+ * @return {String} Plaintext data
+ */
+function openpgp_crypto_symmetricDecrypt(algo, key, data, openpgp_cfb) {
+	util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+algo+"\nencrypteddata:",data);
+	var n = 0;
+	if (!openpgp_cfb)
+		n = 2;
+	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_decrypt(desede, 8, key, data, openpgp_cfb).substring(n, (data.length+n)-10);
+	case 3: // CAST5 (128 bit key, as per [RFC2144])
+		return openpgp_cfb_decrypt(cast5_encrypt, 8, key, data, openpgp_cfb).substring(n, (data.length+n)-10);
+	case 4: // Blowfish (128 bit key, 16 rounds) [BLOWFISH]
+		return openpgp_cfb_decrypt(BFencrypt, 8, key, data, openpgp_cfb).substring(n, (data.length+n)-10);
+	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_decrypt(AESencrypt, 16, keyExpansion(key), data, openpgp_cfb).substring(n, (data.length+n)-18);
+	case 10: // Twofish with 256-bit key [TWOFISH]
+		var result = openpgp_cfb_decrypt(TFencrypt, 16, key, data, openpgp_cfb).substring(n, (data.length+n)-18);
+		return result;
+	case 1: // IDEA [IDEA]
+		util.print_error(""+ (algo == 1 ? "IDEA Algorithm not implemented" : "Twofish Algorithm not implemented"));
+		return null;
+	default:
+	}
+	return null;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.encoding.asciiarmor.js.html b/doc/openpgp.encoding.asciiarmor.js.html new file mode 100644 index 00000000..126f6b54 --- /dev/null +++ b/doc/openpgp.encoding.asciiarmor.js.html @@ -0,0 +1,295 @@ + + + + + JSDoc: Source: encoding/openpgp.encoding.asciiarmor.js + + + + + + + + + + +
+ +

Source: encoding/openpgp.encoding.asciiarmor.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
+
+/**
+ * DeArmor an OpenPGP armored message; verify the checksum and return 
+ * the encoded bytes
+ * @param {String} text OpenPGP armored message
+ * @returns {(String|Object)} Either the bytes of the decoded message 
+ * or an object with attribute "text" containing the message text
+ * and an attribute "openpgp" containing the bytes.
+ */
+function openpgp_encoding_deArmor(text) {
+	var type = getPGPMessageType(text);
+	if (type != 2) {
+	var splittedtext = text.split('-----');
+	data = { openpgp: openpgp_encoding_base64_decode(splittedtext[2].split('\n\n')[1].split("\n=")[0].replace(/\n- /g,"\n")),
+			type: type};
+	if (verifyCheckSum(data.openpgp, splittedtext[2].split('\n\n')[1].split("\n=")[1].split('\n')[0]))
+		return data;
+	else
+		util.print_error("Ascii armor integrity check on message failed: '"+splittedtext[2].split('\n\n')[1].split("\n=")[1].split('\n')[0]+"' should be '"+getCheckSum(data))+"'";
+	} else {
+		var splittedtext = text.split('-----');
+		var result = { text: splittedtext[2].replace(/\n- /g,"\n").split("\n\n")[1],
+		               openpgp: openpgp_encoding_base64_decode(splittedtext[4].split("\n\n")[1].split("\n=")[0]),
+		               type: type};
+		if (verifyCheckSum(result.openpgp, splittedtext[4].split("\n\n")[1].split("\n=")[1]))
+				return result;
+		else
+			util.print_error("Ascii armor integrity check on message failed");
+	}
+}
+
+/**
+ * Finds out which Ascii Armoring type is used. This is an internal function
+ * @param {String} text [String] ascii armored text
+ * @returns {Integer} 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
+ */
+function getPGPMessageType(text) {
+	var splittedtext = text.split('-----');
+	// BEGIN PGP MESSAGE, PART X/Y
+	// Used for multi-part messages, where the armor is split amongst Y
+	// parts, and this is the Xth part out of Y.
+	if (splittedtext[1].match(/BEGIN PGP MESSAGE, PART \d+\/\d+/)) {
+		return 0;
+	} else
+		// BEGIN PGP MESSAGE, PART X
+		// Used for multi-part messages, where this is the Xth part of an
+		// unspecified number of parts. Requires the MESSAGE-ID Armor
+		// Header to be used.
+	if (splittedtext[1].match(/BEGIN PGP MESSAGE, PART \d+/)) {
+		return 1;
+
+	} else
+		// BEGIN PGP SIGNATURE
+		// Used for detached signatures, OpenPGP/MIME signatures, and
+		// cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE
+		// for detached signatures.
+	if (splittedtext[1].match(/BEGIN PGP SIGNED MESSAGE/)) {
+		return 2;
+
+	} else
+  	    // BEGIN PGP MESSAGE
+	    // Used for signed, encrypted, or compressed files.
+	if (splittedtext[1].match(/BEGIN PGP MESSAGE/)) {
+		return 3;
+
+	} else
+		// BEGIN PGP PUBLIC KEY BLOCK
+		// Used for armoring public keys.
+	if (splittedtext[1].match(/BEGIN PGP PUBLIC KEY BLOCK/)) {
+		return 4;
+
+	} else
+		// BEGIN PGP PRIVATE KEY BLOCK
+		// Used for armoring private keys.
+	if (splittedtext[1].match(/BEGIN PGP PRIVATE KEY BLOCK/)) {
+		return 5;
+	}
+}
+
+/**
+ * Add additional information to the armor version of an OpenPGP binary
+ * packet block.
+ * @author  Alex
+ * @version 2011-12-16
+ * @returns {String} The header information
+ */
+function openpgp_encoding_armor_addheader() {
+    var result = "";
+	if (openpgp.config.config.show_version) {
+        result += "Version: "+openpgp.config.versionstring+'\r\n';
+    }
+	if (openpgp.config.config.show_comment) {
+        result += "Comment: "+openpgp.config.commentstring+'\r\n';
+    }
+    result += '\r\n';
+    return result;
+}
+
+/**
+ * Armor an OpenPGP binary packet block
+ * @param {Integer} messagetype type of the message
+ * @param data
+ * @param {Integer} partindex
+ * @param {Integer} parttotal
+ * @returns {String} Armored text
+ */
+function openpgp_encoding_armor(messagetype, data, partindex, parttotal) {
+	var result = "";
+	switch(messagetype) {
+	case 0:
+		result += "-----BEGIN PGP MESSAGE, PART "+partindex+"/"+parttotal+"-----\r\n";
+		result += openpgp_encoding_armor_addheader();
+		result += openpgp_encoding_base64_encode(data);
+		result += "\r\n="+getCheckSum(data)+"\r\n";
+		result += "-----END PGP MESSAGE, PART "+partindex+"/"+parttotal+"-----\r\n";
+		break;
+	case 1:
+		result += "-----BEGIN PGP MESSAGE, PART "+partindex+"-----\r\n";
+		result += openpgp_encoding_armor_addheader();
+		result += openpgp_encoding_base64_encode(data);
+		result += "\r\n="+getCheckSum(data)+"\r\n";
+		result += "-----END PGP MESSAGE, PART "+partindex+"-----\r\n";
+		break;
+	case 2:
+		result += "\r\n-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: "+data.hash+"\r\n\r\n";
+		result += data.text.replace(/\n-/g,"\n- -");
+		result += "\r\n-----BEGIN PGP SIGNATURE-----\r\n";
+		result += openpgp_encoding_armor_addheader();
+		result += openpgp_encoding_base64_encode(data.openpgp);
+		result += "\r\n="+getCheckSum(data.openpgp)+"\r\n";
+		result += "-----END PGP SIGNATURE-----\r\n";
+		break;
+	case 3:
+		result += "-----BEGIN PGP MESSAGE-----\r\n";
+		result += openpgp_encoding_armor_addheader();
+		result += openpgp_encoding_base64_encode(data);
+		result += "\r\n="+getCheckSum(data)+"\r\n";
+		result += "-----END PGP MESSAGE-----\r\n";
+		break;
+	case 4:
+		result += "-----BEGIN PGP PUBLIC KEY BLOCK-----\r\n";
+		result += openpgp_encoding_armor_addheader();
+		result += openpgp_encoding_base64_encode(data);
+		result += "\r\n="+getCheckSum(data)+"\r\n";
+		result += "-----END PGP PUBLIC KEY BLOCK-----\r\n\r\n";
+		break;
+	case 5:
+		result += "-----BEGIN PGP PRIVATE KEY BLOCK-----\r\n";
+		result += openpgp_encoding_armor_addheader();
+		result += openpgp_encoding_base64_encode(data);
+		result += "\r\n="+getCheckSum(data)+"\r\n";
+		result += "-----END PGP PRIVATE KEY BLOCK-----\r\n";
+		break;
+	}
+
+	return result;
+}
+
+/**
+ * Calculates a checksum over the given data and returns it base64 encoded
+ * @param {String} data Data to create a CRC-24 checksum for
+ * @return {String} Base64 encoded checksum
+ */
+function getCheckSum(data) {
+	var c = createcrc24(data);
+	var str = "" + String.fromCharCode(c >> 16)+
+				   String.fromCharCode((c >> 8) & 0xFF)+
+				   String.fromCharCode(c & 0xFF);
+	return openpgp_encoding_base64_encode(str);
+}
+
+/**
+ * Calculates the checksum over the given data and compares it with the 
+ * given base64 encoded checksum
+ * @param {String} data Data to create a CRC-24 checksum for
+ * @param {String} checksum Base64 encoded checksum
+ * @return {Boolean} True if the given checksum is correct; otherwise false
+ */
+function verifyCheckSum(data, checksum) {
+	var c = getCheckSum(data);
+	var d = checksum;
+	return c[0] == d[0] && c[1] == d[1] && c[2] == d[2];
+}
+/**
+ * Internal function to calculate a CRC-24 checksum over a given string (data)
+ * @param {String} data Data to create a CRC-24 checksum for
+ * @return {Integer} The CRC-24 checksum as number
+ */
+var crc_table = [
+0x00000000, 0x00864cfb, 0x018ad50d, 0x010c99f6, 0x0393e6e1, 0x0315aa1a, 0x021933ec, 0x029f7f17, 0x07a18139, 0x0727cdc2, 0x062b5434, 0x06ad18cf, 0x043267d8, 0x04b42b23, 0x05b8b2d5, 0x053efe2e, 0x0fc54e89, 0x0f430272, 0x0e4f9b84, 0x0ec9d77f, 0x0c56a868, 0x0cd0e493, 0x0ddc7d65, 0x0d5a319e, 0x0864cfb0, 0x08e2834b, 0x09ee1abd, 0x09685646, 0x0bf72951, 0x0b7165aa, 0x0a7dfc5c, 0x0afbb0a7, 0x1f0cd1e9, 0x1f8a9d12, 0x1e8604e4, 0x1e00481f, 0x1c9f3708, 0x1c197bf3, 0x1d15e205, 0x1d93aefe, 0x18ad50d0, 0x182b1c2b, 0x192785dd, 0x19a1c926, 0x1b3eb631, 0x1bb8faca, 0x1ab4633c, 0x1a322fc7, 0x10c99f60, 0x104fd39b, 0x11434a6d, 0x11c50696, 0x135a7981, 0x13dc357a, 0x12d0ac8c, 0x1256e077, 0x17681e59, 0x17ee52a2, 0x16e2cb54, 0x166487af, 0x14fbf8b8, 0x147db443, 0x15712db5, 0x15f7614e, 0x3e19a3d2, 0x3e9fef29, 0x3f9376df, 0x3f153a24, 0x3d8a4533, 0x3d0c09c8, 0x3c00903e, 0x3c86dcc5, 0x39b822eb, 0x393e6e10, 0x3832f7e6, 0x38b4bb1d, 0x3a2bc40a, 0x3aad88f1, 0x3ba11107, 0x3b275dfc, 0x31dced5b, 0x315aa1a0,
+0x30563856, 0x30d074ad, 0x324f0bba, 0x32c94741, 0x33c5deb7, 0x3343924c, 0x367d6c62, 0x36fb2099, 0x37f7b96f, 0x3771f594, 0x35ee8a83, 0x3568c678, 0x34645f8e, 0x34e21375, 0x2115723b, 0x21933ec0, 0x209fa736, 0x2019ebcd, 0x228694da, 0x2200d821, 0x230c41d7, 0x238a0d2c, 0x26b4f302, 0x2632bff9, 0x273e260f, 0x27b86af4, 0x252715e3, 0x25a15918, 0x24adc0ee, 0x242b8c15, 0x2ed03cb2, 0x2e567049, 0x2f5ae9bf, 0x2fdca544, 0x2d43da53, 0x2dc596a8, 0x2cc90f5e, 0x2c4f43a5, 0x2971bd8b, 0x29f7f170, 0x28fb6886, 0x287d247d, 0x2ae25b6a, 0x2a641791, 0x2b688e67, 0x2beec29c, 0x7c3347a4, 0x7cb50b5f, 0x7db992a9, 0x7d3fde52, 0x7fa0a145, 0x7f26edbe, 0x7e2a7448, 0x7eac38b3, 0x7b92c69d, 0x7b148a66, 0x7a181390, 0x7a9e5f6b, 0x7801207c, 0x78876c87, 0x798bf571, 0x790db98a, 0x73f6092d, 0x737045d6, 0x727cdc20, 0x72fa90db, 0x7065efcc, 0x70e3a337, 0x71ef3ac1, 0x7169763a, 0x74578814, 0x74d1c4ef, 0x75dd5d19, 0x755b11e2, 0x77c46ef5, 0x7742220e, 0x764ebbf8, 0x76c8f703, 0x633f964d, 0x63b9dab6, 0x62b54340, 0x62330fbb,
+0x60ac70ac, 0x602a3c57, 0x6126a5a1, 0x61a0e95a, 0x649e1774, 0x64185b8f, 0x6514c279, 0x65928e82, 0x670df195, 0x678bbd6e, 0x66872498, 0x66016863, 0x6cfad8c4, 0x6c7c943f, 0x6d700dc9, 0x6df64132, 0x6f693e25, 0x6fef72de, 0x6ee3eb28, 0x6e65a7d3, 0x6b5b59fd, 0x6bdd1506, 0x6ad18cf0, 0x6a57c00b, 0x68c8bf1c, 0x684ef3e7, 0x69426a11, 0x69c426ea, 0x422ae476, 0x42aca88d, 0x43a0317b, 0x43267d80, 0x41b90297, 0x413f4e6c, 0x4033d79a, 0x40b59b61, 0x458b654f, 0x450d29b4, 0x4401b042, 0x4487fcb9, 0x461883ae, 0x469ecf55, 0x479256a3, 0x47141a58, 0x4defaaff, 0x4d69e604, 0x4c657ff2, 0x4ce33309, 0x4e7c4c1e, 0x4efa00e5, 0x4ff69913, 0x4f70d5e8, 0x4a4e2bc6, 0x4ac8673d, 0x4bc4fecb, 0x4b42b230, 0x49ddcd27, 0x495b81dc, 0x4857182a, 0x48d154d1, 0x5d26359f, 0x5da07964, 0x5cace092, 0x5c2aac69, 0x5eb5d37e, 0x5e339f85, 0x5f3f0673, 0x5fb94a88, 0x5a87b4a6, 0x5a01f85d, 0x5b0d61ab, 0x5b8b2d50, 0x59145247, 0x59921ebc, 0x589e874a, 0x5818cbb1, 0x52e37b16, 0x526537ed, 0x5369ae1b, 0x53efe2e0, 0x51709df7, 0x51f6d10c,
+0x50fa48fa, 0x507c0401, 0x5542fa2f, 0x55c4b6d4, 0x54c82f22, 0x544e63d9, 0x56d11cce, 0x56575035, 0x575bc9c3, 0x57dd8538];
+
+function createcrc24(input) {
+  var crc = 0xB704CE;
+  var index = 0;
+
+  while((input.length - index) > 16)  {
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+1)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+2)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+3)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+4)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+5)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+6)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+7)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+8)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+9)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+10)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+11)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+12)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+13)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+14)) & 0xff];
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index+15)) & 0xff];
+   index += 16;
+  }
+
+  for(var j = index; j < input.length; j++) {
+   crc = (crc << 8) ^ crc_table[((crc >> 16) ^ input.charCodeAt(index++)) & 0xff]
+  }
+  return crc & 0xffffff;
+}
+
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.encoding.js.html b/doc/openpgp.encoding.js.html new file mode 100644 index 00000000..a71a2c54 --- /dev/null +++ b/doc/openpgp.encoding.js.html @@ -0,0 +1,190 @@ + + + + + JSDoc: Source: encoding/openpgp.encoding.js + + + + + + + + + + +
+ +

Source: encoding/openpgp.encoding.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
+
+/**
+ * Wrapper function for the base64 codec. 
+ * This function encodes a String (message) in base64 (radix-64)
+ * @param {String} message The message to encode
+ * @return {String} The base64 encoded data
+ */
+function openpgp_encoding_base64_encode(message) {
+	return s2r(message);
+}
+
+
+/**
+ * Wrapper function for the base64 codec.
+ * This function decodes a String(message) in base64 (radix-64)
+ * @param {String} message Base64 encoded data
+ * @return {String} Raw data after decoding
+ */
+function openpgp_encoding_base64_decode(message) {
+	return r2s(message);
+}
+
+/**
+ * Wrapper function for jquery library.
+ * This function escapes HTML characters within a string. This is used 
+ * to prevent XSS.
+ * @param {String} message Message to escape
+ * @return {String} Html encoded string
+ */
+function openpgp_encoding_html_encode(message) {
+	if (message == null)
+		return "";
+	return $('<div/>').text(message).html();
+}
+
+/**
+ * create a EME-PKCS1-v1_5 padding (See RFC4880 13.1.1)
+ * @param {String} message message to be padded
+ * @param {Integer} length Length to the resulting message
+ * @return {String} EME-PKCS1 padded message
+ */
+function openpgp_encoding_eme_pkcs1_encode(message, length) {
+	if (message.length > length-11)
+		return -1;
+	var result = "";
+	result += String.fromCharCode(0);
+	result += String.fromCharCode(2);
+	for (var i = 0; i < length - message.length - 3; i++) {
+		result += String.fromCharCode(openpgp_crypto_getPseudoRandom(1,255));
+	}
+	result += String.fromCharCode(0);
+	result += message;
+	return result;
+}
+
+/**
+ * decodes a EME-PKCS1-v1_5 padding (See RFC4880 13.1.2)
+ * @param {String} message EME-PKCS1 padded message
+ * @return {String} decoded message 
+ */
+function openpgp_encoding_eme_pkcs1_decode(message, len) {
+	if (message.length < len)
+	    message = String.fromCharCode(0)+message;
+	if (message.length < 12 || message.charCodeAt(0) != 0 || message.charCodeAt(1) != 2)
+		return -1;
+	var i = 2;
+	while (message.charCodeAt(i) != 0 && message.length > i)
+	    i++;
+	return message.substring(i+1, message.length);
+}
+/**
+ * ASN1 object identifiers for hashes (See RFC4880 5.2.2)
+ */
+hash_headers = new Array();
+hash_headers[1]  = [0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x04,0x10];
+hash_headers[3]  = [0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x24,0x03,0x02,0x01,0x05,0x00,0x04,0x14];
+hash_headers[2]  = [0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14];
+hash_headers[8]  = [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20];
+hash_headers[9]  = [0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30];
+hash_headers[10] = [0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40];
+hash_headers[11] = [0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,0x04,0x1C];
+
+/**
+ * create a EMSA-PKCS1-v1_5 padding (See RFC4880 13.1.3)
+ * @param {Integer} algo Hash algorithm type used
+ * @param {String} data Data to be hashed
+ * @param {Integer} keylength Key size of the public mpi in bytes
+ * @returns {String} Hashcode with pkcs1padding as string
+ */
+function openpgp_encoding_emsa_pkcs1_encode(algo, data, keylength) {
+	var data2 = "";
+	data2 += String.fromCharCode(0x00);
+	data2 += String.fromCharCode(0x01);
+	for (var i = 0; i < (keylength - hash_headers[algo].length - 3 - openpgp_crypto_getHashByteLength(algo)); i++)
+		data2 += String.fromCharCode(0xff);
+	data2 += String.fromCharCode(0x00);
+	
+	for (var i = 0; i < hash_headers[algo].length; i++)
+		data2 += String.fromCharCode(hash_headers[algo][i]);
+	
+	data2 += openpgp_crypto_hashData(algo, data);
+	return new BigInteger(util.hexstrdump(data2),16);
+}
+
+/**
+ * extract the hash out of an EMSA-PKCS1-v1.5 padding (See RFC4880 13.1.3) 
+ * @param {String} data Hash in pkcs1 encoding
+ * @returns {String} The hash as string
+ */
+function openpgp_encoding_emsa_pkcs1_decode(algo, data) { 
+	var i = 0;
+	if (data.charCodeAt(0) == 0) i++;
+	else if (data.charCodeAt(0) != 1) return -1;
+	else i++;
+
+	while (data.charCodeAt(i) == 0xFF) i++;
+	if (data.charCodeAt(i++) != 0) return -1;
+	var j = 0;
+	for (j = 0; j < hash_headers[algo].length && j+i < data.length; j++) {
+		if (data.charCodeAt(j+i) != hash_headers[algo][j]) return -1;
+	}
+	i+= j;	
+	if (data.substring(i).length < openpgp_crypto_getHashByteLength(algo)) return -1;
+	return data.substring(i);
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.js.html b/doc/openpgp.js.html new file mode 100644 index 00000000..3e3183b2 --- /dev/null +++ b/doc/openpgp.js.html @@ -0,0 +1,509 @@ + + + + + JSDoc: Source: openpgp.js + + + + + + + + + + +
+ +

Source: openpgp.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
+
+/**
+ * @fileoverview 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.
+ */
+
+/**
+ * GPG4Browsers Core interface. A single instance is hold
+ * from the beginning. To use this library call "openpgp.init()"
+ * @alias openpgp
+ * @class
+ * @classdesc Main Openpgp.js class. Use this to initiate and make all calls to this library.
+ */
+function _openpgp () {
+	this.tostring = "";
+	
+	/**
+	 * initializes the library:
+	 * - reading the keyring from local storage
+	 * - reading the config from local storage
+	 */
+	function init() {
+		this.config = new openpgp_config();
+		this.config.read();
+		this.keyring = new openpgp_keyring();
+		this.keyring.init();
+	}
+	
+	/**
+	 * reads several publicKey objects from a ascii armored
+	 * representation an returns openpgp_msg_publickey packets
+	 * @param {String} armoredText OpenPGP armored text containing
+	 * the public key(s)
+	 * @return {openpgp_msg_publickey[]} on error the function
+	 * returns null
+	 */
+	function read_publicKey(armoredText) {
+		var mypos = 0;
+		var publicKeys = new Array();
+		var publicKeyCount = 0;
+		var input = openpgp_encoding_deArmor(armoredText.replace(/\r/g,'')).openpgp;
+		var l = input.length;
+		while (mypos != input.length) {
+			var first_packet = openpgp_packet.read_packet(input, mypos, l);
+			// public key parser
+			if (input[mypos].charCodeAt() == 0x99 || first_packet.tagType == 6) {
+				publicKeys[publicKeyCount] = new openpgp_msg_publickey();				
+				publicKeys[publicKeyCount].header = input.substring(mypos,mypos+3);
+				if (input[mypos].charCodeAt() == 0x99) {
+					// parse the length and read a tag6 packet
+					mypos++;
+					var l = (input[mypos++].charCodeAt() << 8)
+							| input[mypos++].charCodeAt();
+					publicKeys[publicKeyCount].publicKeyPacket = new openpgp_packet_keymaterial();
+					publicKeys[publicKeyCount].publicKeyPacket.header = publicKeys[publicKeyCount].header;
+					publicKeys[publicKeyCount].publicKeyPacket.read_tag6(input, mypos, l);
+					mypos += publicKeys[publicKeyCount].publicKeyPacket.packetLength;
+					mypos += publicKeys[publicKeyCount].read_nodes(publicKeys[publicKeyCount].publicKeyPacket, input, mypos, (input.length - mypos));
+				} else {
+					publicKeys[publicKeyCount] = new openpgp_msg_publickey();
+					publicKeys[publicKeyCount].publicKeyPacket = first_packet;
+					mypos += first_packet.headerLength+first_packet.packetLength;
+					mypos += publicKeys[publicKeyCount].read_nodes(first_packet, input, mypos, input.length -mypos);
+				}
+			} else {
+				util.print_error("no public key found!");
+				return null;
+			}
+			publicKeys[publicKeyCount].data = input.substring(0,mypos);
+			publicKeyCount++;
+		}
+		return publicKeys;
+	}
+	
+	/**
+	 * reads several privateKey objects from a ascii armored
+	 * representation an returns openpgp_msg_privatekey objects
+	 * @param {String} armoredText OpenPGP armored text containing
+	 * the private key(s)
+	 * @return {openpgp_msg_privatekey[]} on error the function
+	 * returns null
+	 */
+	function read_privateKey(armoredText) {
+		var privateKeys = new Array();
+		var privateKeyCount = 0;
+		var mypos = 0;
+		var input = openpgp_encoding_deArmor(armoredText.replace(/\r/g,'')).openpgp;
+		var l = input.length;
+		while (mypos != input.length) {
+			var first_packet = openpgp_packet.read_packet(input, mypos, l);
+			if (first_packet.tagType == 5) {
+				privateKeys[privateKeys.length] = new openpgp_msg_privatekey();
+				mypos += first_packet.headerLength+first_packet.packetLength;
+				mypos += privateKeys[privateKeyCount].read_nodes(first_packet, input, mypos, l);
+			// other blocks	            
+			} else {
+				util.print_error('no block packet found!');
+				return null;
+			}
+			privateKeys[privateKeyCount].data = input.substring(0,mypos);
+			privateKeyCount++;
+		}
+		return privateKeys;		
+	}
+
+	/**
+	 * reads message packets out of an OpenPGP armored text and
+	 * returns an array of message objects
+	 * @param {String} armoredText text to be parsed
+	 * @return {openpgp_msg_message[]} on error the function
+	 * returns null
+	 */
+	function read_message(armoredText) {
+		var dearmored;
+		try{
+    		dearmored = openpgp_encoding_deArmor(armoredText.replace(/\r/g,''));
+		}
+		catch(e){
+    		util.print_error('no message found!');
+    		return null;
+		}
+		return read_messages_dearmored(dearmored);
+		}
+		
+	/**
+	 * reads message packets out of an OpenPGP armored text and
+	 * returns an array of message objects. Can be called externally or internally.
+	 * External call will parse a de-armored messaged and return messages found.
+	 * Internal will be called to read packets wrapped in other packets (i.e. compressed)
+	 * @param {String} input dearmored text of OpenPGP packets, to be parsed
+	 * @return {openpgp_msg_message[]} on error the function
+	 * returns null
+	 */
+	function read_messages_dearmored(input){
+		var messageString = input.openpgp;
+		var signatureText = input.text; //text to verify signatures against. Modified by Tag11.
+		var messages = new Array();
+		var messageCount = 0;
+		var mypos = 0;
+		var l = messageString.length;
+		while (mypos < messageString.length) {
+			var first_packet = openpgp_packet.read_packet(messageString, mypos, l);
+			if (!first_packet) {
+				break;
+			}
+			// public key parser (definition from the standard:)
+			// OpenPGP Message      :- Encrypted Message | Signed Message |
+			//                         Compressed Message | Literal Message.
+			// Compressed Message   :- Compressed Data Packet.
+			// 
+			// Literal Message      :- Literal Data Packet.
+			// 
+			// ESK                  :- Public-Key Encrypted Session Key Packet |
+			//                         Symmetric-Key Encrypted Session Key Packet.
+			// 
+			// ESK Sequence         :- ESK | ESK Sequence, ESK.
+			// 
+			// Encrypted Data       :- Symmetrically Encrypted Data Packet |
+			//                         Symmetrically Encrypted Integrity Protected Data Packet
+			// 
+			// Encrypted Message    :- Encrypted Data | ESK Sequence, Encrypted Data.
+			// 
+			// One-Pass Signed Message :- One-Pass Signature Packet,
+			//                         OpenPGP Message, Corresponding Signature Packet.
+
+			// Signed Message       :- Signature Packet, OpenPGP Message |
+			//                         One-Pass Signed Message.
+			if (first_packet.tagType ==  1 ||
+			    (first_packet.tagType == 2 && first_packet.signatureType < 16) ||
+			     first_packet.tagType ==  3 ||
+			     first_packet.tagType ==  4 ||
+				 first_packet.tagType ==  8 ||
+				 first_packet.tagType ==  9 ||
+				 first_packet.tagType == 10 ||
+				 first_packet.tagType == 11 ||
+				 first_packet.tagType == 18 ||
+				 first_packet.tagType == 19) {
+				messages[messages.length] = new openpgp_msg_message();
+				messages[messageCount].messagePacket = first_packet;
+				messages[messageCount].type = input.type;
+				// Encrypted Message
+				if (first_packet.tagType == 9 ||
+				    first_packet.tagType == 1 ||
+				    first_packet.tagType == 3 ||
+				    first_packet.tagType == 18) {
+					if (first_packet.tagType == 9) {
+						util.print_error("unexpected openpgp packet");
+						break;
+					} else if (first_packet.tagType == 1) {
+						util.print_debug("session key found:\n "+first_packet.toString());
+						var issessionkey = true;
+						messages[messageCount].sessionKeys = new Array();
+						var sessionKeyCount = 0;
+						while (issessionkey) {
+							messages[messageCount].sessionKeys[sessionKeyCount] = first_packet;
+							mypos += first_packet.packetLength + first_packet.headerLength;
+							l -= (first_packet.packetLength + first_packet.headerLength);
+							first_packet = openpgp_packet.read_packet(messageString, mypos, l);
+							
+							if (first_packet.tagType != 1 && first_packet.tagType != 3)
+								issessionkey = false;
+							sessionKeyCount++;
+						}
+						if (first_packet.tagType == 18 || first_packet.tagType == 9) {
+							util.print_debug("encrypted data found:\n "+first_packet.toString());
+							messages[messageCount].encryptedData = first_packet;
+							mypos += first_packet.packetLength+first_packet.headerLength;
+							l -= (first_packet.packetLength+first_packet.headerLength);
+							messageCount++;
+							
+						} else {
+							util.print_debug("something is wrong: "+first_packet.tagType);
+						}
+						
+					} else if (first_packet.tagType == 18) {
+						util.print_debug("symmetric encrypted data");
+						break;
+					}
+				} else 
+					if (first_packet.tagType == 2 && first_packet.signatureType < 3) {
+					// Signed Message
+						mypos += first_packet.packetLength + first_packet.headerLength;
+						l -= (first_packet.packetLength + first_packet.headerLength);
+						messages[messageCount].text = signatureText;
+						messages[messageCount].signature = first_packet;
+				        messageCount++;
+				} else 
+					// Signed Message
+					if (first_packet.tagType == 4) {
+						//TODO: Implement check
+						mypos += first_packet.packetLength + first_packet.headerLength;
+						l -= (first_packet.packetLength + first_packet.headerLength);
+				} else 
+					if (first_packet.tagType == 8) {
+					// Compressed Message
+						mypos += first_packet.packetLength + first_packet.headerLength;
+						l -= (first_packet.packetLength + first_packet.headerLength);
+				        var decompressedText = first_packet.decompress();
+				        messages = messages.concat(openpgp.read_messages_dearmored({text: decompressedText, openpgp: decompressedText}));
+				} else
+					// Marker Packet (Obsolete Literal Packet) (Tag 10)
+					// "Such a packet MUST be ignored when received." see http://tools.ietf.org/html/rfc4880#section-5.8
+					if (first_packet.tagType == 10) {
+						// reset messages
+						messages.length = 0;
+						// continue with next packet
+						mypos += first_packet.packetLength + first_packet.headerLength;
+						l -= (first_packet.packetLength + first_packet.headerLength);
+				} else 
+					if (first_packet.tagType == 11) {
+					// Literal Message -- work is already done in read_packet
+					mypos += first_packet.packetLength + first_packet.headerLength;
+					l -= (first_packet.packetLength + first_packet.headerLength);
+					signatureText = first_packet.data;
+					messages[messageCount].data = first_packet.data;
+					messageCount++;
+				} else 
+					if (first_packet.tagType == 19) {
+					// Modification Detect Code
+						mypos += first_packet.packetLength + first_packet.headerLength;
+						l -= (first_packet.packetLength + first_packet.headerLength);
+				}
+			} else {
+				util.print_error('no message found!');
+				return null;
+			}
+		}
+		
+		return messages;
+	}
+	
+	/**
+	 * creates a binary string representation of an encrypted and signed message.
+	 * The message will be encrypted with the public keys specified and signed
+	 * with the specified private key.
+	 * @param {Object} privatekey {obj: [openpgp_msg_privatekey]} Private key 
+	 * to be used to sign the message
+	 * @param {Object[]} publickeys An arraf of {obj: [openpgp_msg_publickey]}
+	 * - public keys to be used to encrypt the message 
+	 * @param {String} messagetext message text to encrypt and sign
+	 * @return {String} a binary string representation of the message which 
+	 * can be OpenPGP armored
+	 */
+	function write_signed_and_encrypted_message(privatekey, publickeys, messagetext) {
+		var result = "";
+		var literal = new openpgp_packet_literaldata().write_packet(messagetext.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"));
+		util.print_debug_hexstr_dump("literal_packet: |"+literal+"|\n",literal);
+		for (var i = 0; i < publickeys.length; i++) {
+			var onepasssignature = new openpgp_packet_onepasssignature();
+			var onepasssigstr = "";
+			if (i == 0)
+				onepasssigstr = onepasssignature.write_packet(1, openpgp.config.config.prefer_hash_algorithm,  privatekey, false);
+			else
+				onepasssigstr = onepasssignature.write_packet(1, openpgp.config.config.prefer_hash_algorithm,  privatekey, false);
+			util.print_debug_hexstr_dump("onepasssigstr: |"+onepasssigstr+"|\n",onepasssigstr);
+			var datasignature = new openpgp_packet_signature().write_message_signature(1, messagetext.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"), privatekey);
+			util.print_debug_hexstr_dump("datasignature: |"+datasignature.openpgp+"|\n",datasignature.openpgp);
+			if (i == 0) {
+				result = onepasssigstr+literal+datasignature.openpgp;
+			} else {
+				result = onepasssigstr+result+datasignature.openpgp;
+			}
+		}
+		
+		util.print_debug_hexstr_dump("signed packet: |"+result+"|\n",result);
+		// signatures done.. now encryption
+		var sessionkey = openpgp_crypto_generateSessionKey(openpgp.config.config.encryption_cipher); 
+		var result2 = "";
+		
+		// creating session keys for each recipient
+		for (var i = 0; i < publickeys.length; i++) {
+			var pkey = publickeys[i].getEncryptionKey();
+			if (pkey == null) {
+				util.print_error("no encryption key found! Key is for signing only.");
+				return null;
+			}
+			result2 += new openpgp_packet_encryptedsessionkey().
+					write_pub_key_packet(
+						pkey.getKeyId(),
+						pkey.MPIs,
+						pkey.publicKeyAlgorithm,
+						openpgp.config.config.encryption_cipher,
+						sessionkey);
+		}
+		if (openpgp.config.config.integrity_protect) {
+			result2 += new openpgp_packet_encryptedintegrityprotecteddata().write_packet(openpgp.config.config.encryption_cipher, sessionkey, result);
+		} else {
+			result2 += new openpgp_packet_encrypteddata().write_packet(openpgp.config.config.encryption_cipher, sessionkey, result);
+		}
+		return openpgp_encoding_armor(3,result2,null,null);
+	}
+	/**
+	 * creates a binary string representation of an encrypted message.
+	 * The message will be encrypted with the public keys specified 
+	 * @param {Object[]} publickeys An array of {obj: [openpgp_msg_publickey]}
+	 * -public keys to be used to encrypt the message 
+	 * @param {String} messagetext message text to encrypt
+	 * @return {String} a binary string representation of the message
+	 * which can be OpenPGP armored
+	 */
+	function write_encrypted_message(publickeys, messagetext) {
+		var result = "";
+		var literal = new openpgp_packet_literaldata().write_packet(messagetext.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"));
+		util.print_debug_hexstr_dump("literal_packet: |"+literal+"|\n",literal);
+		result = literal;
+		
+		// signatures done.. now encryption
+		var sessionkey = openpgp_crypto_generateSessionKey(openpgp.config.config.encryption_cipher); 
+		var result2 = "";
+		
+		// creating session keys for each recipient
+		for (var i = 0; i < publickeys.length; i++) {
+			var pkey = publickeys[i].getEncryptionKey();
+			if (pkey == null) {
+				util.print_error("no encryption key found! Key is for signing only.");
+				return null;
+			}
+			result2 += new openpgp_packet_encryptedsessionkey().
+					write_pub_key_packet(
+						pkey.getKeyId(),
+						pkey.MPIs,
+						pkey.publicKeyAlgorithm,
+						openpgp.config.config.encryption_cipher,
+						sessionkey);
+		}
+		if (openpgp.config.config.integrity_protect) {
+			result2 += new openpgp_packet_encryptedintegrityprotecteddata().write_packet(openpgp.config.config.encryption_cipher, sessionkey, result);
+		} else {
+			result2 += new openpgp_packet_encrypteddata().write_packet(openpgp.config.config.encryption_cipher, sessionkey, result);
+		}
+		return openpgp_encoding_armor(3,result2,null,null);
+	}
+	
+	/**
+	 * creates a binary string representation a signed message.
+	 * The message will be signed with the specified private key.
+	 * @param {Object} privatekey {obj: [openpgp_msg_privatekey]}
+	 * - the private key to be used to sign the message 
+	 * @param {String} messagetext message text to sign
+	 * @return {Object} {Object: text [String]}, openpgp: {String} a binary
+	 *  string representation of the message which can be OpenPGP
+	 *   armored(openpgp) and a text representation of the message (text). 
+	 * This can be directly used to OpenPGP armor the message
+	 */
+	function write_signed_message(privatekey, messagetext) {
+		var sig = new openpgp_packet_signature().write_message_signature(1, messagetext.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"), privatekey);
+		var result = {text: messagetext.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"), openpgp: sig.openpgp, hash: sig.hash};
+		return openpgp_encoding_armor(2,result, null, null)
+	}
+	
+	/**
+	 * generates a new key pair for openpgp. Beta stage. Currently only 
+	 * supports RSA keys, and no subkeys.
+	 * @param {Integer} keyType to indicate what type of key to make. 
+	 * RSA is 1. Follows algorithms outlined in OpenPGP.
+	 * @param {Integer} numBits number of bits for the key creation. (should 
+	 * be 1024+, generally)
+	 * @param {String} userId assumes already in form of "User Name 
+	 * <username@email.com>"
+	 * @return {Object} {privateKey: [openpgp_msg_privatekey], 
+	 * privateKeyArmored: [string], publicKeyArmored: [string]}
+	 */
+	function generate_key_pair(keyType, numBits, userId, passphrase){
+		var userIdPacket = new openpgp_packet_userid();
+		var userIdString = userIdPacket.write_packet(userId);
+		
+		var keyPair = openpgp_crypto_generateKeyPair(keyType,numBits, passphrase, openpgp.config.config.prefer_hash_algorithm, 3);
+		var privKeyString = keyPair.privateKey;
+		var privKeyPacket = new openpgp_packet_keymaterial().read_priv_key(privKeyString.string,3,privKeyString.string.length);
+		if(!privKeyPacket.decryptSecretMPIs(passphrase))
+		    util.print_error('Issue creating key. Unable to read resulting private key');
+		var privKey = new openpgp_msg_privatekey();
+		privKey.privateKeyPacket = privKeyPacket;
+		privKey.getPreferredSignatureHashAlgorithm = function(){return openpgp.config.config.prefer_hash_algorithm};//need to override this to solve catch 22 to generate signature. 8 is value for SHA256
+		
+		var publicKeyString = privKey.privateKeyPacket.publicKey.data;
+		var hashData = String.fromCharCode(0x99)+ String.fromCharCode(((publicKeyString.length) >> 8) & 0xFF) 
+			+ String.fromCharCode((publicKeyString.length) & 0xFF) +publicKeyString+String.fromCharCode(0xB4) +
+			String.fromCharCode((userId.length) >> 24) +String.fromCharCode(((userId.length) >> 16) & 0xFF) 
+			+ String.fromCharCode(((userId.length) >> 8) & 0xFF) + String.fromCharCode((userId.length) & 0xFF) + userId
+		var signature = new openpgp_packet_signature();
+		signature = signature.write_message_signature(16,hashData, privKey);
+		var publicArmored = openpgp_encoding_armor(4, keyPair.publicKey.string + userIdString + signature.openpgp );
+
+		var privArmored = openpgp_encoding_armor(5,privKeyString.string+userIdString+signature.openpgp);
+		
+		return {privateKey : privKey, privateKeyArmored: privArmored, publicKeyArmored: publicArmored}
+	}
+	
+	this.generate_key_pair = generate_key_pair;
+	this.write_signed_message = write_signed_message; 
+	this.write_signed_and_encrypted_message = write_signed_and_encrypted_message;
+	this.write_encrypted_message = write_encrypted_message;
+	this.read_message = read_message;
+	this.read_messages_dearmored = read_messages_dearmored;
+	this.read_publicKey = read_publicKey;
+	this.read_privateKey = read_privateKey;
+	this.init = init;
+}
+
+var openpgp = new _openpgp();
+
+
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.keyring.js.html b/doc/openpgp.keyring.js.html new file mode 100644 index 00000000..166dd126 --- /dev/null +++ b/doc/openpgp.keyring.js.html @@ -0,0 +1,313 @@ + + + + + JSDoc: Source: openpgp.keyring.js + + + + + + + + + + +
+ +

Source: openpgp.keyring.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
+
+/**
+ * @class
+ * @classdesc The class that deals with storage of the keyring. Currently the only option is to use HTML5 local storage.
+ */
+function openpgp_keyring() {
+		
+	/**
+	 * Initialization routine for the keyring. This method reads the 
+	 * keyring from HTML5 local storage and initializes this instance.
+	 * This method is called by openpgp.init().
+	 */
+	function init() {
+		var sprivatekeys = JSON.parse(window.localStorage.getItem("privatekeys"));
+		var spublickeys = JSON.parse(window.localStorage.getItem("publickeys"));
+		if (sprivatekeys == null || sprivatekeys.length == 0) {
+			sprivatekeys = new Array();
+		}
+
+		if (spublickeys == null || spublickeys.length == 0) {
+			spublickeys = new Array();
+		}
+		this.publicKeys = new Array();
+		this.privateKeys = new Array();
+		var k = 0;
+		for (var i =0; i < sprivatekeys.length; i++) {
+			var r = openpgp.read_privateKey(sprivatekeys[i]);
+			this.privateKeys[k] = { armored: sprivatekeys[i], obj: r[0], keyId: r[0].getKeyId()};
+			k++;
+		}
+		k = 0;
+		for (var i =0; i < spublickeys.length; i++) {
+			var r = openpgp.read_publicKey(spublickeys[i]);
+			if (r[0] != null) {
+				this.publicKeys[k] = { armored: spublickeys[i], obj: r[0], keyId: r[0].getKeyId()};
+				k++;
+			}
+		}
+	}
+	this.init = init;
+
+	/**
+	 * Checks if at least one private key is in the keyring
+	 * @return {Boolean} True if there are private keys, else false.
+	 */
+	function hasPrivateKey() {
+		return this.privateKeys.length > 0;
+	}
+	this.hasPrivateKey = hasPrivateKey;
+
+	/**
+	 * Saves the current state of the keyring to HTML5 local storage.
+	 * The privateKeys array and publicKeys array gets Stringified using JSON
+	 */
+	function store() { 
+		var priv = new Array();
+		for (var i = 0; i < this.privateKeys.length; i++) {
+			priv[i] = this.privateKeys[i].armored;
+		}
+		var pub = new Array();
+		for (var i = 0; i < this.publicKeys.length; i++) {
+			pub[i] = this.publicKeys[i].armored;
+		}
+		window.localStorage.setItem("privatekeys",JSON.stringify(priv));
+		window.localStorage.setItem("publickeys",JSON.stringify(pub));
+	}
+	this.store = store;
+	/**
+	 * searches all public keys in the keyring matching the address or address part of the user ids
+	 * @param {String} email_address
+	 * @return {openpgp_msg_publickey[]} The public keys associated with provided email address.
+	 */
+	function getPublicKeyForAddress(email_address) {
+		var results = new Array();
+		var spl = email_address.split("<");
+		var email = "";
+		if (spl.length > 1) {
+			email = spl[1].split(">")[0];
+		} else {
+			email = email_address.trim();
+		}
+		email = email.toLowerCase();
+		if(!util.emailRegEx.test(email)){
+		    return results;
+		}
+		for (var i =0; i < this.publicKeys.length; i++) {
+			for (var j = 0; j < this.publicKeys[i].obj.userIds.length; j++) {
+				if (this.publicKeys[i].obj.userIds[j].text.toLowerCase().indexOf(email) >= 0)
+					results[results.length] = this.publicKeys[i];
+			}
+		}
+		return results;
+	}
+	this.getPublicKeyForAddress = getPublicKeyForAddress;
+
+	/**
+	 * Searches the keyring for a private key containing the specified email address
+	 * @param {String} email_address email address to search for
+	 * @return {openpgp_msg_privatekey[]} private keys found
+	 */
+	function getPrivateKeyForAddress(email_address) {
+		var results = new Array();
+		var spl = email_address.split("<");
+		var email = "";
+		if (spl.length > 1) {
+			email = spl[1].split(">")[0];
+		} else {
+			email = email_address.trim();
+		}
+		email = email.toLowerCase();
+		if(!util.emailRegEx.test(email)){
+		    return results;
+		}
+		for (var i =0; i < this.privateKeys.length; i++) {
+			for (var j = 0; j < this.privateKeys[i].obj.userIds.length; j++) {
+				if (this.privateKeys[i].obj.userIds[j].text.toLowerCase().indexOf(email) >= 0)
+					results[results.length] = this.privateKeys[i];
+			}
+		}
+		return results;
+	}
+
+	this.getPrivateKeyForAddress = getPrivateKeyForAddress;
+	/**
+	 * Searches the keyring for public keys having the specified key id
+	 * @param {String} keyId provided as string of hex number (lowercase)
+	 * @return {openpgp_msg_privatekey[]} public keys found
+	 */
+	function getPublicKeysForKeyId(keyId) {
+		var result = new Array();
+		for (var i=0; i < this.publicKeys.length; i++) {
+			var key = this.publicKeys[i];
+			if (keyId == key.obj.getKeyId())
+				result[result.length] = key;
+			else if (key.obj.subKeys != null) {
+				for (var j=0; j < key.obj.subKeys.length; j++) {
+					var subkey = key.obj.subKeys[j];
+					if (keyId == subkey.getKeyId()) {
+						result[result.length] = {
+								obj: key.obj.getSubKeyAsKey(j),
+								keyId: subkey.getKeyId()
+						}
+					}
+				}
+			}
+		}
+		return result;
+	}
+	this.getPublicKeysForKeyId = getPublicKeysForKeyId;
+	
+	/**
+	 * Searches the keyring for private keys having the specified key id
+	 * @param {String} keyId 8 bytes as string containing the key id to look for
+	 * @return {openpgp_msg_privatekey[]} private keys found
+	 */
+	function getPrivateKeyForKeyId(keyId) {
+		var result = new Array();
+		for (var i=0; i < this.privateKeys.length; i++) {
+			if (keyId == this.privateKeys[i].obj.getKeyId()) {
+				result[result.length] = { key: this.privateKeys[i], keymaterial: this.privateKeys[i].obj.privateKeyPacket};
+			}
+			if (this.privateKeys[i].obj.subKeys != null) {
+				var subkeyids = this.privateKeys[i].obj.getSubKeyIds();
+				for (var j=0; j < subkeyids.length; j++)
+					if (keyId == util.hexstrdump(subkeyids[j])) {
+						result[result.length] = { key: this.privateKeys[i], keymaterial: this.privateKeys[i].obj.subKeys[j]};
+					}
+			}
+		}
+		return result;
+	}
+	this.getPrivateKeyForKeyId = getPrivateKeyForKeyId;
+	
+	/**
+	 * Imports a public key from an exported ascii armored message 
+	 * @param {String} armored_text PUBLIC KEY BLOCK message to read the public key from
+	 */
+	function importPublicKey (armored_text) {
+		var result = openpgp.read_publicKey(armored_text);
+		for (var i = 0; i < result.length; i++) {
+			this.publicKeys[this.publicKeys.length] = {armored: armored_text, obj: result[i], keyId: result[i].getKeyId()};
+		}
+		return true;
+	}
+
+	/**
+	 * Imports a private key from an exported ascii armored message 
+	 * @param {String} armored_text PRIVATE KEY BLOCK message to read the private key from
+	 */
+	function importPrivateKey (armored_text, password) {
+		var result = openpgp.read_privateKey(armored_text);
+		if(!result[0].decryptSecretMPIs(password))
+		    return false;
+		for (var i = 0; i < result.length; i++) {
+			this.privateKeys[this.privateKeys.length] = {armored: armored_text, obj: result[i], keyId: result[i].getKeyId()};
+		}
+		return true;
+	}
+
+	this.importPublicKey = importPublicKey;
+	this.importPrivateKey = importPrivateKey;
+	
+	/**
+	 * returns the openpgp_msg_privatekey representation of the public key at public key ring index  
+	 * @param {Integer} index the index of the public key within the publicKeys array
+	 * @return {openpgp_msg_privatekey} the public key object
+	 */
+	function exportPublicKey(index) {
+		return this.publicKey[index];
+	}
+	this.exportPublicKey = exportPublicKey;
+		
+	
+	/**
+	 * Removes a public key from the public key keyring at the specified index 
+	 * @param {Integer} index the index of the public key within the publicKeys array
+	 * @return {openpgp_msg_privatekey} The public key object which has been removed
+	 */
+	function removePublicKey(index) {
+		var removed = this.publicKeys.splice(index,1);
+		this.store();
+		return removed;
+	}
+	this.removePublicKey = removePublicKey;
+
+	/**
+	 * returns the openpgp_msg_privatekey representation of the private key at private key ring index  
+	 * @param {Integer} index the index of the private key within the privateKeys array
+	 * @return {openpgp_msg_privatekey} the private key object
+	 */	
+	function exportPrivateKey(index) {
+		return this.privateKeys[index];
+	}
+	this.exportPrivateKey = exportPrivateKey;
+
+	/**
+	 * Removes a private key from the private key keyring at the specified index 
+	 * @param {Integer} index the index of the private key within the privateKeys array
+	 * @return {openpgp_msg_privatekey} The private key object which has been removed
+	 */
+	function removePrivateKey(index) {
+		var removed = this.privateKeys.splice(index,1);
+		this.store();
+		return removed;
+	}
+	this.removePrivateKey = removePrivateKey;
+
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.msg.message.js.html b/doc/openpgp.msg.message.js.html new file mode 100644 index 00000000..b7cd857a --- /dev/null +++ b/doc/openpgp.msg.message.js.html @@ -0,0 +1,185 @@ + + + + + JSDoc: Source: openpgp.msg.message.js + + + + + + + + + + +
+ +

Source: openpgp.msg.message.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
+
+/**
+ * @protected
+ * @class
+ * @classdesc Top-level message object. Contains information from one or more packets
+ */
+
+function openpgp_msg_message() {
+	
+	// -1 = no valid passphrase submitted
+	// -2 = no private key found
+	// -3 = decryption error
+	// text = valid decryption
+	this.text = "";
+	this.messagePacket = null;
+	this.type = null;
+	
+	/**
+	 * Decrypts a message and generates user interface message out of the found.
+	 * MDC will be verified as well as message signatures
+	 * @param {openpgp_msg_privatekey} private_key the private the message is encrypted with (corresponding to the session key)
+	 * @param {openpgp_packet_encryptedsessionkey} sessionkey the session key to be used to decrypt the message
+	 * @return {String} plaintext of the message or null on error
+	 */
+	function decrypt(private_key, sessionkey) {
+        return this.decryptAndVerifySignature(private_key, sessionkey).text;
+	}
+
+	/**
+	 * Decrypts a message and generates user interface message out of the found.
+	 * MDC will be verified as well as message signatures
+	 * @param {openpgp_msg_privatekey} private_key the private the message is encrypted with (corresponding to the session key)
+	 * @param {openpgp_packet_encryptedsessionkey} sessionkey the session key to be used to decrypt the message
+	 * @param {openpgp_msg_publickey} pubkey Array of public keys to check signature against. If not provided, checks local keystore.
+	 * @return {String} plaintext of the message or null on error
+	 */
+	function decryptAndVerifySignature(private_key, sessionkey, pubkey) {
+		if (private_key == null || sessionkey == null || sessionkey == "")
+			return null;
+		var decrypted = sessionkey.decrypt(this, private_key.keymaterial);
+		if (decrypted == null)
+			return null;
+		var packet;
+		var position = 0;
+		var len = decrypted.length;
+		var validSignatures = new Array();
+		util.print_debug_hexstr_dump("openpgp.msg.messge decrypt:\n",decrypted);
+		
+		var messages = openpgp.read_messages_dearmored({text: decrypted, openpgp: decrypted});
+		for(var m in messages){
+			if(messages[m].data){
+				this.text = messages[m].data;
+			}
+			if(messages[m].signature){
+			    validSignatures.push(messages[m].verifySignature(pubkey));
+			}
+		}
+		return {text:this.text, validSignatures:validSignatures};
+	}
+	
+	/**
+	 * Verifies a message signature. This function can be called after read_message if the message was signed only.
+	 * @param {openpgp_msg_publickey} pubkey Array of public keys to check signature against. If not provided, checks local keystore.
+	 * @return {boolean} true if the signature was correct; otherwise false
+	 */
+	function verifySignature(pubkey) {
+		var result = false;
+		if (this.signature.tagType == 2) {
+		    if(!pubkey || pubkey.length == 0){
+			    var pubkey;
+			    if (this.signature.version == 4) {
+				    pubkey = openpgp.keyring.getPublicKeysForKeyId(this.signature.issuerKeyId);
+			    } else if (this.signature.version == 3) {
+				    pubkey = openpgp.keyring.getPublicKeysForKeyId(this.signature.keyId);
+			    } else {
+				    util.print_error("unknown signature type on message!");
+				    return false;
+			    }
+			}
+			if (pubkey.length == 0)
+				util.print_warning("Unable to verify signature of issuer: "+util.hexstrdump(this.signature.issuerKeyId)+". Public key not found in keyring.");
+			else {
+				for (var i = 0 ; i < pubkey.length; i++) {
+					var tohash = this.text.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n");
+					if (this.signature.verify(tohash, pubkey[i])) {
+						util.print_info("Found Good Signature from "+pubkey[i].obj.userIds[0].text+" (0x"+util.hexstrdump(pubkey[i].obj.getKeyId()).substring(8)+")");
+						result = true;
+					} else {
+						util.print_error("Signature verification failed: Bad Signature from "+pubkey[i].obj.userIds[0].text+" (0x"+util.hexstrdump(pubkey[0].obj.getKeyId()).substring(8)+")");
+					}
+				}
+			}
+		}
+		return result;
+	}
+	
+	function toString() {
+		var result = "Session Keys:\n";
+		if (this.sessionKeys !=null)
+		for (var i = 0; i < this.sessionKeys.length; i++) {
+			result += this.sessionKeys[i].toString();
+		}
+		result += "\n\n EncryptedData:\n";
+		if(this.encryptedData != null)
+		result += this.encryptedData.toString();
+		
+		result += "\n\n Signature:\n";
+		if(this.signature != null)
+		result += this.signature.toString();
+		
+		result += "\n\n Text:\n"
+		if(this.signature != null)
+			result += this.text;
+		return result;
+	}
+	this.decrypt = decrypt;
+	this.decryptAndVerifySignature = decryptAndVerifySignature;
+	this.verifySignature = verifySignature;
+	this.toString = toString;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.msg.privatekey.js.html b/doc/openpgp.msg.privatekey.js.html new file mode 100644 index 00000000..508fe737 --- /dev/null +++ b/doc/openpgp.msg.privatekey.js.html @@ -0,0 +1,240 @@ + + + + + JSDoc: Source: openpgp.msg.privatekey.js + + + + + + + + + + +
+ +

Source: openpgp.msg.privatekey.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
+
+/**
+ * @class
+ * @classdesc Class that represents a decoded private key for internal openpgp.js use
+ */
+
+function openpgp_msg_privatekey() {
+	this.subKeys = new Array();
+	this.privateKeyPacket = null;
+	this.userIds = new Array();
+	this.userAttributes = new Array();
+	this.revocationSignatures = new Array();
+	this.subKeys = new Array();
+
+	/**
+	 * 
+	 * @return last position
+	 */
+	function read_nodes(parent_node, input, position, len) {
+		this.privateKeyPacket = parent_node;
+		
+		var pos = position;
+		while (input.length > pos) {
+			var result = openpgp_packet.read_packet(input, pos, input.length - pos);
+			if (result == null) {
+				util.print_error("openpgp.msg.messge decrypt:\n"+'[pub/priv_key]parsing ends here @:' + pos + " l:" + len);
+				break;
+			} else {
+				switch (result.tagType) {
+				case 2: // public key revocation signature
+					if (result.signatureType == 32)
+						this.revocationSignatures[this.revocationSignatures.length] = result;
+					else if (result.signatureType > 15 && result.signatureType < 20) {
+						if (this.certificationsignatures == null)
+							this.certificationSignatures = new Array();
+						this.certificationSignatures[this.certificationSignatures.length] = result;
+					} else
+						util.print_error("openpgp.msg.messge decrypt:\n"+"unknown signature type directly on key "+result.signatureType+" @"+pos);
+					pos += result.packetLength + result.headerLength;
+					break;
+				case 7: // PrivateSubkey Packet
+					this.subKeys[this.subKeys.length] = result;
+					pos += result.packetLength + result.headerLength;
+					pos += result.read_nodes(this.privateKeyPacket,input, pos, input.length - pos);
+					break;
+				case 17: // User Attribute Packet
+					this.userAttributes[this.userAttributes.length] = result;
+					pos += result.packetLength + result.headerLength;
+					pos += result.read_nodes(this.privateKeyPacket,input, pos, input.length - pos);
+					break;
+				case 13: // User ID Packet
+					this.userIds[this.userIds.length] = result;
+					pos += result.packetLength + result.headerLength;
+					pos += result.read_nodes(this.privateKeyPacket, input, pos, input.length - pos);
+					break;
+				default:
+					this.position = position - this.privateKeyPacket.packetLength - this.privateKeyPacket.headerLength;
+					this.len = pos - position;
+					return this.len;
+				}
+			}
+		}
+		this.position = position - this.privateKeyPacket.packetLength - this.privateKeyPacket.headerLength;
+		this.len = pos - position;
+		
+		return this.len;
+	}
+	
+	function getKeyId() {
+		return this.privateKeyPacket.publicKey.getKeyId();
+	}
+	
+	
+	function getSubKeyIds() {
+		if (this.privateKeyPacket.publicKey.version == 4) // V3 keys MUST NOT have subkeys.
+		var result = new Array();
+		for (var i = 0; i < this.subKeys.length; i++) {
+			result[i] = str_sha1(this.subKeys[i].publicKey.header+this.subKeys[i].publicKey.data).substring(12,20);
+		}
+		return result;
+	}
+	
+	
+	function getSigningKey() {
+		if ((this.privateKeyPacket.publicKey.publicKeyAlgorithm == 17 ||
+			 this.privateKeyPacket.publicKey.publicKeyAlgorithm != 2)
+			&& this.privateKeyPacket.publicKey.verifyKey() == 3)
+			return this.privateKeyPacket;
+		else if (this.privateKeyPacket.publicKey.version == 4) // V3 keys MUST NOT have subkeys.
+			for (var j = 0; j < this.privateKeyPacket.subKeys.length; j++) {
+				if ((this.privateKeyPacket.subKeys[j].publicKey.publicKeyAlgorithm == 17 ||
+					 this.privateKeyPacket.subKeys[j].publicKey.publicKeyAlgorithm != 2) &&
+					 this.privateKeyPacket.subKeys[j].publicKey.verifyKey() == 3)
+					return this.privateKeyPacket.subKeys[j];
+			}
+		return null;
+	}
+	
+	function getPreferredSignatureHashAlgorithm() {
+		var pkey = this.getSigningKey();
+		if (pkey == null) {
+			util.print_error("private key is for encryption only! Cannot create a signature.")
+			return null;
+		}
+		if (pkey.publicKey.publicKeyAlgorithm == 17) {
+			var dsa = new DSA();
+			return dsa.select_hash_algorithm(pkey.publicKey.MPIs[1].toBigInteger()); // q
+		}
+		return openpgp.config.config.prefer_hash_algorithm;
+			
+	}
+
+	function decryptSecretMPIs(str_passphrase) {
+		return this.privateKeyPacket.decryptSecretMPIs(str_passphrase);
+	}
+	
+	function getFingerprint() {
+		return this.privateKeyPacket.publicKey.getFingerprint();
+	}
+
+	// TODO need to implement this
+	function revoke() {
+		
+	}
+
+	/**
+	 * extracts the public key part
+	 * @return {String} OpenPGP armored text containing the public key
+	 *                  returns null if no sufficient data to extract public key
+	 */
+	function extractPublicKey() {
+		// add public key
+		var key = this.privateKeyPacket.publicKey.header + this.privateKeyPacket.publicKey.data;
+		for (var i = 0; i < this.userIds.length; i++) {
+			// verify userids
+			if (this.userIds[i].certificationSignatures.length === 0) {
+				util.print_error("extractPublicKey - missing certification signatures");
+				return null;
+			}
+			var userIdPacket = new openpgp_packet_userid();
+			// add userids
+			key += userIdPacket.write_packet(this.userIds[i].text);
+			for (var j = 0; j < this.userIds[i].certificationSignatures.length; j++) {
+				var certSig = this.userIds[i].certificationSignatures[j];
+				// add signatures
+				key += openpgp_packet.write_packet_header(2, certSig.data.length) + certSig.data;
+			}
+		}
+		for (var k = 0; k < this.subKeys.length; k++) {
+			var pubSubKey = this.subKeys[k].publicKey;
+			// add public subkey package
+			key += openpgp_packet.write_old_packet_header(14, pubSubKey.data.length) + pubSubKey.data;
+			var subKeySig = this.subKeys[k].subKeySignature;
+			if (subKeySig !== null) {
+				// add subkey signature
+				key += openpgp_packet.write_packet_header(2, subKeySig.data.length) + subKeySig.data;
+			} else {
+				util.print_error("extractPublicKey - missing subkey signature");
+				return null;
+			}
+		}
+		var publicArmored = openpgp_encoding_armor(4, key);
+		return publicArmored;
+	}
+
+	this.extractPublicKey = extractPublicKey;
+	this.getSigningKey = getSigningKey;
+	this.getFingerprint = getFingerprint;
+	this.getPreferredSignatureHashAlgorithm = getPreferredSignatureHashAlgorithm;
+	this.read_nodes = read_nodes;
+	this.decryptSecretMPIs = decryptSecretMPIs;
+	this.getSubKeyIds = getSubKeyIds;
+	this.getKeyId = getKeyId;
+	
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.msg.publickey.js.html b/doc/openpgp.msg.publickey.js.html new file mode 100644 index 00000000..9417250f --- /dev/null +++ b/doc/openpgp.msg.publickey.js.html @@ -0,0 +1,317 @@ + + + + + JSDoc: Source: openpgp.msg.publickey.js + + + + + + + + + + +
+ +

Source: openpgp.msg.publickey.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
+
+/**
+ * @class
+ * @classdesc Decoded public key object for internal openpgp.js use
+ */
+function openpgp_msg_publickey() {
+	this.data;
+	this.position;
+	this.len;
+	this.tostring = "OPENPGP PUBLIC KEY\n";
+	this.bindingSignature = null;
+	this.publicKeyPacket = null;
+	this.userIds = new Array();
+	this.userAttributes = new Array();
+	this.revocationSignatures = new Array();
+	this.subKeys = new Array();
+	this.arbitraryPacket = new Array();
+	this.directSignatures = new Array();
+	/**
+	 * 
+	 * @return last position
+	 */
+	function read_nodes(parent_node, input, position, len) {
+		this.publicKeyPacket = parent_node;
+		var exit = false;
+		var pos = position;
+		var l = len;
+		while (input.length != pos) {
+			var result = openpgp_packet.read_packet(input, pos, input.length - pos);
+			if (result == null) {
+				util.print_error("openpgp.msg.publickey read_nodes:\n"+'[pub_key]parsing ends here @:' + pos + " l:" + l);
+				break;
+			} else {
+				switch (result.tagType) {
+				case 2: // public key revocation signature
+					if (result.signatureType == 32)
+						this.revocationSignatures[this.revocationSignatures.length] = result;
+					else if (result.signatureType == 16 || result.signatureType == 17 || result.signatureType == 18  || result.signatureType == 19)
+						this.certificationSignature = result;
+					else if (result.signatureType == 25) {
+						this.bindingSignature = result;
+					} else if (result.signatureType == 31) {
+						this.directSignatures[this.directSignatures.length] = result;
+					} else
+						util.print_error("openpgp.msg.publickey read_nodes:\n"+"unknown signature type directly on key "+result.signatureType);
+					pos += result.packetLength + result.headerLength;
+					break;
+				case 14: // Public-Subkey Packet
+					this.subKeys[this.subKeys.length] = result;
+					pos += result.packetLength + result.headerLength;
+					pos += result.read_nodes(this.publicKeyPacket,input, pos, input.length - pos);
+					break;
+				case 17: // User Attribute Packet
+					this.userAttributes[this.userAttributes.length] = result;
+					pos += result.packetLength + result.headerLength;
+					pos += result.read_nodes(this.publicKeyPacket,input, pos, input.length - pos);
+					break;
+				case 13: // User ID Packet
+					this.userIds[this.userIds.length] = result;
+					pos += result.packetLength + result.headerLength;
+					pos += result.read_nodes(this.publicKeyPacket, input, pos, input.length - pos);
+					break;
+				default:
+					this.data = input;
+					this.position = position - this.publicKeyPacket.packetLength - this.publicKeyPacket.headerLength;
+					this.len = pos - position;
+					return this.len;
+				}
+			}
+		}
+		this.data = input;
+		this.position = position - (this.publicKeyPacket.packetLength - this.publicKeyPacket.headerLength);
+		this.len = pos - position;
+		return this.len;
+	}
+
+	function write() {
+
+	}
+
+	function getKeyId() {
+		return this.publicKeyPacket.getKeyId();
+	}
+	
+	function getFingerprint() {
+		return this.publicKeyPacket.getFingerprint();
+	}
+
+
+	
+	function validate() {
+		// check revocation keys
+		for (var i = 0; i < this.revocationSignatures.length; i++) {
+			var tohash = this.publicKeyPacket.header+this.publicKeyPacket.data;
+			if (this.revocationSignatures[i].verify(tohash, this.publicKeyPacket))
+				return false;
+		}
+		
+		if (this.subKeys.length != 0) {
+			// search for a valid subkey
+			var found = false;
+			for (var i = 0; i < this.subKeys.length; i++)
+				if (this.subKeys[i].verifyKey() == 3) {
+					found = true;
+					break;
+				}
+			if (!found)
+				return false;
+		}
+		// search for one valid userid
+		found = false;
+		for (var i = 0; i < this.userIds.length; i++)
+			if (this.userIds[i].verify(this.publicKeyPacket) == 0) {
+				found = true;
+				break;
+			}
+		if (!found)
+			return false;
+		return true;
+	}
+	
+	/**
+	 * verifies all signatures
+	 * @return a 2 dimensional array. the first dimension corresponds to the userids available
+	 */
+	function verifyCertificationSignatures() {
+		var result = new Array();
+		for (var i = 0; i < this.userIds.length; i++) {
+			result[i] = this.userIds[i].verifyCertificationSignatures(this.publicKeyPacket);
+		}
+		return result;
+	}
+	this.verifyCertificationSignatures = verifyCertificationSignatures;
+	
+	/**
+	 * verifies:
+	 *  - revocation certificates directly on key
+	 *  - self signatures
+	 *  - subkey binding and revocation certificates
+	 *  
+	 *  This is useful for validating the key
+	 *  @returns {Boolean} true if the basic signatures are all valid
+	 */
+	function verifyBasicSignatures() {
+		for (var i = 0; i < this.revocationSignatures.length; i++) {
+			var tohash = this.publicKeyPacket.header+this.publicKeyPacket.data;
+			if (this.revocationSignatures[i].verify(tohash, this.publicKeyPacket))
+				return false;
+		}
+		
+		if (this.subKeys.length != 0) {
+			// search for a valid subkey
+			var found = false;
+			for (var i = 0; i < this.subKeys.length; i++) {
+				if (this.subKeys[i] == null)
+					continue;
+				var result = this.subKeys[i].verifyKey();
+				if (result == 3) {
+					found = true;
+					break;
+				} 
+			}
+			if (!found)
+				return false;
+		}
+		var keyId = this.getKeyId();
+		for (var i = 0; i < this.userIds.length; i++) {
+			for (var j = 0; j < this.userIds[i].certificationRevocationSignatures.length; j++) {
+				if (this.userIds[i].certificationSignatures[j].getIssuer == keyId &&
+					this.userIds[i].certificationSignatures[j].verifyBasic(this.publicKeyPacket) != 4)
+					return false;
+			}
+		}
+		return true;
+	}
+	
+	function toString() {
+		var result = " OPENPGP Public Key\n    length: "+this.len+"\n";
+		result += "    Revocation Signatures:\n"
+		for (var i=0; i < this.revocationSignatures.length; i++) {
+			result += "    "+this.revocationSignatures[i].toString(); 
+		}
+		result += "    User Ids:\n";
+		for (var i=0; i < this.userIds.length; i++) {
+			result += "    "+this.userIds[i].toString(); 
+		}
+		result += "    User Attributes:\n";
+		for (var i=0; i < this.userAttributes.length; i++) {
+			result += "    "+this.userAttributes[i].toString(); 
+		}
+		result += "    Public Key SubKeys:\n";
+		for (var i=0; i < this.subKeys.length; i++) {
+			result += "    "+this.subKeys[i].toString(); 
+		}
+		return result;
+	}
+	
+	/**
+	 * finds an encryption key for this public key
+	 * @returns null if no encryption key has been found
+	 */
+	function getEncryptionKey() {
+		// V4: by convention subkeys are prefered for encryption service
+		// V3: keys MUST NOT have subkeys
+		for (var j = 0; j < this.subKeys.length; j++)
+				if (this.subKeys[j].publicKeyAlgorithm != 17 &&
+						this.subKeys[j].publicKeyAlgorithm != 3 &&
+						this.subKeys[j].verifyKey()) {
+					return this.subKeys[j];
+				}
+		// if no valid subkey for encryption, use primary key
+		if (this.publicKeyPacket.publicKeyAlgorithm != 17 && this.publicKeyPacket.publicKeyAlgorithm != 3
+			&& this.publicKeyPacket.verifyKey()) {
+			return this.publicKeyPacket;	
+		}
+		return null;
+	}
+	
+	function getSigningKey() {
+		if ((this.publicKeyPacket.publicKeyAlgorithm == 17 ||
+			 this.publicKeyPacket.publicKeyAlgorithm != 2))
+			return this.publicKeyPacket;
+		else if (this.publicKeyPacket.version == 4) // V3 keys MUST NOT have subkeys.
+			for (var j = 0; j < this.subKeys.length; j++) {
+				if ((this.subKeys[j].publicKeyAlgorithm == 17 ||
+					 this.subKeys[j].publicKeyAlgorithm != 2) &&
+					 this.subKeys[j].verifyKey())
+					return this.subKeys[j];
+			}
+		return null;
+	}
+
+        /* Returns the i-th subKey as a openpgp_msg_publickey object */
+	function getSubKeyAsKey(i) {
+		var ret = new openpgp_msg_publickey();
+		ret.userIds = this.userIds;
+		ret.userAttributes = this.userAttributes;
+		ret.publicKeyPacket = this.subKeys[i];
+		return ret;
+	}
+
+	this.getEncryptionKey = getEncryptionKey;
+	this.getSigningKey = getSigningKey;
+	this.read_nodes = read_nodes;
+	this.write = write;
+	this.toString = toString;
+	this.validate = validate;
+	this.getFingerprint = getFingerprint;
+	this.getKeyId = getKeyId;
+	this.verifyBasicSignatures = verifyBasicSignatures;
+	this.getSubKeyAsKey = getSubKeyAsKey;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.compressed.js.html b/doc/openpgp.packet.compressed.js.html new file mode 100644 index 00000000..618e9812 --- /dev/null +++ b/doc/openpgp.packet.compressed.js.html @@ -0,0 +1,213 @@ + + + + + JSDoc: Source: packet/openpgp.packet.compressed.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.compressed.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */   
+function openpgp_packet_compressed() {
+	this.tagType = 8;
+	this.decompressedData = null;
+	
+	/**
+	 * Parsing function for the packet.
+	 * @param {String} input Payload of a tag 8 packet
+	 * @param {Integer} position Position to start reading from the input string
+	 * @param {Integer} len Length of the packet or the remaining length of 
+	 * input at position
+	 * @return {openpgp_packet_compressed} Object representation
+	 */
+	function read_packet (input, position, len) {
+		this.packetLength = len;
+		var mypos = position;
+		// One octet that gives the algorithm used to compress the packet.
+		this.type = input.charCodeAt(mypos++);
+		// Compressed data, which makes up the remainder of the packet.
+		this.compressedData = input.substring(position+1, position+len);
+		return this;
+	}
+	/**
+	 * Decompression method for decompressing the compressed data
+	 * read by read_packet
+	 * @return {String} The decompressed data
+	 */
+	function decompress() {
+		if (this.decompressedData != null)
+			return this.decompressedData;
+
+		if (this.type == null)
+			return null;
+
+		switch (this.type) {
+		case 0: // - Uncompressed
+			this.decompressedData = this.compressedData;
+			break;
+		case 1: // - ZIP [RFC1951]
+			util.print_info('Decompressed packet [Type 1-ZIP]: ' + this.toString());
+			var compData = this.compressedData;
+			var radix = s2r(compData).replace(/\n/g,"");
+			// no header in this case, directly call deflate
+			var jxg_obj = new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(radix));
+			this.decompressedData = unescape(jxg_obj.deflate()[0][0]);
+			break;
+		case 2: // - ZLIB [RFC1950]
+			util.print_info('Decompressed packet [Type 2-ZLIB]: ' + this.toString());
+			var compressionMethod = this.compressedData.charCodeAt(0) % 0x10; //RFC 1950. Bits 0-3 Compression Method
+			//Bits 4-7 RFC 1950 are LZ77 Window. Generally this value is 7 == 32k window size.
+			//2nd Byte in RFC 1950 is for "FLAGs" Allows for a Dictionary (how is this defined). Basic checksum, and compression level.
+			if (compressionMethod == 8) { //CM 8 is for DEFLATE, RFC 1951
+				// remove 4 bytes ADLER32 checksum from the end
+				var compData = this.compressedData.substring(0, this.compressedData.length - 4);
+				var radix = s2r(compData).replace(/\n/g,"");
+				//TODO check ADLER32 checksum
+				this.decompressedData = JXG.decompress(radix);
+				break;
+			} else {
+				util.print_error("Compression algorithm ZLIB only supports DEFLATE compression method.");
+			}
+			break;
+		case 3: //  - BZip2 [BZ2]
+			// TODO: need to implement this
+			util.print_error("Compression algorithm BZip2 [BZ2] is not implemented.");
+			break;
+		default:
+			util.print_error("Compression algorithm unknown :"+this.type);
+			break;
+		}
+		util.print_debug("decompressed:"+util.hexstrdump(this.decompressedData));
+		return this.decompressedData; 
+	}
+
+	/**
+	 * Compress the packet data (member decompressedData)
+	 * @param {Integer} type Algorithm to be used // See RFC 4880 9.3
+	 * @param {String} data Data to be compressed
+	 * @return {String} The compressed data stored in attribute compressedData
+	 */
+	function compress(type, data) {
+		this.type = type;
+		this.decompressedData = data;
+		switch (this.type) {
+		case 0: // - Uncompressed
+			this.compressedData = this.decompressedData;
+			break;
+		case 1: // - ZIP [RFC1951]
+			util.print_error("Compression algorithm ZIP [RFC1951] is not implemented.");
+			break;
+		case 2: // - ZLIB [RFC1950]
+			// TODO: need to implement this
+			util.print_error("Compression algorithm ZLIB [RFC1950] is not implemented.");
+			break;
+		case 3: //  - BZip2 [BZ2]
+			// TODO: need to implement this
+			util.print_error("Compression algorithm BZip2 [BZ2] is not implemented.");
+			break;
+		default:
+			util.print_error("Compression algorithm unknown :"+this.type);
+			break;
+		}
+		this.packetLength = this.compressedData.length +1;
+		return this.compressedData; 
+	}
+	
+	/**
+	 * Creates a string representation of the packet
+	 * @param {Integer} algorithm Algorithm to be used // See RFC 4880 9.3
+	 * @param {String} data Data to be compressed
+	 * @return {String} String-representation of the packet
+	 */
+	function write_packet(algorithm, data) {
+		this.decompressedData = data;
+		if (algorithm == null) {
+			this.type = 1;
+		}
+		var result = String.fromCharCode(this.type)+this.compress(this.type);
+		return openpgp_packet.write_packet_header(8, result.length)+result;
+	}
+	
+	/**
+	 * Pretty printing the packet (useful for debug purposes)
+	 * @return {String}
+	 */
+	function toString() {
+		return '5.6.  Compressed Data Packet (Tag 8)\n'+
+		   '    length:  '+this.packetLength+'\n'+
+			   '    Compression Algorithm = '+this.type+'\n'+
+		       '    Compressed Data: Byte ['+util.hexstrdump(this.compressedData)+']\n';
+	}
+	
+	this.read_packet = read_packet;
+	this.toString = toString;
+	this.compress = compress;
+	this.decompress = decompress;
+	this.write_packet = write_packet;
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.encrypteddata.js.html b/doc/openpgp.packet.encrypteddata.js.html new file mode 100644 index 00000000..4041b4d6 --- /dev/null +++ b/doc/openpgp.packet.encrypteddata.js.html @@ -0,0 +1,148 @@ + + + + + JSDoc: Source: packet/openpgp.packet.encrypteddata.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.encrypteddata.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
+
+/**
+ * @class
+ * @classdesc 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).
+ */
+
+function openpgp_packet_encrypteddata() {
+	this.tagType = 9;
+	this.packetLength = null;
+	this.encryptedData = null;
+	this.decryptedData = null;
+
+	/**
+	 * Parsing function for the packet.
+	 * 
+	 * @param {String} input Payload of a tag 9 packet
+	 * @param {Integer} position Position to start reading from the input string
+	 * @param {Integer} len Length of the packet or the remaining length of
+	 *            input at position
+	 * @return {openpgp_packet_encrypteddata} Object representation
+	 */
+	function read_packet(input, position, len) {
+		var mypos = position;
+		this.packetLength = len;
+		// - Encrypted data, the output of the selected symmetric-key cipher
+		// operating in OpenPGP's variant of Cipher Feedback (CFB) mode.
+		this.encryptedData = input.substring(position, position + len);
+		return this;
+	}
+
+	/**
+	 * Symmetrically decrypt the packet data
+	 * 
+	 * @param {Integer} symmetric_algorithm_type
+	 *             Symmetric key algorithm to use // See RFC4880 9.2
+	 * @param {String} key
+	 *             Key as string with the corresponding length to the
+	 *            algorithm
+	 * @return The decrypted data;
+	 */
+	function decrypt_sym(symmetric_algorithm_type, key) {
+		this.decryptedData = openpgp_crypto_symmetricDecrypt(
+				symmetric_algorithm_type, key, this.encryptedData, true);
+		util.print_debug("openpgp.packet.encryptedintegrityprotecteddata.js\n"+
+				"data: "+util.hexstrdump(this.decryptedData));
+		return this.decryptedData;
+	}
+
+	/**
+	 * Creates a string representation of the packet
+	 * 
+	 * @param {Integer} algo Symmetric key algorithm to use // See RFC4880 9.2
+	 * @param {String} key Key as string with the corresponding length to the
+	 *            algorithm
+	 * @param {String} data Data to be
+	 * @return {String} String-representation of the packet
+	 */
+	function write_packet(algo, key, data) {
+		var result = "";
+		result += openpgp_crypto_symmetricEncrypt(
+				openpgp_crypto_getPrefixRandom(algo), algo, key, data, true);
+		result = openpgp_packet.write_packet_header(9, result.length) + result;
+		return result;
+	}
+
+	function toString() {
+		return '5.7.  Symmetrically Encrypted Data Packet (Tag 9)\n'
+				+ '    length:  ' + this.packetLength + '\n'
+				+ '    Used symmetric algorithm: ' + this.algorithmType + '\n'
+				+ '    encrypted data: Bytes ['
+				+ util.hexstrdump(this.encryptedData) + ']\n';
+	}
+	this.decrypt_sym = decrypt_sym;
+	this.toString = toString;
+	this.read_packet = read_packet;
+	this.write_packet = write_packet;
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.encryptedintegrityprotecteddata.js.html b/doc/openpgp.packet.encryptedintegrityprotecteddata.js.html new file mode 100644 index 00000000..e994f548 --- /dev/null +++ b/doc/openpgp.packet.encryptedintegrityprotecteddata.js.html @@ -0,0 +1,204 @@ + + + + + JSDoc: Source: packet/openpgp.packet.encryptedintegrityprotecteddata.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.encryptedintegrityprotecteddata.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+
+function openpgp_packet_encryptedintegrityprotecteddata() {
+	this.tagType = 18;
+	this.version = null; // integer == 1
+	this.packetLength = null; // integer
+	this.encryptedData = null; // string
+	this.decrytpedData = null; // string
+	this.hash = null; // string
+	/**
+	 * Parsing function for the packet.
+	 * 
+	 * @param {String} input Payload of a tag 18 packet
+	 * @param {Integer} position
+	 *             position to start reading from the input string
+	 * @param {Integer} len Length of the packet or the remaining length of
+	 *            input at position
+	 * @return {openpgp_packet_encryptedintegrityprotecteddata} object
+	 *         representation
+	 */
+	function read_packet(input, position, len) {
+		this.packetLength = len;
+		// - A one-octet version number. The only currently defined value is
+		// 1.
+		this.version = input[position].charCodeAt();
+		if (this.version != 1) {
+			util
+					.print_error('openpgp.packet.encryptedintegrityprotecteddata.js\nunknown encrypted integrity protected data packet version: '
+							+ this.version
+							+ " , @ "
+							+ position
+							+ "hex:"
+							+ util.hexstrdump(input));
+			return null;
+		}
+		// - Encrypted data, the output of the selected symmetric-key cipher
+		//   operating in Cipher Feedback mode with shift amount equal to the
+		//   block size of the cipher (CFB-n where n is the block size).
+		this.encryptedData = input.substring(position + 1, position + 1 + len);
+		util.print_debug("openpgp.packet.encryptedintegrityprotecteddata.js\n"
+				+ this.toString());
+		return this;
+	}
+
+	/**
+	 * Creates a string representation of a Sym. Encrypted Integrity Protected
+	 * Data Packet (tag 18) (see RFC4880 5.13)
+	 * 
+	 * @param {Integer} symmetric_algorithm
+	 *            The selected symmetric encryption algorithm to be used
+	 * @param {String} key The key of cipher blocksize length to be used
+	 * @param {String} data
+	 *            Plaintext data to be encrypted within the packet
+	 * @return {String} A string representation of the packet
+	 */
+	function write_packet(symmetric_algorithm, key, data) {
+
+		var prefixrandom = openpgp_crypto_getPrefixRandom(symmetric_algorithm);
+		var prefix = prefixrandom
+				+ prefixrandom.charAt(prefixrandom.length - 2)
+				+ prefixrandom.charAt(prefixrandom.length - 1);
+		var tohash = data;
+		tohash += String.fromCharCode(0xD3);
+		tohash += String.fromCharCode(0x14);
+		util.print_debug_hexstr_dump("data to be hashed:"
+				, prefix + tohash);
+		tohash += str_sha1(prefix + tohash);
+		util.print_debug_hexstr_dump("hash:"
+				, tohash.substring(tohash.length - 20,
+						tohash.length));
+		var result = openpgp_crypto_symmetricEncrypt(prefixrandom,
+				symmetric_algorithm, key, tohash, false).substring(0,
+				prefix.length + tohash.length);
+		var header = openpgp_packet.write_packet_header(18, result.length + 1)
+				+ String.fromCharCode(1);
+		this.encryptedData = result;
+		return header + result;
+	}
+
+	/**
+	 * Decrypts the encrypted data contained in this object read_packet must
+	 * have been called before
+	 * 
+	 * @param {Integer} symmetric_algorithm_type
+	 *            The selected symmetric encryption algorithm to be used
+	 * @param {String} key The key of cipher blocksize length to be used
+	 * @return {String} The decrypted data of this packet
+	 */
+	function decrypt(symmetric_algorithm_type, key) {
+		this.decryptedData = openpgp_crypto_symmetricDecrypt(
+				symmetric_algorithm_type, key, this.encryptedData, false);
+		// there must be a modification detection code packet as the
+		// last packet and everything gets hashed except the hash itself
+		this.hash = str_sha1(openpgp_crypto_MDCSystemBytes(
+				symmetric_algorithm_type, key, this.encryptedData)
+				+ this.decryptedData.substring(0,
+						this.decryptedData.length - 20));
+		util.print_debug_hexstr_dump("calc hash = ", this.hash);
+		if (this.hash == this.decryptedData.substring(
+				this.decryptedData.length - 20, this.decryptedData.length))
+			return this.decryptedData;
+		else
+			util
+					.print_error("Decryption stopped: discovered a modification of encrypted data.");
+		return null;
+	}
+
+	function toString() {
+	    var data = '';
+	    if(openpgp.config.debug)
+	        data = '    data: Bytes ['
+				+ util.hexstrdump(this.encryptedData) + ']';
+	    
+		return '5.13.  Sym. Encrypted Integrity Protected Data Packet (Tag 18)\n'
+				+ '    length:  '
+				+ this.packetLength
+				+ '\n'
+				+ '    version: '
+				+ this.version
+				+ '\n'
+				+ data;
+	}
+
+	this.write_packet = write_packet;
+	this.read_packet = read_packet;
+	this.toString = toString;
+	this.decrypt = decrypt;
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.encryptedsessionkey.js.html b/doc/openpgp.packet.encryptedsessionkey.js.html new file mode 100644 index 00000000..38d36d77 --- /dev/null +++ b/doc/openpgp.packet.encryptedsessionkey.js.html @@ -0,0 +1,275 @@ + + + + + JSDoc: Source: packet/openpgp.packet.encryptedsessionkey.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.encryptedsessionkey.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_packet_encryptedsessionkey() {
+
+	/**
+	 * Parsing function for a publickey encrypted session key packet (tag 1).
+	 * 
+	 * @param {String} input Payload of a tag 1 packet
+	 * @param {Integer} position Position to start reading from the input string
+	 * @param {Integer} len Length of the packet or the remaining length of
+	 *            input at position
+	 * @return {openpgp_packet_encrypteddata} Object representation
+	 */
+	function read_pub_key_packet(input, position, len) {
+		this.tagType = 1;
+		this.packetLength = len;
+		var mypos = position;
+		if (len < 10) {
+			util
+					.print_error("openpgp.packet.encryptedsessionkey.js\n" + 'invalid length');
+			return null;
+		}
+
+		this.version = input[mypos++].charCodeAt();
+		this.keyId = new openpgp_type_keyid();
+		this.keyId.read_packet(input, mypos);
+		mypos += 8;
+		this.publicKeyAlgorithmUsed = input[mypos++].charCodeAt();
+
+		switch (this.publicKeyAlgorithmUsed) {
+		case 1:
+		case 2: // RSA
+			this.MPIs = new Array();
+			this.MPIs[0] = new openpgp_type_mpi();
+			this.MPIs[0].read(input, mypos, mypos - position);
+			break;
+		case 16: // Elgamal
+			this.MPIs = new Array();
+			this.MPIs[0] = new openpgp_type_mpi();
+			this.MPIs[0].read(input, mypos, mypos - position);
+			mypos += this.MPIs[0].packetLength;
+			this.MPIs[1] = new openpgp_type_mpi();
+			this.MPIs[1].read(input, mypos, mypos - position);
+			break;
+		default:
+			util.print_error("openpgp.packet.encryptedsessionkey.js\n"
+					+ "unknown public key packet algorithm type "
+					+ this.publicKeyAlgorithmType);
+			break;
+		}
+		return this;
+	}
+
+	/**
+	 * Create a string representation of a tag 1 packet
+	 * 
+	 * @param {String} publicKeyId
+	 *             The public key id corresponding to publicMPIs key as string
+	 * @param {openpgp_type_mpi[]} publicMPIs
+	 *            Multiprecision integer objects describing the public key
+	 * @param {Integer} pubalgo
+	 *            The corresponding public key algorithm // See RFC4880 9.1
+	 * @param {Integer} symmalgo
+	 *            The symmetric cipher algorithm used to encrypt the data 
+	 *            within an encrypteddatapacket or encryptedintegrity-
+	 *            protecteddatapacket 
+	 *            following this packet //See RFC4880 9.2
+	 * @param {String} sessionkey
+	 *            A string of randombytes representing the session key
+	 * @return {String} The string representation
+	 */
+	function write_pub_key_packet(publicKeyId, publicMPIs, pubalgo, symmalgo,
+			sessionkey) {
+		var result = String.fromCharCode(3);
+		var data = String.fromCharCode(symmalgo);
+		data += sessionkey;
+		var checksum = util.calc_checksum(sessionkey);
+		data += String.fromCharCode((checksum >> 8) & 0xFF);
+		data += String.fromCharCode((checksum) & 0xFF);
+		result += publicKeyId;
+		result += String.fromCharCode(pubalgo);
+		var mpi = new openpgp_type_mpi();
+		var mpiresult = openpgp_crypto_asymetricEncrypt(pubalgo, publicMPIs,
+				mpi.create(openpgp_encoding_eme_pkcs1_encode(data,
+						publicMPIs[0].mpiByteLength)));
+		for ( var i = 0; i < mpiresult.length; i++) {
+			result += mpiresult[i];
+		}
+		result = openpgp_packet.write_packet_header(1, result.length) + result;
+		return result;
+	}
+
+	/**
+	 * Parsing function for a symmetric encrypted session key packet (tag 3).
+	 * 
+	 * @param {String} input Payload of a tag 1 packet
+	 * @param {Integer} position Position to start reading from the input string
+	 * @param {Integer} len
+	 *            Length of the packet or the remaining length of
+	 *            input at position
+	 * @return {openpgp_packet_encrypteddata} Object representation
+	 */
+	function read_symmetric_key_packet(input, position, len) {
+		this.tagType = 3;
+		var mypos = position;
+		// A one-octet version number. The only currently defined version is 4.
+		this.version = input[mypos++];
+
+		// A one-octet number describing the symmetric algorithm used.
+		this.symmetricKeyAlgorithmUsed = input[mypos++];
+		// A string-to-key (S2K) specifier, length as defined above.
+		this.s2k = new openpgp_type_s2k();
+		this.s2k.read(input, mypos);
+
+		// Optionally, the encrypted session key itself, which is decrypted
+		// with the string-to-key object.
+		if ((s2k.s2kLength + mypos) < len) {
+			this.encryptedSessionKey = new Array();
+			for ( var i = (mypos - position); i < len; i++) {
+				this.encryptedSessionKey[i] = input[mypos++];
+			}
+		}
+		return this;
+	}
+	/**
+	 * Decrypts the session key (only for public key encrypted session key
+	 * packets (tag 1)
+	 * 
+	 * @param {openpgp_msg_message} msg
+	 *            The message object (with member encryptedData
+	 * @param {openpgp_msg_privatekey} key
+	 *            Private key with secMPIs unlocked
+	 * @return {String} The unencrypted session key
+	 */
+	function decrypt(msg, key) {
+		if (this.tagType == 1) {
+			var result = openpgp_crypto_asymetricDecrypt(
+					this.publicKeyAlgorithmUsed, key.publicKey.MPIs,
+					key.secMPIs, this.MPIs).toMPI();
+			var checksum = ((result.charCodeAt(result.length - 2) << 8) + result
+					.charCodeAt(result.length - 1));
+			var decoded = openpgp_encoding_eme_pkcs1_decode(result.substring(2, result.length - 2), key.publicKey.MPIs[0].getByteLength());
+			var sesskey = decoded.substring(1);
+			var algo = decoded.charCodeAt(0);
+			if (msg.encryptedData.tagType == 18)
+				return msg.encryptedData.decrypt(algo, sesskey);
+			else
+				return msg.encryptedData.decrypt_sym(algo, sesskey);
+		} else if (this.tagType == 3) {
+			util
+					.print_error("Symmetric encrypted sessionkey is not supported!");
+			return null;
+		}
+	}
+
+	/**
+	 * Creates a string representation of this object (useful for debug
+	 * purposes)
+	 * 
+	 * @return {String} The string containing a openpgp description
+	 */
+	function toString() {
+		if (this.tagType == 1) {
+			var result = '5.1.  Public-Key Encrypted Session Key Packets (Tag 1)\n'
+					+ '    KeyId:  '
+					+ this.keyId.toString()
+					+ '\n'
+					+ '    length: '
+					+ this.packetLength
+					+ '\n'
+					+ '    version:'
+					+ this.version
+					+ '\n'
+					+ '    pubAlgUs:'
+					+ this.publicKeyAlgorithmUsed + '\n';
+			for ( var i = 0; i < this.MPIs.length; i++) {
+				result += this.MPIs[i].toString();
+			}
+			return result;
+		} else
+			return '5.3 Symmetric-Key Encrypted Session Key Packets (Tag 3)\n'
+					+ '    KeyId:  ' + this.keyId.toString() + '\n'
+					+ '    length: ' + this.packetLength + '\n'
+					+ '    version:' + this.version + '\n' + '    symKeyA:'
+					+ this.symmetricKeyAlgorithmUsed + '\n' + '    s2k:    '
+					+ this.s2k + '\n';
+	}
+
+	this.read_pub_key_packet = read_pub_key_packet;
+	this.read_symmetric_key_packet = read_symmetric_key_packet;
+	this.write_pub_key_packet = write_pub_key_packet;
+	this.toString = toString;
+	this.decrypt = decrypt;
+};
+
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.js.html b/doc/openpgp.packet.js.html new file mode 100644 index 00000000..e72d44f0 --- /dev/null +++ b/doc/openpgp.packet.js.html @@ -0,0 +1,456 @@ + + + + + JSDoc: Source: packet/openpgp.packet.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.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
+
+/**
+ * @class
+ * @classdesc Parent openpgp packet class. Operations focus on determining 
+ * packet types and packet header.
+ */
+function _openpgp_packet() {
+	/**
+	 * Encodes a given integer of length to the openpgp length specifier to a
+	 * string
+	 * 
+	 * @param {Integer} length The length to encode
+	 * @return {String} String with openpgp length representation
+	 */
+	function encode_length(length) {
+		result = "";
+		if (length < 192) {
+			result += String.fromCharCode(length);
+		} else if (length > 191 && length < 8384) {
+			/*
+			 * let a = (total data packet length) - 192 let bc = two octet
+			 * representation of a let d = b + 192
+			 */
+			result += String.fromCharCode(((length - 192) >> 8) + 192);
+			result += String.fromCharCode((length - 192) & 0xFF);
+		} else {
+			result += String.fromCharCode(255);
+			result += String.fromCharCode((length >> 24) & 0xFF);
+			result += String.fromCharCode((length >> 16) & 0xFF);
+			result += String.fromCharCode((length >> 8) & 0xFF);
+			result += String.fromCharCode(length & 0xFF);
+		}
+		return result;
+	}
+	this.encode_length = encode_length;
+
+	/**
+	 * Writes a packet header version 4 with the given tag_type and length to a
+	 * string
+	 * 
+	 * @param {Integer} tag_type Tag type
+	 * @param {Integer} length Length of the payload
+	 * @return {String} String of the header
+	 */
+	function write_packet_header(tag_type, length) {
+		/* we're only generating v4 packet headers here */
+		var result = "";
+		result += String.fromCharCode(0xC0 | tag_type);
+		result += encode_length(length);
+		return result;
+	}
+
+	/**
+	 * Writes a packet header Version 3 with the given tag_type and length to a
+	 * string
+	 * 
+	 * @param {Integer} tag_type Tag type
+	 * @param {Integer} length Length of the payload
+	 * @return {String} String of the header
+	 */
+	function write_old_packet_header(tag_type, length) {
+		var result = "";
+		if (length < 256) {
+			result += String.fromCharCode(0x80 | (tag_type << 2));
+			result += String.fromCharCode(length);
+		} else if (length < 65536) {
+			result += String.fromCharCode(0x80 | (tag_type << 2) | 1);
+			result += String.fromCharCode(length >> 8);
+			result += String.fromCharCode(length & 0xFF);
+		} else {
+			result += String.fromCharCode(0x80 | (tag_type << 2) | 2);
+			result += String.fromCharCode((length >> 24) & 0xFF);
+			result += String.fromCharCode((length >> 16) & 0xFF);
+			result += String.fromCharCode((length >> 8) & 0xFF);
+			result += String.fromCharCode(length & 0xFF);
+		}
+		return result;
+	}
+	this.write_old_packet_header = write_old_packet_header;
+	this.write_packet_header = write_packet_header;
+	/**
+	 * Generic static Packet Parser function
+	 * 
+	 * @param {String} input Input stream as string
+	 * @param {integer} position Position to start parsing
+	 * @param {integer} len Length of the input from position on
+	 * @return {Object} Returns a parsed openpgp_packet
+	 */
+	function read_packet(input, position, len) {
+		// some sanity checks
+		if (input == null || input.length <= position
+				|| input.substring(position).length < 2
+				|| (input[position].charCodeAt() & 0x80) == 0) {
+			util
+					.print_error("Error during parsing. This message / key is probably not containing a valid OpenPGP format.");
+			return null;
+		}
+		var mypos = position;
+		var tag = -1;
+		var format = -1;
+
+		format = 0; // 0 = old format; 1 = new format
+		if ((input[mypos].charCodeAt() & 0x40) != 0) {
+			format = 1;
+		}
+
+		var packet_length_type;
+		if (format) {
+			// new format header
+			tag = input[mypos].charCodeAt() & 0x3F; // bit 5-0
+		} else {
+			// old format header
+			tag = (input[mypos].charCodeAt() & 0x3F) >> 2; // bit 5-2
+			packet_length_type = input[mypos].charCodeAt() & 0x03; // bit 1-0
+		}
+
+		// header octet parsing done
+		mypos++;
+
+		// parsed length from length field
+		var bodydata = null;
+
+		// used for partial body lengths
+		var real_packet_length = -1;
+		if (!format) {
+			// 4.2.1. Old Format Packet Lengths
+			switch (packet_length_type) {
+			case 0: // The packet has a one-octet length. The header is 2 octets
+				// long.
+				packet_length = input[mypos++].charCodeAt();
+				break;
+			case 1: // The packet has a two-octet length. The header is 3 octets
+				// long.
+				packet_length = (input[mypos++].charCodeAt() << 8)
+						| input[mypos++].charCodeAt();
+				break;
+			case 2: // The packet has a four-octet length. The header is 5
+				// octets long.
+				packet_length = (input[mypos++].charCodeAt() << 24)
+						| (input[mypos++].charCodeAt() << 16)
+						| (input[mypos++].charCodeAt() << 8)
+						| input[mypos++].charCodeAt();
+				break;
+			default:
+				// 3 - The packet is of indeterminate length. The header is 1
+				// octet long, and the implementation must determine how long
+				// the packet is. If the packet is in a file, this means that
+				// the packet extends until the end of the file. In general, 
+				// an implementation SHOULD NOT use indeterminate-length 
+				// packets except where the end of the data will be clear 
+				// from the context, and even then it is better to use a 
+				// definite length, or a new format header. The new format 
+				// headers described below have a mechanism for precisely
+				// encoding data of indeterminate length.
+				packet_length = len;
+				break;
+			}
+
+		} else // 4.2.2. New Format Packet Lengths
+		{
+
+			// 4.2.2.1. One-Octet Lengths
+			if (input[mypos].charCodeAt() < 192) {
+				packet_length = input[mypos++].charCodeAt();
+				util.print_debug("1 byte length:" + packet_length);
+				// 4.2.2.2. Two-Octet Lengths
+			} else if (input[mypos].charCodeAt() >= 192
+					&& input[mypos].charCodeAt() < 224) {
+				packet_length = ((input[mypos++].charCodeAt() - 192) << 8)
+						+ (input[mypos++].charCodeAt()) + 192;
+				util.print_debug("2 byte length:" + packet_length);
+				// 4.2.2.4. Partial Body Lengths
+			} else if (input[mypos].charCodeAt() > 223
+					&& input[mypos].charCodeAt() < 255) {
+				packet_length = 1 << (input[mypos++].charCodeAt() & 0x1F);
+				util.print_debug("4 byte length:" + packet_length);
+				// EEEK, we're reading the full data here...
+				var mypos2 = mypos + packet_length;
+				bodydata = input.substring(mypos, mypos + packet_length);
+				while (true) {
+					if (input[mypos2].charCodeAt() < 192) {
+						var tmplen = input[mypos2++].charCodeAt();
+						packet_length += tmplen;
+						bodydata += input.substring(mypos2, mypos2 + tmplen);
+						mypos2 += tmplen;
+						break;
+					} else if (input[mypos2].charCodeAt() >= 192
+							&& input[mypos2].charCodeAt() < 224) {
+						var tmplen = ((input[mypos2++].charCodeAt() - 192) << 8)
+								+ (input[mypos2++].charCodeAt()) + 192;
+						packet_length += tmplen;
+						bodydata += input.substring(mypos2, mypos2 + tmplen);
+						mypos2 += tmplen;
+						break;
+					} else if (input[mypos2].charCodeAt() > 223
+							&& input[mypos2].charCodeAt() < 255) {
+						var tmplen = 1 << (input[mypos2++].charCodeAt() & 0x1F);
+						packet_length += tmplen;
+						bodydata += input.substring(mypos2, mypos2 + tmplen);
+						mypos2 += tmplen;
+					} else {
+						mypos2++;
+						var tmplen = (input[mypos2++].charCodeAt() << 24)
+								| (input[mypos2++].charCodeAt() << 16)
+								| (input[mypos2++].charCodeAt() << 8)
+								| input[mypos2++].charCodeAt();
+						bodydata += input.substring(mypos2, mypos2 + tmplen);
+						packet_length += tmplen;
+						mypos2 += tmplen;
+						break;
+					}
+				}
+				real_packet_length = mypos2;
+				// 4.2.2.3. Five-Octet Lengths
+			} else {
+				mypos++;
+				packet_length = (input[mypos++].charCodeAt() << 24)
+						| (input[mypos++].charCodeAt() << 16)
+						| (input[mypos++].charCodeAt() << 8)
+						| input[mypos++].charCodeAt();
+			}
+		}
+
+		// if there was'nt a partial body length: use the specified
+		// packet_length
+		if (real_packet_length == -1) {
+			real_packet_length = packet_length;
+		}
+
+		if (bodydata == null) {
+			bodydata = input.substring(mypos, mypos + real_packet_length);
+		}
+
+		// alert('tag type: '+this.tag+' length: '+packet_length);
+		var version = 1; // (old format; 2= new format)
+		// if (input[mypos++].charCodeAt() > 15)
+		// version = 2;
+
+		switch (tag) {
+		case 0: // Reserved - a packet tag MUST NOT have this value
+			break;
+		case 1: // Public-Key Encrypted Session Key Packet
+			var result = new openpgp_packet_encryptedsessionkey();
+			if (result.read_pub_key_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 2: // Signature Packet
+			var result = new openpgp_packet_signature();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 3: // Symmetric-Key Encrypted Session Key Packet
+			var result = new openpgp_packet_encryptedsessionkey();
+			if (result.read_symmetric_key_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 4: // One-Pass Signature Packet
+			var result = new openpgp_packet_onepasssignature();
+			if (result.read_packet(bodydata, 0, packet_length)) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 5: // Secret-Key Packet
+			var result = new openpgp_packet_keymaterial();
+			result.header = input.substring(position, mypos);
+			if (result.read_tag5(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 6: // Public-Key Packet
+			var result = new openpgp_packet_keymaterial();
+			result.header = input.substring(position, mypos);
+			if (result.read_tag6(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 7: // Secret-Subkey Packet
+			var result = new openpgp_packet_keymaterial();
+			if (result.read_tag7(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 8: // Compressed Data Packet
+			var result = new openpgp_packet_compressed();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 9: // Symmetrically Encrypted Data Packet
+			var result = new openpgp_packet_encrypteddata();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 10: // Marker Packet = PGP (0x50, 0x47, 0x50)
+			var result = new openpgp_packet_marker();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 11: // Literal Data Packet
+			var result = new openpgp_packet_literaldata();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.header = input.substring(position, mypos);
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 12: // Trust Packet
+			// TODO: to be implemented
+			break;
+		case 13: // User ID Packet
+			var result = new openpgp_packet_userid();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 14: // Public-Subkey Packet
+			var result = new openpgp_packet_keymaterial();
+			result.header = input.substring(position, mypos);
+			if (result.read_tag14(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 17: // User Attribute Packet
+			var result = new openpgp_packet_userattribute();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 18: // Sym. Encrypted and Integrity Protected Data Packet
+			var result = new openpgp_packet_encryptedintegrityprotecteddata();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		case 19: // Modification Detection Code Packet
+			var result = new openpgp_packet_modificationdetectioncode();
+			if (result.read_packet(bodydata, 0, packet_length) != null) {
+				result.headerLength = mypos - position;
+				result.packetLength = real_packet_length;
+				return result;
+			}
+			break;
+		default:
+			util.print_error("openpgp.packet.js\n"
+					+ "[ERROR] openpgp_packet: failed to parse packet @:"
+					+ mypos + "\nchar:'"
+					+ util.hexstrdump(input.substring(mypos)) + "'\ninput:"
+					+ util.hexstrdump(input));
+			return null;
+			break;
+		}
+	}
+
+	this.read_packet = read_packet;
+}
+
+var openpgp_packet = new _openpgp_packet();
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:32 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.keymaterial.js.html b/doc/openpgp.packet.keymaterial.js.html new file mode 100644 index 00000000..9c0e6e5a --- /dev/null +++ b/doc/openpgp.packet.keymaterial.js.html @@ -0,0 +1,868 @@ + + + + + JSDoc: Source: packet/openpgp.packet.keymaterial.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.keymaterial.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_packet_keymaterial() {
+	// members:
+	this.publicKeyAlgorithm = null;
+	this.tagType = null;
+	this.creationTime = null;
+	this.version = null;
+	this.expiration  = null;// V3
+	this.MPIs = null;
+	this.secMPIs = null;
+	this.publicKey = null;
+	this.symmetricEncryptionAlgorithm = null;
+	this.s2kUsageConventions = null;
+	this.IVLength  = null;
+    this.encryptedMPIData = null;
+    this.hasUnencryptedSecretKeyData = null;
+    this.checksum = null;
+    this.parentNode = null;
+	this.subKeySignature = null;
+	this.subKeyRevocationSignature = null;
+
+	// 5.5.1. Key Packet Variants
+	
+	// 5.5.1.3. Secret-Key Packet (Tag 5)
+	/**
+	 * This function reads the payload of a secret key packet (Tag 5)
+	 * and initializes the openpgp_packet_keymaterial
+	 * @param {String} input Input string to read the packet from
+	 * @param {Integer} position Start position for the parser
+	 * @param {Intefer} len Length of the packet or remaining length of input
+	 * @return {openpgp_packet_keymaterial}
+	 */
+	function read_tag5(input, position, len) {
+		this.tagType = 5;
+		this.read_priv_key(input, position, len);
+		return this;
+	}
+
+	// 5.5.1.1. Public-Key Packet (Tag 6)
+	/**
+	 * This function reads the payload of a public key packet (Tag 6)
+	 * and initializes the openpgp_packet_keymaterial
+	 * @param {String} input Input string to read the packet from
+	 * @param {Integer} position Start position for the parser
+	 * @param {Integer} len Length of the packet or remaining length of input
+	 * @return {openpgp_packet_keymaterial}
+	 */
+	function read_tag6(input, position, len) {
+		// A Public-Key packet starts a series of packets that forms an OpenPGP
+		// key (sometimes called an OpenPGP certificate).
+		this.tagType = 6;
+		this.packetLength = len;
+		this.read_pub_key(input, position,len);
+		
+		return this;
+	}
+
+	// 5.5.1.4. Secret-Subkey Packet (Tag 7)
+	/**
+	 * This function reads the payload of a secret key sub packet (Tag 7)
+	 * and initializes the openpgp_packet_keymaterial
+	 * @param {String} input Input string to read the packet from
+	 * @param {Integer} position Start position for the parser
+	 * @param {Integer} len Length of the packet or remaining length of input
+	 * @return {openpgp_packet_keymaterial}
+	 */
+	function read_tag7(input, position, len) {
+		this.tagType = 7;
+		this.packetLength = len;
+		return this.read_priv_key(input, position, len);
+	}
+
+	// 5.5.1.2. Public-Subkey Packet (Tag 14)
+	/**
+	 * This function reads the payload of a public key sub packet (Tag 14)
+	 * and initializes the openpgp_packet_keymaterial
+	 * @param {String} input Input string to read the packet from
+	 * @param {Integer} position Start position for the parser
+	 * @param {Integer} len Length of the packet or remaining length of input
+	 * @return {openpgp_packet_keymaterial}
+	 */
+	function read_tag14(input, position, len) {
+		this.subKeySignature = null;
+		this.subKeyRevocationSignature = new Array();
+		this.tagType = 14;
+		this.packetLength = len;
+		this.read_pub_key(input, position,len);
+		return this;
+	}
+	
+	/**
+	 * Internal Parser for public keys as specified in RFC 4880 section 
+	 * 5.5.2 Public-Key Packet Formats
+	 * called by read_tag<num>
+	 * @param {String} input Input string to read the packet from
+	 * @param {Integer} position Start position for the parser
+	 * @param {Integer} len Length of the packet or remaining length of input
+	 * @return {Object} This object with attributes set by the parser
+	 */  
+	function read_pub_key(input, position, len) {
+		var mypos = position;
+		// A one-octet version number (3 or 4).
+		this.version = input[mypos++].charCodeAt();
+		if (this.version == 3) {
+			// A four-octet number denoting the time that the key was created.
+			this.creationTime = new Date(((input[mypos++].charCodeAt() << 24) |
+				(input[mypos++].charCodeAt() << 16) |
+				(input[mypos++].charCodeAt() <<  8) |
+				(input[mypos++].charCodeAt()))*1000);
+			
+		    // - A two-octet number denoting the time in days that this key is
+		    //   valid.  If this number is zero, then it does not expire.
+			this.expiration = (input[mypos++].charCodeAt() << 8) & input[mypos++].charCodeAt();
+	
+		    // - A one-octet number denoting the public-key algorithm of this key.
+			this.publicKeyAlgorithm = input[mypos++].charCodeAt();
+			var mpicount = 0;
+		    // - A series of multiprecision integers comprising the key material:
+			//   Algorithm-Specific Fields for RSA public keys:
+		    //       - a multiprecision integer (MPI) of RSA public modulus n;
+		    //       - an MPI of RSA public encryption exponent e.
+			if (this.publicKeyAlgorithm > 0 && this.publicKeyAlgorithm < 4)
+				mpicount = 2;
+			//   Algorithm-Specific Fields for Elgamal public keys:
+			//     - MPI of Elgamal prime p;
+			//     - MPI of Elgamal group generator g;
+			//     - MPI of Elgamal public key value y (= g**x mod p where x  is secret).
+
+			else if (this.publicKeyAlgorithm == 16)
+				mpicount = 3;
+			//   Algorithm-Specific Fields for DSA public keys:
+			//       - MPI of DSA prime p;
+			//       - MPI of DSA group order q (q is a prime divisor of p-1);
+			//       - MPI of DSA group generator g;
+			//       - MPI of DSA public-key value y (= g**x mod p where x  is secret).
+			else if (this.publicKeyAlgorithm == 17)
+				mpicount = 4;
+
+			this.MPIs = new Array();
+			for (var i = 0; i < mpicount; i++) {
+				this.MPIs[i] = new openpgp_type_mpi();
+				if (this.MPIs[i].read(input, mypos, (mypos-position)) != null && 
+						!this.packetLength < (mypos-position)) {
+					mypos += this.MPIs[i].packetLength;
+				} else {
+					util.print_error("openpgp.packet.keymaterial.js\n"+'error reading MPI @:'+mypos);
+				}
+			}
+			this.packetLength = mypos-position;
+		} else if (this.version == 4) {
+			// - A four-octet number denoting the time that the key was created.
+			this.creationTime = new Date(((input[mypos++].charCodeAt() << 24) |
+			(input[mypos++].charCodeAt() << 16) |
+			(input[mypos++].charCodeAt() <<  8) |
+			(input[mypos++].charCodeAt()))*1000);
+			
+			// - A one-octet number denoting the public-key algorithm of this key.
+			this.publicKeyAlgorithm = input[mypos++].charCodeAt();
+			var mpicount = 0;
+		    // - A series of multiprecision integers comprising the key material:
+			//   Algorithm-Specific Fields for RSA public keys:
+		    //       - a multiprecision integer (MPI) of RSA public modulus n;
+		    //       - an MPI of RSA public encryption exponent e.
+			if (this.publicKeyAlgorithm > 0 && this.publicKeyAlgorithm < 4)
+					mpicount = 2;
+			//   Algorithm-Specific Fields for Elgamal public keys:
+			//     - MPI of Elgamal prime p;
+			//     - MPI of Elgamal group generator g;
+			//     - MPI of Elgamal public key value y (= g**x mod p where x  is secret).
+			else if (this.publicKeyAlgorithm == 16)
+				mpicount = 3;
+
+			//   Algorithm-Specific Fields for DSA public keys:
+			//       - MPI of DSA prime p;
+			//       - MPI of DSA group order q (q is a prime divisor of p-1);
+			//       - MPI of DSA group generator g;
+			//       - MPI of DSA public-key value y (= g**x mod p where x  is secret).
+			else if (this.publicKeyAlgorithm == 17)
+				mpicount = 4;
+
+			this.MPIs = new Array();
+			var i = 0;
+			for (var i = 0; i < mpicount; i++) {
+				this.MPIs[i] = new openpgp_type_mpi();
+				if (this.MPIs[i].read(input, mypos, (mypos-position)) != null &&
+						!this.packetLength < (mypos-position)) {
+					mypos += this.MPIs[i].packetLength;
+				} else {
+					util.print_error("openpgp.packet.keymaterial.js\n"+'error reading MPI @:'+mypos);
+				}
+			}
+			this.packetLength = mypos-position;
+		} else {
+			return null;
+		}
+		this.data = input.substring(position, mypos);
+		this.packetdata = input.substring(position, mypos);
+		return this;
+	}
+	
+	// 5.5.3.  Secret-Key Packet Formats
+	
+	/**
+	 * Internal parser for private keys as specified in RFC 4880 section 5.5.3
+	 * @param {String} input Input string to read the packet from
+	 * @param {Integer} position Start position for the parser
+	 * @param {Integer} len Length of the packet or remaining length of input
+	 * @return {Object} This object with attributes set by the parser
+	 */
+	function read_priv_key(input,position, len) {
+	    // - A Public-Key or Public-Subkey packet, as described above.
+	    this.publicKey = new openpgp_packet_keymaterial();
+		if (this.publicKey.read_pub_key(input,position, len) == null) {
+			util.print_error("openpgp.packet.keymaterial.js\n"+"Failed reading public key portion of a private key: "+input[position].charCodeAt()+" "+position+" "+len+"\n Aborting here...");
+			return null;
+		}
+		this.publicKey.header = openpgp_packet.write_old_packet_header(6,this.publicKey.packetLength);
+		// this.publicKey.header = String.fromCharCode(0x99) + String.fromCharCode(this.publicKey.packetLength >> 8 & 0xFF)+String.fromCharCode(this.publicKey.packetLength & 0xFF);
+		var mypos = position + this.publicKey.data.length;
+		this.packetLength = len;
+		
+	    // - One octet indicating string-to-key usage conventions.  Zero
+	    //   indicates that the secret-key data is not encrypted.  255 or 254
+	    //   indicates that a string-to-key specifier is being given.  Any
+	    //   other value is a symmetric-key encryption algorithm identifier.
+	    this.s2kUsageConventions = input[mypos++].charCodeAt();
+	    
+	    if (this.s2kUsageConventions == 0)
+	    	this.hasUnencryptedSecretKeyData = true;
+	   
+	    // - [Optional] If string-to-key usage octet was 255 or 254, a one-
+	    //   octet symmetric encryption algorithm.
+	    if (this.s2kUsageConventions == 255 || this.s2kUsageConventions == 254) {
+	    	this.symmetricEncryptionAlgorithm = input[mypos++].charCodeAt();
+	    }
+	     
+	    // - [Optional] If string-to-key usage octet was 255 or 254, a
+	    //   string-to-key specifier.  The length of the string-to-key
+	    //   specifier is implied by its type, as described above.
+	    if (this.s2kUsageConventions == 255 || this.s2kUsageConventions == 254) {
+	    	this.s2k = new openpgp_type_s2k();
+	    	this.s2k.read(input, mypos);
+	    	mypos +=this.s2k.s2kLength;
+	    }
+	    
+	    // - [Optional] If secret data is encrypted (string-to-key usage octet
+	    //   not zero), an Initial Vector (IV) of the same length as the
+	    //   cipher's block size.
+	    this.symkeylength = 0;
+	    if (this.s2kUsageConventions != 0 && this.s2kUsageConventions != 255 &&
+	    		this.s2kUsageConventions != 254) {
+	    	this.symmetricEncryptionAlgorithm = this.s2kUsageConventions;
+	    }
+	    if (this.s2kUsageConventions != 0 && this.s2k.type != 1001) {
+	    	this.hasIV = true;
+	    	switch (this.symmetricEncryptionAlgorithm) {
+		    case  1: // - IDEA [IDEA]
+		    	util.print_error("openpgp.packet.keymaterial.js\n"+"symmetric encrytryption algorithim: IDEA is not implemented");
+		    	return null;
+	    	case  2: // - TripleDES (DES-EDE, [SCHNEIER] [HAC] - 168 bit key derived from 192)
+	    	case  3: // - CAST5 (128 bit key, as per [RFC2144])
+	    		this.IVLength = 8;
+		    	break;
+		    case  4: // - Blowfish (128 bit key, 16 rounds) [BLOWFISH]
+		    case  7: // - AES with 128-bit key [AES]
+	    	case  8: // - AES with 192-bit key
+	    	case  9: // - AES with 256-bit key
+	    		this.IVLength = 16;
+		    	break;
+	    	case 10: // - Twofish with 256-bit key [TWOFISH]
+	    		this.IVLength = 32;	    		
+		    	break;
+	    	case  5: // - Reserved
+	    	case  6: // - Reserved
+	    	default:
+	    		util.print_error("openpgp.packet.keymaterial.js\n"+"unknown encryption algorithm for secret key :"+this.symmetricEncryptionAlgorithm);
+	    		return null;
+	    	}
+	    	mypos++; 
+	    	this.IV = input.substring(mypos, mypos+this.IVLength);
+	    	mypos += this.IVLength;
+	    }
+	    // - Plain or encrypted multiprecision integers comprising the secret
+	    //   key data.  These algorithm-specific fields are as described
+	    //   below.
+
+      // s2k type 1001 corresponds to GPG specific extension without primary key secrets
+      // http://www.gnupg.org/faq/GnuPG-FAQ.html#how-can-i-use-gnupg-in-an-automated-environment
+	    if (this.s2kUsageConventions != 0 && this.s2k.type == 1001) {
+	    	this.secMPIs = null;
+	    	this.encryptedMPIData = null;
+	    } else if (!this.hasUnencryptedSecretKeyData) {
+	    	this.encryptedMPIData = input.substring(mypos, len);
+	    	mypos += this.encryptedMPIData.length;
+	    } else {
+	    	if (this.publicKey.publicKeyAlgorithm > 0 && this.publicKey.publicKeyAlgorithm < 4) {
+	    		//   Algorithm-Specific Fields for RSA secret keys:
+	    		//   - multiprecision integer (MPI) of RSA secret exponent d.
+	    		//   - MPI of RSA secret prime value p.
+	    		//   - MPI of RSA secret prime value q (p < q).
+	    		//   - MPI of u, the multiplicative inverse of p, mod q.
+	    		this.secMPIs = new Array();
+	    		this.secMPIs[0] = new openpgp_type_mpi();
+	    		this.secMPIs[0].read(input, mypos, len-2- (mypos - position));
+	    		mypos += this.secMPIs[0].packetLength;
+	    		this.secMPIs[1] = new openpgp_type_mpi();
+	    		this.secMPIs[1].read(input, mypos, len-2- (mypos - position));
+	    		mypos += this.secMPIs[1].packetLength;
+	    		this.secMPIs[2] = new openpgp_type_mpi();
+	    		this.secMPIs[2].read(input, mypos, len-2- (mypos - position));
+	    		mypos += this.secMPIs[2].packetLength;
+	    		this.secMPIs[3] = new openpgp_type_mpi();
+	    		this.secMPIs[3].read(input, mypos, len-2- (mypos - position));
+	    		mypos += this.secMPIs[3].packetLength;
+	    	} else if (this.publicKey.publicKeyAlgorithm == 16) {
+	    		// Algorithm-Specific Fields for Elgamal secret keys:
+	    		//   - MPI of Elgamal secret exponent x.
+	    		this.secMPIs = new Array();
+	    		this.secMPIs[0] = new openpgp_type_mpi();
+	    		this.secMPIs[0].read(input, mypos, len-2- (mypos - position));
+	    		mypos += this.secMPIs[0].packetLength;
+	    	} else if (this.publicKey.publicKeyAlgorithm == 17) {
+	    		// Algorithm-Specific Fields for DSA secret keys:
+	    		//   - MPI of DSA secret exponent x.
+	    		this.secMPIs = new Array();
+	    		this.secMPIs[0] = new openpgp_type_mpi();
+	    		this.secMPIs[0].read(input, mypos, len-2- (mypos - position));
+	    		mypos += this.secMPIs[0].packetLength;
+	    	}
+	    	// checksum because s2k usage convention is 0
+	        this.checksum = new Array(); 
+		    this.checksum[0] = input[mypos++].charCodeAt();
+		    this.checksum[1] = input[mypos++].charCodeAt();
+	    }
+	    return this;
+	}
+	
+
+	/**
+	 * Decrypts the private key MPIs which are needed to use the key.
+	 * openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be 
+	 * false otherwise
+	 * a call to this function is not needed
+	 * 
+	 * @param {String} str_passphrase The passphrase for this private key 
+	 * as string
+	 * @return {Boolean} True if the passphrase was correct; false if not
+	 */
+	function decryptSecretMPIs(str_passphrase) {
+		if (this.hasUnencryptedSecretKeyData)
+			return this.secMPIs;
+		// creating a key out of the passphrase
+		var key = this.s2k.produce_key(str_passphrase);
+		var cleartextMPIs = "";
+    	switch (this.symmetricEncryptionAlgorithm) {
+	    case  1: // - IDEA [IDEA]
+	    	util.print_error("openpgp.packet.keymaterial.js\n"+"symmetric encryption algorithim: IDEA is not implemented");
+	    	return false;
+    	case  2: // - TripleDES (DES-EDE, [SCHNEIER] [HAC] - 168 bit key derived from 192)
+    		cleartextMPIs = normal_cfb_decrypt(function(block, key) {
+    			return des(key, block,1,null,0);
+    		}, this.IVLength, key, this.encryptedMPIData, this.IV);
+    		break;
+    	case  3: // - CAST5 (128 bit key, as per [RFC2144])
+    		cleartextMPIs = normal_cfb_decrypt(function(block, key) {
+        		var cast5 = new openpgp_symenc_cast5();
+        		cast5.setKey(key);
+        		return cast5.encrypt(util.str2bin(block)); 
+    		}, this.IVLength, util.str2bin(key.substring(0,16)), this.encryptedMPIData, this.IV);
+    		break;
+	    case  4: // - Blowfish (128 bit key, 16 rounds) [BLOWFISH]
+	    	cleartextMPIs = normal_cfb_decrypt(function(block, key) {
+    			var blowfish = new Blowfish(key);
+        		return blowfish.encrypt(block); 
+    		}, this.IVLength, key, this.encryptedMPIData, this.IV);
+    		break;
+	    case  7: // - AES with 128-bit key [AES]
+    	case  8: // - AES with 192-bit key
+    	case  9: // - AES with 256-bit key
+    	    var numBytes = 16;
+            //This is a weird way to achieve this. If's within a switch is probably not ideal.
+    	    if(this.symmetricEncryptionAlgorithm == 8){
+    	        numBytes = 24;
+    	        key = this.s2k.produce_key(str_passphrase,numBytes);
+    	    }
+    	    if(this.symmetricEncryptionAlgorithm == 9){
+    	        numBytes = 32;
+    	        key = this.s2k.produce_key(str_passphrase,numBytes);
+    	    }
+    		cleartextMPIs = normal_cfb_decrypt(function(block,key){
+    		    return AESencrypt(util.str2bin(block),key);
+    		},
+    				this.IVLength, keyExpansion(key.substring(0,numBytes)), this.encryptedMPIData, this.IV);
+	    	break;
+    	case 10: // - Twofish with 256-bit key [TWOFISH]
+    		util.print_error("openpgp.packet.keymaterial.js\n"+"Key material is encrypted with twofish: not implemented");   		
+	    	return false;
+    	case  5: // - Reserved
+    	case  6: // - Reserved
+    	default:
+    		util.print_error("openpgp.packet.keymaterial.js\n"+"unknown encryption algorithm for secret key :"+this.symmetricEncryptionAlgorithm);
+    		return false;
+    	}
+    	
+    	if (cleartextMPIs == null) {
+    		util.print_error("openpgp.packet.keymaterial.js\n"+"cleartextMPIs was null");
+    		return false;
+    	}
+    	
+    	var cleartextMPIslength = cleartextMPIs.length;
+
+    	if (this.s2kUsageConventions == 254 &&
+    			str_sha1(cleartextMPIs.substring(0,cleartextMPIs.length - 20)) == 
+    				cleartextMPIs.substring(cleartextMPIs.length - 20)) {
+    		cleartextMPIslength -= 20;
+    	} else if (this.s2kUsageConventions != 254 && util.calc_checksum(cleartextMPIs.substring(0,cleartextMPIs.length - 2)) == 
+    			(cleartextMPIs.charCodeAt(cleartextMPIs.length -2) << 8 | cleartextMPIs.charCodeAt(cleartextMPIs.length -1))) {
+    		cleartextMPIslength -= 2;
+    	} else {
+    		return false;
+    	}
+
+    	if (this.publicKey.publicKeyAlgorithm > 0 && this.publicKey.publicKeyAlgorithm < 4) {
+    		//   Algorithm-Specific Fields for RSA secret keys:
+    		//   - multiprecision integer (MPI) of RSA secret exponent d.
+    		//   - MPI of RSA secret prime value p.
+    		//   - MPI of RSA secret prime value q (p < q).
+    		//   - MPI of u, the multiplicative inverse of p, mod q.
+    		var mypos = 0;
+    		this.secMPIs = new Array();
+    		this.secMPIs[0] = new openpgp_type_mpi();
+    		this.secMPIs[0].read(cleartextMPIs, 0, cleartextMPIslength);
+    		mypos += this.secMPIs[0].packetLength;
+    		this.secMPIs[1] = new openpgp_type_mpi();
+    		this.secMPIs[1].read(cleartextMPIs, mypos, cleartextMPIslength-mypos);
+    		mypos += this.secMPIs[1].packetLength;
+    		this.secMPIs[2] = new openpgp_type_mpi();
+    		this.secMPIs[2].read(cleartextMPIs, mypos, cleartextMPIslength-mypos);
+    		mypos += this.secMPIs[2].packetLength;
+    		this.secMPIs[3] = new openpgp_type_mpi();
+    		this.secMPIs[3].read(cleartextMPIs, mypos, cleartextMPIslength-mypos);
+    		mypos += this.secMPIs[3].packetLength;
+    	} else if (this.publicKey.publicKeyAlgorithm == 16) {
+    		// Algorithm-Specific Fields for Elgamal secret keys:
+    		//   - MPI of Elgamal secret exponent x.
+    		this.secMPIs = new Array();
+    		this.secMPIs[0] = new openpgp_type_mpi();
+    		this.secMPIs[0].read(cleartextMPIs, 0, cleartextMPIs);
+    	} else if (this.publicKey.publicKeyAlgorithm == 17) {
+    		// Algorithm-Specific Fields for DSA secret keys:
+    		//   - MPI of DSA secret exponent x.
+    		this.secMPIs = new Array();
+    		this.secMPIs[0] = new openpgp_type_mpi();
+    		this.secMPIs[0].read(cleartextMPIs, 0, cleartextMPIslength);
+    	}
+    	return true;
+	}
+	
+	/**
+	 * Generates Debug output
+	 * @return String which gives some information about the keymaterial
+	 */
+	function toString() {
+		var result = "";
+		switch (this.tagType) {
+		case 6:
+			 result += '5.5.1.1. Public-Key Packet (Tag 6)\n'+
+			   '    length:             '+this.packetLength+'\n'+
+			   '    version:            '+this.version+'\n'+
+			   '    creation time:      '+this.creationTime+'\n'+
+			   '    expiration time:    '+this.expiration+'\n'+
+			   '    publicKeyAlgorithm: '+this.publicKeyAlgorithm+'\n';
+			break;
+		case 14:
+			result += '5.5.1.2. Public-Subkey Packet (Tag 14)\n'+
+			   '    length:             '+this.packetLength+'\n'+
+			   '    version:            '+this.version+'\n'+
+			   '    creation time:      '+this.creationTime+'\n'+
+			   '    expiration time:    '+this.expiration+'\n'+
+			   '    publicKeyAlgorithm: '+this.publicKeyAlgorithm+'\n';
+			break;
+		case 5:
+			result +='5.5.1.3. Secret-Key Packet (Tag 5)\n'+
+			   '    length:             '+this.packetLength+'\n'+
+			   '    version:            '+this.publicKey.version+'\n'+
+			   '    creation time:      '+this.publicKey.creationTime+'\n'+
+			   '    expiration time:    '+this.publicKey.expiration+'\n'+
+			   '    publicKeyAlgorithm: '+this.publicKey.publicKeyAlgorithm+'\n';
+			break;
+		case 7:
+			result += '5.5.1.4. Secret-Subkey Packet (Tag 7)\n'+
+			   '    length:             '+this.packetLength+'\n'+
+			   '    version[1]:         '+(this.version == 4)+'\n'+
+			   '    creationtime[4]:    '+this.creationTime+'\n'+
+			   '    expiration[2]:      '+this.expiration+'\n'+
+			   '    publicKeyAlgorithm: '+this.publicKeyAlgorithm+'\n';
+			break;
+		default:
+			result += 'unknown key material packet\n';
+		}
+		if (this.MPIs != null) {
+			result += "Public Key MPIs:\n";
+			for (var i = 0; i < this.MPIs.length; i++) {
+      	  	result += this.MPIs[i].toString();
+        	}
+		}
+		if (this.publicKey != null && this.publicKey.MPIs != null) {
+			result += "Public Key MPIs:\n";
+			for (var i = 0; i < this.publicKey.MPIs.length; i++) {
+	      	  	result += this.publicKey.MPIs[i].toString();
+        	}
+		}
+		if (this.secMPIs != null) {
+			result += "Secret Key MPIs:\n";
+			for (var i = 0; i < this.secMPIs.length; i++) {
+		      	  result += this.secMPIs[i].toString();
+		        }
+		}
+		
+		if (this.subKeySignature != null)
+			result += "subKey Signature:\n"+this.subKeySignature.toString();
+		
+		if (this.subKeyRevocationSignature != null )
+			result += "subKey Revocation Signature:\n"+this.subKeyRevocationSignature.toString();
+        return result;
+	}
+	
+	/**
+	 * Continue parsing packets belonging to the key material such as signatures
+	 * @param {Object} parent_node The parent object
+	 * @param {String} input Input string to read the packet(s) from
+	 * @param {Integer} position Start position for the parser
+	 * @param {Integer} len Length of the packet(s) or remaining length of input
+	 * @return {Integer} Length of nodes read
+	 */
+	function read_nodes(parent_node, input, position, len) {
+		this.parentNode = parent_node;
+		if (this.tagType == 14) { // public sub-key packet
+			var pos = position;
+			var result = null;
+			while (input.length != pos) {
+				var l = input.length - pos;
+				result = openpgp_packet.read_packet(input, pos, l);
+				if (result == null) {
+					util.print_error("openpgp.packet.keymaterial.js\n"+'[user_keymat_pub]parsing ends here @:' + pos + " l:" + l);
+					break;
+				} else {
+					
+					switch (result.tagType) {
+					case 2: // Signature Packet certification signature
+						if (result.signatureType == 24)  { // subkey binding signature
+							this.subKeySignature = result;
+							pos += result.packetLength + result.headerLength;
+							break;
+						} else if (result.signatureType == 40) { // subkey revocation signature
+							this.subKeyRevocationSignature[this.subKeyRevocationSignature.length] = result;
+							pos += result.packetLength + result.headerLength;
+							break;
+						} else {
+							util.print_error("openpgp.packet.keymaterial.js\nunknown signature:"+result.toString());
+						}
+						
+					default:
+						this.data = input;
+						this.position = position - this.parentNode.packetLength;
+						this.len = pos - position;
+						return this.len;
+						break;
+					}
+				}
+			}
+			this.data = input;
+			this.position = position - this.parentNode.packetLength;
+			this.len = pos - position;
+			return this.len;
+		} else if (this.tagType == 7) { // private sub-key packet
+			var pos = position;
+			while (input.length != pos) {
+				var result = openpgp_packet.read_packet(input, pos, len - (pos - position));
+				if (result == null) {
+					util.print_error("openpgp.packet.keymaterial.js\n"+'[user_keymat_priv] parsing ends here @:' + pos);
+					break;
+				} else {
+					switch (result.tagType) {
+					case 2: // Signature Packet certification signature
+						if (result.signatureType == 24) // subkey embedded signature
+							this.subKeySignature = result; 
+						else if (result.signatureType == 40) // subkey revocation signature
+							this.subKeyRevocationSignature[this.subKeyRevocationSignature.length] = result;
+						pos += result.packetLength + result.headerLength;
+						break;
+					default:
+						this.data = input;
+						this.position = position - this.parentNode.packetLength;
+						this.len = pos - position;
+						return this.len;
+					}
+				}
+			}
+			this.data = input;
+			this.position = position - this.parentNode.packetLength;
+			this.len = pos - position;
+			return this.len;
+		} else {
+			util.print_error("openpgp.packet.keymaterial.js\n"+"unknown parent node for a key material packet "+parent_node.tagType);
+		}
+	}
+
+	/**
+	 * Checks the validity for usage of this (sub)key
+	 * @return {Integer} 0 = bad key, 1 = expired, 2 = revoked, 3 = valid
+	 */
+	function verifyKey() {
+		if (this.tagType == 14) {
+			if (this.subKeySignature == null) {
+				return 0;
+			}
+			if (this.subKeySignature.version == 4 &&
+				this.subKeySignature.keyNeverExpires != null &&
+				!this.subKeySignature.keyNeverExpires &&
+				new Date((this.subKeySignature.keyExpirationTime*1000)+ this.creationTime.getTime()) < new Date()) {
+				    return 1;
+				}
+			var hashdata = String.fromCharCode(0x99)+this.parentNode.header.substring(1)+this.parentNode.data+
+			String.fromCharCode(0x99)+this.header.substring(1)+this.packetdata;
+			if (!this.subKeySignature.verify(hashdata,this.parentNode)) {
+				return 0;
+			}
+			for (var i = 0; i < this.subKeyRevocationSignature.length; i++) {
+			    if (this.getKeyId() == this.subKeyRevocationSignature[i].keyId){
+			        return 2;
+			    }
+			}
+		}
+		return 3;
+	}
+
+	/**
+	 * Calculates the key id of they key 
+	 * @return {String} A 8 byte key id
+	 */
+	function getKeyId() {
+		if (this.version == 4) {
+			var f = this.getFingerprint();
+			return f.substring(12,20);
+		} else if (this.version == 3 && this.publicKeyAlgorithm > 0 && this.publicKeyAlgorithm < 4) {
+			var key_id = this.MPIs[0].substring((this.MPIs[0].mpiByteLength-8));
+			util.print_debug("openpgp.msg.publickey read_nodes:\n"+"V3 key ID: "+key_id);
+			return key_id;
+		}
+	}
+	
+	/**
+	 * Calculates the fingerprint of the key
+	 * @return {String} A string containing the fingerprint
+	 */
+	function getFingerprint() {
+		if (this.version == 4) {
+			tohash = String.fromCharCode(0x99)+ String.fromCharCode(((this.packetdata.length) >> 8) & 0xFF) 
+				+ String.fromCharCode((this.packetdata.length) & 0xFF)+this.packetdata;
+			util.print_debug("openpgp.msg.publickey creating subkey fingerprint by hashing:"+util.hexstrdump(tohash)+"\npublickeyalgorithm: "+this.publicKeyAlgorithm);
+			return str_sha1(tohash, tohash.length);
+		} else if (this.version == 3 && this.publicKeyAlgorithm > 0 && this.publicKeyAlgorithm < 4) {
+			return MD5(this.MPIs[0].MPI);
+		}
+	}
+	
+	/*
+     * Creates an OpenPGP key packet for the given key. much 
+	 * TODO in regards to s2k, subkeys.
+     * @param {Integer} keyType Follows the OpenPGP algorithm standard, 
+	 * IE 1 corresponds to RSA.
+     * @param {RSA.keyObject} key
+     * @param password
+     * @param s2kHash
+     * @param symmetricEncryptionAlgorithm
+     * @param timePacket
+     * @return {Object} {body: [string]OpenPGP packet body contents, 
+		header: [string] OpenPGP packet header, string: [string] header+body}
+     */
+    function write_private_key(keyType, key, password, s2kHash, symmetricEncryptionAlgorithm, timePacket){
+        this.symmetricEncryptionAlgorithm = symmetricEncryptionAlgorithm;
+		var tag = 5;
+		var body = String.fromCharCode(4);
+		body += timePacket;
+		switch(keyType){
+		case 1:
+		    body += String.fromCharCode(keyType);//public key algo
+		    body += key.n.toMPI();
+		    body += key.ee.toMPI();
+		    var algorithmStart = body.length;
+		    //below shows ske/s2k
+		    if(password){
+		        body += String.fromCharCode(254); //octet of 254 indicates s2k with SHA1
+		        //if s2k == 255,254 then 1 octet symmetric encryption algo
+		        body += String.fromCharCode(this.symmetricEncryptionAlgorithm);
+		        //if s2k == 255,254 then s2k specifier
+		        body += String.fromCharCode(3); //s2k salt+iter
+		        body += String.fromCharCode(s2kHash);
+		        //8 octet salt value
+		        //1 octet count
+		        var cleartextMPIs = key.d.toMPI() + key.p.toMPI() + key.q.toMPI() + key.u.toMPI();
+		        var sha1Hash = str_sha1(cleartextMPIs);
+   		        util.print_debug_hexstr_dump('write_private_key sha1: ',sha1Hash);
+		        var salt = openpgp_crypto_getRandomBytes(8);
+		        util.print_debug_hexstr_dump('write_private_key Salt: ',salt);
+		        body += salt;
+		        var c = 96; //c of 96 translates to count of 65536
+		        body += String.fromCharCode(c);
+		        util.print_debug('write_private_key c: '+ c);
+		        var s2k = new openpgp_type_s2k();
+		        var hashKey = s2k.write(3, s2kHash, password, salt, c);
+		        //if s2k, IV of same length as cipher's block
+		        switch(this.symmetricEncryptionAlgorithm){
+		        case 3:
+		            this.IVLength = 8;
+		            this.IV = openpgp_crypto_getRandomBytes(this.IVLength);
+            		ciphertextMPIs = normal_cfb_encrypt(function(block, key) {
+                		var cast5 = new openpgp_symenc_cast5();
+                		cast5.setKey(key);
+                		return cast5.encrypt(util.str2bin(block)); 
+            		}, this.IVLength, util.str2bin(hashKey.substring(0,16)), cleartextMPIs + sha1Hash, this.IV);
+            		body += this.IV + ciphertextMPIs;
+		            break;
+		        case 7:
+		        case 8:
+		        case 9:
+		            this.IVLength = 16;
+		            this.IV = openpgp_crypto_getRandomBytes(this.IVLength);
+		            ciphertextMPIs = normal_cfb_encrypt(AESencrypt,
+            				this.IVLength, hashKey, cleartextMPIs + sha1Hash, this.IV);
+            		body += this.IV + ciphertextMPIs;
+	            	break;
+		        }
+		    }
+		    else{
+		        body += String.fromCharCode(0);//1 octet -- s2k, 0 for no s2k
+		        body += key.d.toMPI() + key.p.toMPI() + key.q.toMPI() + key.u.toMPI();
+		        var checksum = util.calc_checksum(key.d.toMPI() + key.p.toMPI() + key.q.toMPI() + key.u.toMPI());
+        		body += String.fromCharCode(checksum/0x100) + String.fromCharCode(checksum%0x100);//DEPRECATED:s2k == 0, 255: 2 octet checksum, sum all octets%65536
+        		util.print_debug_hexstr_dump('write_private_key basic checksum: '+ checksum);
+		    }
+		    break;
+		default :
+			body = "";
+			util.print_error("openpgp.packet.keymaterial.js\n"+'error writing private key, unknown type :'+keyType);
+        }
+		var header = openpgp_packet.write_packet_header(tag,body.length);
+		return {string: header+body , header: header, body: body};
+    }
+	
+	/*
+     * Same as write_private_key, but has less information because of 
+	 * public key.
+     * @param {Integer} keyType Follows the OpenPGP algorithm standard, 
+	 * IE 1 corresponds to RSA.
+     * @param {RSA.keyObject} key
+     * @param timePacket
+     * @return {Object} {body: [string]OpenPGP packet body contents, 
+	 * header: [string] OpenPGP packet header, string: [string] header+body}
+     */
+    function write_public_key(keyType, key, timePacket){
+        var tag = 6;
+        var body = String.fromCharCode(4);
+        body += timePacket;
+		switch(keyType){
+		case 1:
+		    body += String.fromCharCode(1);//public key algo
+		    body += key.n.toMPI();
+		    body += key.ee.toMPI();
+		    break;
+	    default:
+	    	util.print_error("openpgp.packet.keymaterial.js\n"+'error writing private key, unknown type :'+keyType);
+	    }
+        var header = openpgp_packet.write_packet_header(tag,body.length);
+        return {string: header+body , header: header, body: body};
+        }
+
+	
+	this.read_tag5 = read_tag5;
+	this.read_tag6 = read_tag6;
+	this.read_tag7 = read_tag7;
+	this.read_tag14 = read_tag14;
+	this.toString = toString;
+	this.read_pub_key = read_pub_key;
+	this.read_priv_key = read_priv_key;
+	this.decryptSecretMPIs = decryptSecretMPIs;
+	this.read_nodes = read_nodes;
+	this.verifyKey = verifyKey;
+	this.getKeyId = getKeyId;
+	this.getFingerprint = getFingerprint;
+	this.write_private_key = write_private_key;
+	this.write_public_key = write_public_key;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.literaldata.js.html b/doc/openpgp.packet.literaldata.js.html new file mode 100644 index 00000000..01f9a199 --- /dev/null +++ b/doc/openpgp.packet.literaldata.js.html @@ -0,0 +1,147 @@ + + + + + JSDoc: Source: packet/openpgp.packet.literaldata.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.literaldata.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_packet_literaldata() {
+	this.tagType = 11;
+
+	/**
+	 * Parsing function for a literal data packet (tag 11).
+	 * 
+	 * @param {String} input Payload of a tag 11 packet
+	 * @param {Integer} position
+	 *            Position to start reading from the input string
+	 * @param {Integer} len
+	 *            Length of the packet or the remaining length of
+	 *            input at position
+	 * @return {openpgp_packet_encrypteddata} object representation
+	 */
+	function read_packet(input, position, len) {
+		this.packetLength = len;
+		// - A one-octet field that describes how the data is formatted.
+
+		this.format = input[position];
+		this.filename = input.substr(position + 2, input
+				.charCodeAt(position + 1));
+		this.date = new Date(parseInt(input.substr(position + 2
+				+ input.charCodeAt(position + 1), 4)) * 1000);
+		this.data = input.substring(position + 6
+				+ input.charCodeAt(position + 1));
+		return this;
+	}
+
+	/**
+	 * Creates a string representation of the packet
+	 * 
+	 * @param {String} data The data to be inserted as body
+	 * @return {String} string-representation of the packet
+	 */
+	function write_packet(data) {
+		data = data.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n");
+		this.filename = "msg.txt";
+		this.date = new Date();
+		this.format = 't';
+		var result = openpgp_packet.write_packet_header(11, data.length + 6
+				+ this.filename.length);
+		result += this.format;
+		result += String.fromCharCode(this.filename.length);
+		result += this.filename;
+		result += String
+				.fromCharCode((Math.round(this.date.getTime() / 1000) >> 24) & 0xFF);
+		result += String
+				.fromCharCode((Math.round(this.date.getTime() / 1000) >> 16) & 0xFF);
+		result += String
+				.fromCharCode((Math.round(this.date.getTime() / 1000) >> 8) & 0xFF);
+		result += String
+				.fromCharCode(Math.round(this.date.getTime() / 1000) & 0xFF);
+		result += data;
+		this.data = data;
+		return result;
+	}
+
+	/**
+	 * Generates debug output (pretty print)
+	 * 
+	 * @return {String} String which gives some information about the keymaterial
+	 */
+	function toString() {
+		return '5.9.  Literal Data Packet (Tag 11)\n' + '    length: '
+				+ this.packetLength + '\n' + '    format: ' + this.format
+				+ '\n' + '    filename:' + this.filename + '\n'
+				+ '    date:   ' + this.date + '\n' + '    data:  |'
+				+ this.data + '|\n' + '    rdata: |' + this.real_data + '|\n';
+	}
+
+	this.read_packet = read_packet;
+	this.toString = toString;
+	this.write_packet = write_packet;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.marker.js.html b/doc/openpgp.packet.marker.js.html new file mode 100644 index 00000000..532e5f43 --- /dev/null +++ b/doc/openpgp.packet.marker.js.html @@ -0,0 +1,114 @@ + + + + + JSDoc: Source: packet/openpgp.packet.marker.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.marker.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_packet_marker() {
+	this.tagType = 10;
+	/**
+	 * Parsing function for a literal data packet (tag 10).
+	 * 
+	 * @param {String} input Payload of a tag 10 packet
+	 * @param {Integer} position
+	 *            Position to start reading from the input string
+	 * @param {Integer} len
+	 *            Length of the packet or the remaining length of
+	 *            input at position
+	 * @return {openpgp_packet_encrypteddata} Object representation
+	 */
+	function read_packet(input, position, len) {
+		this.packetLength = 3;
+		if (input[position].charCodeAt() == 0x50 && // P
+				input[position + 1].charCodeAt() == 0x47 && // G
+				input[position + 2].charCodeAt() == 0x50) // P
+			return this;
+		// marker packet does not contain "PGP"
+		return null;
+	}
+
+	/**
+	 * Generates Debug output
+	 * 
+	 * @return {String} String which gives some information about the 
+	 * keymaterial
+	 */
+	function toString() {
+		return "5.8.  Marker Packet (Obsolete Literal Packet) (Tag 10)\n"
+				+ "     packet reads: \"PGP\"\n";
+	}
+
+	this.read_packet = read_packet;
+	this.toString = toString;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.modificationdetectioncode.js.html b/doc/openpgp.packet.modificationdetectioncode.js.html new file mode 100644 index 00000000..7704a34e --- /dev/null +++ b/doc/openpgp.packet.modificationdetectioncode.js.html @@ -0,0 +1,128 @@ + + + + + JSDoc: Source: packet/openpgp.packet.modificationdetectioncode.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.modificationdetectioncode.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+
+function openpgp_packet_modificationdetectioncode() {
+	this.tagType = 19;
+	this.hash = null;
+	/**
+	 * parsing function for a modification detection code packet (tag 19).
+	 * 
+	 * @param {String} input payload of a tag 19 packet
+	 * @param {Integer} position
+	 *            position to start reading from the input string
+	 * @param {Integer} len
+	 *            length of the packet or the remaining length of
+	 *            input at position
+	 * @return {openpgp_packet_encrypteddata} object representation
+	 */
+	function read_packet(input, position, len) {
+		this.packetLength = len;
+
+		if (len != 20) {
+			util
+					.print_error("openpgp.packet.modificationdetectioncode.js\n"
+							+ 'invalid length for a modification detection code packet!'
+							+ len);
+			return null;
+		}
+		// - A 20-octet SHA-1 hash of the preceding plaintext data of the
+		// Symmetrically Encrypted Integrity Protected Data packet,
+		// including prefix data, the tag octet, and length octet of the
+		// Modification Detection Code packet.
+		this.hash = input.substring(position, position + 20);
+		return this;
+	}
+
+	/*
+	 * this packet is created within the encryptedintegrityprotected packet
+	 * function write_packet(data) { }
+	 */
+
+	/**
+	 * generates debug output (pretty print)
+	 * 
+	 * @return {String} String which gives some information about the 
+	 * modification detection code
+	 */
+	function toString() {
+		return '5.14 Modification detection code packet\n' + '    bytes ('
+				+ this.hash.length + '): [' + util.hexstrdump(this.hash) + ']';
+	}
+	this.read_packet = read_packet;
+	this.toString = toString;
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.onepasssignature.js.html b/doc/openpgp.packet.onepasssignature.js.html new file mode 100644 index 00000000..0a0a6e80 --- /dev/null +++ b/doc/openpgp.packet.onepasssignature.js.html @@ -0,0 +1,168 @@ + + + + + JSDoc: Source: packet/openpgp.packet.onepasssignature.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.onepasssignature.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_packet_onepasssignature() {
+	this.tagType = 4;
+	this.version = null; // A one-octet version number.  The current version is 3.
+	this.type = null; 	 // A one-octet signature type.  Signature types are described in RFC4880 Section 5.2.1.
+	this.hashAlgorithm = null; 	   // A one-octet number describing the hash algorithm used. (See RFC4880 9.4)
+	this.publicKeyAlgorithm = null;	     // A one-octet number describing the public-key algorithm used. (See RFC4880 9.1)
+	this.signingKeyId = null; // An eight-octet number holding the Key ID of the signing key.
+	this.flags = null; 	//  A one-octet number holding a flag showing whether the signature is nested.  A zero value indicates that the next packet is another One-Pass Signature packet that describes another signature to be applied to the same message data.
+
+	/**
+	 * parsing function for a one-pass signature packet (tag 4).
+	 * @param {String} input payload of a tag 4 packet
+	 * @param {Integer} position position to start reading from the input string
+	 * @param {Integer} len length of the packet or the remaining length of input at position
+	 * @return {openpgp_packet_encrypteddata} object representation
+	 */
+	function read_packet(input, position, len) {
+		this.packetLength = len;
+		var mypos = position;
+		// A one-octet version number.  The current version is 3.
+		this.version = input.charCodeAt(mypos++);
+
+	     // A one-octet signature type.  Signature types are described in
+	     //   Section 5.2.1.
+		this.type = input.charCodeAt(mypos++);
+
+	     // A one-octet number describing the hash algorithm used.
+		this.hashAlgorithm = input.charCodeAt(mypos++);
+
+	     // A one-octet number describing the public-key algorithm used.
+		this.publicKeyAlgorithm = input.charCodeAt(mypos++);
+	     // An eight-octet number holding the Key ID of the signing key.
+		this.signingKeyId = new openpgp_type_keyid();
+		this.signingKeyId.read_packet(input,mypos);
+		mypos += 8;
+		
+	     // A one-octet number holding a flag showing whether the signature
+	     //   is nested.  A zero value indicates that the next packet is
+	     //   another One-Pass Signature packet that describes another
+	     //   signature to be applied to the same message data.
+		this.flags = input.charCodeAt(mypos++);
+		return this;
+	}
+
+	/**
+	 * creates a string representation of a one-pass signature packet
+	 * @param {Integer} type Signature types as described in RFC4880 Section 5.2.1.
+	 * @param {Integer} hashalgorithm the hash algorithm used within the signature
+	 * @param {openpgp_msg_privatekey} privatekey the private key used to generate the signature
+	 * @param {Integer} length length of data to be signed
+	 * @param {boolean} nested boolean showing whether the signature is nested. 
+	 *  "true" indicates that the next packet is another One-Pass Signature packet
+	 *   that describes another signature to be applied to the same message data. 
+	 * @return {String} a string representation of a one-pass signature packet
+	 */
+	function write_packet(type, hashalgorithm, privatekey,length, nested) {
+		var result =""; 
+		
+		result += openpgp_packet.write_packet_header(4,13);
+		result += String.fromCharCode(3);
+		result += String.fromCharCode(type);
+		result += String.fromCharCode(hashalgorithm);
+		result += String.fromCharCode(privatekey.privateKeyPacket.publicKey.publicKeyAlgorithm);
+		result += privatekey.getKeyId();
+		if (nested)
+			result += String.fromCharCode(0);
+		else
+			result += String.fromCharCode(1);
+		
+		return result;
+	}
+	
+	/**
+	 * generates debug output (pretty print)
+	 * @return {String} String which gives some information about the one-pass signature packet
+	 */
+	function toString() {
+		return '5.4.  One-Pass Signature Packets (Tag 4)\n'+
+			   '    length: '+this.packetLength+'\n'+
+			   '    type:   '+this.type+'\n'+
+			   '    keyID:  '+this.signingKeyId.toString()+'\n'+
+			   '    hashA:  '+this.hashAlgorithm+'\n'+
+			   '    pubKeyA:'+this.publicKeyAlgorithm+'\n'+
+			   '    flags:  '+this.flags+'\n'+
+			   '    version:'+this.version+'\n';
+	}
+	
+	this.read_packet = read_packet;
+	this.toString = toString;
+	this.write_packet = write_packet;
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.signature.js.html b/doc/openpgp.packet.signature.js.html new file mode 100644 index 00000000..1eb3d54a --- /dev/null +++ b/doc/openpgp.packet.signature.js.html @@ -0,0 +1,778 @@ + + + + + JSDoc: Source: packet/openpgp.packet.signature.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.signature.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_packet_signature() {
+	this.tagType = 2;
+	this.signatureType = null;
+	this.creationTime = null;
+	this.keyId = null;
+	this.signatureData = null;
+	this.signatureExpirationTime = null;
+	this.signatureNeverExpires = null;
+	this.signedHashValue = null;
+	this.MPIs = null;
+	this.publicKeyAlgorithm = null; 
+	this.hashAlgorithm = null;
+	this.exportable = null;
+	this.trustLevel = null;
+	this.trustAmount = null;
+	this.regular_expression = null;
+	this.revocable = null;
+	this.keyExpirationTime = null;
+	this.keyNeverExpires = null;
+	this.preferredSymmetricAlgorithms = null;
+	this.revocationKeyClass = null;
+	this.revocationKeyAlgorithm = null;
+	this.revocationKeyFingerprint = null;
+	this.issuerKeyId = null;
+	this.notationFlags = null; 
+	this.notationName = null;
+	this.notationValue = null;
+	this.preferredHashAlgorithms = null;
+	this.preferredCompressionAlgorithms = null;
+	this.keyServerPreferences = null;
+	this.preferredKeyServer = null;
+	this.isPrimaryUserID = null;
+	this.policyURI = null;
+	this.keyFlags = null;
+	this.signersUserId = null;
+	this.reasonForRevocationFlag = null;
+	this.reasonForRevocationString = null;
+	this.signatureTargetPublicKeyAlgorithm = null;
+	this.signatureTargetHashAlgorithm = null;
+	this.signatureTargetHash = null;
+	this.embeddedSignature = null;
+	this.verified = false;
+	
+
+	/**
+	 * parsing function for a signature packet (tag 2).
+	 * @param {String} input payload of a tag 2 packet
+	 * @param {Integer} position position to start reading from the input string
+	 * @param {Integer} len length of the packet or the remaining length of input at position
+	 * @return {openpgp_packet_encrypteddata} object representation
+	 */
+	function read_packet(input, position, len) {
+		this.data = input.substring	(position, position+len);
+		if (len < 0) {
+			util.print_debug("openpgp.packet.signature.js\n"+"openpgp_packet_signature read_packet length < 0 @:"+position);
+			return null;
+		}
+		var mypos = position;
+		this.packetLength = len;
+		// alert('starting parsing signature: '+position+' '+this.packetLength);
+		this.version = input[mypos++].charCodeAt();
+		// switch on version (3 and 4)
+		switch (this.version) {
+		case 3:
+			// One-octet length of following hashed material. MUST be 5.
+			if (input[mypos++].charCodeAt() != 5)
+				util.print_debug("openpgp.packet.signature.js\n"+'invalid One-octet length of following hashed material.  MUST be 5. @:'+(mypos-1));
+			var sigpos = mypos;
+			// One-octet signature type.
+			this.signatureType = input[mypos++].charCodeAt();
+
+			// Four-octet creation time.
+			this.creationTime = new Date(((input[mypos++].charCodeAt()) << 24 |
+					(input[mypos++].charCodeAt() << 16) | (input[mypos++].charCodeAt() << 8) |
+					input[mypos++].charCodeAt())* 1000);
+			
+			// storing data appended to data which gets verified
+			this.signatureData = input.substring(position, mypos);
+			
+			// Eight-octet Key ID of signer.
+			this.keyId = input.substring(mypos, mypos +8);
+			mypos += 8;
+
+			// One-octet public-key algorithm.
+			this.publicKeyAlgorithm = input[mypos++].charCodeAt();
+
+			// One-octet hash algorithm.
+			this.hashAlgorithm = input[mypos++].charCodeAt();
+
+			// Two-octet field holding left 16 bits of signed hash value.
+			this.signedHashValue = (input[mypos++].charCodeAt() << 8) | input[mypos++].charCodeAt();
+			var mpicount = 0;
+			// Algorithm-Specific Fields for RSA signatures:
+			// 	    - multiprecision integer (MPI) of RSA signature value m**d mod n.
+			if (this.publicKeyAlgorithm > 0 && this.publicKeyAlgorithm < 4)
+				mpicount = 1;
+			//    Algorithm-Specific Fields for DSA signatures:
+			//      - MPI of DSA value r.
+			//      - MPI of DSA value s.
+			else if (this.publicKeyAlgorithm == 17)
+				mpicount = 2;
+			
+			this.MPIs = new Array();
+			for (var i = 0; i < mpicount; i++) {
+				this.MPIs[i] = new openpgp_type_mpi();
+				if (this.MPIs[i].read(input, mypos, (mypos-position)) != null && 
+						!this.packetLength < (mypos-position)) {
+					mypos += this.MPIs[i].packetLength;
+				} else {
+			 		util.print_error('signature contains invalid MPI @:'+mypos);
+				}
+			}
+		break;
+		case 4:
+			this.signatureType = input[mypos++].charCodeAt();
+			this.publicKeyAlgorithm = input[mypos++].charCodeAt();
+			this.hashAlgorithm = input[mypos++].charCodeAt();
+
+			// Two-octet scalar octet count for following hashed subpacket
+			// data.
+			var hashed_subpacket_count = (input[mypos++].charCodeAt() << 8) + input[mypos++].charCodeAt();
+
+			// Hashed subpacket data set (zero or more subpackets)
+			var subpacket_length = 0;
+			while (hashed_subpacket_count != subpacket_length) {
+				if (hashed_subpacket_count < subpacket_length) {
+					util.print_debug("openpgp.packet.signature.js\n"+"hashed missed something: "+mypos+" c:"+hashed_subpacket_count+" l:"+subpacket_length);
+				}
+
+				subpacket_length += this._raw_read_signature_sub_packet(input,
+						mypos + subpacket_length, hashed_subpacket_count
+								- subpacket_length);
+			}
+			
+			mypos += hashed_subpacket_count;
+			this.signatureData = input.substring(position, mypos);
+
+			// alert("signatureData: "+util.hexstrdump(this.signatureData));
+			
+			// Two-octet scalar octet count for the following unhashed subpacket
+			var subpacket_count = (input[mypos++].charCodeAt() << 8) + input[mypos++].charCodeAt();
+				
+			// Unhashed subpacket data set (zero or more subpackets).
+			subpacket_length = 0;
+			while (subpacket_count != subpacket_length) {
+				if (subpacket_count < subpacket_length) {
+					util.print_debug("openpgp.packet.signature.js\n"+"missed something: "+subpacket_length+" c:"+subpacket_count+" "+" l:"+subpacket_length);
+				}
+				subpacket_length += this._raw_read_signature_sub_packet(input,
+						mypos + subpacket_length, subpacket_count
+								- subpacket_length);
+
+			}
+			mypos += subpacket_count;
+			// Two-octet field holding the left 16 bits of the signed hash
+			// value.
+			this.signedHashValue = (input[mypos++].charCodeAt() << 8) | input[mypos++].charCodeAt();
+			// One or more multiprecision integers comprising the signature.
+			// This portion is algorithm specific, as described above.
+			var mpicount = 0;
+			if (this.publicKeyAlgorithm > 0 && this.publicKeyAlgorithm < 4)
+				mpicount = 1;
+			else if (this.publicKeyAlgorithm == 17)
+				mpicount = 2;
+			
+			this.MPIs = new Array();
+			for (var i = 0; i < mpicount; i++) {
+				this.MPIs[i] = new openpgp_type_mpi();
+				if (this.MPIs[i].read(input, mypos, (mypos-position)) != null && 
+						!this.packetLength < (mypos-position)) {
+					mypos += this.MPIs[i].packetLength;
+				} else {
+			 		util.print_error('signature contains invalid MPI @:'+mypos);
+				}
+			}
+			break;
+		default:
+			util.print_error("openpgp.packet.signature.js\n"+'unknown signature packet version'+this.version);
+			break;
+		}
+		// util.print_message("openpgp.packet.signature.js\n"+"end signature: l: "+this.packetLength+"m: "+mypos+" m-p: "+(mypos-position));
+		return this;
+	}
+	/**
+	 * creates a string representation of a message signature packet (tag 2).
+	 * This can be only used on text data
+	 * @param {Integer} signature_type should be 1 (one) 
+	 * @param {String} data data to be signed
+	 * @param {openpgp_msg_privatekey} privatekey private key used to sign the message. (secMPIs MUST be unlocked)
+	 * @return {String} string representation of a signature packet
+	 */
+	function write_message_signature(signature_type, data, privatekey) {
+		var publickey = privatekey.privateKeyPacket.publicKey;
+		var hash_algo = privatekey.getPreferredSignatureHashAlgorithm();
+		var result = String.fromCharCode(4); 
+		result += String.fromCharCode(signature_type);
+		result += String.fromCharCode(publickey.publicKeyAlgorithm);
+		result += String.fromCharCode(hash_algo);
+		var d = Math.round(new Date().getTime() / 1000);
+		var datesubpacket = write_sub_signature_packet(2,""+
+				String.fromCharCode((d >> 24) & 0xFF) + 
+				String.fromCharCode((d >> 16) & 0xFF) +
+				String.fromCharCode((d >> 8) & 0xFF) + 
+				String.fromCharCode(d & 0xFF));
+		var issuersubpacket = write_sub_signature_packet(16, privatekey.getKeyId());
+		result += String.fromCharCode(((datesubpacket.length + issuersubpacket.length) >> 8) & 0xFF);
+		result += String.fromCharCode ((datesubpacket.length + issuersubpacket.length) & 0xFF);
+		result += datesubpacket;
+		result += issuersubpacket;
+		var trailer = '';
+		
+		trailer += String.fromCharCode(4);
+		trailer += String.fromCharCode(0xFF);
+		trailer += String.fromCharCode((result.length) >> 24);
+		trailer += String.fromCharCode(((result.length) >> 16) & 0xFF);
+		trailer += String.fromCharCode(((result.length) >> 8) & 0xFF);
+		trailer += String.fromCharCode((result.length) & 0xFF);
+		var result2 = String.fromCharCode(0);
+		result2 += String.fromCharCode(0);
+		var hash = openpgp_crypto_hashData(hash_algo, data+result+trailer);
+		util.print_debug("DSA Signature is calculated with:|"+data+result+trailer+"|\n"+util.hexstrdump(data+result+trailer)+"\n hash:"+util.hexstrdump(hash));
+		result2 += hash.charAt(0);
+		result2 += hash.charAt(1);
+		result2 += openpgp_crypto_signData(hash_algo,privatekey.privateKeyPacket.publicKey.publicKeyAlgorithm,
+				publickey.MPIs,
+				privatekey.privateKeyPacket.secMPIs,
+				data+result+trailer);
+		return {openpgp: (openpgp_packet.write_packet_header(2, (result+result2).length)+result + result2), 
+				hash: util.get_hashAlgorithmString(hash_algo)};
+	}
+	/**
+	 * creates a string representation of a sub signature packet (See RFC 4880 5.2.3.1)
+	 * @param {Integer} type subpacket signature type. Signature types as described in RFC4880 Section 5.2.3.2
+	 * @param {String} data data to be included
+	 * @return {String} a string-representation of a sub signature packet (See RFC 4880 5.2.3.1)
+	 */
+	function write_sub_signature_packet(type, data) {
+		var result = "";
+		result += openpgp_packet.encode_length(data.length+1);
+		result += String.fromCharCode(type);
+		result += data;
+		return result;
+	}
+	
+	// V4 signature sub packets
+	
+	this._raw_read_signature_sub_packet = function(input, position, len) {
+		if (len < 0)
+			util.print_debug("openpgp.packet.signature.js\n"+"_raw_read_signature_sub_packet length < 0 @:"+position);
+		var mypos = position;
+		var subplen = 0;
+		// alert('starting signature subpackage read at position:'+position+' length:'+len);
+		if (input[mypos].charCodeAt() < 192) {
+			subplen = input[mypos++].charCodeAt();
+		} else if (input[mypos].charCodeAt() >= 192 && input[mypos].charCodeAt() < 224) {
+			subplen = ((input[mypos++].charCodeAt() - 192) << 8) + (input[mypos++].charCodeAt()) + 192;
+		} else if (input[mypos].charCodeAt() > 223 && input[mypos].charCodeAt() < 255) {
+			subplen = 1 << (input[mypos++].charCodeAt() & 0x1F);
+		} else if (input[mypos].charCodeAt() < 255) {
+			mypos++;
+			subplen = (input[mypos++].charCodeAt() << 24) | (input[mypos++].charCodeAt() << 16)
+					|  (input[mypos++].charCodeAt() << 8) |  input[mypos++].charCodeAt();
+		}
+		
+		var type = input[mypos++].charCodeAt() & 0x7F;
+		// alert('signature subpacket type '+type+" with length: "+subplen);
+		// subpacket type
+		switch (type) {
+		case 2: // Signature Creation Time
+			this.creationTime = new Date(((input[mypos++].charCodeAt() << 24) | (input[mypos++].charCodeAt() << 16)
+					| (input[mypos++].charCodeAt() << 8) | input[mypos++].charCodeAt())*1000);
+			break;
+		case 3: // Signature Expiration Time
+			this.signatureExpirationTime =  (input[mypos++].charCodeAt() << 24)
+					| (input[mypos++].charCodeAt() << 16) | (input[mypos++].charCodeAt() << 8)
+					| input[mypos++].charCodeAt();
+			this.signatureNeverExpires = (this.signature_expiration_time == 0);
+			
+			break;
+		case 4: // Exportable Certification
+			this.exportable = input[mypos++].charCodeAt() == 1;
+			break;
+		case 5: // Trust Signature
+			this.trustLevel = input[mypos++].charCodeAt();
+			this.trustAmount = input[mypos++].charCodeAt();
+			break;
+		case 6: // Regular Expression
+			this.regular_expression = new String();
+			for (var i = 0; i < subplen - 1; i++)
+				this.regular_expression += (input[mypos++]);
+			break;
+		case 7: // Revocable
+			this.revocable = input[mypos++].charCodeAt() == 1;
+			break;
+		case 9: // Key Expiration Time
+			this.keyExpirationTime = (input[mypos++].charCodeAt() << 24)
+					| (input[mypos++].charCodeAt() << 16) | (input[mypos++].charCodeAt() << 8)
+					| input[mypos++].charCodeAt();
+			this.keyNeverExpires = (this.keyExpirationTime == 0);
+			break;
+		case 11: // Preferred Symmetric Algorithms
+			this.preferredSymmetricAlgorithms = new Array();
+			for (var i = 0; i < subplen-1; i++) {
+				this.preferredSymmetricAlgorithms = input[mypos++].charCodeAt();
+			}
+			break;
+		case 12: // Revocation Key
+			// (1 octet of class, 1 octet of public-key algorithm ID, 20
+			// octets of
+			// fingerprint)
+			this.revocationKeyClass = input[mypos++].charCodeAt();
+			this.revocationKeyAlgorithm = input[mypos++].charCodeAt();
+			this.revocationKeyFingerprint = new Array();
+			for ( var i = 0; i < 20; i++) {
+				this.revocationKeyFingerprint = input[mypos++].charCodeAt();
+			}
+			break;
+		case 16: // Issuer
+			this.issuerKeyId = input.substring(mypos,mypos+8);
+			mypos += 8;
+			break;
+		case 20: // Notation Data
+			this.notationFlags = (input[mypos++].charCodeAt() << 24) | 
+								 (input[mypos++].charCodeAt() << 16) |
+								 (input[mypos++].charCodeAt() <<  8) | 
+								 (input[mypos++].charCodeAt());
+			var nameLength = (input[mypos++].charCodeAt() <<  8) | (input[mypos++].charCodeAt());
+			var valueLength = (input[mypos++].charCodeAt() <<  8) | (input[mypos++].charCodeAt());
+			this.notationName = "";
+			for (var i = 0; i < nameLength; i++) {
+				this.notationName += input[mypos++];
+			}
+			this.notationValue = "";
+			for (var i = 0; i < valueLength; i++) {
+				this.notationValue += input[mypos++];
+			}
+			break;
+		case 21: // Preferred Hash Algorithms
+			this.preferredHashAlgorithms = new Array();
+			for (var i = 0; i < subplen-1; i++) {
+				this.preferredHashAlgorithms = input[mypos++].charCodeAt();
+			}
+			break;
+		case 22: // Preferred Compression Algorithms
+			this.preferredCompressionAlgorithms = new Array();
+			for ( var i = 0; i < subplen-1; i++) {
+				this.preferredCompressionAlgorithms = input[mypos++].charCodeAt();
+			}
+			break;
+		case 23: // Key Server Preferences
+			this.keyServerPreferences = new Array();
+			for ( var i = 0; i < subplen-1; i++) {
+				this.keyServerPreferences = input[mypos++].charCodeAt();
+			}
+			break;
+		case 24: // Preferred Key Server
+			this.preferredKeyServer = new String();
+			for ( var i = 0; i < subplen-1; i++) {
+				this.preferredKeyServer += input[mypos++];
+			}
+			break;
+		case 25: // Primary User ID
+			this.isPrimaryUserID = input[mypos++] != 0;
+			break;
+		case 26: // Policy URI
+			this.policyURI = new String();
+			for ( var i = 0; i < subplen-1; i++) {
+				this.policyURI += input[mypos++];
+			}
+			break;
+		case 27: // Key Flags
+			this.keyFlags = new Array();
+			for ( var i = 0; i < subplen-1; i++) {
+				this.keyFlags = input[mypos++].charCodeAt();
+			}
+			break;
+		case 28: // Signer's User ID
+			this.signersUserId = new String();
+			for ( var i = 0; i < subplen-1; i++) {
+				this.signersUserId += input[mypos++];
+			}
+			break;
+		case 29: // Reason for Revocation
+			this.reasonForRevocationFlag = input[mypos++].charCodeAt();
+			this.reasonForRevocationString = new String();
+			for ( var i = 0; i < subplen -2; i++) {
+				this.reasonForRevocationString += input[mypos++];
+			}
+			break;
+		case 30: // Features
+			// TODO: to be implemented
+			return subplen+1;
+		case 31: // Signature Target
+			// (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash)
+			this.signatureTargetPublicKeyAlgorithm = input[mypos++].charCodeAt();
+			this.signatureTargetHashAlgorithm = input[mypos++].charCodeAt();
+			var signatureTargetHashAlgorithmLength = 0;
+			switch(this.signatureTargetHashAlgorithm) {
+			case  1: // - MD5 [HAC]                             "MD5"
+			case  2: // - SHA-1 [FIPS180]                       "SHA1"
+				signatureTargetHashAlgorithmLength = 20;
+				break;
+			case  3: // - RIPE-MD/160 [HAC]                     "RIPEMD160"
+			case  8: // - SHA256 [FIPS180]                      "SHA256"
+			case  9: // - SHA384 [FIPS180]                      "SHA384"
+			case 10: // - SHA512 [FIPS180]                      "SHA512"
+			case 11: // - SHA224 [FIPS180]                      "SHA224"
+				break;
+			// 100 to 110 - Private/Experimental algorithm
+	    	default:
+	    		util.print_error("openpgp.packet.signature.js\n"+"unknown signature target hash algorithm:"+this.signatureTargetHashAlgorithm);
+	    		return null;
+			}
+			this.signatureTargetHash = new Array();
+			for (var i = 0; i < signatureTargetHashAlgorithmLength; i++) {
+				this.signatureTargetHash[i] = input[mypos++]; 
+			}
+		case 32: // Embedded Signature
+			this.embeddedSignature = new openpgp_packet_signature();
+			this.embeddedSignature.read_packet(input, mypos, len -(mypos-position));
+			return ((mypos+ this.embeddedSignature.packetLength) - position);
+			break;
+		case 100: // Private or experimental
+		case 101: // Private or experimental
+		case 102: // Private or experimental
+		case 103: // Private or experimental
+		case 104: // Private or experimental
+		case 105: // Private or experimental
+		case 106: // Private or experimental
+		case 107: // Private or experimental
+		case 108: // Private or experimental
+		case 109: // Private or experimental
+		case 110: // Private or experimental
+			util.print_error("openpgp.packet.signature.js\n"+'private or experimental signature subpacket type '+type+" @:"+mypos+" subplen:"+subplen+" len:"+len);
+			return subplen+1;
+			break;	
+		case 0: // Reserved
+		case 1: // Reserved
+		case 8: // Reserved
+		case 10: // Placeholder for backward compatibility
+		case 13: // Reserved
+		case 14: // Reserved
+		case 15: // Reserved
+		case 17: // Reserved
+		case 18: // Reserved
+		case 19: // Reserved
+		default:
+			util.print_error("openpgp.packet.signature.js\n"+'unknown signature subpacket type '+type+" @:"+mypos+" subplen:"+subplen+" len:"+len);
+			return subplen+1;
+			break;
+		}
+		return mypos -position;
+	};
+	/**
+	 * verifys the signature packet. Note: not signature types are implemented
+	 * @param {String} data data which on the signature applies
+	 * @param {openpgp_msg_privatekey} key the public key to verify the signature
+	 * @return {boolean} True if message is verified, else false.
+	 */
+	function verify(data, key) {
+		// calculating the trailer
+		var trailer = '';
+		trailer += String.fromCharCode(this.version);
+		trailer += String.fromCharCode(0xFF);
+		trailer += String.fromCharCode(this.signatureData.length >> 24);
+		trailer += String.fromCharCode((this.signatureData.length >> 16) &0xFF);
+		trailer += String.fromCharCode((this.signatureData.length >> 8) &0xFF);
+		trailer += String.fromCharCode(this.signatureData.length & 0xFF);
+		switch(this.signatureType) {
+		case 0: // 0x00: Signature of a binary document.
+			if (this.version == 4) {
+				this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm, 
+					this.MPIs, key.obj.publicKeyPacket.MPIs, data+this.signatureData+trailer);
+			}
+			break;
+
+		case 1: // 0x01: Signature of a canonical text document.
+			if (this.version == 4) {
+				this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm, 
+					this.MPIs, key.obj.publicKeyPacket.MPIs, data+this.signatureData+trailer);
+				return this.verified;
+			}
+			break;
+				
+		case 2: // 0x02: Standalone signature.
+			// This signature is a signature of only its own subpacket contents.
+			// It is calculated identically to a signature over a zero-length
+			// binary document.  Note that it doesn't make sense to have a V3
+			// standalone signature.
+			if (this.version == 3) {
+				this.verified = false;
+				break;
+				}
+			
+			this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm, 
+					this.MPIs, key.obj.publicKeyPacket.MPIs, this.signatureData+trailer);
+			break;
+		case 16:			
+			// 0x10: Generic certification of a User ID and Public-Key packet.
+			// The issuer of this certification does not make any particular
+			// assertion as to how well the certifier has checked that the owner
+			// of the key is in fact the person described by the User ID.
+		case 17:
+			// 0x11: Persona certification of a User ID and Public-Key packet.
+			// The issuer of this certification has not done any verification of
+			// the claim that the owner of this key is the User ID specified.
+		case 18:
+			// 0x12: Casual certification of a User ID and Public-Key packet.
+			// The issuer of this certification has done some casual
+			// verification of the claim of identity.
+		case 19:
+			// 0x13: Positive certification of a User ID and Public-Key packet.
+			// The issuer of this certification has done substantial
+			// verification of the claim of identity.
+			// 
+			// Most OpenPGP implementations make their "key signatures" as 0x10
+			// certifications.  Some implementations can issue 0x11-0x13
+			// certifications, but few differentiate between the types.
+		case 48:
+			// 0x30: Certification revocation signature
+			// This signature revokes an earlier User ID certification signature
+			// (signature class 0x10 through 0x13) or direct-key signature
+			// (0x1F).  It should be issued by the same key that issued the
+			// revoked signature or an authorized revocation key.  The signature
+			// is computed over the same data as the certificate that it
+			// revokes, and should have a later creation date than that
+			// certificate.
+
+			this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm, 
+					this.MPIs, key.MPIs, data+this.signatureData+trailer);
+			break;
+						
+		case 24:
+			// 0x18: Subkey Binding Signature
+			// This signature is a statement by the top-level signing key that
+			// indicates that it owns the subkey.  This signature is calculated
+			// directly on the primary key and subkey, and not on any User ID or
+			// other packets.  A signature that binds a signing subkey MUST have
+			// an Embedded Signature subpacket in this binding signature that
+			// contains a 0x19 signature made by the signing subkey on the
+			// primary key and subkey.
+			if (this.version == 3) {
+				this.verified = false;
+				break;
+			}
+			
+			this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm, 
+					this.MPIs, key.MPIs, data+this.signatureData+trailer);
+			break;
+		case 25:
+			// 0x19: Primary Key Binding Signature
+			// This signature is a statement by a signing subkey, indicating
+			// that it is owned by the primary key and subkey.  This signature
+			// is calculated the same way as a 0x18 signature: directly on the
+			// primary key and subkey, and not on any User ID or other packets.
+			
+			// When a signature is made over a key, the hash data starts with the
+			// octet 0x99, followed by a two-octet length of the key, and then body
+			// of the key packet.  (Note that this is an old-style packet header for
+			// a key packet with two-octet length.)  A subkey binding signature
+			// (type 0x18) or primary key binding signature (type 0x19) then hashes
+			// the subkey using the same format as the main key (also using 0x99 as
+			// the first octet).
+		case 31:
+			// 0x1F: Signature directly on a key
+			// This signature is calculated directly on a key.  It binds the
+			// information in the Signature subpackets to the key, and is
+			// appropriate to be used for subpackets that provide information
+			// about the key, such as the Revocation Key subpacket.  It is also
+			// appropriate for statements that non-self certifiers want to make
+			// about the key itself, rather than the binding between a key and a
+			// name.
+		case 32:
+			// 0x20: Key revocation signature
+			// The signature is calculated directly on the key being revoked.  A
+			// revoked key is not to be used.  Only revocation signatures by the
+			// key being revoked, or by an authorized revocation key, should be
+			// considered valid revocation signatures.
+		case 40:
+			// 0x28: Subkey revocation signature
+			// The signature is calculated directly on the subkey being revoked.
+			// A revoked subkey is not to be used.  Only revocation signatures
+			// by the top-level signature key that is bound to this subkey, or
+			// by an authorized revocation key, should be considered valid
+			// revocation signatures.
+			this.verified = openpgp_crypto_verifySignature(this.publicKeyAlgorithm, this.hashAlgorithm, 
+					this.MPIs, key.MPIs, data+this.signatureData+trailer);
+			break;
+			
+			// Key revocation signatures (types 0x20 and 0x28)
+			// hash only the key being revoked.
+		case 64:
+			// 0x40: Timestamp signature.
+			// This signature is only meaningful for the timestamp contained in
+			// it.
+		case 80:
+			//    0x50: Third-Party Confirmation signature.
+			// This signature is a signature over some other OpenPGP Signature
+			// packet(s).  It is analogous to a notary seal on the signed data.
+			// A third-party signature SHOULD include Signature Target
+			// subpacket(s) to give easy identification.  Note that we really do
+			// mean SHOULD.  There are plausible uses for this (such as a blind
+			// party that only sees the signature, not the key or source
+			// document) that cannot include a target subpacket.
+		default:
+			util.print_error("openpgp.packet.signature.js\n"+"signature verification for type"+ this.signatureType+" not implemented");
+			break;
+		}
+		return this.verified;
+	}
+	/**
+	 * generates debug output (pretty print)
+	 * @return {String} String which gives some information about the signature packet
+	 */
+
+	function toString () {
+		if (this.version == 3) {
+			var result = '5.2. Signature Packet (Tag 2)\n'+
+	          "Packet Length:                     :"+this.packetLength+'\n'+
+	          "Packet version:                    :"+this.version+'\n'+
+	          "One-octet signature type           :"+this.signatureType+'\n'+
+	          "Four-octet creation time.          :"+this.creationTime+'\n'+
+	         "Eight-octet Key ID of signer.       :"+util.hexidump(this.keyId)+'\n'+
+	          "One-octet public-key algorithm.    :"+this.publicKeyAlgorithm+'\n'+
+	          "One-octet hash algorithm.          :"+this.hashAlgorithm+'\n'+
+	          "Two-octet field holding left\n" +
+	          " 16 bits of signed hash value.     :"+this.signedHashValue+'\n';
+		} else {
+          var result = '5.2. Signature Packet (Tag 2)\n'+
+          "Packet Length:                     :"+this.packetLength+'\n'+
+          "Packet version:                    :"+this.version+'\n'+
+          "One-octet signature type           :"+this.signatureType+'\n'+
+          "One-octet public-key algorithm.    :"+this.publicKeyAlgorithm+'\n'+
+          "One-octet hash algorithm.          :"+this.hashAlgorithm+'\n'+
+          "Two-octet field holding left\n" +
+          " 16 bits of signed hash value.     :"+this.signedHashValue+'\n'+
+          "Signature Creation Time            :"+this.creationTime+'\n'+
+          "Signature Expiration Time          :"+this.signatureExpirationTime+'\n'+
+          "Signature Never Expires            :"+this.signatureNeverExpires+'\n'+
+          "Exportable Certification           :"+this.exportable+'\n'+
+          "Trust Signature level:             :"+this.trustLevel+' amount'+this.trustAmount+'\n'+
+          "Regular Expression                 :"+this.regular_expression+'\n'+
+          "Revocable                          :"+this.revocable+'\n'+
+          "Key Expiration Time                :"+this.keyExpirationTime+" "+this.keyNeverExpires+'\n'+
+          "Preferred Symmetric Algorithms     :"+this.preferredSymmetricAlgorithms+'\n'+
+          "Revocation Key"+'\n'+
+          "   ( 1 octet of class,             :"+this.revocationKeyClass +'\n'+
+          "     1 octet of public-key ID,     :" +this.revocationKeyAlgorithm+'\n'+
+          "    20 octets of fingerprint)      :"+this.revocationKeyFingerprint+'\n'+
+          "Issuer                             :"+util.hexstrdump(this.issuerKeyId)+'\n'+
+          "Preferred Hash Algorithms          :"+this.preferredHashAlgorithms+'\n'+
+          "Preferred Compression Alg.         :"+this.preferredCompressionAlgorithms+'\n'+
+          "Key Server Preferences             :"+this.keyServerPreferences+'\n'+
+          "Preferred Key Server               :"+this.preferredKeyServer+'\n'+
+          "Primary User ID                    :"+this.isPrimaryUserID+'\n'+
+          "Policy URI                         :"+this.policyURI+'\n'+
+          "Key Flags                          :"+this.keyFlags+'\n'+
+          "Signer's User ID                   :"+this.signersUserId+'\n'+
+          "Notation                           :"+this.notationName+" = "+this.notationValue+"\n"+
+          "Reason for Revocation\n"+
+          "      Flag                         :"+this.reasonForRevocationFlag+'\n'+
+          "      Reason                       :"+this.reasonForRevocationString+'\nMPI:\n';
+		}
+          for (var i = 0; i < this.MPIs.length; i++) {
+        	  result += this.MPIs[i].toString();
+          }
+          return result;
+     }
+
+	/**
+	 * gets the issuer key id of this signature
+	 * @return {String} issuer key id as string (8bytes)
+	 */
+	function getIssuer() {
+		 if (this.version == 4)
+			 return this.issuerKeyId;
+		 if (this.verions == 4)
+			 return this.keyId;
+		 return null;
+	}
+
+	/**
+	 * Tries to get the corresponding public key out of the public keyring for the issuer created this signature
+	 * @return {Object} {obj: [openpgp_msg_publickey], text: [String]} if found the public key will be returned. null otherwise
+	 */
+	function getIssuerKey() {
+		 var result = null;
+		 if (this.version == 4) {
+			 result = openpgp.keyring.getPublicKeysForKeyId(this.issuerKeyId);
+		 } else if (this.version == 3) {
+			 result = openpgp.keyring.getPublicKeysForKeyId(this.keyId);
+		 } else return null;
+		 if (result.length == 0)
+			 return null;
+		 return result[0];
+	}
+	this.getIssuerKey = getIssuerKey;
+	this.getIssuer = getIssuer;	 
+	this.write_message_signature = write_message_signature;
+	this.verify = verify;
+    this.read_packet = read_packet;
+    this.toString = toString;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.userattribute.js.html b/doc/openpgp.packet.userattribute.js.html new file mode 100644 index 00000000..7f9cc23d --- /dev/null +++ b/doc/openpgp.packet.userattribute.js.html @@ -0,0 +1,204 @@ + + + + + JSDoc: Source: packet/openpgp.packet.userattribute.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.userattribute.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
+
+/** 
+ * @class
+ * @classdesc Implementation of the User Attribute Packet (Tag 17)
+ *  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.
+ */
+function openpgp_packet_userattribute() {
+	this.tagType = 17;
+	this.certificationSignatures = new Array();
+	this.certificationRevocationSignatures = new Array();
+	this.revocationSignatures = new Array();
+	this.parentNode = null;
+
+	/**
+	 * parsing function for a user attribute packet (tag 17).
+	 * @param {String} input payload of a tag 17 packet
+	 * @param {Integer} position position to start reading from the input string
+	 * @param {Integer} len length of the packet or the remaining length of input at position
+	 * @return {openpgp_packet_encrypteddata} object representation
+	 */
+	function read_packet (input, position, len) {
+		var total_len = 0;
+		this.packetLength = len;
+		this.userattributes = new Array();
+		var count = 0;
+		var mypos = position;
+		while (len != total_len) {
+			var current_len = 0;
+			// 4.2.2.1. One-Octet Lengths
+			if (input[mypos].charCodeAt() < 192) {
+				packet_length = input[mypos++].charCodeAt();
+				current_len = 1;
+			// 4.2.2.2. Two-Octet Lengths
+			} else if (input[mypos].charCodeAt() >= 192 && input[mypos].charCodeAt() < 224) {
+				packet_length = ((input[mypos++].charCodeAt() - 192) << 8)
+					+ (input[mypos++].charCodeAt()) + 192;
+				current_len = 2;
+			// 4.2.2.4. Partial Body Lengths
+			} else if (input[mypos].charCodeAt() > 223 && input[mypos].charCodeAt() < 255) {
+				packet_length = 1 << (input[mypos++].charCodeAt() & 0x1F);
+				current_len = 1;
+			// 4.2.2.3. Five-Octet Lengths
+			} else {
+				current_len = 5;
+				mypos++;
+				packet_length = (input[mypos++].charCodeAt() << 24) | (input[mypos++].charCodeAt() << 16)
+					| (input[mypos++].charCodeAt() << 8) | input[mypos++].charCodeAt();
+			}
+			
+			var subpackettype = input[mypos++].charCodeAt();
+			packet_length--;
+			current_len++;
+			this.userattributes[count] = new Array();
+			this.userattributes[count] = input.substring(mypos, mypos + packet_length);
+			mypos += packet_length;
+			total_len += current_len+packet_length;
+		}
+		this.packetLength = mypos - position;
+		return this;
+	}
+	
+	/**
+	 * generates debug output (pretty print)
+	 * @return {String} String which gives some information about the user attribute packet
+	 */
+	function toString() {
+		var result = '5.12.  User Attribute Packet (Tag 17)\n'+
+		             '    AttributePackets: (count = '+this.userattributes.length+')\n';
+		for (var i = 0; i < this.userattributes.length; i++) {
+			result += '    ('+this.userattributes[i].length+') bytes: ['+util.hexidump(this.userattributes[i])+']\n'; 
+		}
+		return result;
+	}
+	
+	/**
+	 * Continue parsing packets belonging to the user attribute packet such as signatures
+	 * @param {Object} parent_node the parent object
+	 * @param {String} input input string to read the packet(s) from
+	 * @param {Integer} position start position for the parser
+	 * @param {Integer} len length of the packet(s) or remaining length of input
+	 * @return {Integer} length of nodes read
+	 */
+	function read_nodes(parent_node, input, position, len) {
+		
+		this.parentNode = parent_node;
+		var exit = false;
+		var pos = position;
+		var l = len;
+		while (input.length != pos) {
+			var result = openpgp_packet.read_packet(input, pos, l);
+			if (result == null) {
+				util.print_error("openpgp.packet.userattribute.js\n"+'[user_attr] parsing ends here @:' + pos + " l:" + l);
+				break;
+			} else {
+				switch (result.tagType) {
+				case 2: // Signature Packet
+					if (result.signatureType > 15
+							&& result.signatureType < 20) // certification
+						// //
+						// signature
+						this.certificationSignatures[this.certificationSignatures.length] = result;
+					else if (result.signatureType == 32) // certification revocation signature
+						this.certificationRevocationSignatures[this.certificationRevocationSignatures.length] = result;
+					pos += result.packetLength + result.headerLength;
+					l = len - (pos - position);
+					break;
+				default:
+					this.data = input;
+					this.position = position - parent_node.packetLength;
+					this.len = pos - position;
+					return this.len;
+					break;
+				}
+			}
+		}
+		this.data = input;
+		this.position = position - parent_node.packetLength;
+		this.len = pos - position;
+		return this.len;
+
+	}
+	
+	this.read_packet = read_packet;
+	this.read_nodes = read_nodes;
+	this.toString = toString;
+	
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.packet.userid.js.html b/doc/openpgp.packet.userid.js.html new file mode 100644 index 00000000..fa8c072a --- /dev/null +++ b/doc/openpgp.packet.userid.js.html @@ -0,0 +1,385 @@ + + + + + JSDoc: Source: packet/openpgp.packet.userid.js + + + + + + + + + + +
+ +

Source: packet/openpgp.packet.userid.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
+
+/**
+ * @class
+ * @classdesc Implementation of the User ID Packet (Tag 13)
+ * 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. 
+ */
+
+function openpgp_packet_userid() {
+	this.tagType = 13;
+	this.certificationSignatures = new Array();
+	this.certificationRevocationSignatures = new Array();
+	this.revocationSignatures = new Array();
+	this.parentNode = null;
+
+	/**
+	 * parsing function for a user id packet (tag 13).
+	 * @param {String} input payload of a tag 13 packet
+	 * @param {Integer} position position to start reading from the input string
+	 * @param {Integer} len length of the packet or the remaining length of input at position
+	 * @return {openpgp_packet_encrypteddata} object representation
+	 */
+	function read_packet(input, position, len) {
+		this.text = '';
+		this.packetLength = len;
+
+		for ( var i = 0; i < len; i++) {
+			this.text += input[position + i];
+		}
+		return this;
+	}
+
+	/**
+	 * creates a string representation of the user id packet
+	 * @param {String} user_id the user id as string ("John Doe <john.doe@mail.us")
+	 * @return {String} string representation
+	 */
+	function write_packet(user_id) {
+		this.text = user_id;
+		var result = openpgp_packet.write_packet_header(13,this.text.length);
+		result += this.text;
+		return result;
+	}
+
+	/**
+	 * Continue parsing packets belonging to the userid packet such as signatures
+	 * @param {Object} parent_node the parent object
+	 * @param {String} input input string to read the packet(s) from
+	 * @param {Integer} position start position for the parser
+	 * @param {Integer} len length of the packet(s) or remaining length of input
+	 * @return {Integer} length of nodes read
+	 */
+	function read_nodes(parent_node, input, position, len) {
+		if (parent_node.tagType == 6) { // public key
+			this.parentNode = parent_node;
+			var pos = position;
+			var l = len;
+			while (input.length != pos) {
+				var result = openpgp_packet.read_packet(input, pos, l - (pos - position));
+				if (result == null) {
+					util.print_error('[user_id] parsing ends here @:' + pos + " l:" + l);
+					break;
+				} else {
+					
+					pos += result.packetLength + result.headerLength;
+					l = input.length - pos;
+					switch (result.tagType) {
+					case 2: // Signature Packet
+						if (result.signatureType > 15
+								&& result.signatureType < 20) { // certification
+							// //
+							// signature
+							this.certificationSignatures[this.certificationSignatures.length] = result;
+							break;
+						} else if (result.signatureType == 48) {// certification revocation signature
+							this.certificationRevocationSignatures[this.certificationRevocationSignatures.length] = result;
+							break;
+						} else if (result.signatureType == 24) { // omg. standalone signature 
+							this.certificationSignatures[this.certificationSignatures.length] = result;
+							break;
+						} else {
+							util.print_debug("unknown sig t: "+result.signatureType+"@"+(pos - (result.packetLength + result.headerLength)));
+						}
+					default:
+						this.data = input;
+						this.position = position - parent_node.packetLength;
+						this.len = pos - position -(result.headerLength + result.packetLength);
+						return this.len;
+					}
+				}
+			}
+			this.data = input;
+			this.position = position - parent_node.packetLength;
+			this.len = pos - position -(result.headerLength + result.packetLength);
+			return this.len;
+		} else if (parent_node.tagType == 5) { // secret Key
+			this.parentNode = parent_node;
+			var exit = false;
+			var pos = position;
+			while (input.length != pos) {
+				var result = openpgp_packet.read_packet(input, pos, l - (pos - position));
+				if (result == null) {
+					util.print_error('parsing ends here @:' + pos + " l:" + l);
+					break;
+				} else {
+					pos += result.packetLength + result.headerLength;
+					l = input.length - pos;
+					switch (result.tagType) {
+					case 2: // Signature Packet certification signature
+						if (result.signatureType > 15
+								&& result.signatureType < 20)
+							this.certificationSignatures[this.certificationSignatures.length] = result;
+						// certification revocation signature
+						else if (result.signatureType == 48)
+							this.certificationRevocationSignatures[this.certificationRevocationSignatures.length] = result;
+					default:
+						this.data = input;
+						this.position = position - parent_node.packetLength;
+						this.len = pos - position -(result.headerLength + result.packetLength);
+						return this.len;
+					}
+				}
+			}
+		} else {
+			util.print_error("unknown parent node for a userId packet "+parent_node.tagType);
+		}
+	}
+	
+	/**
+	 * generates debug output (pretty print)
+	 * @return {String} String which gives some information about the user id packet
+	 */
+	function toString() {
+		var result = '     5.11.  User ID Packet (Tag 13)\n' + '    text ('
+				+ this.text.length + '): "' + this.text.replace("<", "<")
+				+ '"\n';
+		result +="certification signatures:\n";
+		for (var i = 0; i < this.certificationSignatures.length; i++) {
+			result += "        "+this.certificationSignatures[i].toString();
+		}
+		result +="certification revocation signatures:\n";
+		for (var i = 0; i < this.certificationRevocationSignatures.length; i++) {
+			result += "        "+this.certificationRevocationSignatures[i].toString();
+		}
+		return result;
+	}
+
+	/**
+	 * lookup function to find certification revocation signatures
+	 * @param {String} keyId string containing the key id of the issuer of this signature
+	 * @return a CertificationRevocationSignature if found; otherwise null
+	 */
+	function hasCertificationRevocationSignature(keyId) {
+		for (var i = 0; i < this.certificationRevocationSignatures.length; i++) {
+			if ((this.certificationRevocationSignatures[i].version == 3 &&
+				 this.certificationRevocationSignatures[i].keyId == keyId) ||
+				(this.certificationRevocationSignatures[i].version == 4 &&
+				 this.certificationRevocationSignatures[i].issuerKeyId == keyId))
+				return this.certificationRevocationSignatures[i];
+		}
+		return null;
+	}
+
+	/**
+	 * Verifies all certification signatures. This method does not consider possible revocation signatures.
+	 * @param {Object} publicKeyPacket the top level key material
+	 * @return {Integer[]} An array of integers corresponding to the array of certification signatures. The meaning of each integer is the following:
+	 * 0 = bad signature
+	 * 1 = signature expired
+	 * 2 = issuer key not available
+	 * 3 = revoked
+	 * 4 = signature valid
+	 * 5 = signature by key owner expired
+	 * 6 = signature by key owner revoked
+	 */
+	function verifyCertificationSignatures(publicKeyPacket) {
+		result = new Array();
+		for (var i = 0 ; i < this.certificationSignatures.length; i++) {
+			// A certification signature (type 0x10 through 0x13) hashes the User
+			// ID being bound to the key into the hash context after the above
+			// data.  A V3 certification hashes the contents of the User ID or
+			// attribute packet packet, without any header.  A V4 certification
+			// hashes the constant 0xB4 for User ID certifications or the constant
+			// 0xD1 for User Attribute certifications, followed by a four-octet
+			// number giving the length of the User ID or User Attribute data, and
+			// then the User ID or User Attribute data.
+
+			if (this.certificationSignatures[i].version == 4) {
+				if (this.certificationSignatures[i].signatureExpirationTime != null &&
+						this.certificationSignatures[i].signatureExpirationTime != null &&
+						this.certificationSignatures[i].signatureExpirationTime != 0 &&
+						!this.certificationSignatures[i].signatureNeverExpires &&
+						new Date(this.certificationSignatures[i].creationTime.getTime() +(this.certificationSignatures[i].signatureExpirationTime*1000)) < new Date()) {
+					if (this.certificationSignatures[i].issuerKeyId == publicKeyPacket.getKeyId())
+						result[i] = 5;
+					else
+						result[i] = 1;
+					continue;
+				}
+				if (this.certificationSignatures[i].issuerKeyId == null) {
+					result[i] = 0;
+					continue;
+				}
+				var issuerPublicKey = openpgp.keyring.getPublicKeysForKeyId(this.certificationSignatures[i].issuerKeyId);
+				if (issuerPublicKey == null || issuerPublicKey.length == 0) {
+					result[i] = 2;
+					continue;
+				}
+				// TODO: try to verify all returned issuer public keys (key ids are not unique!)
+				var issuerPublicKey = issuerPublicKey[0];
+				var signingKey = issuerPublicKey.obj.getSigningKey();
+				if (signingKey == null) {
+					result[i] = 0;
+					continue;
+				}
+				var revocation = this.hasCertificationRevocationSignature(this.certificationSignatures[i].issuerKeyId);
+				if (revocation != null && revocation.creationTime > 
+					this.certificationSignatures[i].creationTime) {
+					var signaturedata = String.fromCharCode(0x99)+ publicKeyPacket.header.substring(1)+
+					publicKeyPacket.data+String.fromCharCode(0xB4)+
+					String.fromCharCode((this.text.length >> 24) & 0xFF)+
+					String.fromCharCode((this.text.length >> 16) & 0xFF)+
+					String.fromCharCode((this.text.length >>  8) & 0xFF)+
+					String.fromCharCode((this.text.length) & 0xFF)+
+					this.text;
+					if (revocation.verify(signaturedata, signingKey)) {
+						if (this.certificationSignatures[i].issuerKeyId == publicKeyPacket.getKeyId())
+							result[i] = 6;
+						else
+							result[i] = 3;
+						continue;
+					}
+				}
+				var signaturedata = String.fromCharCode(0x99)+ publicKeyPacket.header.substring(1)+
+						publicKeyPacket.data+String.fromCharCode(0xB4)+
+						String.fromCharCode((this.text.length >> 24) & 0xFF)+
+						String.fromCharCode((this.text.length >> 16) & 0xFF)+
+						String.fromCharCode((this.text.length >>  8) & 0xFF)+
+						String.fromCharCode((this.text.length) & 0xFF)+
+						this.text;
+				if (this.certificationSignatures[i].verify(signaturedata, signingKey)) {
+					result[i] = 4;
+				} else
+				result[i] = 0;
+			} else if (this.certificationSignatures[i].version == 3) {
+				if (this.certificationSignatures[i].keyId == null) {
+					result[i] = 0;
+					continue;
+				}
+				var issuerPublicKey = openpgp.keyring.getPublicKeysForKeyId(this.certificationSignatures[i].keyId);
+				if (issuerPublicKey == null || issuerPublicKey.length == 0) {
+					result[i] = 2;
+					continue;
+				}
+				issuerPublicKey = issuerPublicKey[0];
+				var signingKey = publicKey.obj.getSigningKey();
+				if (signingKey == null) {
+					result[i] = 0;
+					continue;
+				}
+				var revocation = this.hasCertificationRevocationSignature(this.certificationSignatures[i].keyId);
+				if (revocation != null && revocation.creationTime > 
+					this.certificationSignatures[i].creationTime) {
+					var signaturedata = String.fromCharCode(0x99)+ this.publicKeyPacket.header.substring(1)+
+					this.publicKeyPacket.data+this.text;
+					if (revocation.verify(signaturedata, signingKey)) {
+						if (revocation.keyId == publicKeyPacket.getKeyId())
+							result[i] = 6;
+						else
+							result[i] = 3;
+						continue;
+					}
+				}
+				var signaturedata = String.fromCharCode(0x99)+ publicKeyPacket.header.substring(1)+
+					publicKeyPacket.data+this.text;
+				if (this.certificationSignatures[i].verify(signaturedata, signingKey)) {
+					result[i] = 4;
+				} else 
+				result[i] = 0;
+			} else {
+				result[i] = 0;
+			}
+		}
+		return result;
+	}
+
+	/**
+	 * verifies the signatures of the user id
+	 * @return 0 if the userid is valid; 1 = userid expired; 2 = userid revoked
+	 */
+	function verify(publicKeyPacket) {
+		var result = this.verifyCertificationSignatures(publicKeyPacket);
+		if (result.indexOf(6) != -1)
+			return 2;
+		if (result.indexOf(5) != -1)
+			return 1;
+		return 0;
+	}
+
+	// TODO: implementation missing
+	function addCertification(publicKeyPacket, privateKeyPacket) {
+		
+	}
+
+	// TODO: implementation missing
+	function revokeCertification(publicKeyPacket, privateKeyPacket) {
+		
+	}
+
+	this.hasCertificationRevocationSignature = hasCertificationRevocationSignature;
+	this.verifyCertificationSignatures = verifyCertificationSignatures;
+	this.verify = verify;
+	this.read_packet = read_packet;
+	this.write_packet = write_packet;
+	this.toString = toString;
+	this.read_nodes = read_nodes;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.type.keyid.js.html b/doc/openpgp.type.keyid.js.html new file mode 100644 index 00000000..097a6c4a --- /dev/null +++ b/doc/openpgp.type.keyid.js.html @@ -0,0 +1,98 @@ + + + + + JSDoc: Source: type/openpgp.type.keyid.js + + + + + + + + + + +
+ +

Source: type/openpgp.type.keyid.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_type_keyid() {
+	/**
+	 * Parsing method for a key id
+	 * @param {String} input Input to read the key id from 
+	 * @param {integer} position Position where to start reading the key 
+	 * id from input
+	 * @return {openpgp_type_keyid} This object
+	 */
+	function read_packet(input, position) {
+		this.bytes = input.substring(position, position+8);
+		return this;
+	}
+	
+	/**
+	 * Generates debug output (pretty print)
+	 * @return {String} Key Id as hexadecimal string
+	 */
+	function toString() {
+		return util.hexstrdump(this.bytes);
+	}
+	
+	this.read_packet = read_packet;
+	this.toString = toString;
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.type.mpi.js.html b/doc/openpgp.type.mpi.js.html new file mode 100644 index 00000000..d2ba414e --- /dev/null +++ b/doc/openpgp.type.mpi.js.html @@ -0,0 +1,184 @@ + + + + + JSDoc: Source: type/openpgp.type.mpi.js + + + + + + + + + + +
+ +

Source: type/openpgp.type.mpi.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
+
+// Hint: We hold our MPIs as an array of octets in big endian format preceeding a two
+// octet scalar: MPI: [a,b,c,d,e,f]
+// - MPI size: (a << 8) | b 
+// - MPI = c | d << 8 | e << ((MPI.length -2)*8) | f ((MPI.length -2)*8)
+
+/**
+ * @class
+ * @classdescImplementation 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.
+ */
+function openpgp_type_mpi() {
+	this.MPI = null;
+	this.mpiBitLength = null;
+	this.mpiByteLength = null;
+	this.data = null;
+	/**
+	 * Parsing function for a mpi (RFC 4880 3.2).
+	 * @param {String} input Payload of mpi data
+	 * @param {Integer} position Position to start reading from the input 
+	 * string
+	 * @param {Integer} len Length of the packet or the remaining length of 
+	 * input at position
+	 * @return {openpgp_type_mpi} Object representation
+	 */
+	function read(input, position, len) {
+		var mypos = position;
+		
+		this.mpiBitLength = (input[mypos++].charCodeAt() << 8) | input[mypos++].charCodeAt();
+		
+		// Additional rules:
+		//
+		//    The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
+		//
+		//    The length field of an MPI describes the length starting from its
+		//	  most significant non-zero bit.  Thus, the MPI [00 02 01] is not
+		//    formed correctly.  It should be [00 01 01].
+
+		// TODO: Verification of this size method! This size calculation as
+		// 		 specified above is not applicable in JavaScript
+		this.mpiByteLength = (this.mpiBitLength - (this.mpiBitLength % 8)) / 8;
+		if (this.mpiBitLength % 8 != 0)
+			this.mpiByteLength++;
+		
+		this.MPI = input.substring(mypos,mypos+this.mpiByteLength);
+		this.data = input.substring(position, position+2+this.mpiByteLength);
+		this.packetLength = this.mpiByteLength +2;
+		return this;
+	}
+	
+	/**
+	 * Generates debug output (pretty print)
+	 * @return {String} String which gives some information about the mpi
+	 */
+	function toString() {
+		var r = "    MPI("+this.mpiBitLength+"b/"+this.mpiByteLength+"B) : 0x";
+		r+=util.hexstrdump(this.MPI);
+		return r+'\n';
+	}
+	
+	/**
+	 * Converts the mpi to an BigInteger object
+	 * @return {BigInteger}
+	 */
+	function getBigInteger() {
+		return new BigInteger(util.hexstrdump(this.MPI),16); 
+	}
+
+	
+	function getBits(num) {
+		for (var i = 0; i < 9; i++)
+		if (num >> i == 0)
+		return i;
+	}
+	
+	/**
+	 * Gets the length of the mpi in bytes
+	 * @return {Integer} Mpi byte length
+	 */
+	function getByteLength() {
+		return this.mpiByteLength;
+	}
+	
+	/**
+	 * Creates an mpi from the specified string
+	 * @param {String} data Data to read the mpi from
+	 * @return {openpgp_type_mpi} 
+	 */
+	function create(data) {
+		this.MPI = data;
+		this.mpiBitLength = (data.length -1) *8 + getBits(data.charCodeAt(0));
+		this.mpiByteLength = data.length;
+		return this;
+	}
+	
+	/**
+	 * Converts the mpi object to a string as specified in RFC4880 3.2
+	 * @return {String} mpi Byte representation
+	 */
+	function toBin() {
+		var result = String.fromCharCode((this.mpiBitLength >> 8) & 0xFF);
+		result += String.fromCharCode(this.mpiBitLength & 0xFF);
+		result += this.MPI;
+		return result;
+	}
+	
+	this.read = read;
+	this.toBigInteger = getBigInteger;
+	this.toString = toString;
+	this.create = create;
+	this.toBin = toBin;
+	this.getByteLength = getByteLength;
+}
+
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/openpgp.type.s2k.js.html b/doc/openpgp.type.s2k.js.html new file mode 100644 index 00000000..ab0d4894 --- /dev/null +++ b/doc/openpgp.type.s2k.js.html @@ -0,0 +1,189 @@ + + + + + JSDoc: Source: type/openpgp.type.s2k.js + + + + + + + + + + +
+ +

Source: type/openpgp.type.s2k.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
+
+/**
+ * @class
+ * @classdesc 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.
+ */
+function openpgp_type_s2k() {
+	/**
+	 * Parsing function for a string-to-key specifier (RFC 4880 3.7).
+	 * @param {String} input Payload of string-to-key specifier
+	 * @param {Integer} position Position to start reading from the input string
+	 * @return {openpgp_type_s2k} Object representation
+	 */
+	function read(input, position) {
+		var mypos = position;
+		this.type = input[mypos++].charCodeAt();
+		switch (this.type) {
+		case 0: // Simple S2K
+			// Octet 1: hash algorithm
+			this.hashAlgorithm = input[mypos++].charCodeAt();
+			this.s2kLength = 1;
+			break;
+
+		case 1: // Salted S2K
+			// Octet 1: hash algorithm
+			this.hashAlgorithm = input[mypos++].charCodeAt();
+
+			// Octets 2-9: 8-octet salt value
+			this.saltValue = input.substring(mypos, mypos+8);
+			mypos += 8;
+			this.s2kLength = 9;
+			break;
+
+		case 3: // Iterated and Salted S2K
+			// Octet 1: hash algorithm
+			this.hashAlgorithm = input[mypos++].charCodeAt();
+
+			// Octets 2-9: 8-octet salt value
+			this.saltValue = input.substring(mypos, mypos+8);
+			mypos += 8;
+
+			// Octet 10: count, a one-octet, coded value
+			this.EXPBIAS = 6;
+			var c = input[mypos++].charCodeAt();
+			this.count = (16 + (c & 15)) << ((c >> 4) + this.EXPBIAS);
+			this.s2kLength = 10;
+			break;
+
+		case 101:
+			if(input.substring(mypos+1, mypos+4) == "GNU") {
+				this.hashAlgorithm = input[mypos++].charCodeAt();
+				mypos += 3; // GNU
+				var gnuExtType = 1000 + input[mypos++].charCodeAt();
+				if(gnuExtType == 1001) {
+					this.type = gnuExtType;
+					this.s2kLength = 5;
+					// GnuPG extension mode 1001 -- don't write secret key at all
+				} else {
+					util.print_error("unknown s2k gnu protection mode! "+this.type);
+				}
+			} else {
+				util.print_error("unknown s2k type! "+this.type);
+			}
+			break;
+
+		case 2: // Reserved value
+		default:
+			util.print_error("unknown s2k type! "+this.type);
+			break;
+		}
+		return this;
+	}
+	
+	
+	/**
+	 * writes an s2k hash based on the inputs.
+	 * @return {String} Produced key of hashAlgorithm hash length
+	 */
+	function write(type, hash, passphrase, salt, c){
+	    this.type = type;
+	    if(this.type == 3){this.saltValue = salt;
+	        this.hashAlgorithm = hash;
+	        this.count = (16 + (c & 15)) << ((c >> 4) + 6);
+	        this.s2kLength = 10;
+	    }
+	    return this.produce_key(passphrase);
+	}
+
+	/**
+	 * Produces a key using the specified passphrase and the defined 
+	 * hashAlgorithm 
+	 * @param {String} passphrase Passphrase containing user input
+	 * @return {String} Produced key with a length corresponding to 
+	 * hashAlgorithm hash length
+	 */
+	function produce_key(passphrase, numBytes) {
+		if (this.type == 0) {
+			return openpgp_crypto_hashData(this.hashAlgorithm,passphrase);
+		} else if (this.type == 1) {
+			return openpgp_crypto_hashData(this.hashAlgorithm,this.saltValue+passphrase);
+		} else if (this.type == 3) {
+			var isp = [];
+			isp[0] = this.saltValue+passphrase;
+			while (isp.length*(this.saltValue+passphrase).length < this.count)
+				isp.push(this.saltValue+passphrase);
+			isp = isp.join('');			
+			if (isp.length > this.count)
+				isp = isp.substr(0, this.count);
+			if(numBytes && (numBytes == 24 || numBytes == 32)){ //This if accounts for RFC 4880 3.7.1.1 -- If hash size is greater than block size, use leftmost bits.  If blocksize larger than hash size, we need to rehash isp and prepend with 0.
+			    var key = openpgp_crypto_hashData(this.hashAlgorithm,isp);
+			    return key + openpgp_crypto_hashData(this.hashAlgorithm,String.fromCharCode(0)+isp);
+			}
+			return openpgp_crypto_hashData(this.hashAlgorithm,isp);
+		} else return null;
+	}
+	
+	this.read = read;
+	this.write = write;
+	this.produce_key = produce_key;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/rsa.js.html b/doc/rsa.js.html new file mode 100644 index 00000000..5c07d159 --- /dev/null +++ b/doc/rsa.js.html @@ -0,0 +1,184 @@ + + + + + JSDoc: Source: ciphers/asymmetric/rsa.js + + + + + + + + + + +
+ +

Source: ciphers/asymmetric/rsa.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
+//
+// RSA implementation
+
+function SecureRandom(){
+    function nextBytes(byteArray){
+        for(var n = 0; n < byteArray.length;n++){
+            byteArray[n] = openpgp_crypto_getSecureRandomOctet();
+        }
+    }
+    this.nextBytes = nextBytes;
+}
+
+function RSA() {
+	/**
+	 * This function uses jsbn Big Num library to decrypt RSA
+	 * @param m
+	 *            message
+	 * @param d
+	 *            RSA d as BigInteger
+	 * @param p
+	 *            RSA p as BigInteger
+	 * @param q
+	 *            RSA q as BigInteger
+	 * @param u
+	 *            RSA u as BigInteger
+	 * @return {BigInteger} The decrypted value of the message
+	 */
+	function decrypt(m, d, p, q, u) {
+		var xp = m.mod(p).modPow(d.mod(p.subtract(BigInteger.ONE)), p);
+		var xq = m.mod(q).modPow(d.mod(q.subtract(BigInteger.ONE)), q);
+		util.print_debug("rsa.js decrypt\nxpn:"+util.hexstrdump(xp.toMPI())+"\nxqn:"+util.hexstrdump(xq.toMPI()));
+
+		var t = xq.subtract(xp);
+		if (t[0] == 0) {
+			t = xp.subtract(xq);
+			t = t.multiply(u).mod(q);
+			t = q.subtract(t);
+		} else {
+			t = t.multiply(u).mod(q);
+		}
+		return t.multiply(p).add(xp);
+	}
+	
+	/**
+	 * encrypt message
+	 * @param m message as BigInteger
+	 * @param e public MPI part as BigInteger
+	 * @param n public MPI part as BigInteger
+	 * @return BigInteger
+	 */
+	function encrypt(m,e,n) {
+		return m.modPowInt(e, n);
+	}
+	
+	/* Sign and Verify */
+	function sign(m,d,n) {
+		return m.modPow(d, n);
+	}
+		
+	function verify(x,e,n) {
+		return x.modPowInt(e, n);
+	}
+	
+	// "empty" RSA key constructor
+    function keyObject() {
+        this.n = null;
+        this.e = 0;
+        this.ee = null;
+        this.d = null;
+        this.p = null;
+        this.q = null;
+        this.dmp1 = null;
+        this.dmq1 = null;
+        this.u = null;
+    }
+	
+	// Generate a new random private key B bits long, using public expt E
+    function generate(B,E) {
+        var key = new keyObject();
+        var rng = new SecureRandom();
+        var qs = B>>1;
+        key.e = parseInt(E,16);
+        key.ee = new BigInteger(E,16);
+        for(;;) {
+            for(;;) {
+                key.p = new BigInteger(B-qs,1,rng);
+                if(key.p.subtract(BigInteger.ONE).gcd(key.ee).compareTo(BigInteger.ONE) == 0 && key.p.isProbablePrime(10)) break;
+            }
+            for(;;) {
+                key.q = new BigInteger(qs,1,rng);
+                if(key.q.subtract(BigInteger.ONE).gcd(key.ee).compareTo(BigInteger.ONE) == 0 && key.q.isProbablePrime(10)) break;
+            }
+            if(key.p.compareTo(key.q) <= 0) {
+                var t = key.p;
+                key.p = key.q;
+                key.q = t;
+            }
+            var p1 = key.p.subtract(BigInteger.ONE);
+            var q1 = key.q.subtract(BigInteger.ONE);
+            var phi = p1.multiply(q1);
+            if(phi.gcd(key.ee).compareTo(BigInteger.ONE) == 0) {
+                key.n = key.p.multiply(key.q);
+                key.d = key.ee.modInverse(phi);
+                key.dmp1 = key.d.mod(p1);
+                key.dmq1 = key.d.mod(q1);
+                key.u = key.p.modInverse(key.q);
+                break;
+            }
+        }
+        return key;
+    }
+		
+	this.encrypt = encrypt;
+	this.decrypt = decrypt;
+	this.verify = verify;
+	this.sign = sign;
+	this.generate = generate;
+	this.keyObject = keyObject;
+}
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + + diff --git a/doc/util.js.html b/doc/util.js.html new file mode 100644 index 00000000..cb8575a1 --- /dev/null +++ b/doc/util.js.html @@ -0,0 +1,336 @@ + + + + + JSDoc: Source: util/util.js + + + + + + + + + + +
+ +

Source: util/util.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
+
+var Util = function() {
+
+    this.emailRegEx = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
+	
+	this.hexdump = function(str) {
+	    var r=[];
+	    var e=str.length;
+	    var c=0;
+	    var h;
+	    var i = 0;
+	    while(c<e){
+	        h=str.charCodeAt(c++).toString(16);
+	        while(h.length<2) h="0"+h;
+	        r.push(" "+h);
+	        i++;
+	        if (i % 32 == 0)
+	        	r.push("\n           ");
+	    }
+	    return r.join('');
+	};
+	
+	/**
+	 * Create hexstring from a binary
+	 * @param {String} str String to convert
+	 * @return {String} String containing the hexadecimal values
+	 */
+	this.hexstrdump = function(str) {
+		if (str == null)
+			return "";
+	    var r=[];
+	    var e=str.length;
+	    var c=0;
+	    var h;
+	    while(c<e){
+	        h=str[c++].charCodeAt().toString(16);
+	        while(h.length<2) h="0"+h;
+	        r.push(""+h);
+	    }
+	    return r.join('');
+	};
+	
+	/**
+	 * Create binary string from a hex encoded string
+	 * @param {String} str Hex string to convert
+	 * @return {String} String containing the binary values
+	 */
+	this.hex2bin = function(hex) {
+	    var str = '';
+	    for (var i = 0; i < hex.length; i += 2)
+	        str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
+	    return str;
+	};
+	
+	/**
+	 * Creating a hex string from an binary array of integers (0..255)
+	 * @param {String} str Array of bytes to convert
+	 * @return {String} Hexadecimal representation of the array
+	 */
+	this.hexidump = function(str) {
+	    var r=[];
+	    var e=str.length;
+	    var c=0;
+	    var h;
+	    while(c<e){
+	        h=str[c++].toString(16);
+	        while(h.length<2) h="0"+h;
+	        r.push(""+h);
+	    }
+	    return r.join('');
+	};
+	
+	/**
+	 * Convert a string to an array of integers(0.255)
+	 * @param {String} str String to convert
+	 * @return {Integer[]} An array of (binary) integers
+	 */
+	this.str2bin = function(str) {
+		var result = new Array();
+		for (var i = 0; i < str.length; i++) {
+			result[i] = str.charCodeAt(i);
+		}
+		
+		return result;
+	};
+
+	/**
+	 * Convert an array of integers(0.255) to a string 
+	 * @param {Integer[]} bin An array of (binary) integers to convert
+	 * @return {String} The string representation of the array
+	 */
+	this.bin2str = function(bin) {
+		var result = [];
+		for (var i = 0; i < bin.length; i++) {
+			result.push(String.fromCharCode(bin[i]));
+		}
+		return result.join('');
+	};
+	
+	/**
+	 * Convert a string to a Uint8Array
+	 * @param {String} str String to convert
+	 * @return {Uint8Array} The array of (binary) integers
+	 */
+	this.str2Uint8Array = function(str){
+        var uintArray = new Uint8Array(new ArrayBuffer(str.length));
+        for(var n = 0; n < str.length; n++){
+            uintArray[n] = str.charCodeAt(n);
+        }
+        return uintArray;
+	};
+	
+	/**
+	 * Convert a Uint8Array to a string. This currently functions 
+	 * the same as bin2str. 
+	 * @param {Uint8Array} bin An array of (binary) integers to convert
+	 * @return {String} String representation of the array
+	 */
+	this.Uint8Array2str = function(bin) {
+        var result = [];
+        for(n = 0; n< bin.length; n++){
+            result[n] = String.fromCharCode(bin[n]);
+        }
+        return result.join('');
+	};
+	
+	/**
+	 * Calculates a 16bit sum of a string by adding each character 
+	 * codes modulus 65535
+	 * @param {String} text String to create a sum of
+	 * @return {Integer} An integer containing the sum of all character 
+	 * codes % 65535
+	 */
+	this.calc_checksum = function(text) {
+		var checksum = {  s: 0, add: function (sadd) { this.s = (this.s + sadd) % 65536; }};
+		for (var i = 0; i < text.length; i++) {
+			checksum.add(text.charCodeAt(i));
+		}
+		return checksum.s;
+	};
+	
+	/**
+	 * 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 '<br/>'
+	 * @param {String} str String of the debug message
+	 * @return {String} An HTML tt entity containing a paragraph with a 
+	 * style attribute where the debug message is HTMLencoded in. 
+	 */
+	this.print_debug = function(str) {
+		if (openpgp.config.debug) {
+			str = openpgp_encoding_html_encode(str);
+			showMessages("<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str.replace(/\n/g,"<br>")+"</p></tt>");
+		}
+	};
+	
+	/**
+	 * 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 '<br/>'
+	 * Different than print_debug because will call hexstrdump iff necessary.
+	 * @param {String} str String of the debug message
+	 * @return {String} An HTML tt entity containing a paragraph with a 
+	 * style attribute where the debug message is HTMLencoded in. 
+	 */
+	this.print_debug_hexstr_dump = function(str,strToHex) {
+		if (openpgp.config.debug) {
+			str = str + this.hexstrdump(strToHex);
+			str = openpgp_encoding_html_encode(str);
+			showMessages("<tt><p style=\"background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\">"+str.replace(/\n/g,"<br>")+"</p></tt>");
+		}
+	};
+	
+	/**
+	 * 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 '<br/>'
+	 * @param {String} str String of the error message
+	 * @return {String} A HTML paragraph entity with a style attribute 
+	 * containing the HTML encoded error message
+	 */
+	this.print_error = function(str) {
+		str = openpgp_encoding_html_encode(str);
+		showMessages("<p style=\"font-size: 80%; background-color: #FF8888; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>ERROR:</b></span>	"+str.replace(/\n/g,"<br>")+"</p>");
+	};
+	
+	/**
+	 * 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 '<br/>'.
+	 * @param {String} str String of the info message
+	 * @return {String} A HTML paragraph entity with a style attribute 
+	 * containing the HTML encoded info message
+	 */
+	this.print_info = function(str) {
+		str = openpgp_encoding_html_encode(str);
+		showMessages("<p style=\"font-size: 80%; background-color: #88FF88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>INFO:</b></span>	"+str.replace(/\n/g,"<br>")+"</p>");
+	};
+	
+	this.print_warning = function(str) {
+		str = openpgp_encoding_html_encode(str);
+		showMessages("<p style=\"font-size: 80%; background-color: #FFAA88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;\"><span style=\"color: #888;\"><b>WARNING:</b></span>	"+str.replace(/\n/g,"<br>")+"</p>");
+	};
+	
+	this.getLeftNBits = function (string, bitcount) {
+		var rest = bitcount % 8;
+		if (rest == 0)
+			return string.substring(0, bitcount / 8);
+		var bytes = (bitcount - rest) / 8 +1;
+		var result = string.substring(0, bytes);
+		return this.shiftRight(result, 8-rest); // +String.fromCharCode(string.charCodeAt(bytes -1) << (8-rest) & 0xFF);
+	};
+
+	/**
+	 * Shifting a string to n bits right
+	 * @param {String} value The string to shift
+	 * @param {Integer} bitcount Amount of bits to shift (MUST be smaller 
+	 * than 9)
+	 * @return {String} Resulting string. 
+	 */
+	this.shiftRight = function(value, bitcount) {
+		var temp = util.str2bin(value);
+        if (bitcount % 8 != 0) {
+        	for (var i = temp.length-1; i >= 0; i--) {
+        		temp[i] >>= bitcount % 8;
+        		if (i > 0)
+        			temp[i] |= (temp[i - 1] << (8 - (bitcount % 8))) & 0xFF;
+        	}
+        } else {
+        	return value;
+        }
+        return util.bin2str(temp);
+	};
+	
+	/**
+	 * Return the algorithm type as string
+	 * @return {String} String representing the message type
+	 */
+	this.get_hashAlgorithmString = function(algo) {
+		switch(algo) {
+		case 1:
+			return "MD5";
+		case 2:
+			return "SHA1";
+		case 3:
+			return "RIPEMD160";
+		case 8:
+			return "SHA256";
+		case 9:
+			return "SHA384";
+		case 10:
+			return "SHA512";
+		case 11:
+			return "SHA224";
+		}
+		return "unknown";
+	};
+};
+
+/**
+ * an instance that should be used. 
+ */
+var util = new Util();
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.2.0-dev on Fri Apr 12 2013 14:20:33 GMT+0200 (CEST) +
+ + + +