Crypto.sym

This commit is contained in:
Michal Kolodziej 2013-04-12 13:04:00 +02:00
parent 8545feb03d
commit 6242e72a1d
3 changed files with 88 additions and 2155 deletions

File diff suppressed because it is too large Load Diff

View File

@ -48,13 +48,13 @@
</div> </div>
<nav> <nav>
<h2><a href="index.html">Index</a></h2><h3>Global</h3><ul><li><a href="global.html#openpgp_crypto_asymetricDecrypt">openpgp_crypto_asymetricDecrypt</a></li><li><a href="global.html#openpgp_crypto_asymetricEncrypt">openpgp_crypto_asymetricEncrypt</a></li><li><a href="global.html#openpgp_crypto_generateKeyPair">openpgp_crypto_generateKeyPair</a></li><li><a href="global.html#openpgp_crypto_generateSessionKey">openpgp_crypto_generateSessionKey</a></li><li><a href="global.html#openpgp_crypto_getHashByteLength">openpgp_crypto_getHashByteLength</a></li><li><a href="global.html#openpgp_crypto_getPrefixRandom">openpgp_crypto_getPrefixRandom</a></li><li><a href="global.html#openpgp_crypto_getPseudoRandom">openpgp_crypto_getPseudoRandom</a></li><li><a href="global.html#openpgp_crypto_getRandomBigInteger">openpgp_crypto_getRandomBigInteger</a></li><li><a href="global.html#openpgp_crypto_getRandomBytes">openpgp_crypto_getRandomBytes</a></li><li><a href="global.html#openpgp_crypto_getSecureRandom">openpgp_crypto_getSecureRandom</a></li><li><a href="global.html#openpgp_crypto_hashData">openpgp_crypto_hashData</a></li><li><a href="global.html#openpgp_crypto_MDCSystemBytes">openpgp_crypto_MDCSystemBytes</a></li><li><a href="global.html#openpgp_crypto_signData">openpgp_crypto_signData</a></li><li><a href="global.html#openpgp_crypto_verifySignature">openpgp_crypto_verifySignature</a></li></ul> <h2><a href="index.html">Index</a></h2><h3>Global</h3><ul><li><a href="global.html#openpgp_crypto_symmetricDecrypt">openpgp_crypto_symmetricDecrypt</a></li><li><a href="global.html#openpgp_crypto_symmetricEncrypt">openpgp_crypto_symmetricEncrypt</a></li></ul>
</nav> </nav>
<br clear="both"> <br clear="both">
<footer> <footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Fri Apr 12 2013 12:58:17 GMT+0200 (CEST) Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a> on Fri Apr 12 2013 13:03:34 GMT+0200 (CEST)
</footer> </footer>
<script> prettyPrint(); </script> <script> prettyPrint(); </script>

View File

@ -21,14 +21,14 @@
* Symmetrically encrypts data using prefixedrandom, a key with length * Symmetrically encrypts data using prefixedrandom, a key with length
* depending on the algorithm in openpgp_cfb mode with or without resync * depending on the algorithm in openpgp_cfb mode with or without resync
* (MDC style) * (MDC style)
* @param prefixrandom secure random bytes as string in length equal to the * @param {String} prefixrandom Secure random bytes as string in
* block size of the algorithm used (use openpgp_crypto_getPrefixRandom(algo) * length equal to the block size of the algorithm used (use
* to retrieve that string * openpgp_crypto_getPrefixRandom(algo) to retrieve that string
* @param algo [Integer] algorithm to use (see RFC4880 9.2) * @param {Integer} algo Algorithm to use (see RFC4880 9.2)
* @param key [String] key as string. length is depending on the algorithm used * @param {String} key Key as string. length is depending on the algorithm used
* @param data [String] data to encrypt * @param {String} data Data to encrypt
* @param openpgp_cfb [boolean] * @param {Boolean} openpgp_cfb
* @return [String] encrypted data * @return {String} Encrypted data
*/ */
function openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_cfb) { function openpgp_crypto_symmetricEncrypt(prefixrandom, algo, key, data, openpgp_cfb) {
switch(algo) { 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 * Symmetrically decrypts data using a key with length depending on the
* algorithm in openpgp_cfb mode with or without resync (MDC style) * algorithm in openpgp_cfb mode with or without resync (MDC style)
* @param algo [Integer] algorithm to use (see RFC4880 9.2) * @param {Integer} algo Algorithm to use (see RFC4880 9.2)
* @param key [String] key as string. length is depending on the algorithm used * @param {String} key Key as string. length is depending on the algorithm used
* @param data [String] data to be decrypted * @param {String} data Data to be decrypted
* @param openpgp_cfb [boolean] if true use the resync (for encrypteddata); * @param {Boolean} openpgp_cfb If true use the resync (for encrypteddata);
* otherwise use without the resync (for MDC encrypted data) * 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) { function openpgp_crypto_symmetricDecrypt(algo, key, data, openpgp_cfb) {
util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+algo+"\nencrypteddata:",data); util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+algo+"\nencrypteddata:",data);