Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
2e423d9
initial commit for GitHub
bitwiseshiftleft May 26, 2010
282c33c
initial import didn't include codeview template; adding it
bitwiseshiftleft May 26, 2010
d5d7164
fix 32-bit error in sjcl.js default. still present in makefile.
bitwiseshiftleft May 26, 2010
eb77f08
fix 32-bit bug in source, with a hack. oh well
bitwiseshiftleft May 26, 2010
11066d6
ocb2_vectors typo for old IE
Jun 9, 2010
6efa968
browserUtil.js now works in IE6
Jun 9, 2010
c3435d1
workaround for bug in Opera 10.60 a1. should get rolled back if that…
Jun 11, 2010
017ff8c
ECC initial import.
Aug 18, 2010
624b611
ecdsa works! now time for some tests...
Oct 8, 2010
2bb04bb
shamir's trick
Oct 8, 2010
4f316af
ecdh, ecdsa tests
Oct 8, 2010
f7559d7
pass lint; work around chromium jit bug
Oct 8, 2010
4ecf95a
cbc mode. beware!
Oct 16, 2010
ac441e8
fix an issue reported by ctemplin that prevents event handlers from b…
Nov 7, 2010
84fe489
fix an issue reported by ctemplin that prevents event handlers from b…
Nov 7, 2010
4e37892
fix an issue reported by ctemplin that prevents event handlers from b…
Nov 7, 2010
b87f993
fix json encoding issue
Nov 27, 2010
f281196
removed errant debugging variable
Dec 9, 2010
54f531d
elliptic curve diffie hellman
Dec 9, 2010
080df57
add SHA-1 implementation
sqs Apr 19, 2011
24d390c
add missing notready exception
sqs Apr 19, 2011
b395616
update minified sjcl.js after adding notready exception
sqs Apr 19, 2011
7a75736
add keyexchange namespace
sqs Apr 19, 2011
8b379cc
update minified sjcl.js after adding sha1
sqs Apr 19, 2011
b3e81f4
Merge branch 'sha1' into srp
sqs Apr 19, 2011
909a503
SRP tests
sqs Apr 19, 2011
71c84f1
Merge branch 'ecc' of github.com:sqs/sjcl into srp
sqs Apr 19, 2011
8fe21ec
ws
sqs Apr 19, 2011
89905ac
add srp X
sqs Apr 19, 2011
2bbda85
add bn powermod and mulmod
sqs Apr 19, 2011
44ddce8
test srp x and v
sqs Apr 19, 2011
b55ed28
srp implementation
sqs Apr 19, 2011
d5c014a
update minified after srp changes
sqs Apr 19, 2011
393b4d1
notready
Apr 19, 2011
754e975
notready -> notReady
Apr 19, 2011
e6cc1dd
add srp, sha1, and bn tests to browser test list
sqs Apr 19, 2011
de23a40
bn_mod and bn_mulmod tests
sqs Apr 19, 2011
945d6c4
smaller bn test vectors
sqs Apr 19, 2011
57da299
SRP group as object
sqs Apr 19, 2011
c085b77
docs for makeX
sqs Apr 19, 2011
cf4ffd7
docs for makeVerifier
sqs Apr 19, 2011
5acaf98
sample vals from RFC 5054
sqs Apr 19, 2011
d6ea18a
merge changes made while preparing to push ecc
sqs Apr 21, 2011
c63917c
remove ecc
sqs Apr 21, 2011
90a62ba
add srp.js file header
sqs Apr 21, 2011
3346363
wrap params
sqs Apr 21, 2011
56154f3
remove duplicated comment
sqs Apr 21, 2011
0fbd276
re-./configure after srp changes
sqs Apr 21, 2011
86fe235
undo ecc
sqs Apr 21, 2011
0e7ab6a
add back sjcl.bitArray.extract - needed for bn
sqs Apr 21, 2011
57d5169
re-make sjcl.js after undoing ecc
sqs Apr 21, 2011
746dcb8
merge resolved?
Apr 28, 2011
28b0b38
resolve merge in sjcl.js
Apr 28, 2011
117fce4
restore ecc, cbc
May 23, 2011
6ee517c
Fix OCB2 test dependecy checking
vibornoff Jun 14, 2011
291414a
vibornoff: fix stopCollectors
Jun 14, 2011
71ef53f
Merge pull request #27 from vibornoff/ocb2-test-fix
bitwiseshiftleft Jun 14, 2011
8aee1ef
remake
Jun 14, 2011
9d07c28
fix ts -> tag
Jun 25, 2011
8d3a6e7
fix ts -> tag
Jun 25, 2011
c1fcb9a
randomness in Chrome
bitwiseshiftleft Jul 10, 2011
b25a0d6
remove extra variable i
bitwiseshiftleft Jul 10, 2011
cddf9c8
base64url
bitwiseshiftleft Aug 14, 2011
9d01837
base64url
bitwiseshiftleft Aug 14, 2011
3fddb9e
Merge pull request #38 from regality/master
bitwiseshiftleft Nov 6, 2011
caaf800
export sjcl for commonjs compliant environments
Nov 21, 2011
502d313
Added double quotes around keys in JSON encoded strings to conform wi…
Nov 24, 2011
61228e7
Merge pull request #40 from RobertLarsen/master
bitwiseshiftleft Nov 25, 2011
8aa3859
Merge pull request #39 from azer/master
bitwiseshiftleft Nov 25, 2011
5780c6c
remake
bitwiseshiftleft Nov 25, 2011
4cc368f
re-fix JSON encoding issue again!... and remake
bitwiseshiftleft Dec 3, 2011
4abe395
turning off random iv works
bitwiseshiftleft Jan 25, 2012
f922fc3
fix demo when json is disabled
bitwiseshiftleft Jan 25, 2012
f811403
fix typo
Feb 8, 2012
6f02fe7
fix type annotation
Feb 8, 2012
205d7de
Merge pull request #47 from mrdomino/master
bitwiseshiftleft Feb 11, 2012
c0d8675
fix adata security bug
bitwiseshiftleft Feb 28, 2012
4255527
don't subtract defaults
bitwiseshiftleft Feb 29, 2012
e1e0b7a
fix opacify.pl not to change 1.0 -> 1["0"]
bitwiseshiftleft Apr 22, 2012
181e2c7
fix opacify.pl not to change 1.0 -> 1["0"]
bitwiseshiftleft Apr 22, 2012
0057045
Add syntax highlighting
legionus Apr 29, 2012
ba90d0c
Refactoring of code base - modularized code, introduced configuration…
simonrupf Apr 29, 2012
23487ce
Fixed bug with missing directory separator and added .htaccess files …
simonrupf Apr 30, 2012
5d6401b
Merge branch 'master' of https://github.com/legion-github/ZeroBin
simonrupf Apr 30, 2012
edf95ff
added autoloading, configurable paste size limit, changed JS to calcu…
simonrupf Apr 30, 2012
778eb91
Add UglifyJS
legionus May 11, 2012
a791c8c
Add install script
legionus May 11, 2012
7cee995
Merge pull request #1 from legion-github/elrido-uglifyjs
elrido May 19, 2012
421e6cb
implemented zerobin_db model, added more options for paste expiration…
simonrupf May 19, 2012
a7f8302
jsdoc: fix param names in misc.cachedPbkdf2
Jun 19, 2012
ec303b2
Merge pull request #58 from fmarier/cachedpbkdf2_docs
bitwiseshiftleft Jun 19, 2012
8bf8bbb
sjcl.random.addEntropy():
Jul 24, 2012
0278f2f
sjcl.random.addEntropy():
Jul 24, 2012
45d99e5
Merge pull request #60 from Sc00bz/master
bitwiseshiftleft Jul 25, 2012
7c42661
remake
bitwiseshiftleft Jul 25, 2012
da0c687
fix exception when mouse crosses 0
bitwiseshiftleft Jul 26, 2012
f1e5769
removed submodule uglifyjs - i don't think it improves performance th…
simonrupf Aug 10, 2012
f37303d
For server-load and privacy reasons, disallow robots.
Aug 2, 2012
9075388
removed leftovers from submodule uglifyjs, added credits file,
simonrupf Aug 25, 2012
2d4f155
had to revert to HTML5 instead of XHTML5 because of compatibility
simonrupf Aug 28, 2012
2470871
add robots meta tag, in case we are not installed in the root
simonrupf Sep 8, 2012
6f47588
cleanup repository before import
simonrupf Sep 8, 2012
8b21a4a
Merge branch 'master' of /home/elrido/Projekte/SJCL
simonrupf Sep 8, 2012
2b69a86
moved updated sjcl into place
simonrupf Sep 8, 2012
0079c73
added test for entropy of cypher text
simonrupf Sep 8, 2012
51008d3
added test for entropy of cypher text - closes #3
simonrupf Sep 8, 2012
8582dd0
Merge branch 'master' of git@github.com:elrido/ZeroBin.git
simonrupf Sep 8, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implemented zerobin_db model, added more options for paste expiration…
…, made comments and max data size configurable
  • Loading branch information
simonrupf committed May 19, 2012
commit 421e6cba97d079e0206042dbf8daef1fcbfc4b63
96 changes: 96 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Documentation
=============

For Administrators
------------------

In the index.php in the main folder you can define a different PATH. This is
useful if you want to secure your installation and want to move the
configuration, data files, templates and PHP libraries (directories cfg, lib
and tpl) outside of your document root. This new location must still be
accessible to your webserver / PHP process.

> ### PATH Example ###
> Your zerobin installation lives in a subfolder called "paste" inside of your
> document root. The URL looks like this:
> http://example.com/paste/
> The ZeroBin folder on your webserver is really:
> /home/example.com/htdocs/paste
>
> When setting the path like this:
> define('PATH', '../../secret/zerobin/');
> ZeroBin will look for your includes here:
> /home/example.com/secret/zerobin

In the file "cfg/conf.ini" you can configure ZeroBin. The config file is
divided into multiple sections, which are enclosed in square brackets. In the
"[main]" section you can enable or disable the discussion feature, set the
limit of stored pastes and comments in bytes. The "[traffic]" section lets you
set a time limit in seconds. Users may not post more often the this limit to
your ZeroBin.

Finally the "[model]" and "[model_options]" sections let you configure your
favourite way of storing the pastes and discussions on your server.
"zerobin_data" is the default model, which stores everything in files in the
data folder. This is the recommended setup for low traffic sites. Under high
load, in distributed setups or if you are not allowed to store files locally,
you might want to switch to the "zerobin_db" model. This lets you store your
data in a database. Basically all databases, that are supported by PDO (PHP
data objects) may be used. Automatic table creation is provided for pdo_ibm,
pdo_informix, pdo_mssql, pdo_mysql, pdo_oci, pdo_pgsql and pdo_sqlite. You may
want to provide a table prefix, if you have to share the zerobin database with
another application. The table prefix option is called "tbl".

> ### Note ###
> The "zerobin_db" model has only been tested with sqlite and MySQL, although
> it would not be recommended to use sqlite in a production environment. If you
> gain any experience running ZeroBin on other RDBMS, let us know.

For reference or if you want to create the table schema for yourself:

CREATE TABLE prefix_paste (
dataid CHAR(16),
data TEXT,
postdate INT,
expiredate INT,
opendiscussion INT,
burnafterreading INT
);

CREATE TABLE prefix_comment (
dataid CHAR(16),
pasteid CHAR(16),
parentid CHAR(16),
data TEXT,
nickname VARCHAR(255),
vizhash TEXT,
postdate INT
);

For Developers
--------------
If you want to create your own data models, you might want to know how the arrays, that you have to store, look like:

public function create($pasteid, $paste)
{
$pasteid = substr(hash('md5', $paste['data']), 0, 16);

$paste['data'] // text
$paste['meta']['postdate'] // int UNIX timestamp
$paste['meta']['expire_date'] // int UNIX timestamp
$paste['meta']['opendiscussion'] // true (if false it is unset)
$paste['meta']['burnafterreading'] // true (if false it is unset; if true, then opendiscussion is unset)
}

public function createComment($pasteid, $parentid, $commentid, $comment)
{
$pasteid // the id of the paste this comment belongs to
$parentid // the id of the parent of this comment, may be the paste id itself
$commentid = substr(hash('md5', $paste['data']), 0, 16);

$paste['data'] // text
$paste['meta']['nickname'] // text or null (if anonymous)
$paste['meta']['vizhash'] // text or null (if anonymous)
$paste['meta']['postdate'] // int UNIX timestamp
}

45 changes: 29 additions & 16 deletions cfg/conf.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,41 @@
; @license http://www.opensource.org/licenses/zlib-license.php The zlib/libpng License
; @version 0.15

; time limit between calls from the same IP address in seconds
traffic_limit = 10
traffic_dir = PATH "data"
[main]
; enable or disable discussions
opendiscussion = true

; size limit per paste or comment in bytes
size_limit = 2000000
sizelimit = 2097152

[traffic]
; time limit between calls from the same IP address in seconds
limit = 10
dir = PATH "data"

[model]
; name of data model class to load and directory for storage
; the default model "zerobin_data" stores everything in the filesystem
model = zerobin_data
model_options["dir"] = PATH "data"
class = zerobin_data
[model_options]
dir = PATH "data"

;[model]
; example of DB configuration for MySQL
;model = zerobin_db
;model_options["dsn"] = "mysql:host=localhost;dbname=zerobin"
;model_options["usr"] = "zerobin"
;model_options["pwd"] = "Z3r0P4ss"
;model_options["opt"][PDO::ATTR_PERSISTENT] = true
;class = zerobin_db
;[model_options]
;dsn = "mysql:host=localhost;dbname=zerobin;charset=UTF8"
;tbl = "zerobin_" ; table prefix
;usr = "zerobin"
;pwd = "Z3r0P4ss"
;opt[12] = true ; PDO::ATTR_PERSISTENT

;[model]
; example of DB configuration for SQLite
;model = zerobin_db
;model_options["dsn"] = "sqlite:" PATH "data"/db.sq3"
;model_options["usr"] = null
;model_options["pwd"] = null
;model_options["opt"] = null
;[model_options]
;class = zerobin_db
;dsn = "sqlite:" PATH "data/db.sq3"
;usr = null
;pwd = null
;opt[12] = true ; PDO::ATTR_PERSISTENT

50 changes: 36 additions & 14 deletions lib/zerobin.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ private function _init()
);
}

$this->_conf = parse_ini_file(PATH . 'cfg/conf.ini');
$this->_model = $this->_conf['model'];
$this->_conf = parse_ini_file(PATH . 'cfg/conf.ini', true);
$this->_model = $this->_conf['model']['class'];
}

/**
Expand All @@ -117,7 +117,10 @@ private function _model()
{
// if needed, initialize the model
if(is_string($this->_model)) {
$this->_model = forward_static_call(array($this->_model, 'getInstance'), $this->_conf['model_options']);
$this->_model = forward_static_call(
array($this->_model, 'getInstance'),
$this->_conf['model_options']
);
}
return $this->_model;
}
Expand All @@ -129,7 +132,7 @@ private function _model()
* data (mandatory) = json encoded SJCL encrypted text (containing keys: iv,salt,ct)
*
* All optional data will go to meta information:
* expire (optional) = expiration delay (never,10min,1hour,1day,1month,1year,burn) (default:never)
* expire (optional) = expiration delay (never,5min,10min,1hour,1day,1week,1month,1year,burn) (default:never)
* opendiscusssion (optional) = is the discussion allowed on this paste ? (0/1) (default:0)
* nickname (optional) = in discussion, encoded SJCL encrypted text nickname of author of comment (containing keys: iv,salt,ct)
* parentid (optional) = in discussion, which comment this comment replies to.
Expand All @@ -143,18 +146,30 @@ private function _create()
header('Content-type: application/json');
$error = false;

// Make sure last paste from the IP address was more than 10 seconds ago.
trafficlimiter::setLimit($this->_conf['traffic_limit']);
trafficlimiter::setPath($this->_conf['traffic_dir']);
// Make sure last paste from the IP address was more than X seconds ago.
trafficlimiter::setLimit($this->_conf['traffic']['limit']);
trafficlimiter::setPath($this->_conf['traffic']['dir']);
if (
!trafficlimiter::canPass($_SERVER['REMOTE_ADDR'])
) $this->_return_message(1, 'Please wait 10 seconds between each post.');
) $this->_return_message(
1,
'Please wait ' .
$this->_conf['traffic']['limit'] .
' seconds between each post.'
);

// Make sure content is not too big.
$data = $_POST['data'];
if (
strlen($data) > 2000000
) $this->_return_message(1, 'Paste is limited to 2 MB of encrypted data.');
strlen($data) > $this->_conf['main']['sizelimit']
) $this->_return_message(
1,
'Paste is limited to ' .
$this->_conf['main']['sizelimit'] .
' ' .
filter::size_humanreadable($this->_conf['main']['sizelimit']) .
' of encrypted data.'
);

// Make sure format is correct.
if (!sjcl::isValid($data)) $this->_return_message(1, 'Invalid data.');
Expand All @@ -167,6 +182,12 @@ private function _create()
{
switch ($_POST['expire'])
{
case 'burn':
$meta['burnafterreading'] = true;
break;
case '5min':
$meta['expire_date'] = time()+5*60;
break;
case '10min':
$meta['expire_date'] = time()+10*60;
break;
Expand All @@ -176,19 +197,19 @@ private function _create()
case '1day':
$meta['expire_date'] = time()+24*60*60;
break;
case '1week':
$meta['expire_date'] = time()+7*24*60*60;
break;
case '1month':
$meta['expire_date'] = strtotime('+1 month');
break;
case '1year':
$meta['expire_date'] = strtotime('+1 year');
break;
case 'burn':
$meta['burnafterreading'] = true;
}
}

// Read open discussion flag.
if (!empty($_POST['opendiscussion']))
if ($this->_conf['main']['opendiscussion'] && !empty($_POST['opendiscussion']))
{
$opendiscussion = $_POST['opendiscussion'];
if ($opendiscussion != 0)
Expand Down Expand Up @@ -381,6 +402,7 @@ private function _view()
// We escape it here because ENT_NOQUOTES can't be used in RainTPL templates.
$page->assign('CIPHERDATA', htmlspecialchars($this->_data, ENT_NOQUOTES));
$page->assign('ERRORMESSAGE', $this->_error);
$page->assign('OPENDISCUSSION', $this->_conf['main']['opendiscussion']);
$page->assign('VERSION', self::VERSION);
$page->draw('page');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/zerobin/abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private function __clone() {}
*
* @access public
* @static
* @return zerobin
* @return zerobin_abstract
*/
abstract public static function getInstance($options);

Expand Down
4 changes: 2 additions & 2 deletions lib/zerobin/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class zerobin_data extends zerobin_abstract
*
* @access public
* @static
* @return zerobin
* @return zerobin_data
*/
public static function getInstance($options)
public static function getInstance($options = null)
{
// if given update the data directory
if (
Expand Down
Loading