Skip to content

Commit

Permalink
undo ecc
Browse files Browse the repository at this point in the history
  • Loading branch information
sqs committed Apr 21, 2011
1 parent 40c8b0d commit 8615cb3
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 647 deletions.
5 changes: 2 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;

my ($arg, $i, $j, $targ);

my @targets = qw/sjcl aes bitArray codecString codecHex codecBase64 codecBytes bn sha256 sha1 ccm cbc ocb2 hmac pbkdf2 srp random convenience/;
my @targets = qw/sjcl aes bitArray codecString codecHex codecBase64 codecBytes bn sha256 sha1 ccm ocb2 hmac pbkdf2 srp random convenience/;
my %deps = ('aes'=>'sjcl',
'bitArray'=>'sjcl',
'codecString'=>'bitArray',
Expand All @@ -13,7 +13,6 @@ my %deps = ('aes'=>'sjcl',
'codecBytes'=>'bitArray',
'sha256'=>'codecString',
'sha1'=>'codecString',
'cbc'=>'bitArray,aes',
'ccm'=>'bitArray,aes',
'ocb2'=>'bitArray,aes',
'hmac'=>'sha256',
Expand All @@ -28,7 +27,7 @@ my $compress = "closure";
my %enabled = ();
$enabled{$_} = 0 foreach (@targets);

# by default, all but codecBytes, srp, bn, cbc
# by default, all but codecBytes, srp, bn
$enabled{$_} = 1 foreach (qw/aes bitArray codecString codecHex codecBase64 sha256 ccm ocb2 hmac pbkdf2 random convenience/);

# argument parsing
Expand Down
23 changes: 1 addition & 22 deletions core/bitArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
sjcl.bitArray = {
/**
* Array slices in units of bits.
* @param {bitArray} a The array to slice.
* @param {bitArray a} The array to slice.
* @param {Number} bstart The offset to the start of the slice, in bits.
* @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
* slice until the end of the array.
Expand All @@ -42,27 +42,6 @@ sjcl.bitArray = {
return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
},

/**
* Extract a number packed into a bit array.
* @param {bitArray} a The array to slice.
* @param {Number} bstart The offset to the start of the slice, in bits.
* @param {Number} length The length of the number to extract.
* @return {Number} The requested slice.
*/
extract: function(a, bstart, blength) {
// FIXME: this Math.floor is not necessary at all, but for some reason
// seems to suppress a bug in the Chromium JIT.
var x, sh = Math.floor((-bstart-blength) & 31);
if ((bstart + blength - 1 ^ bstart) & -32) {
// it crosses a boundary
x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh);
} else {
// within a single word
x = a[bstart/32|0] >>> sh;
}
return x & ((1<<blength) - 1);
},

/**
* Concatenate two bit arrays.
* @param {bitArray} a1 The first array.
Expand Down
115 changes: 0 additions & 115 deletions core/cbc.js

This file was deleted.

15 changes: 7 additions & 8 deletions core/convenience.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
/* do the encryption */
p.ct = sjcl.mode[p.mode].encrypt(prp, plaintext, p.iv, p.adata, p.tag);

//return j.encode(j._subtract(p, j.defaults));
return j.encode(p);
return j.encode(j._subtract(p, j.defaults));
},

/** Simple decryption function.
Expand Down Expand Up @@ -123,7 +122,7 @@
if (!i.match(/^[a-z0-9]+$/i)) {
throw new sjcl.exception.invalid("json encode: invalid property name");
}
out += comma + '"' + i + '":';
out += comma + i + ':';
comma = ',';

switch (typeof obj[i]) {
Expand Down Expand Up @@ -161,13 +160,13 @@
}
var a = str.replace(/^\{|\}$/g, '').split(/,/), out={}, i, m;
for (i=0; i<a.length; i++) {
if (!(m=a[i].match(/^(?:(["']?)([a-z][a-z0-9]*)\1):(?:(\d+)|"([a-z0-9+\/%*_.@=\-]*)")$/i))) {
if (!(m=a[i].match(/^([a-z][a-z0-9]*):(?:(\d+)|"([a-z0-9+\/%*_.@=\-]*)")$/i))) {
throw new sjcl.exception.invalid("json decode: this isn't json!");
}
if (m[3]) {
out[m[2]] = parseInt(m[3],10);
if (m[2]) {
out[m[1]] = parseInt(m[2],10);
} else {
out[m[2]] = m[2].match(/^(ct|salt|iv)$/) ? sjcl.codec.base64.toBits(m[4]) : unescape(m[4]);
out[m[1]] = m[1].match(/^(ct|salt|iv)$/) ? sjcl.codec.base64.toBits(m[3]) : unescape(m[3]);
}
}
return out;
Expand Down Expand Up @@ -197,6 +196,7 @@

/** Remove all elements of minus from plus. Does not modify plus.
* @private
*/
_subtract: function (plus, minus) {
var out = {}, i;

Expand All @@ -208,7 +208,6 @@

return out;
},
*/

/** Return only the specified elements of src.
* @private
Expand Down
5 changes: 2 additions & 3 deletions core/ocb2.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ sjcl.mode.ocb2 = {
/* Encrypt a non-final block */
bi = plaintext.slice(i,i+4);
checksum = xor(checksum, bi);
bi = xor(delta,prp.encrypt(xor(delta, bi)));
output.splice(i,0,bi[0],bi[1],bi[2],bi[3]);
output = output.concat(xor(delta,prp.encrypt(xor(delta, bi))));
delta = times2(delta);
}

Expand Down Expand Up @@ -106,7 +105,7 @@ sjcl.mode.ocb2 = {
/* Decrypt a non-final block */
bi = xor(delta, prp.decrypt(xor(delta, ciphertext.slice(i,i+4))));
checksum = xor(checksum, bi);
output.splice(i,0,bi[0],bi[1],bi[2],bi[3]);
output = output.concat(bi);
delta = times2(delta);
}

Expand Down
2 changes: 1 addition & 1 deletion core/sjcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var sjcl = {
this.toString = function() { return "BUG: "+this.message; };
this.message = message;
},

/** @class Something isn't ready. */
notReady: function(message) {
this.toString = function() { return "NOT READY: "+this.message; };
Expand Down
33 changes: 0 additions & 33 deletions test/cbc_test.js

This file was deleted.

Loading

4 comments on commit 8615cb3

@zooko
Copy link

@zooko zooko commented on 8615cb3 May 20, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit is described as "undo ecc" but it seems to be eliminating cbc, removing two ecc tests, and making a few changes that I don't understand to ocb2.js and convenience.js. Mis-merge?

@sqs
Copy link
Contributor Author

@sqs sqs commented on 8615cb3 May 20, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very clear, I admit. I was backing out changes introduced in the "ecc" branch. So, the "ecc" refers to the branch, not to ECC code.

@zooko
Copy link

@zooko zooko commented on 8615cb3 May 20, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, so the cbc code was added in the ecc branch, and you intended to back out just the cbc part?

Or did you intend to back out the whole branch? (Ref the other commits: 4fec0a0 0594279 4e28720 8615cb3 )

@sqs
Copy link
Contributor Author

@sqs sqs commented on 8615cb3 May 21, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The former--I was just backing out the cbc part.

Please sign in to comment.