Skip to content

Commit

Permalink
added debug info to rsasign-1.2.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lieser committed May 31, 2013
1 parent e374f0d commit 5127c97
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.3.3pre [2013-05-30]
---------------------
- added debug info to rsasign-1.2.js

0.3.2 [2013-05-30]
------------------
- fixed regex pattern for SDID, Selector and local_part
Expand Down
11 changes: 8 additions & 3 deletions chrome/content/dkim.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Verifies the DKIM-Signatures as specified in RFC 6376
* http://tools.ietf.org/html/rfc6376
*
* version: 0.3.2 (30 May 2013)
* version: 0.3.3pre (30 May 2013)
*
* Copyright (c) 2013 Philippe Lieser
*
Expand Down Expand Up @@ -912,7 +912,7 @@ DKIM_Verifier.DKIMVerifier = (function() {
var isValid = rsa.verifyString(headerHashInput, DKIM_Verifier.b64tohex(msg.DKIMSignature.b));

if (!isValid) {
throw new DKIM_SigError(DKIM_STRINGS.DKIM_SIGERROR_CORRUPT_B);
throw new DKIM_SigError(DKIM_STRINGS.DKIM_SIGERROR_BADSIG);
}

// show result
Expand Down Expand Up @@ -1113,7 +1113,12 @@ var that = {
Components.utils.reportError(e+"\n"+e.stack);
}
}
}
},

/*
* make function dkimDebugMsg(message) public
*/
dkimDebugMsg : dkimDebugMsg
};
return that;
}()); // the parens here cause the anonymous function to execute and return
Expand Down
24 changes: 22 additions & 2 deletions chrome/content/rsasign-1.2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Original version 1.2.1 (08 May 2013)
* Modified by Philippe Lieser for "DKIM Verifier" version 0.3.3
*
* Modifications:
* - added debug info to _rsasign_verifyString
*/

/*! rsasign-1.2.js (c) 2012 Kenji Urushima | kjur.github.com/jsrsasign/license
*/
//
Expand Down Expand Up @@ -267,14 +275,26 @@ function _rsasign_verifyHexSignatureForMessage(hSig, sMsg) {
*/
function _rsasign_verifyString(sMsg, hSig) {
hSig = hSig.replace(_RE_HEXDECONLY, '');
if (hSig.length != this.n.bitLength() / 4) return 0;
// if (hSig.length != this.n.bitLength() / 4) return 0;
if (hSig.length != this.n.bitLength() / 4) {
DKIMVerifier.dkimDebugMsg("rsasign: hSig has wrong length");
return 0;
// throw new Error("rsasign Error: hSig has wrong length");
}
hSig = hSig.replace(/[ \n]+/g, "");
var biSig = parseBigInt(hSig, 16);
var biDecryptedSig = this.doPublic(biSig);
var hDigestInfo = biDecryptedSig.toString(16).replace(/^1f+00/, '');
var digestInfoAry = _rsasign_getAlgNameAndHashFromHexDisgestInfo(hDigestInfo);

if (digestInfoAry.length == 0) return false;
// if (digestInfoAry.length == 0) return false;
if (digestInfoAry.length == 0) {
DKIMVerifier.dkimDebugMsg("rsasign: biDecryptedSig (hex): " + biDecryptedSig.toString(16));
DKIMVerifier.dkimDebugMsg("rsasign: n (hex): " + this.n.toString(16));
DKIMVerifier.dkimDebugMsg("rsasign: e: " + this.e);
DKIMVerifier.dkimDebugMsg("rsasign: digestInfoAry.length == 0");
return false;
}
var algName = digestInfoAry[0];
var diHashValue = digestInfoAry[1];
var ff = _RSASIGN_HASHHEXFUNC[algName];
Expand Down
3 changes: 2 additions & 1 deletion chrome/locale/en-US/dkim.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ DKIM_STRINGS.DKIM_SIGERROR_MISSING_V = "DKIM version missing";
DKIM_STRINGS.DKIM_SIGERROR_MISSING_A = "Missing signature algorithm";
DKIM_STRINGS.DKIM_SIGERROR_UNKNOWN_A = "Unsupported Signature algorithm";
DKIM_STRINGS.DKIM_SIGERROR_MISSING_B = "Missing signature";
DKIM_STRINGS.DKIM_SIGERROR_CORRUPT_B = "Signature wrong";
// DKIM_STRINGS.DKIM_SIGERROR_CORRUPT_B = "Signature wrong";
DKIM_STRINGS.DKIM_SIGERROR_BADSIG = "Signature wrong";
DKIM_STRINGS.DKIM_SIGERROR_MISSING_BH = "Missing body hash";
DKIM_STRINGS.DKIM_SIGERROR_CORRUPT_BH = "Wrong body hash";
DKIM_STRINGS.DKIM_SIGERROR_UNKNOWN_C_H = "Unsupported canonicalization algorithm for header";
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<em:name>DKIM Verifier</em:name>
<em:description>Verifies the DKIM-Signature of an e-mail.</em:description>

<em:version>0.3.2</em:version>
<em:version>0.3.3pre</em:version>

<em:creator>Philippe Lieser</em:creator>

Expand Down

0 comments on commit 5127c97

Please sign in to comment.