Skip to content

Commit

Permalink
Merge branch 'cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
dchest committed Dec 22, 2014
2 parents 6964ee2 + 1cd3cf3 commit 416b1de
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions nacl-fast.js
Original file line number Diff line number Diff line change
Expand Up @@ -2155,6 +2155,10 @@ function checkArrayTypes() {
}
}

function cleanup(arr) {
for (var i = 0; i < arr.length; i++) arr[i] = 0;
}

nacl.util = {};

nacl.util.decodeUTF8 = function(s) {
Expand Down Expand Up @@ -2397,6 +2401,7 @@ nacl.setPRNG = function(fn) {
var i, v = new Uint8Array(n);
crypto.getRandomValues(v);
for (i = 0; i < n; i++) x[i] = v[i];
cleanup(v);
});
}
} else if (typeof require !== 'undefined') {
Expand All @@ -2406,6 +2411,7 @@ nacl.setPRNG = function(fn) {
nacl.setPRNG(function(x, n) {
var i, v = crypto.randomBytes(n);
for (i = 0; i < n; i++) x[i] = v[i];
cleanup(v);
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions nacl-fast.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions nacl.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,10 @@ function checkArrayTypes() {
}
}

function cleanup(arr) {
for (var i = 0; i < arr.length; i++) arr[i] = 0;
}

nacl.util = {};

nacl.util.decodeUTF8 = function(s) {
Expand Down Expand Up @@ -1184,6 +1188,7 @@ nacl.setPRNG = function(fn) {
var i, v = new Uint8Array(n);
crypto.getRandomValues(v);
for (i = 0; i < n; i++) x[i] = v[i];
cleanup(v);
});
}
} else if (typeof require !== 'undefined') {
Expand All @@ -1193,6 +1198,7 @@ nacl.setPRNG = function(fn) {
nacl.setPRNG(function(x, n) {
var i, v = crypto.randomBytes(n);
for (i = 0; i < n; i++) x[i] = v[i];
cleanup(v);
});
}
}
Expand Down
Loading

0 comments on commit 416b1de

Please sign in to comment.