diff --git a/ciform/src/main/js/ciform.js b/ciform/src/main/js/ciform.js index 948d17e..32fd956 100644 --- a/ciform/src/main/js/ciform.js +++ b/ciform/src/main/js/ciform.js @@ -5,7 +5,7 @@ // Copyright © 2008 Nicolas BONARDELLE // -(function( $defined ) { +(function( $defined, Crypto, console ) { /** @@ -201,7 +201,7 @@ Ciform.Field = function( target, options ) // 2. applies the encrypted value to the output field this['output'].value = this._ciphertext; - } + }; }; Ciform.Field.prototype = new Object(); @@ -284,7 +284,7 @@ Ciform.ciphers.SHA1Encoder.prototype = new Ciform.ciphers.Encoder(); Ciform.ciphers.SHA1Encoder.prototype.encode = function( message ) { console.debug(this,"encode(",message,")"); - return (this['preamble'] ? "sha1:b64:" : "") + b64_sha1(message); + return (this['preamble'] ? "sha1:b64:" : "") + Crypto.SHA1.b64_sha1(message); }; @@ -404,7 +404,7 @@ Ciform.ciphers.RSAEncoder.prototype._getMPI = function() // this function can be called several times so we don't compute the following each time if ( ! this.pubKey['mpi'] ) { - this.pubKey['mpi'] = s2r(b2mpi(this.pubKey['pq'])+b2mpi([this.pubKey['e']])).replace(/\n/,''); + this.pubKey['mpi'] = Crypto.Base64.s2r(Crypto.RSA.b2mpi(this.pubKey['pq'])+Crypto.RSA.b2mpi([this.pubKey['e']])).replace(/\n/,''); } return this.pubKey['mpi']; @@ -436,7 +436,7 @@ Ciform.ciphers.RSAEncoder.prototype._getSalt = function() */ Ciform.ciphers.RSAEncoder.prototype.maxLength = function() { - var s = r2s(this._getMPI()); + var s = Crypto.Base64.r2s(this._getMPI()); var l = Math.floor((s.charCodeAt(0)*256 + s.charCodeAt(1)+7)/8); var lmax = l - 4; @@ -490,12 +490,12 @@ Ciform.ciphers.RSAEncoder.prototype.encode = function( message ) throw new RangeError("Plain text length must be less than "+maxLength+" characters"); } - var b = s2b(p); + var b = Crypto.Hex.s2b(p); // rsa-encrypts the result and converts into mpi - var ciphertext = RSAencrypt(b,exp,mod); + var ciphertext = Crypto.RSA.encrypt(b,exp,mod); - return (this.preamble ? "rsa:0x" : "") + s2hex(b2s(ciphertext)); + return (this.preamble ? "rsa:0x" : "") + Crypto.Hex.s2hex(Crypto.Hex.b2s(ciphertext)); }; @@ -1220,4 +1220,4 @@ Ciform.Cipher.prototype.encryptURL = function( url, options ) // } // } -})($defined); \ No newline at end of file +})($defined,Crypto,console); \ No newline at end of file diff --git a/crypto/rsa/src/main/js/rsa.js b/crypto/rsa/src/main/js/rsa.js index 8d01004..c2b7a2d 100644 --- a/crypto/rsa/src/main/js/rsa.js +++ b/crypto/rsa/src/main/js/rsa.js @@ -411,8 +411,9 @@ function b2mpi(b) // return { - encrypt: RSAencrypt, - decrypt: RSAdecrypt + b2mpi: b2mpi, + encrypt: RSAencrypt, + decrypt: RSAdecrypt }; })(/*window, undefined, $*/); \ No newline at end of file diff --git a/crypto/sha1/src/main/js/sha1.js b/crypto/sha1/src/main/js/sha1.js index 5315e13..3b47057 100644 --- a/crypto/sha1/src/main/js/sha1.js +++ b/crypto/sha1/src/main/js/sha1.js @@ -222,10 +222,12 @@ function binb2b64(binarray) // return { - str2binb: str2binb, - binb2str: binb2str, - binb2hex: binb2hex, - binb2b64: binb2b64 + hex_sha:hex_sha1, + b64_sha1:b64_sha1, + str_sha1:str_sha1, + hex_hmac_sha1:hex_hmac_sha1, + b64_hmac_sha1:b64_hmac_sha1, + str_hmac_sha1:str_hmac_sha1 }; })(/*window, undefined, $*/); \ No newline at end of file