diff --git a/.gitignore b/.gitignore index 29a8aeb20..ca18306c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *.o *.a +.deps +.dirstamp stratum/stratum stratum/blocknotify blocknotify/blocknotify @@ -18,3 +20,6 @@ web/serverconfig.php web/assets/ *.rej *.orig +.idea/* +web/yaamp/.idea/ +*.0 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..f9546188c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: cpp +script: + - (cd blocknotify && make) + - (cd stratum/iniparser && make) + - (cd stratum && make) diff --git a/README.md b/README.md index 00b2a4a69..f710ee0d2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ +[![Build Status](https://travis-ci.org/tpruvot/yiimp.svg?branch=next)](https://travis-ci.org/tpruvot/yiimp) + #yiimp - yaamp fork +WARNINGS +- Use at your own risks. +- Usage of this software requires abilities with sysadmin, database admin, coin daemons, and sometimes a bit of programming. Running a production pool can literally be more work than a full-time job. + Required: linux, mysql, php, memcached, a webserver (lighttpd or nginx recommended) @@ -65,7 +71,7 @@ Add your exchange API public and secret keys in these two separated files: You can find sample config files in web/serverconfig.sample.php and web/keys.sample.php -This web application includes some command line tools, add bin/ folder to your path and type "yiic" to list them, "yiic checkup" can help to test your initial setup. +This web application includes some command line tools, add bin/ folder to your path and type "yiimp" to list them, "yiimp checkup" can help to test your initial setup. Future scripts and maybe the "cron" jobs will then use this yiic console interface. You need at least three backend shells (in screen) running these scripts: @@ -123,4 +129,9 @@ Credits: Thanks to globalzon to have released the initial Yaamp source code. +-- + +You can support this project donating to tpruvot : + +BTC : 1Auhps1mHZQpoX4mCcVL8odU81VakZQ6dR diff --git a/bin/kill_stratum b/bin/kill_stratum new file mode 100755 index 000000000..4d8d06e22 --- /dev/null +++ b/bin/kill_stratum @@ -0,0 +1,13 @@ +#!/bin/bash + +PLINE=$(ps -ef | grep "stratum config/$1" | grep -v grep) +if [ $? ]; then + PS=$(echo $PLINE | cut -d ' ' -f 2) + if [ $PS ]; then + kill $PS + echo "killed stratum process $PS" + else + echo "Process not found" + exit 1 + fi +fi diff --git a/bin/yiimp b/bin/yiimp index 2fcfd3774..269115bfe 100755 --- a/bin/yiimp +++ b/bin/yiimp @@ -3,6 +3,6 @@ ROOTDIR=/data/yiimp DIR=`pwd` -cd "$ROOTDIR/web" && php yaamp/yiic.php $* +cd "$ROOTDIR/web" && php yaamp/yiic.php "$@" cd $DIR diff --git a/blocknotify-dcr/Makefile b/blocknotify-dcr/Makefile index d24dec588..b1d19fa15 100644 --- a/blocknotify-dcr/Makefile +++ b/blocknotify-dcr/Makefile @@ -1,9 +1,14 @@ OUT_GO=blocknotify-dcr OUTPUT=blocknotify-dcr +ROOT=`pwd` all: rm -f $(OUT_GO) - go build + rm -rf vendor + glide install + ln -s ../vendor vendor/src + rm -f vendor/src/github.com/decred/dcrrpcclient/wallet.go + GOPATH="$(GOPATH):$(ROOT)/vendor" go build install: all strip -s $(OUT_GO) @@ -11,3 +16,7 @@ install: all mv $(OUT_GO) ../bin/$(OUTPUT) sh -c "../bin/$(OUTPUT) &" +clean: + rm -f $(OUT_GO) + rm -rf vendor + diff --git a/blocknotify-dcr/blocknotify.go b/blocknotify-dcr/blocknotify.go index 3b65caa96..7f5b6791d 100644 --- a/blocknotify-dcr/blocknotify.go +++ b/blocknotify-dcr/blocknotify.go @@ -1,10 +1,9 @@ -// Copyright (c) 2016 The btcsuite developers -// Copyright (c) 2015-2016 The Decred developers -// Use of this source code is governed by an ISC -// license that can be found in the LICENSE file. +// Copyright (c) 2015-2017 YiiMP -// Sample blocknofify tool compatible with decred -// will call the standard blocknotify yiimp tool on new block event. +// Sample blocknotify wrapper tool compatible with decred notifications +// will call the standard bin/blocknotify yiimp tool on new block event. + +// Note: this tool is connected directly to dcrd, not to the wallet! package main @@ -13,20 +12,21 @@ import ( "log" "os/exec" "path/filepath" - "time" - "github.com/decred/dcrd/chaincfg/chainhash" + "bytes" // dcrd > 0.6+ + "github.com/decred/dcrd/wire" + "github.com/decred/dcrrpcclient" // "github.com/decred/dcrutil" ) const ( processName = "blocknotify" // set the full path if required - stratumDest = "yaamp.com:5744" // stratum host:port + stratumDest = "yaamp.com:3252" // stratum host:port coinId = "1574" // decred database coin id - walletUser = "yiimprpc" - walletPass = "myDecredPassword" + dcrdUser = "yiimprpc" + dcrdPass = "myDcrdPassword" debug = false ) @@ -37,27 +37,31 @@ func main() { // for notifications. See the documentation of the dcrrpcclient // NotificationHandlers type for more details about each handler. ntfnHandlers := dcrrpcclient.NotificationHandlers{ - OnBlockConnected: func(hash *chainhash.Hash, height int32, time time.Time, vb uint16) { - - // Find the process path. - str := hash.String() - args := []string{ stratumDest, coinId, str } - out, err := exec.Command(processName, args...).Output() - if err != nil { - log.Printf("err %s", err) - } else if debug { - log.Printf("out %s", out) - } - if (debug) { - log.Printf("Block connected: %s %d", hash, height) + OnBlockConnected: func(blockHeader []byte, transactions [][]byte) { + // log.Printf("Block bytes: %v %v", blockHeader, transactions) + var bhead wire.BlockHeader + err := bhead.Deserialize(bytes.NewReader(blockHeader)) + if err == nil { + str := bhead.BlockHash().String(); + args := []string{ stratumDest, coinId, str } + out, err := exec.Command(processName, args...).Output() + if err != nil { + log.Printf("err %s", err) + } else if debug { + log.Printf("out %s", out) + } + if (debug) { + log.Printf("Block connected: %s", str) + } } }, + } // Connect to local dcrd RPC server using websockets. - // dcrwHomeDir := dcrutil.AppDataDir("dcrwallet", false) - // folder := dcrwHomeDir + // dcrdHomeDir := dcrutil.AppDataDir("dcrd", false) + // folder := dcrdHomeDir folder := "" certs, err := ioutil.ReadFile(filepath.Join(folder, "rpc.cert")) if err != nil { @@ -66,11 +70,11 @@ func main() { } connCfg := &dcrrpcclient.ConnConfig{ - Host: "127.0.0.1:15740", + Host: "127.0.0.1:9109", Endpoint: "ws", // websocket - User: walletUser, - Pass: walletPass, + User: dcrdUser, + Pass: dcrdPass, DisableTLS: (certs == nil), Certificates: certs, diff --git a/blocknotify-dcr/glide.lock b/blocknotify-dcr/glide.lock new file mode 100644 index 000000000..995b56c83 --- /dev/null +++ b/blocknotify-dcr/glide.lock @@ -0,0 +1,46 @@ +hash: 4e74a8534cece2f2c1de27bcab0da6efba0e47d533cf8475f588e87851473e81 +updated: 2017-09-12T12:14:36.151798958+02:00 +imports: +- name: github.com/btcsuite/btclog + version: 73889fb79bd687870312b6e40effcecffbd57d30 +- name: github.com/btcsuite/go-socks + version: 4720035b7bfd2a9bb130b1c184f8bbe41b6f0d0f + subpackages: + - socks +- name: github.com/btcsuite/seelog + version: 313961b101eb55f65ae0f03ddd4e322731763b6c +- name: github.com/btcsuite/websocket + version: 31079b6807923eb23992c421b114992b95131b55 +- name: github.com/decred/blake256 + version: a840e32d7c31fe2e0218607334cb120a683951a4 +- name: github.com/decred/dcrd + version: 5bed758f85159b2ee76240207ba775c40000a4c1 + subpackages: + - blockchain/stake + - blockchain/stake/internal/dbnamespace + - blockchain/stake/internal/ticketdb + - blockchain/stake/internal/tickettreap + - chaincfg + - chaincfg/chainec + - chaincfg/chainhash + - database + - dcrec/edwards + - dcrec/secp256k1 + - dcrec/secp256k1/schnorr + - dcrjson + - txscript + - wire +- name: github.com/decred/dcrrpcclient + version: d6edcb0f8f2d01fbf9169f240f73756b41423189 +- name: github.com/decred/dcrutil + version: ebd2e98736e819ac043d54439969b30144b92ced + subpackages: + - base58 +- name: github.com/decred/ed25519 + version: b0909d3f798b97a03c9e77023f97a5301a2a7900 + subpackages: + - edwards25519 +- name: golang.org/x/crypto + version: c7af5bf2638a1164f2eb5467c39c6cffbd13a02e + subpackages: + - ripemd160 diff --git a/blocknotify-dcr/glide.yaml b/blocknotify-dcr/glide.yaml new file mode 100644 index 000000000..36917cb92 --- /dev/null +++ b/blocknotify-dcr/glide.yaml @@ -0,0 +1,9 @@ +package: github.com/tpruvot/yiimp/blocknotify-dcr +import: +- package: github.com/decred/dcrd + subpackages: + - wire +- package: github.com/decred/dcrjson +# - package: github.com/decred/dcrrpcclient +- package: github.com/decred/dcrutil + diff --git a/rc.local b/rc.local index 474b70b73..68f8200db 100644 --- a/rc.local +++ b/rc.local @@ -17,18 +17,26 @@ screen -dmS loop2 $WEB_DIR/loop2.sh screen -dmS blocks $WEB_DIR/blocks.sh screen -dmS debug tail -f $LOG_DIR/debug.log -# Stratum ports +# Stratum instances (skipped/exit if no .conf) screen -dmS c11 $STRATUM_DIR/run.sh c11 +screen -dmS deep $STRATUM_DIR/run.sh deep + screen -dmS x11 $STRATUM_DIR/run.sh x11 screen -dmS x11evo $STRATUM_DIR/run.sh x11evo screen -dmS x13 $STRATUM_DIR/run.sh x13 -screen -dmS x14 $STRATUM_DIR/run.sh x14 -screen -dmS x15 $STRATUM_DIR/run.sh x15 +#screen -dmS x14 $STRATUM_DIR/run.sh x14 +#screen -dmS x15 $STRATUM_DIR/run.sh x15 +#screen -dmS x16r $STRATUM_DIR/run.sh x16r screen -dmS x17 $STRATUM_DIR/run.sh x17 screen -dmS xevan $STRATUM_DIR/run.sh xevan +screen -dmS timetravel $STRATUM_DIR/run.sh timetravel +screen -dmS bitcore $STRATUM_DIR/run.sh bitcore +screen -dmS hmq1725 $STRATUM_DIR/run.sh hmq1725 +screen -dmS tribus $STRATUM_DIR/run.sh tribus screen -dmS sha $STRATUM_DIR/run.sh sha +screen -dmS sha256t $STRATUM_DIR/run.sh sha256t screen -dmS scrypt $STRATUM_DIR/run.sh scrypt screen -dmS scryptn $STRATUM_DIR/run.sh scryptn screen -dmS luffa $STRATUM_DIR/run.sh luffa @@ -37,11 +45,15 @@ screen -dmS nist5 $STRATUM_DIR/run.sh nist5 screen -dmS penta $STRATUM_DIR/run.sh penta screen -dmS quark $STRATUM_DIR/run.sh quark screen -dmS qubit $STRATUM_DIR/run.sh qubit +screen -dmS jha $STRATUM_DIR/run.sh jha #screen -dmS dmd-gr $STRATUM_DIR/run.sh dmd-gr screen -dmS myr-gr $STRATUM_DIR/run.sh myr-gr screen -dmS lbry $STRATUM_DIR/run.sh lbry -screen -dmS lyra2 $STRATUM_DIR/run.sh lyra2 +screen -dmS allium $STRATUM_DIR/run.sh allium +#screen -dmS lyra2 $STRATUM_DIR/run.sh lyra2 screen -dmS lyra2v2 $STRATUM_DIR/run.sh lyra2v2 +screen -dmS lyra2z $STRATUM_DIR/run.sh lyra2z +screen -dmS rainforest $STRATUM_DIR/run.sh rainforest screen -dmS blakecoin $STRATUM_DIR/run.sh blakecoin # blake 8 screen -dmS blake $STRATUM_DIR/run.sh blake @@ -50,15 +62,22 @@ screen -dmS vanilla $STRATUM_DIR/run.sh vanilla # blake 8 screen -dmS decred $STRATUM_DIR/run.sh decred # blake 14 #screen -dmS keccak $STRATUM_DIR/run.sh keccak +#screen -dmS keccakc $STRATUM_DIR/run.sh keccakc +#screen -dmS phi $STRATUM_DIR/run.sh phi +#screen -dmS polytimos $STRATUM_DIR/run.sh polytimos screen -dmS whirlpool $STRATUM_DIR/run.sh whirlpool screen -dmS skein $STRATUM_DIR/run.sh skein screen -dmS skein2 $STRATUM_DIR/run.sh skein2 screen -dmS yescrypt $STRATUM_DIR/run.sh yescrypt +#screen -dmS yescryptR16 $STRATUM_DIR/run.sh yescryptR16 screen -dmS zr5 $STRATUM_DIR/run.sh zr5 screen -dmS sib $STRATUM_DIR/run.sh sib screen -dmS m7m $STRATUM_DIR/run.sh m7m screen -dmS veltor $STRATUM_DIR/run.sh veltor screen -dmS velvet $STRATUM_DIR/run.sh velvet screen -dmS argon2 $STRATUM_DIR/run.sh argon2 +screen -dmS argon2d-dyn $STRATUM_DIR/run.sh argon2d-dyn +screen -dmS x22i $STRATUM_DIR/run.sh x22i +screen -dmS lbk3 $STRATUM_DIR/run.sh lbk3 diff --git a/sql/2016-11-23-coins.sql b/sql/2016-11-23-coins.sql new file mode 100644 index 000000000..ca49abf7f --- /dev/null +++ b/sql/2016-11-23-coins.sql @@ -0,0 +1,13 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +-- don't forget to restart memcached service to refresh the db structure + +ALTER TABLE `coins` ADD `powend_height` INT(11) NULL AFTER `target_height`; +ALTER TABLE `coins` ADD `mature_blocks` INT(11) NULL AFTER `reward_mul`; +ALTER TABLE `coins` ADD `block_time` INT(11) NULL AFTER `payout_max`; +ALTER TABLE `coins` ADD `available` DOUBLE NULL AFTER `balance`; +ALTER TABLE `coins` ADD `cleared` DOUBLE NULL AFTER `balance`; +ALTER TABLE `coins` ADD `immature` DOUBLE NULL AFTER `balance`; +ALTER TABLE `coins` ADD `max_miners` INT(11) NULL AFTER `visible`; +ALTER TABLE `coins` ADD `max_shares` INT(11) NULL AFTER `max_miners`; diff --git a/sql/2017-02-05-benchmarks.sql b/sql/2017-02-05-benchmarks.sql new file mode 100644 index 000000000..4a4e8b0c4 --- /dev/null +++ b/sql/2017-02-05-benchmarks.sql @@ -0,0 +1,10 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +-- don't forget to restart memcached service to refresh the db structure + +ALTER TABLE `benchmarks` ADD `realfreq` INT(8) UNSIGNED NULL AFTER `freq`; +ALTER TABLE `benchmarks` ADD `realmemf` INT(8) UNSIGNED NULL AFTER `memf`; +ALTER TABLE `benchmarks` ADD `plimit` INT(5) UNSIGNED NULL AFTER `power`; +ALTER TABLE `benchmarks` DROP COLUMN `mem`; + diff --git a/sql/2017-03-31-earnings_index.sql b/sql/2017-03-31-earnings_index.sql new file mode 100644 index 000000000..b2a0b4e0b --- /dev/null +++ b/sql/2017-03-31-earnings_index.sql @@ -0,0 +1,5 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +ALTER TABLE `earnings` ADD UNIQUE INDEX `ndx_user_block`(`userid`, `blockid`); + diff --git a/sql/2017-05-accounts_case_swaptime.sql b/sql/2017-05-accounts_case_swaptime.sql new file mode 100644 index 000000000..66002d90b --- /dev/null +++ b/sql/2017-05-accounts_case_swaptime.sql @@ -0,0 +1,9 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +-- Adds binary type to be case sensitive +ALTER TABLE accounts CHANGE `username` `username` varchar(128) binary NOT NULL; + +-- Remember last coin id swap +ALTER TABLE accounts ADD `swap_time` INT(10) UNSIGNED NULL AFTER `coinsymbol`; + diff --git a/sql/2017-06-payouts_coinid_memo.sql b/sql/2017-06-payouts_coinid_memo.sql new file mode 100644 index 000000000..4d00d1632 --- /dev/null +++ b/sql/2017-06-payouts_coinid_memo.sql @@ -0,0 +1,20 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +-- Store coin id used on payment, memoid could be used later for xrp + +ALTER TABLE `payouts` + ADD `idcoin` int(11) NULL AFTER `account_id`, + ADD `memoid` varchar(128) NULL AFTER `tx`; + +ALTER TABLE `payouts` DROP COLUMN `account_ids`; + +ALTER TABLE `payouts` + ADD KEY `payouts_coin` (`idcoin`); + +ALTER TABLE `payouts` ADD CONSTRAINT fk_payouts_coin FOREIGN KEY (`idcoin`) + REFERENCES coins (`id`) ON DELETE CASCADE; + +ALTER TABLE `payouts` ADD CONSTRAINT fk_payouts_account FOREIGN KEY (`account_id`) + REFERENCES accounts (`id`) ON DELETE CASCADE; + diff --git a/sql/2017-09-notifications.sql b/sql/2017-09-notifications.sql new file mode 100644 index 000000000..656713642 --- /dev/null +++ b/sql/2017-09-notifications.sql @@ -0,0 +1,6 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +ALTER TABLE `notifications` CHANGE `lastchecked` `lastchecked` int(10) UNSIGNED NOT NULL DEFAULT '0'; +ALTER TABLE `notifications` CHANGE `lasttriggered` `lasttriggered` int(10) UNSIGNED NOT NULL DEFAULT '0'; + diff --git a/sql/2017-10-bookmarks.sql b/sql/2017-10-bookmarks.sql new file mode 100644 index 000000000..d89ea7fcc --- /dev/null +++ b/sql/2017-10-bookmarks.sql @@ -0,0 +1,8 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +ALTER TABLE `notifications` CHANGE `lastchecked` `lastchecked` int(10) UNSIGNED NULL; +ALTER TABLE `notifications` CHANGE `lasttriggered` `lasttriggered` int(10) UNSIGNED NULL; + +ALTER TABLE `bookmarks` CHANGE `lastused` `lastused` int(10) UNSIGNED NULL; + diff --git a/sql/2017-11-segwit.sql b/sql/2017-11-segwit.sql new file mode 100644 index 000000000..3399cfa9b --- /dev/null +++ b/sql/2017-11-segwit.sql @@ -0,0 +1,7 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +ALTER TABLE `blocks` ADD `segwit` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `txhash`; + +ALTER TABLE `coins` ADD `usesegwit` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `usememorypool`; + diff --git a/sql/2018-01-stratums_ports.sql b/sql/2018-01-stratums_ports.sql new file mode 100644 index 000000000..d46ef7bb2 --- /dev/null +++ b/sql/2018-01-stratums_ports.sql @@ -0,0 +1,17 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +-- filled by the stratum instance, to allow to handle/watch multiple instances + +ALTER TABLE `stratums` ADD `started` int(11) UNSIGNED NULL AFTER `time`; + +ALTER TABLE `stratums` ADD `workers` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `algo`; + +ALTER TABLE `stratums` ADD `port` int(6) UNSIGNED NULL AFTER `workers`; + +ALTER TABLE `stratums` ADD `symbol` varchar(16) NULL AFTER `port`; + +ALTER TABLE `stratums` ADD `url` varchar(128) NULL AFTER `symbol`; + +ALTER TABLE `stratums` ADD `fds` int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `url`; + diff --git a/sql/2018-02-coins_getinfo.sql b/sql/2018-02-coins_getinfo.sql new file mode 100644 index 000000000..b3ea822f9 --- /dev/null +++ b/sql/2018-02-coins_getinfo.sql @@ -0,0 +1,13 @@ +-- Recent additions to add after db init (.gz) +-- mysql yaamp -p < file.sql + +-- filled by the stratum instance, to allow to handle/watch multiple instances + +ALTER TABLE `coins` ADD `hasgetinfo` tinyint(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `account`; + +UPDATE coins SET hassubmitblock=0 WHERE hassubmitblock IS NULL; +UPDATE coins SET hassubmitblock=1 WHERE hassubmitblock > 0; +ALTER TABLE `coins` CHANGE `hassubmitblock` `hassubmitblock` tinyint(1) UNSIGNED NOT NULL DEFAULT '1'; + +ALTER TABLE `coins` ADD `no_explorer` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `visible`; + diff --git a/stratum/Makefile b/stratum/Makefile index 8f12dd38d..3bf978bf3 100755 --- a/stratum/Makefile +++ b/stratum/Makefile @@ -8,12 +8,6 @@ SQLFLAGS= `mysql_config --cflags --libs` # if you use the auto exchange feature... CFLAGS += -DNO_EXCHANGE -#CFLAGS += -DHASH_DEBUGLOG_ -#CFLAGS += -DRPC_DEBUGLOG_ -#CFLAGS += -DREMOTE_DEBUGLOG_ -#CFLAGS += -DSOCKET_DEBUGLOG_ -#CFLAGS += -DCLIENT_DEBUGLOG_ - #CFLAGS=-c -O2 -I /usr/include/mysql LDFLAGS=-O2 `mysql_config --libs` @@ -63,6 +57,7 @@ clean: rm -f algos/*.a rm -f sha3/*.o rm -f sha3/*.a + rm -f algos/ar2/*.o install: clean all strip -s stratum diff --git a/stratum/algos/Lyra2-z.c b/stratum/algos/Lyra2-z.c new file mode 100755 index 000000000..80122aa54 --- /dev/null +++ b/stratum/algos/Lyra2-z.c @@ -0,0 +1,250 @@ +/** + * Implementation of the Lyra2 Password Hashing Scheme (PHS). + * + * Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014. + * + * This software is hereby placed in the public domain. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include "Lyra2.h" +#include "Sponge.h" + +static __thread uint64_t *wholeMatrix = NULL; +static __thread uint64_t **memMatrix = NULL; +static __thread uint64_t curRows = 0; + +/** + * Executes Lyra2 based on the G function from Blake2b. This version supports salts and passwords + * whose combined length is smaller than the size of the memory matrix, (i.e., (nRows x nCols x b) bits, + * where "b" is the underlying sponge's bitrate). In this implementation, the "basil" is composed by all + * integer parameters (treated as type "unsigned int") in the order they are provided, plus the value + * of nCols, (i.e., basil = kLen || pwdlen || saltlen || timeCost || nRows || nCols). + * + * @param K The derived key to be output by the algorithm + * @param kLen Desired key length + * @param pwd User password + * @param pwdlen Password length + * @param salt Salt + * @param saltlen Salt length + * @param timeCost Parameter to determine the processing time (T) + * @param nRows Number or rows of the memory matrix (R) + * @param nCols Number of columns of the memory matrix (C) + * + * @return 0 if the key is generated correctly; -1 if there is an error (usually due to lack of memory for allocation) + */ +int LYRA2z(void *K, uint64_t kLen, const void *pwd, uint64_t pwdlen, const void *salt, uint64_t saltlen, uint64_t timeCost, uint64_t nRows, uint64_t nCols) { + + //============================= Basic variables ============================// + int64_t row = 2; //index of row to be processed + int64_t prev = 1; //index of prev (last row ever computed/modified) + int64_t rowa = 0; //index of row* (a previous row, deterministically picked during Setup and randomly picked while Wandering) + int64_t tau; //Time Loop iterator + int64_t step = 1; //Visitation step (used during Setup and Wandering phases) + int64_t window = 2; //Visitation window (used to define which rows can be revisited during Setup) + int64_t gap = 1; //Modifier to the step, assuming the values 1 or -1 + int64_t i; //auxiliary iteration counter + //==========================================================================/ + + //========== Initializing the Memory Matrix and pointers to it =============// + //Tries to allocate enough space for the whole memory matrix + + + const int64_t ROW_LEN_INT64 = BLOCK_LEN_INT64 * nCols; + const int64_t ROW_LEN_BYTES = ROW_LEN_INT64 * 8; + + + uint64_t *ptrWord = wholeMatrix; + + if (!wholeMatrix || !memMatrix) { + curRows = nRows + 32; + i = (int64_t) ((int64_t) curRows * (int64_t) ROW_LEN_BYTES); + wholeMatrix = (uint64_t*) malloc(i); + if (wholeMatrix == NULL) { + return -1; + } + + //Allocates pointers to each row of the matrix + memMatrix = malloc(sizeof(uint64_t*) * curRows); + if (memMatrix == NULL) { + return -1; + } + + //Places the pointers in the correct positions + ptrWord = wholeMatrix; + for (i = 0; i < curRows; i++) { + memMatrix[i] = ptrWord; + ptrWord += ROW_LEN_INT64; + } + } else { + if (nRows > curRows) { + free(memMatrix); memMatrix = NULL; + free(wholeMatrix); wholeMatrix = NULL; + return -2; + } + memset(wholeMatrix, 0, nRows * ROW_LEN_BYTES); + } +/* + i = (int64_t) ((int64_t) nRows * (int64_t) ROW_LEN_BYTES); + uint64_t *wholeMatrix = malloc(i); + if (wholeMatrix == NULL) { + return -1; + } + memset(wholeMatrix, 0, i); + + //Allocates pointers to each row of the matrix + uint64_t **memMatrix = malloc(nRows * sizeof (uint64_t*)); + if (memMatrix == NULL) { + return -1; + } + //Places the pointers in the correct positions + uint64_t *ptrWord = wholeMatrix; + for (i = 0; i < nRows; i++) { + memMatrix[i] = ptrWord; + ptrWord += ROW_LEN_INT64; + } +*/ + //==========================================================================/ + + //============= Getting the password + salt + basil padded with 10*1 ===============// + //OBS.:The memory matrix will temporarily hold the password: not for saving memory, + //but this ensures that the password copied locally will be overwritten as soon as possible + + //First, we clean enough blocks for the password, salt, basil and padding + uint64_t nBlocksInput = ((saltlen + pwdlen + 6 * sizeof (uint64_t)) / BLOCK_LEN_BLAKE2_SAFE_BYTES) + 1; + byte *ptrByte = (byte*) wholeMatrix; + memset(ptrByte, 0, nBlocksInput * BLOCK_LEN_BLAKE2_SAFE_BYTES); + + //Prepends the password + memcpy(ptrByte, pwd, pwdlen); + ptrByte += pwdlen; + + //Concatenates the salt + memcpy(ptrByte, salt, saltlen); + ptrByte += saltlen; + + //Concatenates the basil: every integer passed as parameter, in the order they are provided by the interface + memcpy(ptrByte, &kLen, sizeof (uint64_t)); + ptrByte += sizeof (uint64_t); + memcpy(ptrByte, &pwdlen, sizeof (uint64_t)); + ptrByte += sizeof (uint64_t); + memcpy(ptrByte, &saltlen, sizeof (uint64_t)); + ptrByte += sizeof (uint64_t); + memcpy(ptrByte, &timeCost, sizeof (uint64_t)); + ptrByte += sizeof (uint64_t); + memcpy(ptrByte, &nRows, sizeof (uint64_t)); + ptrByte += sizeof (uint64_t); + memcpy(ptrByte, &nCols, sizeof (uint64_t)); + ptrByte += sizeof (uint64_t); + + //Now comes the padding + *ptrByte = 0x80; //first byte of padding: right after the password + ptrByte = (byte*) wholeMatrix; //resets the pointer to the start of the memory matrix + ptrByte += nBlocksInput * BLOCK_LEN_BLAKE2_SAFE_BYTES - 1; //sets the pointer to the correct position: end of incomplete block + *ptrByte ^= 0x01; //last byte of padding: at the end of the last incomplete block + //==========================================================================/ + + //======================= Initializing the Sponge State ====================// + //Sponge state: 16 uint64_t, BLOCK_LEN_INT64 words of them for the bitrate (b) and the remainder for the capacity (c) + uint64_t *state = malloc(16 * sizeof (uint64_t)); + if (state == NULL) { + return -1; + } + initState(state); + //==========================================================================/ + + //================================ Setup Phase =============================// + //Absorbing salt, password and basil: this is the only place in which the block length is hard-coded to 512 bits + ptrWord = wholeMatrix; + for (i = 0; i < nBlocksInput; i++) { + absorbBlockBlake2Safe(state, ptrWord); //absorbs each block of pad(pwd || salt || basil) + ptrWord += BLOCK_LEN_BLAKE2_SAFE_INT64; //goes to next block of pad(pwd || salt || basil) + } + + //Initializes M[0] and M[1] + reducedSqueezeRow0(state, memMatrix[0], nCols); //The locally copied password is most likely overwritten here + reducedDuplexRow1(state, memMatrix[0], memMatrix[1], nCols); + + do { + //M[row] = rand; //M[row*] = M[row*] XOR rotW(rand) + reducedDuplexRowSetup(state, memMatrix[prev], memMatrix[rowa], memMatrix[row], nCols); + + + //updates the value of row* (deterministically picked during Setup)) + rowa = (rowa + step) & (window - 1); + //update prev: it now points to the last row ever computed + prev = row; + //updates row: goes to the next row to be computed + row++; + + //Checks if all rows in the window where visited. + if (rowa == 0) { + step = window + gap; //changes the step: approximately doubles its value + window *= 2; //doubles the size of the re-visitation window + gap = -gap; //inverts the modifier to the step + } + + } while (row < nRows); + //==========================================================================/ + + //============================ Wandering Phase =============================// + row = 0; //Resets the visitation to the first row of the memory matrix + for (tau = 1; tau <= timeCost; tau++) { + //Step is approximately half the number of all rows of the memory matrix for an odd tau; otherwise, it is -1 + step = (tau % 2 == 0) ? -1 : nRows / 2 - 1; + do { + //Selects a pseudorandom index row* + //------------------------------------------------------------------------------------------ + //rowa = ((unsigned int)state[0]) & (nRows-1); //(USE THIS IF nRows IS A POWER OF 2) + rowa = ((uint64_t) (state[0])) % nRows; //(USE THIS FOR THE "GENERIC" CASE) + //------------------------------------------------------------------------------------------ + + //Performs a reduced-round duplexing operation over M[row*] XOR M[prev], updating both M[row*] and M[row] + reducedDuplexRow(state, memMatrix[prev], memMatrix[rowa], memMatrix[row], nCols); + + //update prev: it now points to the last row ever computed + prev = row; + + //updates row: goes to the next row to be computed + //------------------------------------------------------------------------------------------ + //row = (row + step) & (nRows-1); //(USE THIS IF nRows IS A POWER OF 2) + row = (row + step) % nRows; //(USE THIS FOR THE "GENERIC" CASE) + //------------------------------------------------------------------------------------------ + + } while (row != 0); + } + //==========================================================================/ + + //============================ Wrap-up Phase ===============================// + //Absorbs the last block of the memory matrix + absorbBlock(state, memMatrix[rowa]); + + //Squeezes the key + squeeze(state, K, kLen); + //==========================================================================/ + + //========================= Freeing the memory =============================// + //free(memMatrix); + //free(wholeMatrix); + + //Wiping out the sponge's internal state before freeing it + memset(state, 0, 16 * sizeof (uint64_t)); + free(state); + //==========================================================================/ + + return 0; +} diff --git a/stratum/algos/Lyra2-z.h b/stratum/algos/Lyra2-z.h new file mode 100755 index 000000000..09b2ed943 --- /dev/null +++ b/stratum/algos/Lyra2-z.h @@ -0,0 +1,51 @@ +/** + * Header file for the Lyra2 Password Hashing Scheme (PHS). + * + * Author: The Lyra PHC team (http://www.lyra-kdf.net/) -- 2014. + * + * This software is hereby placed in the public domain. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef LYRA2z_H_ +#define LYRA2z_H_ + +#include + +typedef unsigned char byte; + +//Block length required so Blake2's Initialization Vector (IV) is not overwritten (THIS SHOULD NOT BE MODIFIED) +#define BLOCK_LEN_BLAKE2_SAFE_INT64 8 //512 bits (=64 bytes, =8 uint64_t) +#define BLOCK_LEN_BLAKE2_SAFE_BYTES (BLOCK_LEN_BLAKE2_SAFE_INT64 * 8) //same as above, in bytes + + +#ifdef BLOCK_LEN_BITS + #define BLOCK_LEN_INT64 (BLOCK_LEN_BITS/64) //Block length: 768 bits (=96 bytes, =12 uint64_t) + #define BLOCK_LEN_BYTES (BLOCK_LEN_BITS/8) //Block length, in bytes +#else //default block lenght: 768 bits + #define BLOCK_LEN_INT64 12 //Block length: 768 bits (=96 bytes, =12 uint64_t) + #define BLOCK_LEN_BYTES (BLOCK_LEN_INT64 * 8) //Block length, in bytes +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + int LYRA2z(void *K, uint64_t kLen, const void *pwd, uint64_t pwdlen, const void *salt, uint64_t saltlen, uint64_t timeCost, uint64_t nRows, uint64_t nCols); + +#ifdef __cplusplus +} + +#endif + +#endif /* LYRA2z_H_ */ diff --git a/stratum/algos/Lyra2.c b/stratum/algos/Lyra2.c index 46ff09b5e..dbcc3fa6b 100644 --- a/stratum/algos/Lyra2.c +++ b/stratum/algos/Lyra2.c @@ -44,7 +44,7 @@ * * @return 0 if the key is generated correctly; -1 if there is an error (usually due to lack of memory for allocation) */ -int LYRA2(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int16_t nRows, const int16_t nCols) +int LYRA2(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int64_t nRows, const int16_t nCols) { //============================= Basic variables ============================// int64_t row = 2; //index of row to be processed @@ -164,10 +164,10 @@ int LYRA2(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *sa //Checks if all rows in the window where visited. if (rowa == 0) { - step = window + gap; //changes the step: approximately doubles its value - window *= 2; //doubles the size of the re-visitation window - gap = -gap; //inverts the modifier to the step - } + step = window + gap; //changes the step: approximately doubles its value + window *= 2; //doubles the size of the re-visitation window + gap = -gap; //inverts the modifier to the step + } } while (row < nRows); //==========================================================================/ diff --git a/stratum/algos/Lyra2.h b/stratum/algos/Lyra2.h index edf917927..e25432a1a 100644 --- a/stratum/algos/Lyra2.h +++ b/stratum/algos/Lyra2.h @@ -37,6 +37,6 @@ typedef unsigned char byte; #define BLOCK_LEN_BYTES (BLOCK_LEN_INT64 * 8) //Block length, in bytes #endif -int LYRA2(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int16_t nRows, const int16_t nCols); +int LYRA2(void *K, int64_t kLen, const void *pwd, int32_t pwdlen, const void *salt, int32_t saltlen, int64_t timeCost, const int64_t nRows, const int16_t nCols); #endif /* LYRA2_H_ */ diff --git a/stratum/algos/SWIFFTX/SWIFFTX.c b/stratum/algos/SWIFFTX/SWIFFTX.c new file mode 100644 index 000000000..7acead122 --- /dev/null +++ b/stratum/algos/SWIFFTX/SWIFFTX.c @@ -0,0 +1,1155 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// +// SWIFFTX ANSI C OPTIMIZED 32BIT IMPLEMENTATION FOR NIST SHA-3 COMPETITION +// +// SWIFFTX.c +// +// October 2008 +// +// This is the source file of the OPTIMIZED 32BIT implementation of SWIFFTX hash function. +// SWIFFTX is a candidate function for SHA-3 NIST competition. +// More details about SWIFFTX can be found in the accompanying submission documents. +// +/////////////////////////////////////////////////////////////////////////////////////////////// +#include "SWIFFTX.h" +// See the remarks concerning compatibility issues inside stdint.h. +#include "stdint.h" +// Remove this while using gcc: +//#include "stdbool.h" +#include + +/////////////////////////////////////////////////////////////////////////////////////////////// +// Constants and static tables portion. +/////////////////////////////////////////////////////////////////////////////////////////////// + +// In SWIFFTX we work over Z_257, so this is the modulus and the arithmetic is performed modulo +// this number. +#define FIELD_SIZE 257 + +// The size of FFT we use: +#define N 64 + +#define LOGN 6 + +#define EIGHTH_N (N / 8) + +// The number of FFTS done on the input. +#define M (SWIFFTX_INPUT_BLOCK_SIZE / 8) // 32 + +// Omega is the 128th root of unity in Z_257. +// We choose w = 42. +#define OMEGA 42 + +// The size of the inner FFT lookup table: +#define W 8 + +// Calculates the sum and the difference of two numbers. +// +// Parameters: +// - A: the first operand. After the operation stores the sum of the two operands. +// - B: the second operand. After the operation stores the difference between the first and the +// second operands. +#define ADD_SUB(A, B) {register int temp = (B); B = ((A) - (B)); A = ((A) + (temp));} + +// Quickly reduces an integer modulo 257. +// +// Parameters: +// - A: the input. +#define Q_REDUCE(A) (((A) & 0xff) - ((A) >> 8)) + +// Since we need to do the setup only once, this is the indicator variable: +static bool wasSetupDone = false; + +// This array stores the powers of omegas that correspond to the indices, which are the input +// values. Known also as the "outer FFT twiddle factors". +swift_int16_t multipliers[N]; + +// This array stores the powers of omegas, multiplied by the corresponding values. +// We store this table to save computation time. +// +// To calculate the intermediate value of the compression function (the first out of two +// stages), we multiply the k-th bit of x_i by w^[(2i + 1) * k]. {x_i} is the input to the +// compression function, i is between 0 and 31, x_i is a 64-bit value. +// One can see the formula for this (intermediate) stage in the SWIFFT FSE 2008 paper -- +// formula (2), section 3, page 6. +swift_int16_t fftTable[256 * EIGHTH_N]; + +// The A's we use in SWIFFTX shall be random elements of Z_257. +// We generated these A's from the decimal expansion of PI as follows: we converted each +// triple of digits into a decimal number d. If d < (257 * 3) we used (d % 257) for the next A +// element, otherwise move to the next triple of digits in the expansion. This guarntees that +// the A's are random, provided that PI digits are. +const swift_int16_t As[3 * M * N] = +{141, 78, 139, 75, 238, 205, 129, 126, 22, 245, 197, 169, 142, 118, 105, 78, + 50, 149, 29, 208, 114, 34, 85, 117, 67, 148, 86, 256, 25, 49, 133, 93, + 95, 36, 68, 231, 211, 102, 151, 128, 224, 117, 193, 27, 102, 187, 7, 105, + 45, 130, 108, 124, 171, 151, 189, 128, 218, 134, 233, 165, 14, 201, 145, 134, + 52, 203, 91, 96, 197, 69, 134, 213, 136, 93, 3, 249, 141, 16, 210, 73, + 6, 92, 58, 74, 174, 6, 254, 91, 201, 107, 110, 76, 103, 11, 73, 16, + 34, 209, 7, 127, 146, 254, 95, 176, 57, 13, 108, 245, 77, 92, 186, 117, + 124, 97, 105, 118, 34, 74, 205, 122, 235, 53, 94, 238, 210, 227, 183, 11, + 129, 159, 105, 183, 142, 129, 86, 21, 137, 138, 224, 223, 190, 188, 179, 188, + 256, 25, 217, 176, 36, 176, 238, 127, 160, 210, 155, 148, 132, 0, 54, 127, + 145, 6, 46, 85, 243, 95, 173, 123, 178, 207, 211, 183, 224, 173, 146, 35, + 71, 114, 50, 22, 175, 1, 28, 19, 112, 129, 21, 34, 161, 159, 115, 52, + 4, 193, 211, 92, 115, 49, 59, 217, 218, 96, 61, 81, 24, 202, 198, 89, + 45, 128, 8, 51, 253, 87, 171, 35, 4, 188, 171, 10, 3, 137, 238, 73, + 19, 208, 124, 163, 103, 177, 155, 147, 46, 84, 253, 233, 171, 241, 211, 217, + 159, 48, 96, 79, 237, 18, 171, 226, 99, 1, 97, 195, 216, 163, 198, 95, + 0, 201, 65, 228, 21, 153, 124, 230, 44, 35, 44, 108, 85, 156, 249, 207, + 26, 222, 131, 1, 60, 242, 197, 150, 181, 19, 116, 213, 75, 98, 124, 240, + 123, 207, 62, 255, 60, 143, 187, 157, 139, 9, 12, 104, 89, 49, 193, 146, + 104, 196, 181, 82, 198, 253, 192, 191, 255, 122, 212, 104, 47, 20, 132, 208, + 46, 170, 2, 69, 234, 36, 56, 163, 28, 152, 104, 238, 162, 56, 24, 58, + 38, 150, 193, 254, 253, 125, 173, 35, 73, 126, 247, 239, 216, 6, 199, 15, + 90, 12, 97, 122, 9, 84, 207, 127, 219, 72, 58, 30, 29, 182, 41, 192, + 235, 248, 237, 74, 72, 176, 210, 252, 45, 64, 165, 87, 202, 241, 236, 223, + 151, 242, 119, 239, 52, 112, 169, 28, 13, 37, 160, 60, 158, 81, 133, 60, + 16, 145, 249, 192, 173, 217, 214, 93, 141, 184, 54, 34, 161, 104, 157, 95, + 38, 133, 218, 227, 211, 181, 9, 66, 137, 143, 77, 33, 248, 159, 4, 55, + 228, 48, 99, 219, 222, 184, 15, 36, 254, 256, 157, 237, 87, 139, 209, 113, + 232, 85, 126, 167, 197, 100, 103, 166, 64, 225, 125, 205, 117, 135, 84, 128, + 231, 112, 90, 241, 28, 22, 210, 147, 186, 49, 230, 21, 108, 39, 194, 47, + 123, 199, 107, 114, 30, 210, 250, 143, 59, 156, 131, 133, 221, 27, 76, 99, + 208, 250, 78, 12, 211, 141, 95, 81, 195, 106, 8, 232, 150, 212, 205, 221, + 11, 225, 87, 219, 126, 136, 137, 180, 198, 48, 68, 203, 239, 252, 194, 235, + 142, 137, 174, 172, 190, 145, 250, 221, 182, 204, 1, 195, 130, 153, 83, 241, + 161, 239, 211, 138, 11, 169, 155, 245, 174, 49, 10, 166, 16, 130, 181, 139, + 222, 222, 112, 99, 124, 94, 51, 243, 133, 194, 244, 136, 35, 248, 201, 177, + 178, 186, 129, 102, 89, 184, 180, 41, 149, 96, 165, 72, 225, 231, 134, 158, + 199, 28, 249, 16, 225, 195, 10, 210, 164, 252, 138, 8, 35, 152, 213, 199, + 82, 116, 97, 230, 63, 199, 241, 35, 79, 120, 54, 174, 67, 112, 1, 76, + 69, 222, 194, 96, 82, 94, 25, 228, 196, 145, 155, 136, 228, 234, 46, 101, + 246, 51, 103, 166, 246, 75, 9, 200, 161, 4, 108, 35, 129, 168, 208, 144, + 50, 14, 13, 220, 41, 132, 122, 127, 194, 9, 232, 234, 107, 28, 187, 8, + 51, 141, 97, 221, 225, 9, 113, 170, 166, 102, 135, 22, 231, 185, 227, 187, + 110, 145, 251, 146, 76, 22, 146, 228, 7, 53, 64, 25, 62, 198, 130, 190, + 221, 232, 169, 64, 188, 199, 237, 249, 173, 218, 196, 191, 48, 224, 5, 113, + 100, 166, 160, 21, 191, 197, 61, 162, 149, 171, 240, 183, 129, 231, 123, 204, + 192, 179, 134, 15, 47, 161, 142, 177, 239, 234, 186, 237, 231, 53, 208, 95, + 146, 36, 225, 231, 89, 142, 93, 248, 137, 124, 83, 39, 69, 77, 89, 208, + 182, 48, 85, 147, 244, 164, 246, 68, 38, 190, 220, 35, 202, 91, 157, 151, + 201, 240, 185, 218, 4, 152, 2, 132, 177, 88, 190, 196, 229, 74, 220, 135, + 137, 196, 11, 47, 5, 251, 106, 144, 163, 60, 222, 127, 52, 57, 202, 102, + 64, 140, 110, 206, 23, 182, 39, 245, 1, 163, 157, 186, 163, 80, 7, 230, + 44, 249, 176, 102, 164, 125, 147, 120, 18, 191, 186, 125, 64, 65, 198, 157, + 164, 213, 95, 61, 13, 181, 208, 91, 242, 197, 158, 34, 98, 169, 91, 14, + 17, 93, 157, 17, 65, 30, 183, 6, 139, 58, 255, 108, 100, 136, 209, 144, + 164, 6, 237, 33, 210, 110, 57, 126, 197, 136, 125, 244, 165, 151, 168, 3, + 143, 251, 247, 155, 136, 130, 88, 14, 74, 121, 250, 133, 21, 226, 185, 232, + 118, 132, 89, 64, 204, 161, 2, 70, 224, 159, 35, 204, 123, 180, 13, 52, + 231, 57, 25, 78, 66, 69, 97, 42, 198, 84, 176, 59, 8, 232, 125, 134, + 193, 2, 232, 109, 216, 69, 90, 142, 32, 38, 249, 37, 75, 180, 184, 188, + 19, 47, 120, 87, 146, 70, 232, 120, 191, 45, 33, 38, 19, 248, 110, 110, + 44, 64, 2, 84, 244, 228, 252, 228, 170, 123, 38, 144, 213, 144, 171, 212, + 243, 87, 189, 46, 128, 110, 84, 77, 65, 183, 61, 184, 101, 44, 168, 68, + 14, 106, 105, 8, 227, 211, 166, 39, 152, 43, 52, 254, 197, 55, 119, 89, + 168, 65, 53, 138, 177, 56, 219, 0, 58, 121, 148, 18, 44, 100, 215, 103, + 145, 229, 117, 196, 91, 89, 113, 143, 172, 239, 249, 184, 154, 39, 112, 65, + 204, 42, 84, 38, 155, 151, 151, 16, 100, 87, 174, 162, 145, 147, 149, 186, + 237, 145, 134, 144, 198, 235, 213, 163, 48, 230, 24, 47, 57, 71, 127, 0, + 150, 219, 12, 81, 197, 150, 131, 13, 169, 63, 175, 184, 48, 235, 65, 243, + 149, 200, 163, 254, 202, 114, 247, 67, 143, 250, 126, 228, 80, 130, 216, 214, + 36, 2, 230, 33, 119, 125, 3, 142, 237, 100, 3, 152, 197, 174, 244, 129, + 232, 30, 206, 199, 39, 210, 220, 43, 237, 221, 201, 54, 179, 42, 28, 133, + 246, 203, 198, 177, 0, 28, 194, 85, 223, 109, 155, 147, 221, 60, 133, 108, + 157, 254, 26, 75, 157, 185, 49, 142, 31, 137, 71, 43, 63, 64, 237, 148, + 237, 172, 159, 160, 155, 254, 234, 224, 140, 193, 114, 140, 62, 109, 136, 39, + 255, 8, 158, 146, 128, 49, 222, 96, 57, 209, 180, 249, 202, 127, 113, 231, + 78, 178, 46, 33, 228, 215, 104, 31, 207, 186, 82, 41, 42, 39, 103, 119, + 123, 133, 243, 254, 238, 156, 90, 186, 37, 212, 33, 107, 252, 51, 177, 36, + 237, 76, 159, 245, 93, 214, 97, 56, 190, 38, 160, 94, 105, 222, 220, 158, + 49, 16, 191, 52, 120, 87, 179, 2, 27, 144, 223, 230, 184, 6, 129, 227, + 69, 47, 215, 181, 162, 139, 72, 200, 45, 163, 159, 62, 2, 221, 124, 40, + 159, 242, 35, 208, 179, 166, 98, 67, 178, 68, 143, 225, 178, 146, 187, 159, + 57, 66, 176, 192, 236, 250, 168, 224, 122, 43, 159, 120, 133, 165, 122, 64, + 87, 74, 161, 241, 9, 87, 90, 24, 255, 113, 203, 220, 57, 139, 197, 159, + 31, 151, 27, 140, 77, 162, 7, 27, 84, 228, 187, 220, 53, 126, 162, 242, + 84, 181, 223, 103, 86, 177, 207, 31, 140, 18, 207, 256, 201, 166, 96, 23, + 233, 103, 197, 84, 161, 75, 59, 149, 138, 154, 119, 92, 16, 53, 116, 97, + 220, 114, 35, 45, 77, 209, 40, 196, 71, 22, 81, 178, 110, 14, 3, 180, + 110, 129, 112, 47, 18, 61, 134, 78, 73, 79, 254, 232, 125, 180, 205, 54, + 220, 119, 63, 89, 181, 52, 77, 109, 151, 77, 80, 207, 144, 25, 20, 6, + 208, 47, 201, 206, 192, 14, 73, 176, 256, 201, 207, 87, 216, 60, 56, 73, + 92, 243, 179, 113, 49, 59, 55, 168, 121, 137, 69, 154, 95, 57, 187, 47, + 129, 4, 15, 92, 6, 116, 69, 196, 48, 134, 84, 81, 111, 56, 38, 176, + 239, 6, 128, 72, 242, 134, 36, 221, 59, 48, 242, 68, 130, 110, 171, 89, + 13, 220, 48, 29, 5, 75, 104, 233, 91, 129, 105, 162, 44, 113, 163, 163, + 85, 147, 190, 111, 197, 80, 213, 153, 81, 68, 203, 33, 161, 165, 10, 61, + 120, 252, 0, 205, 28, 42, 193, 64, 39, 37, 83, 175, 5, 218, 215, 174, + 128, 121, 231, 11, 150, 145, 135, 197, 136, 91, 193, 5, 107, 88, 82, 6, + 4, 188, 256, 70, 40, 2, 167, 57, 169, 203, 115, 254, 215, 172, 84, 80, + 188, 167, 34, 137, 43, 243, 2, 79, 178, 38, 188, 135, 233, 194, 208, 13, + 11, 151, 231, 196, 12, 122, 162, 56, 17, 114, 191, 207, 90, 132, 64, 238, + 187, 6, 198, 176, 240, 88, 118, 236, 15, 226, 166, 22, 193, 229, 82, 246, + 213, 64, 37, 63, 31, 243, 252, 37, 156, 38, 175, 204, 138, 141, 211, 82, + 106, 217, 97, 139, 153, 56, 129, 218, 158, 9, 83, 26, 87, 112, 71, 21, + 250, 5, 65, 141, 68, 116, 231, 113, 10, 218, 99, 205, 201, 92, 157, 4, + 97, 46, 49, 220, 72, 139, 103, 171, 149, 129, 193, 19, 69, 245, 43, 31, + 58, 68, 36, 195, 159, 22, 54, 34, 233, 141, 205, 100, 226, 96, 22, 192, + 41, 231, 24, 79, 234, 138, 30, 120, 117, 216, 172, 197, 172, 107, 86, 29, + 181, 151, 0, 6, 146, 186, 68, 55, 54, 58, 213, 182, 60, 231, 33, 232, + 77, 210, 216, 154, 80, 51, 141, 122, 68, 148, 219, 122, 254, 48, 64, 175, + 41, 115, 62, 243, 141, 81, 119, 121, 5, 68, 121, 88, 239, 29, 230, 90, + 135, 159, 35, 223, 168, 112, 49, 37, 146, 60, 126, 134, 42, 145, 115, 90, + 73, 133, 211, 86, 120, 141, 122, 241, 127, 56, 130, 36, 174, 75, 83, 246, + 112, 45, 136, 194, 201, 115, 1, 156, 114, 167, 208, 12, 176, 147, 32, 170, + 251, 100, 102, 220, 122, 210, 6, 49, 75, 201, 38, 105, 132, 135, 126, 102, + 13, 121, 76, 228, 202, 20, 61, 213, 246, 13, 207, 42, 148, 168, 37, 253, + 34, 94, 141, 185, 18, 234, 157, 109, 104, 64, 250, 125, 49, 236, 86, 48, + 196, 77, 75, 237, 156, 103, 225, 19, 110, 229, 22, 68, 177, 93, 221, 181, + 152, 153, 61, 108, 101, 74, 247, 195, 127, 216, 30, 166, 168, 61, 83, 229, + 120, 156, 96, 120, 201, 124, 43, 27, 253, 250, 120, 143, 89, 235, 189, 243, + 150, 7, 127, 119, 149, 244, 84, 185, 134, 34, 128, 193, 236, 234, 132, 117, + 137, 32, 145, 184, 44, 121, 51, 76, 11, 228, 142, 251, 39, 77, 228, 251, + 41, 58, 246, 107, 125, 187, 9, 240, 35, 8, 11, 162, 242, 220, 158, 163, + 2, 184, 163, 227, 242, 2, 100, 101, 2, 78, 129, 34, 89, 28, 26, 157, + 79, 31, 107, 250, 194, 156, 186, 69, 212, 66, 41, 180, 139, 42, 211, 253, + 256, 239, 29, 129, 104, 248, 182, 68, 1, 189, 48, 226, 36, 229, 3, 158, + 41, 53, 241, 22, 115, 174, 16, 163, 224, 19, 112, 219, 177, 233, 42, 27, + 250, 134, 18, 28, 145, 122, 68, 34, 134, 31, 147, 17, 39, 188, 150, 76, + 45, 42, 167, 249, 12, 16, 23, 182, 13, 79, 121, 3, 70, 197, 239, 44, + 86, 177, 255, 81, 64, 171, 138, 131, 73, 110, 44, 201, 254, 198, 146, 91, + 48, 9, 104, 31, 29, 161, 101, 31, 138, 180, 231, 233, 79, 137, 61, 236, + 140, 15, 249, 218, 234, 119, 99, 195, 110, 137, 237, 207, 8, 31, 45, 24, + 90, 155, 203, 253, 192, 203, 65, 176, 210, 171, 142, 214, 220, 122, 136, 237, + 189, 186, 147, 40, 80, 254, 173, 33, 191, 46, 192, 26, 108, 255, 228, 205, + 61, 76, 39, 107, 225, 126, 228, 182, 140, 251, 143, 134, 252, 168, 221, 8, + 185, 85, 60, 233, 147, 244, 87, 137, 8, 140, 96, 80, 53, 45, 175, 160, + 124, 189, 112, 37, 144, 19, 70, 17, 170, 242, 2, 3, 28, 95, 120, 199, + 212, 43, 9, 117, 86, 151, 101, 241, 200, 145, 241, 19, 178, 69, 204, 197, + 227, 166, 94, 7, 193, 45, 247, 234, 19, 187, 212, 212, 236, 125, 33, 95, + 198, 121, 122, 103, 77, 155, 235, 49, 25, 237, 249, 11, 162, 7, 238, 24, + 16, 150, 129, 25, 152, 17, 42, 67, 247, 162, 77, 154, 31, 133, 55, 137, + 79, 119, 153, 10, 86, 28, 244, 186, 41, 169, 106, 44, 10, 49, 110, 179, + 32, 133, 155, 244, 61, 70, 131, 168, 170, 39, 231, 252, 32, 69, 92, 238, + 239, 35, 132, 136, 236, 167, 90, 32, 123, 88, 69, 22, 20, 89, 145, 166, + 30, 118, 75, 4, 49, 31, 225, 54, 11, 50, 56, 191, 246, 1, 187, 33, + 119, 107, 139, 68, 19, 240, 131, 55, 94, 113, 31, 252, 12, 179, 121, 2, + 120, 252, 0, 76, 41, 80, 185, 42, 62, 121, 105, 159, 121, 109, 111, 98, + 7, 118, 86, 29, 210, 70, 231, 179, 223, 229, 164, 70, 62, 47, 0, 206, + 204, 178, 168, 120, 224, 166, 99, 25, 103, 63, 246, 224, 117, 204, 75, 124, + 140, 133, 110, 110, 222, 88, 151, 118, 46, 37, 22, 143, 158, 40, 2, 50, + 153, 94, 190, 199, 13, 198, 127, 211, 180, 90, 183, 98, 0, 142, 210, 154, + 100, 187, 67, 231, 202, 100, 198, 235, 252, 160, 247, 124, 247, 14, 121, 221, + 57, 88, 253, 243, 185, 89, 45, 249, 221, 194, 108, 175, 193, 119, 50, 141, + 223, 133, 136, 64, 176, 250, 129, 100, 124, 94, 181, 159, 99, 185, 177, 240, + 135, 42, 103, 52, 202, 208, 143, 186, 193, 103, 154, 237, 102, 88, 225, 161, + 50, 188, 191, 109, 12, 87, 19, 227, 247, 183, 13, 52, 205, 170, 205, 146, + 89, 160, 18, 105, 192, 73, 231, 225, 184, 157, 252, 220, 61, 59, 169, 183, + 221, 20, 141, 20, 158, 101, 245, 7, 245, 225, 118, 137, 84, 55, 19, 27, + 164, 110, 35, 25, 202, 94, 150, 46, 91, 152, 130, 1, 7, 46, 16, 237, + 171, 109, 19, 200, 65, 38, 10, 213, 70, 96, 126, 226, 185, 225, 181, 46, + 10, 165, 11, 123, 53, 158, 22, 147, 64, 22, 227, 69, 182, 237, 197, 37, + 39, 49, 186, 223, 139, 128, 55, 36, 166, 178, 220, 20, 98, 172, 166, 253, + 45, 0, 120, 180, 189, 185, 158, 159, 196, 6, 214, 79, 141, 52, 156, 107, + 5, 109, 142, 159, 33, 64, 190, 133, 95, 132, 95, 202, 160, 63, 186, 23, + 231, 107, 163, 33, 234, 15, 244, 77, 108, 49, 51, 7, 164, 87, 142, 99, + 240, 202, 47, 256, 118, 190, 196, 178, 217, 42, 39, 153, 21, 192, 232, 202, + 14, 82, 179, 64, 233, 4, 219, 10, 133, 78, 43, 144, 146, 216, 202, 81, + 71, 252, 8, 201, 68, 256, 85, 233, 164, 88, 176, 30, 5, 152, 126, 179, + 249, 84, 140, 190, 159, 54, 118, 98, 2, 159, 27, 133, 74, 121, 239, 196, + 71, 149, 119, 135, 102, 20, 87, 112, 44, 75, 221, 3, 151, 158, 5, 98, + 152, 25, 97, 106, 63, 171, 240, 79, 234, 240, 230, 92, 76, 70, 173, 196, + 36, 225, 218, 133, 64, 240, 150, 41, 146, 66, 133, 51, 134, 73, 170, 238, + 140, 90, 45, 89, 46, 147, 96, 169, 174, 174, 244, 151, 90, 40, 32, 74, + 38, 154, 246, 57, 31, 14, 189, 151, 83, 243, 197, 183, 220, 185, 53, 225, + 51, 106, 188, 208, 222, 248, 93, 13, 93, 215, 131, 25, 142, 185, 113, 222, + 131, 215, 149, 50, 159, 85, 32, 5, 205, 192, 2, 227, 42, 214, 197, 42, + 126, 182, 68, 123, 109, 36, 237, 179, 170, 199, 77, 256, 5, 128, 214, 243, + 137, 177, 170, 253, 179, 180, 153, 236, 100, 196, 216, 231, 198, 37, 192, 80, + 121, 221, 246, 1, 16, 246, 29, 78, 64, 148, 124, 38, 96, 125, 28, 20, + 48, 51, 73, 187, 139, 208, 98, 253, 221, 188, 84, 129, 1, 205, 95, 205, + 117, 79, 71, 126, 134, 237, 19, 184, 137, 125, 129, 178, 223, 54, 188, 112, + 30, 7, 225, 228, 205, 184, 233, 87, 117, 22, 58, 10, 8, 42, 2, 114, + 254, 19, 17, 13, 150, 92, 233, 179, 63, 12, 60, 171, 127, 35, 50, 5, + 195, 113, 241, 25, 249, 184, 166, 44, 221, 35, 151, 116, 8, 54, 195, 89, + 218, 186, 132, 5, 41, 89, 226, 177, 11, 41, 87, 172, 5, 23, 20, 59, + 228, 94, 76, 33, 137, 43, 151, 221, 61, 232, 4, 120, 93, 217, 80, 228, + 228, 6, 58, 25, 62, 84, 91, 48, 209, 20, 247, 243, 55, 106, 80, 79, + 235, 34, 20, 180, 146, 2, 236, 13, 236, 206, 243, 222, 204, 83, 148, 213, + 214, 117, 237, 98, 0, 90, 204, 168, 32, 41, 126, 67, 191, 74, 27, 255, + 26, 75, 240, 113, 185, 105, 167, 154, 112, 67, 151, 63, 161, 134, 239, 176, + 42, 87, 249, 130, 45, 242, 17, 100, 107, 120, 212, 218, 237, 76, 231, 162, + 175, 172, 118, 155, 92, 36, 124, 17, 121, 71, 13, 9, 82, 126, 147, 142, + 218, 148, 138, 80, 163, 106, 164, 123, 140, 129, 35, 42, 186, 154, 228, 214, + 75, 73, 8, 253, 42, 153, 232, 164, 95, 24, 110, 90, 231, 197, 90, 196, + 57, 164, 252, 181, 31, 7, 97, 256, 35, 77, 200, 212, 99, 179, 92, 227, + 17, 180, 49, 176, 9, 188, 13, 182, 93, 44, 128, 219, 134, 92, 151, 6, + 23, 126, 200, 109, 66, 30, 140, 180, 146, 134, 67, 200, 7, 9, 223, 168, + 186, 221, 3, 154, 150, 165, 43, 53, 138, 27, 86, 213, 235, 160, 70, 2, + 240, 20, 89, 212, 84, 141, 168, 246, 183, 227, 30, 167, 138, 185, 253, 83, + 52, 143, 236, 94, 59, 65, 89, 218, 194, 157, 164, 156, 111, 95, 202, 168, + 245, 256, 151, 28, 222, 194, 72, 130, 217, 134, 253, 77, 246, 100, 76, 32, + 254, 174, 182, 193, 14, 237, 74, 1, 74, 26, 135, 216, 152, 208, 112, 38, + 181, 62, 25, 71, 61, 234, 254, 97, 191, 23, 92, 256, 190, 205, 6, 16, + 134, 147, 210, 219, 148, 59, 73, 185, 24, 247, 174, 143, 116, 220, 128, 144, + 111, 126, 101, 98, 130, 136, 101, 102, 69, 127, 24, 168, 146, 226, 226, 207, + 176, 122, 149, 254, 134, 196, 22, 151, 197, 21, 50, 205, 116, 154, 65, 116, + 177, 224, 127, 77, 177, 159, 225, 69, 176, 54, 100, 104, 140, 8, 11, 126, + 11, 188, 185, 159, 107, 16, 254, 142, 80, 28, 5, 157, 104, 57, 109, 82, + 102, 80, 173, 242, 238, 207, 57, 105, 237, 160, 59, 189, 189, 199, 26, 11, + 190, 156, 97, 118, 20, 12, 254, 189, 165, 147, 142, 199, 5, 213, 64, 133, + 108, 217, 133, 60, 94, 28, 116, 136, 47, 165, 125, 42, 183, 143, 14, 129, + 223, 70, 212, 205, 181, 180, 3, 201, 182, 46, 57, 104, 239, 60, 99, 181, + 220, 231, 45, 79, 156, 89, 149, 143, 190, 103, 153, 61, 235, 73, 136, 20, + 89, 243, 16, 130, 247, 141, 134, 93, 80, 68, 85, 84, 8, 72, 194, 4, + 242, 110, 19, 133, 199, 70, 172, 92, 132, 254, 67, 74, 36, 94, 13, 90, + 154, 184, 9, 109, 118, 243, 214, 71, 36, 95, 0, 90, 201, 105, 112, 215, + 69, 196, 224, 210, 236, 242, 155, 211, 37, 134, 69, 113, 157, 97, 68, 26, + 230, 149, 219, 180, 20, 76, 172, 145, 154, 40, 129, 8, 93, 56, 162, 124, + 207, 233, 105, 19, 3, 183, 155, 134, 8, 244, 213, 78, 139, 88, 156, 37, + 51, 152, 111, 102, 112, 250, 114, 252, 201, 241, 133, 24, 136, 153, 5, 90, + 210, 197, 216, 24, 131, 17, 147, 246, 13, 86, 3, 253, 179, 237, 101, 114, + 243, 191, 207, 2, 220, 133, 244, 53, 87, 125, 154, 158, 197, 20, 8, 83, + 32, 191, 38, 241, 204, 22, 168, 59, 217, 123, 162, 82, 21, 50, 130, 89, + 239, 253, 195, 56, 253, 74, 147, 125, 234, 199, 250, 28, 65, 193, 22, 237, + 193, 94, 58, 229, 139, 176, 69, 42, 179, 164, 150, 168, 246, 214, 86, 174, + 59, 117, 15, 19, 76, 37, 214, 238, 153, 226, 154, 45, 109, 114, 198, 107, + 45, 70, 238, 196, 142, 252, 244, 71, 123, 136, 134, 188, 99, 132, 25, 42, + 240, 0, 196, 33, 26, 124, 256, 145, 27, 102, 153, 35, 28, 132, 221, 167, + 138, 133, 41, 170, 95, 224, 40, 139, 239, 153, 1, 106, 255, 106, 170, 163, + 127, 44, 155, 232, 194, 119, 232, 117, 239, 143, 108, 41, 3, 9, 180, 256, + 144, 113, 133, 200, 79, 69, 128, 216, 31, 50, 102, 209, 249, 136, 150, 154, + 182, 51, 228, 39, 127, 142, 87, 15, 94, 92, 187, 245, 31, 236, 64, 58, + 114, 11, 17, 166, 189, 152, 218, 34, 123, 39, 58, 37, 153, 91, 63, 121, + 31, 34, 12, 254, 106, 96, 171, 14, 155, 247, 214, 69, 24, 98, 3, 204, + 202, 194, 207, 30, 253, 44, 119, 70, 14, 96, 82, 250, 63, 6, 232, 38, + 89, 144, 102, 191, 82, 254, 20, 222, 96, 162, 110, 6, 159, 58, 200, 226, + 98, 128, 42, 70, 84, 247, 128, 211, 136, 54, 143, 166, 60, 118, 99, 218, + 27, 193, 85, 81, 219, 223, 46, 41, 23, 233, 152, 222, 36, 236, 54, 181, + 56, 50, 4, 207, 129, 92, 78, 88, 197, 251, 131, 105, 31, 172, 38, 131, + 19, 204, 129, 47, 227, 106, 202, 183, 23, 6, 77, 224, 102, 147, 11, 218, + 131, 132, 60, 192, 208, 223, 236, 23, 103, 115, 89, 18, 185, 171, 70, 174, + 139, 0, 100, 160, 221, 11, 228, 60, 12, 122, 114, 12, 157, 235, 148, 57, + 83, 62, 173, 131, 169, 126, 85, 99, 93, 243, 81, 80, 29, 245, 206, 82, + 236, 227, 166, 14, 230, 213, 144, 97, 27, 111, 99, 164, 105, 150, 89, 111, + 252, 118, 140, 232, 120, 183, 137, 213, 232, 157, 224, 33, 134, 118, 186, 80, + 159, 2, 186, 193, 54, 242, 25, 237, 232, 249, 226, 213, 90, 149, 90, 160, + 118, 69, 64, 37, 10, 183, 109, 246, 30, 52, 219, 69, 189, 26, 116, 220, + 50, 244, 243, 243, 139, 137, 232, 98, 38, 45, 256, 143, 171, 101, 73, 238, + 123, 45, 194, 167, 250, 123, 12, 29, 136, 237, 141, 21, 89, 96, 199, 44, + 8, 214, 208, 17, 113, 41, 137, 26, 166, 155, 89, 85, 54, 58, 97, 160, + 50, 239, 58, 71, 21, 157, 139, 12, 37, 198, 182, 131, 149, 134, 16, 204, + 164, 181, 248, 166, 52, 216, 136, 201, 37, 255, 187, 240, 5, 101, 147, 231, + 14, 163, 253, 134, 146, 216, 8, 54, 224, 90, 220, 195, 75, 215, 186, 58, + 71, 204, 124, 105, 239, 53, 16, 85, 69, 163, 195, 223, 33, 38, 69, 88, + 88, 203, 99, 55, 176, 13, 156, 204, 236, 99, 194, 134, 75, 247, 126, 129, + 160, 124, 233, 206, 139, 144, 154, 45, 233, 51, 206, 61, 60, 55, 205, 107, + 84, 108, 96, 188, 203, 31, 89, 20, 115, 144, 137, 90, 237, 78, 231, 185, + 120, 217, 1, 176, 169, 30, 155, 176, 100, 113, 53, 42, 193, 108, 14, 121, + 176, 158, 137, 92, 178, 44, 110, 249, 108, 234, 94, 101, 128, 12, 250, 173, + 72, 202, 232, 66, 139, 152, 189, 18, 32, 197, 9, 238, 246, 55, 119, 183, + 196, 119, 113, 247, 191, 100, 200, 245, 46, 16, 234, 112, 136, 116, 232, 48, + 176, 108, 11, 237, 14, 153, 93, 177, 124, 72, 67, 121, 135, 143, 45, 18, + 97, 251, 184, 172, 136, 55, 213, 8, 103, 12, 221, 212, 13, 160, 116, 91, + 237, 127, 218, 190, 103, 131, 77, 82, 36, 100, 22, 252, 79, 69, 54, 26, + 65, 182, 115, 142, 247, 20, 89, 81, 188, 244, 27, 120, 240, 248, 13, 230, + 67, 133, 32, 201, 129, 87, 9, 245, 66, 88, 166, 34, 46, 184, 119, 218, + 144, 235, 163, 40, 138, 134, 127, 217, 64, 227, 116, 67, 55, 202, 130, 48, + 199, 42, 251, 112, 124, 153, 123, 194, 243, 49, 250, 12, 78, 157, 167, 134, + 210, 73, 156, 102, 21, 88, 216, 123, 45, 11, 208, 18, 47, 187, 20, 43, + 3, 180, 124, 2, 136, 176, 77, 111, 138, 139, 91, 225, 126, 8, 74, 255, + 88, 192, 193, 239, 138, 204, 139, 194, 166, 130, 252, 184, 140, 168, 30, 177, + 121, 98, 131, 124, 69, 171, 75, 49, 184, 34, 76, 122, 202, 115, 184, 253, + 120, 182, 33, 251, 1, 74, 216, 217, 243, 168, 70, 162, 119, 158, 197, 198, + 61, 89, 7, 5, 54, 199, 211, 170, 23, 226, 44, 247, 165, 195, 7, 225, + 91, 23, 50, 15, 51, 208, 106, 94, 12, 31, 43, 112, 146, 139, 246, 182, + 113, 1, 97, 15, 66, 2, 51, 76, 164, 184, 237, 200, 218, 176, 72, 98, + 33, 135, 38, 147, 140, 229, 50, 94, 81, 187, 129, 17, 238, 168, 146, 203, + 181, 99, 164, 3, 104, 98, 255, 189, 114, 142, 86, 102, 229, 102, 80, 129, + 64, 84, 79, 161, 81, 156, 128, 111, 164, 197, 18, 15, 55, 196, 198, 191, + 28, 113, 117, 96, 207, 253, 19, 158, 231, 13, 53, 130, 252, 211, 58, 180, + 212, 142, 7, 219, 38, 81, 62, 109, 167, 113, 33, 56, 97, 185, 157, 130, + 186, 129, 119, 182, 196, 26, 54, 110, 65, 170, 166, 236, 30, 22, 162, 0, + 106, 12, 248, 33, 48, 72, 159, 17, 76, 244, 172, 132, 89, 171, 196, 76, + 254, 166, 76, 218, 226, 3, 52, 220, 238, 181, 179, 144, 225, 23, 3, 166, + 158, 35, 228, 154, 204, 23, 203, 71, 134, 189, 18, 168, 236, 141, 117, 138, + 2, 132, 78, 57, 154, 21, 250, 196, 184, 40, 161, 40, 10, 178, 134, 120, + 132, 123, 101, 82, 205, 121, 55, 140, 231, 56, 231, 71, 206, 246, 198, 150, + 146, 192, 45, 105, 242, 1, 125, 18, 176, 46, 222, 122, 19, 80, 113, 133, + 131, 162, 81, 51, 98, 168, 247, 161, 139, 39, 63, 162, 22, 153, 170, 92, + 91, 130, 174, 200, 45, 112, 99, 164, 132, 184, 191, 186, 200, 167, 86, 145, + 167, 227, 130, 44, 12, 158, 172, 249, 204, 17, 54, 249, 16, 200, 21, 174, + 67, 223, 105, 201, 50, 36, 133, 203, 244, 131, 228, 67, 29, 195, 91, 91, + 55, 107, 167, 154, 170, 137, 218, 183, 169, 61, 99, 175, 128, 23, 142, 183, + 66, 255, 59, 187, 66, 85, 212, 109, 168, 82, 16, 43, 67, 139, 114, 176, + 216, 255, 130, 94, 152, 79, 183, 64, 100, 23, 214, 82, 34, 230, 48, 15, + 242, 130, 50, 241, 81, 32, 5, 125, 183, 182, 184, 99, 248, 109, 159, 210, + 226, 61, 119, 129, 39, 149, 78, 214, 107, 78, 147, 124, 228, 18, 143, 188, + 84, 180, 233, 119, 64, 39, 158, 133, 177, 168, 6, 150, 80, 117, 150, 56, + 49, 72, 49, 37, 30, 242, 49, 142, 33, 156, 34, 44, 44, 72, 58, 22, + 249, 46, 168, 80, 25, 196, 64, 174, 97, 179, 244, 134, 213, 105, 63, 151, + 21, 90, 168, 90, 245, 28, 157, 65, 250, 232, 188, 27, 99, 160, 156, 127, + 68, 193, 10, 80, 205, 36, 138, 229, 12, 223, 70, 169, 251, 41, 48, 94, + 41, 177, 99, 256, 158, 0, 6, 83, 231, 191, 120, 135, 157, 146, 218, 213, + 160, 7, 47, 234, 98, 211, 79, 225, 179, 95, 175, 105, 185, 79, 115, 0, + 104, 14, 65, 124, 15, 188, 52, 9, 253, 27, 132, 137, 13, 127, 75, 238, + 185, 253, 33, 8, 52, 157, 164, 68, 232, 188, 69, 28, 209, 233, 5, 129, + 216, 90, 252, 212, 33, 200, 222, 9, 112, 15, 43, 36, 226, 114, 15, 249, + 217, 8, 148, 22, 147, 23, 143, 67, 222, 116, 235, 250, 212, 210, 39, 142, + 108, 64, 209, 83, 73, 66, 99, 34, 17, 29, 45, 151, 244, 114, 28, 241, + 144, 208, 146, 179, 132, 89, 217, 198, 252, 219, 205, 165, 75, 107, 11, 173, + 76, 6, 196, 247, 152, 216, 248, 91, 209, 178, 57, 250, 174, 60, 79, 123, + 18, 135, 9, 241, 230, 159, 184, 68, 156, 251, 215, 9, 113, 234, 75, 235, + 103, 194, 205, 129, 230, 45, 96, 73, 157, 20, 200, 212, 212, 228, 161, 7, + 231, 228, 108, 43, 198, 87, 140, 140, 4, 182, 164, 3, 53, 104, 250, 213, + 85, 38, 89, 61, 52, 187, 35, 204, 86, 249, 100, 71, 248, 213, 163, 215, + 66, 106, 252, 129, 40, 111, 47, 24, 186, 221, 85, 205, 199, 237, 122, 181, + 32, 46, 182, 135, 33, 251, 142, 34, 208, 242, 128, 255, 4, 234, 15, 33, + 167, 222, 32, 186, 191, 34, 255, 244, 98, 240, 228, 204, 30, 142, 32, 70, + 69, 83, 110, 151, 10, 243, 141, 21, 223, 69, 61, 37, 59, 209, 102, 114, + 223, 33, 129, 254, 255, 103, 86, 247, 235, 72, 126, 177, 102, 226, 102, 30, + 149, 221, 62, 247, 251, 120, 163, 173, 57, 202, 204, 24, 39, 106, 120, 143, + 202, 176, 191, 147, 37, 38, 51, 133, 47, 245, 157, 132, 154, 71, 183, 111, + 30, 180, 18, 202, 82, 96, 170, 91, 157, 181, 212, 140, 256, 8, 196, 121, + 149, 79, 66, 127, 113, 78, 4, 197, 84, 256, 111, 222, 102, 63, 228, 104, + 136, 223, 67, 193, 93, 154, 249, 83, 204, 101, 200, 234, 84, 252, 230, 195, + 43, 140, 120, 242, 89, 63, 166, 233, 209, 94, 43, 170, 126, 5, 205, 78, + 112, 80, 143, 151, 146, 248, 137, 203, 45, 183, 61, 1, 155, 8, 102, 59, + 68, 212, 230, 61, 254, 191, 128, 223, 176, 123, 229, 27, 146, 120, 96, 165, + 213, 12, 232, 40, 186, 225, 66, 105, 200, 195, 212, 110, 237, 238, 151, 19, + 12, 171, 150, 82, 7, 228, 79, 52, 15, 78, 62, 43, 21, 154, 114, 21, + 12, 212, 256, 232, 125, 127, 5, 51, 37, 252, 136, 13, 47, 195, 168, 191, + 231, 55, 57, 251, 214, 116, 15, 86, 210, 41, 249, 242, 119, 27, 250, 203, + 107, 69, 90, 43, 206, 154, 127, 54, 100, 78, 187, 54, 244, 177, 234, 167, + 202, 136, 209, 171, 69, 114, 133, 173, 26, 139, 78, 141, 128, 32, 124, 39, + 45, 218, 96, 68, 90, 44, 67, 62, 83, 190, 188, 256, 103, 42, 102, 64, + 249, 0, 141, 11, 61, 69, 70, 66, 233, 237, 29, 200, 251, 157, 71, 51, + 64, 133, 113, 76, 35, 125, 76, 137, 217, 145, 35, 69, 226, 180, 56, 249, + 156, 163, 176, 237, 81, 54, 85, 169, 115, 211, 129, 70, 248, 40, 252, 192, + 194, 101, 247, 8, 181, 124, 217, 191, 194, 93, 99, 127, 117, 177, 144, 151, + 228, 121, 32, 11, 89, 81, 26, 29, 183, 76, 249, 132, 179, 70, 34, 102, + 20, 66, 87, 63, 124, 205, 174, 177, 87, 219, 73, 218, 91, 87, 176, 72, + 15, 211, 47, 61, 251, 165, 39, 247, 146, 70, 150, 57, 1, 212, 36, 162, + 39, 38, 16, 216, 3, 50, 116, 200, 32, 234, 77, 181, 155, 19, 90, 188, + 36, 6, 254, 46, 46, 203, 25, 230, 181, 196, 4, 151, 225, 65, 122, 216, + 168, 86, 158, 131, 136, 16, 49, 102, 233, 64, 154, 88, 228, 52, 146, 69, + 93, 157, 243, 121, 70, 209, 126, 213, 88, 145, 236, 65, 70, 96, 204, 47, + 10, 200, 77, 8, 103, 150, 48, 153, 5, 37, 52, 235, 209, 31, 181, 126, + 83, 142, 224, 140, 6, 32, 200, 171, 160, 179, 115, 229, 75, 194, 208, 39, + 59, 223, 52, 247, 38, 197, 135, 1, 6, 189, 106, 114, 168, 5, 211, 222, + 44, 63, 90, 160, 116, 172, 170, 133, 125, 138, 39, 131, 23, 178, 10, 214, + 36, 93, 28, 59, 68, 17, 123, 25, 255, 184, 204, 102, 194, 214, 129, 94, + 159, 245, 112, 141, 62, 11, 61, 197, 124, 221, 205, 11, 79, 71, 201, 54, + 58, 150, 29, 121, 87, 46, 240, 201, 68, 20, 194, 209, 47, 152, 158, 174, + 193, 164, 120, 255, 216, 165, 247, 58, 85, 130, 220, 23, 122, 223, 188, 98, + 21, 70, 72, 170, 150, 237, 76, 143, 112, 238, 206, 146, 215, 110, 4, 250, + 68, 44, 174, 177, 30, 98, 143, 241, 180, 127, 113, 48, 0, 1, 179, 199, + 59, 106, 201, 114, 29, 86, 173, 133, 217, 44, 200, 141, 107, 172, 16, 60, + 82, 58, 239, 94, 141, 234, 186, 235, 109, 173, 249, 139, 141, 59, 100, 248, + 84, 144, 49, 160, 51, 207, 164, 103, 74, 97, 146, 202, 193, 125, 168, 134, + 236, 111, 135, 121, 59, 145, 168, 200, 181, 173, 109, 2, 255, 6, 9, 245, + 90, 202, 214, 143, 121, 65, 85, 232, 132, 77, 228, 84, 26, 54, 184, 15, + 161, 29, 177, 79, 43, 0, 156, 184, 163, 165, 62, 90, 179, 93, 45, 239, + 1, 16, 120, 189, 127, 47, 74, 166, 20, 214, 233, 226, 89, 217, 229, 26, + 156, 53, 162, 60, 21, 3, 192, 72, 111, 51, 53, 101, 181, 208, 88, 82, + 179, 160, 219, 113, 240, 108, 43, 224, 162, 147, 62, 14, 95, 81, 205, 4, + 160, 177, 225, 115, 29, 69, 235, 168, 148, 29, 128, 114, 124, 129, 172, 165, + 215, 231, 214, 86, 160, 44, 157, 91, 248, 183, 73, 164, 56, 181, 162, 92, + 141, 118, 127, 240, 196, 77, 0, 9, 244, 79, 250, 100, 195, 25, 255, 85, + 94, 35, 212, 137, 107, 34, 110, 20, 200, 104, 17, 32, 231, 43, 150, 159, + 231, 216, 223, 190, 226, 109, 162, 197, 87, 92, 224, 11, 111, 73, 60, 225, + 238, 73, 246, 169, 19, 217, 119, 38, 121, 118, 70, 82, 99, 241, 110, 67, + 31, 76, 146, 215, 124, 240, 31, 103, 139, 224, 75, 160, 31, 78, 93, 4, + 64, 9, 103, 223, 6, 227, 119, 85, 116, 81, 21, 43, 46, 206, 234, 132, + 85, 99, 22, 131, 135, 97, 86, 13, 234, 188, 21, 14, 89, 169, 207, 238, + 219, 177, 190, 72, 157, 41, 114, 140, 92, 141, 186, 1, 63, 107, 225, 184, + 118, 150, 153, 254, 241, 106, 120, 210, 104, 144, 151, 161, 88, 206, 125, 164, + 15, 211, 173, 49, 146, 241, 71, 36, 58, 201, 46, 27, 33, 187, 91, 162, + 117, 19, 210, 213, 187, 97, 193, 50, 190, 114, 217, 60, 61, 167, 207, 213, + 213, 53, 135, 34, 156, 91, 115, 119, 46, 99, 242, 1, 90, 52, 198, 227, + 201, 91, 216, 146, 210, 82, 121, 38, 73, 133, 182, 193, 132, 148, 246, 75, + 109, 157, 179, 113, 176, 134, 205, 159, 148, 58, 103, 171, 132, 156, 133, 147, + 161, 231, 39, 100, 175, 97, 125, 28, 183, 129, 135, 191, 202, 181, 29, 218, + 43, 104, 148, 203, 189, 204, 4, 182, 169, 1, 134, 122, 141, 202, 13, 187, + 177, 112, 162, 35, 231, 6, 8, 241, 99, 6, 191, 45, 113, 113, 101, 104}; + +// The S-Box we use for further linearity breaking. +// We created it by taking the digits of decimal expansion of e. +// The code that created it can be found in 'ProduceRandomSBox.c'. +unsigned char SBox[256] = { +//0 1 2 3 4 5 6 7 8 9 A B C D E F +0x7d, 0xd1, 0x70, 0x0b, 0xfa, 0x39, 0x18, 0xc3, 0xf3, 0xbb, 0xa7, 0xd4, 0x84, 0x25, 0x3b, 0x3c, // 0 +0x2c, 0x15, 0x69, 0x9a, 0xf9, 0x27, 0xfb, 0x02, 0x52, 0xba, 0xa8, 0x4b, 0x20, 0xb5, 0x8b, 0x3a, // 1 +0x88, 0x8e, 0x26, 0xcb, 0x71, 0x5e, 0xaf, 0xad, 0x0c, 0xac, 0xa1, 0x93, 0xc6, 0x78, 0xce, 0xfc, // 2 +0x2a, 0x76, 0x17, 0x1f, 0x62, 0xc2, 0x2e, 0x99, 0x11, 0x37, 0x65, 0x40, 0xfd, 0xa0, 0x03, 0xc1, // 3 +0xca, 0x48, 0xe2, 0x9b, 0x81, 0xe4, 0x1c, 0x01, 0xec, 0x68, 0x7a, 0x5a, 0x50, 0xf8, 0x0e, 0xa3, // 4 +0xe8, 0x61, 0x2b, 0xa2, 0xeb, 0xcf, 0x8c, 0x3d, 0xb4, 0x95, 0x13, 0x08, 0x46, 0xab, 0x91, 0x7b, // 5 +0xea, 0x55, 0x67, 0x9d, 0xdd, 0x29, 0x6a, 0x8f, 0x9f, 0x22, 0x4e, 0xf2, 0x57, 0xd2, 0xa9, 0xbd, // 6 +0x38, 0x16, 0x5f, 0x4c, 0xf7, 0x9e, 0x1b, 0x2f, 0x30, 0xc7, 0x41, 0x24, 0x5c, 0xbf, 0x05, 0xf6, // 7 +0x0a, 0x31, 0xa5, 0x45, 0x21, 0x33, 0x6b, 0x6d, 0x6c, 0x86, 0xe1, 0xa4, 0xe6, 0x92, 0x9c, 0xdf, // 8 +0xe7, 0xbe, 0x28, 0xe3, 0xfe, 0x06, 0x4d, 0x98, 0x80, 0x04, 0x96, 0x36, 0x3e, 0x14, 0x4a, 0x34, // 9 +0xd3, 0xd5, 0xdb, 0x44, 0xcd, 0xf5, 0x54, 0xdc, 0x89, 0x09, 0x90, 0x42, 0x87, 0xff, 0x7e, 0x56, // A +0x5d, 0x59, 0xd7, 0x23, 0x75, 0x19, 0x97, 0x73, 0x83, 0x64, 0x53, 0xa6, 0x1e, 0xd8, 0xb0, 0x49, // B +0x3f, 0xef, 0xbc, 0x7f, 0x43, 0xf0, 0xc9, 0x72, 0x0f, 0x63, 0x79, 0x2d, 0xc0, 0xda, 0x66, 0xc8, // C +0x32, 0xde, 0x47, 0x07, 0xb8, 0xe9, 0x1d, 0xc4, 0x85, 0x74, 0x82, 0xcc, 0x60, 0x51, 0x77, 0x0d, // D +0xaa, 0x35, 0xed, 0x58, 0x7c, 0x5b, 0xb9, 0x94, 0x6e, 0x8d, 0xb1, 0xc5, 0xb7, 0xee, 0xb6, 0xae, // E +0x10, 0xe0, 0xd6, 0xd9, 0xe5, 0x4f, 0xf1, 0x12, 0x00, 0xd0, 0xf4, 0x1a, 0x6f, 0x8a, 0xb3, 0xb2 }; // F + +/////////////////////////////////////////////////////////////////////////////////////////////// +// +// Helper functions definition portion. +// +/////////////////////////////////////////////////////////////////////////////////////////////// + +// Translates an input array with values in base 257 to output array with values in base 256. +// Returns the carry bit. +// +// Parameters: +// - input: the input array of size EIGHTH_N. Each value in the array is a number in Z_257. +// The MSB is assumed to be the last one in the array. +// - output: the input array encoded in base 256. +// +// Returns: +// - The carry bit (MSB). +swift_int16_t TranslateToBase256(swift_int32_t input[EIGHTH_N], unsigned char output[EIGHTH_N]); + +// Translates an input integer into the range (-FIELD_SIZE / 2) <= result <= (FIELD_SIZE / 2). +// +// Parameters: +// - x: the input integer. +// +// Returns: +// - The result, which equals (x MOD FIELD_SIZE), such that |result| <= (FIELD_SIZE / 2). +int Center(int x); + +// Calculates bit reversal permutation. +// +// Parameters: +// - input: the input to reverse. +// - numOfBits: the number of bits in the input to reverse. +// +// Returns: +// - The resulting number, which is obtained from the input by reversing its bits. +int ReverseBits(int input, int numOfBits); + +// Initializes the FFT fast lookup table. +// Shall be called only once. +void InitializeSWIFFTX(); + +// Calculates the FFT. +// +// Parameters: +// - input: the input to the FFT. +// - output: the resulting output. +void FFT(const unsigned char input[EIGHTH_N], swift_int32_t *output); + +/////////////////////////////////////////////////////////////////////////////////////////////// +// Helper functions implementation portion. +/////////////////////////////////////////////////////////////////////////////////////////////// + +swift_int16_t TranslateToBase256(swift_int32_t input[EIGHTH_N], unsigned char output[EIGHTH_N]) +{ + swift_int32_t pairs[EIGHTH_N / 2]; + int i; + + for (i = 0; i < EIGHTH_N; i += 2) + { + // input[i] + 257 * input[i + 1] + pairs[i >> 1] = input[i] + input[i + 1] + (input[i + 1] << 8); + } + + for (i = (EIGHTH_N / 2) - 1; i > 0; --i) + { + int j; + + for (j = i - 1; j < (EIGHTH_N / 2) - 1; ++j) + { + // pairs[j + 1] * 513, because 257^2 = 513 % 256^2. + register swift_int32_t temp = pairs[j] + pairs[j + 1] + (pairs[j + 1] << 9); + pairs[j] = temp & 0xffff; + pairs[j + 1] += (temp >> 16); + } + } + + for (i = 0; i < EIGHTH_N; i += 2) + { + output[i] = (unsigned char) (pairs[i >> 1] & 0xff); + output[i + 1] = (unsigned char) ((pairs[i >> 1] >> 8) & 0xff); + } + + return (pairs[EIGHTH_N/2 - 1] >> 16); +} + +int Center(int x) +{ + int result = x % FIELD_SIZE; + + if (result > (FIELD_SIZE / 2)) + result -= FIELD_SIZE; + + if (result < (FIELD_SIZE / -2)) + result += FIELD_SIZE; + + return result; +} + +int ReverseBits(int input, int numOfBits) +{ + register int reversed = 0; + + for (input |= numOfBits; input > 1; input >>= 1) + reversed = (reversed << 1) | (input & 1); + + return reversed; +} + +void InitializeSWIFFTX() +{ + int i, j, k, x; + // The powers of OMEGA + int omegaPowers[2 * N]; + omegaPowers[0] = 1; + + if (wasSetupDone) + return; + + for (i = 1; i < (2 * N); ++i) + { + omegaPowers[i] = Center(omegaPowers[i - 1] * OMEGA); + } + + for (i = 0; i < (N / W); ++i) + { + for (j = 0; j < W; ++j) + { + multipliers[(i << 3) + j] = omegaPowers[ReverseBits(i, N / W) * (2 * j + 1)]; + } + } + + for (x = 0; x < 256; ++x) + { + for (j = 0; j < 8; ++j) + { + register int temp = 0; + for (k = 0; k < 8; ++k) + { + temp += omegaPowers[(EIGHTH_N * (2 * j + 1) * ReverseBits(k, W)) % (2 * N)] + * ((x >> k) & 1); + } + + fftTable[(x << 3) + j] = Center(temp); + } + } + + wasSetupDone = true; +} + +void FFT(const unsigned char input[EIGHTH_N], swift_int32_t *output) +{ + register swift_int16_t *mult = multipliers; + register swift_int32_t F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, + F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, + F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, + F30, F31, F32, F33, F34, F35, F36, F37, F38, F39, + F40, F41, F42, F43, F44, F45, F46, F47, F48, F49, + F50, F51, F52, F53, F54, F55, F56, F57, F58, F59, + F60, F61, F62, F63; + + // First loop unrolling: + register swift_int16_t *table = &(fftTable[input[0] << 3]); + + F0 = mult[0] * table[0]; + F8 = mult[1] * table[1]; + F16 = mult[2] * table[2]; + F24 = mult[3] * table[3]; + F32 = mult[4] * table[4]; + F40 = mult[5] * table[5]; + F48 = mult[6] * table[6]; + F56 = mult[7] * table[7]; + + mult += 8; + table = &(fftTable[input[1] << 3]); + + F1 = mult[0] * table[0]; + F9 = mult[1] * table[1]; + F17 = mult[2] * table[2]; + F25 = mult[3] * table[3]; + F33 = mult[4] * table[4]; + F41 = mult[5] * table[5]; + F49 = mult[6] * table[6]; + F57 = mult[7] * table[7]; + + mult += 8; + table = &(fftTable[input[2] << 3]); + + F2 = mult[0] * table[0]; + F10 = mult[1] * table[1]; + F18 = mult[2] * table[2]; + F26 = mult[3] * table[3]; + F34 = mult[4] * table[4]; + F42 = mult[5] * table[5]; + F50 = mult[6] * table[6]; + F58 = mult[7] * table[7]; + + mult += 8; + table = &(fftTable[input[3] << 3]); + + F3 = mult[0] * table[0]; + F11 = mult[1] * table[1]; + F19 = mult[2] * table[2]; + F27 = mult[3] * table[3]; + F35 = mult[4] * table[4]; + F43 = mult[5] * table[5]; + F51 = mult[6] * table[6]; + F59 = mult[7] * table[7]; + + mult += 8; + table = &(fftTable[input[4] << 3]); + + F4 = mult[0] * table[0]; + F12 = mult[1] * table[1]; + F20 = mult[2] * table[2]; + F28 = mult[3] * table[3]; + F36 = mult[4] * table[4]; + F44 = mult[5] * table[5]; + F52 = mult[6] * table[6]; + F60 = mult[7] * table[7]; + + mult += 8; + table = &(fftTable[input[5] << 3]); + + F5 = mult[0] * table[0]; + F13 = mult[1] * table[1]; + F21 = mult[2] * table[2]; + F29 = mult[3] * table[3]; + F37 = mult[4] * table[4]; + F45 = mult[5] * table[5]; + F53 = mult[6] * table[6]; + F61 = mult[7] * table[7]; + + mult += 8; + table = &(fftTable[input[6] << 3]); + + F6 = mult[0] * table[0]; + F14 = mult[1] * table[1]; + F22 = mult[2] * table[2]; + F30 = mult[3] * table[3]; + F38 = mult[4] * table[4]; + F46 = mult[5] * table[5]; + F54 = mult[6] * table[6]; + F62 = mult[7] * table[7]; + + mult += 8; + table = &(fftTable[input[7] << 3]); + + F7 = mult[0] * table[0]; + F15 = mult[1] * table[1]; + F23 = mult[2] * table[2]; + F31 = mult[3] * table[3]; + F39 = mult[4] * table[4]; + F47 = mult[5] * table[5]; + F55 = mult[6] * table[6]; + F63 = mult[7] * table[7]; + + // Second loop unrolling: + // Iteration 0: + ADD_SUB(F0, F1); + ADD_SUB(F2, F3); + ADD_SUB(F4, F5); + ADD_SUB(F6, F7); + + F3 <<= 4; + F7 <<= 4; + + ADD_SUB(F0, F2); + ADD_SUB(F1, F3); + ADD_SUB(F4, F6); + ADD_SUB(F5, F7); + + F5 <<= 2; + F6 <<= 4; + F7 <<= 6; + + ADD_SUB(F0, F4); + ADD_SUB(F1, F5); + ADD_SUB(F2, F6); + ADD_SUB(F3, F7); + + output[0] = Q_REDUCE(F0); + output[8] = Q_REDUCE(F1); + output[16] = Q_REDUCE(F2); + output[24] = Q_REDUCE(F3); + output[32] = Q_REDUCE(F4); + output[40] = Q_REDUCE(F5); + output[48] = Q_REDUCE(F6); + output[56] = Q_REDUCE(F7); + + // Iteration 1: + ADD_SUB(F8, F9); + ADD_SUB(F10, F11); + ADD_SUB(F12, F13); + ADD_SUB(F14, F15); + + F11 <<= 4; + F15 <<= 4; + + ADD_SUB(F8, F10); + ADD_SUB(F9, F11); + ADD_SUB(F12, F14); + ADD_SUB(F13, F15); + + F13 <<= 2; + F14 <<= 4; + F15 <<= 6; + + ADD_SUB(F8, F12); + ADD_SUB(F9, F13); + ADD_SUB(F10, F14); + ADD_SUB(F11, F15); + + output[1] = Q_REDUCE(F8); + output[9] = Q_REDUCE(F9); + output[17] = Q_REDUCE(F10); + output[25] = Q_REDUCE(F11); + output[33] = Q_REDUCE(F12); + output[41] = Q_REDUCE(F13); + output[49] = Q_REDUCE(F14); + output[57] = Q_REDUCE(F15); + + // Iteration 2: + ADD_SUB(F16, F17); + ADD_SUB(F18, F19); + ADD_SUB(F20, F21); + ADD_SUB(F22, F23); + + F19 <<= 4; + F23 <<= 4; + + ADD_SUB(F16, F18); + ADD_SUB(F17, F19); + ADD_SUB(F20, F22); + ADD_SUB(F21, F23); + + F21 <<= 2; + F22 <<= 4; + F23 <<= 6; + + ADD_SUB(F16, F20); + ADD_SUB(F17, F21); + ADD_SUB(F18, F22); + ADD_SUB(F19, F23); + + output[2] = Q_REDUCE(F16); + output[10] = Q_REDUCE(F17); + output[18] = Q_REDUCE(F18); + output[26] = Q_REDUCE(F19); + output[34] = Q_REDUCE(F20); + output[42] = Q_REDUCE(F21); + output[50] = Q_REDUCE(F22); + output[58] = Q_REDUCE(F23); + + // Iteration 3: + ADD_SUB(F24, F25); + ADD_SUB(F26, F27); + ADD_SUB(F28, F29); + ADD_SUB(F30, F31); + + F27 <<= 4; + F31 <<= 4; + + ADD_SUB(F24, F26); + ADD_SUB(F25, F27); + ADD_SUB(F28, F30); + ADD_SUB(F29, F31); + + F29 <<= 2; + F30 <<= 4; + F31 <<= 6; + + ADD_SUB(F24, F28); + ADD_SUB(F25, F29); + ADD_SUB(F26, F30); + ADD_SUB(F27, F31); + + output[3] = Q_REDUCE(F24); + output[11] = Q_REDUCE(F25); + output[19] = Q_REDUCE(F26); + output[27] = Q_REDUCE(F27); + output[35] = Q_REDUCE(F28); + output[43] = Q_REDUCE(F29); + output[51] = Q_REDUCE(F30); + output[59] = Q_REDUCE(F31); + + // Iteration 4: + ADD_SUB(F32, F33); + ADD_SUB(F34, F35); + ADD_SUB(F36, F37); + ADD_SUB(F38, F39); + + F35 <<= 4; + F39 <<= 4; + + ADD_SUB(F32, F34); + ADD_SUB(F33, F35); + ADD_SUB(F36, F38); + ADD_SUB(F37, F39); + + F37 <<= 2; + F38 <<= 4; + F39 <<= 6; + + ADD_SUB(F32, F36); + ADD_SUB(F33, F37); + ADD_SUB(F34, F38); + ADD_SUB(F35, F39); + + output[4] = Q_REDUCE(F32); + output[12] = Q_REDUCE(F33); + output[20] = Q_REDUCE(F34); + output[28] = Q_REDUCE(F35); + output[36] = Q_REDUCE(F36); + output[44] = Q_REDUCE(F37); + output[52] = Q_REDUCE(F38); + output[60] = Q_REDUCE(F39); + + // Iteration 5: + ADD_SUB(F40, F41); + ADD_SUB(F42, F43); + ADD_SUB(F44, F45); + ADD_SUB(F46, F47); + + F43 <<= 4; + F47 <<= 4; + + ADD_SUB(F40, F42); + ADD_SUB(F41, F43); + ADD_SUB(F44, F46); + ADD_SUB(F45, F47); + + F45 <<= 2; + F46 <<= 4; + F47 <<= 6; + + ADD_SUB(F40, F44); + ADD_SUB(F41, F45); + ADD_SUB(F42, F46); + ADD_SUB(F43, F47); + + output[5] = Q_REDUCE(F40); + output[13] = Q_REDUCE(F41); + output[21] = Q_REDUCE(F42); + output[29] = Q_REDUCE(F43); + output[37] = Q_REDUCE(F44); + output[45] = Q_REDUCE(F45); + output[53] = Q_REDUCE(F46); + output[61] = Q_REDUCE(F47); + + // Iteration 6: + ADD_SUB(F48, F49); + ADD_SUB(F50, F51); + ADD_SUB(F52, F53); + ADD_SUB(F54, F55); + + F51 <<= 4; + F55 <<= 4; + + ADD_SUB(F48, F50); + ADD_SUB(F49, F51); + ADD_SUB(F52, F54); + ADD_SUB(F53, F55); + + F53 <<= 2; + F54 <<= 4; + F55 <<= 6; + + ADD_SUB(F48, F52); + ADD_SUB(F49, F53); + ADD_SUB(F50, F54); + ADD_SUB(F51, F55); + + output[6] = Q_REDUCE(F48); + output[14] = Q_REDUCE(F49); + output[22] = Q_REDUCE(F50); + output[30] = Q_REDUCE(F51); + output[38] = Q_REDUCE(F52); + output[46] = Q_REDUCE(F53); + output[54] = Q_REDUCE(F54); + output[62] = Q_REDUCE(F55); + + // Iteration 7: + ADD_SUB(F56, F57); + ADD_SUB(F58, F59); + ADD_SUB(F60, F61); + ADD_SUB(F62, F63); + + F59 <<= 4; + F63 <<= 4; + + ADD_SUB(F56, F58); + ADD_SUB(F57, F59); + ADD_SUB(F60, F62); + ADD_SUB(F61, F63); + + F61 <<= 2; + F62 <<= 4; + F63 <<= 6; + + ADD_SUB(F56, F60); + ADD_SUB(F57, F61); + ADD_SUB(F58, F62); + ADD_SUB(F59, F63); + + output[7] = Q_REDUCE(F56); + output[15] = Q_REDUCE(F57); + output[23] = Q_REDUCE(F58); + output[31] = Q_REDUCE(F59); + output[39] = Q_REDUCE(F60); + output[47] = Q_REDUCE(F61); + output[55] = Q_REDUCE(F62); + output[63] = Q_REDUCE(F63); +} + +// Calculates the FFT part of SWIFFT. +// We divided the SWIFFT calculation into two, because that way we could save 2 computations of +// the FFT part, since in the first stage of SWIFFTX the difference between the first 3 SWIFFTs +// is only the A's part. +// +// Parameters: +// - input: the input to FFT. +// - m: the input size divided by 8. The function performs m FFTs. +// - output: will store the result. +void SWIFFTFFT(const unsigned char *input, int m, swift_int32_t *output) +{ + int i; + + for (i = 0; + i < m; + i++, input += EIGHTH_N, output += N) + { + FFT(input, output); + } +} + +// Calculates the 'sum' part of SWIFFT, including the base change at the end. +// We divided the SWIFFT calculation into two, because that way we could save 2 computations of +// the FFT part, since in the first stage of SWIFFTX the difference between the first 3 SWIFFTs +// is only the A's part. +// +// Parameters: +// - input: the input. Of size 64 * m. +// - m: the input size divided by 64. +// - output: will store the result. +// - a: the coefficients in the sum. Of size 64 * m. +void SWIFFTSum(const swift_int32_t *input, int m, unsigned char *output, const swift_int16_t *a) +{ + int i, j; + swift_int32_t result[N]; + register swift_int16_t carry = 0; + + for (j = 0; j < N; ++j) + { + register swift_int32_t sum = 0; + const register swift_int32_t *f = input + j; + const register swift_int16_t *k = a + j; + + for (i = 0; i < m; i++, f += N,k += N) + { + sum += (*f) * (*k); + } + + result[j] = sum; + } + + for (j = 0; j < N; ++j) + { + result[j] = ((FIELD_SIZE << 22) + result[j]) % FIELD_SIZE; + } + + for (j = 0; j < 8; ++j) + { + int register carryBit = TranslateToBase256(result + (j << 3), output + (j << 3)); + carry |= carryBit << j; + } + + output[N] = carry; +} + +void ComputeSingleSWIFFTX(unsigned char input[SWIFFTX_INPUT_BLOCK_SIZE], + unsigned char output[SWIFFTX_OUTPUT_BLOCK_SIZE], + bool doSmooth) +{ + int i; + // Will store the result of the FFT parts: + swift_int32_t fftOut[N * M]; + unsigned char intermediate[N * 3 + 8]; + unsigned char carry0,carry1,carry2; + + // Do the three SWIFFTS while remembering the three carry bytes (each carry byte gets + // overriden by the following SWIFFT): + + // 1. Compute the FFT of the input - the common part for the first 3 SWIFFTs: + SWIFFTFFT(input, M, fftOut); + + // 2. Compute the sums of the 3 SWIFFTs, each using a different set of coefficients: + + // 2a. The first SWIFFT: + SWIFFTSum(fftOut, M, intermediate, As); + // Remember the carry byte: + carry0 = intermediate[N]; + + // 2b. The second one: + SWIFFTSum(fftOut, M, intermediate + N, As + (M * N)); + carry1 = intermediate[2 * N]; + + // 2c. The third one: + SWIFFTSum(fftOut, M, intermediate + (2 * N), As + 2 * (M * N)); + carry2 = intermediate[3 * N]; + + //2d. Put three carry bytes in their place + intermediate[3 * N] = carry0; + intermediate[(3 * N) + 1] = carry1; + intermediate[(3 * N) + 2] = carry2; + + // Padding intermediate output with 5 zeroes. + memset(intermediate + (3 * N) + 3, 0, 5); + + // Apply the S-Box: + for (i = 0; i < (3 * N) + 8; ++i) + { + intermediate[i] = SBox[intermediate[i]]; + } + + // 3. The final and last SWIFFT: + SWIFFTFFT(intermediate, 3 * (N/8) + 1, fftOut); + SWIFFTSum(fftOut, 3 * (N/8) + 1, output, As); + + if (doSmooth) + { + unsigned char sum[N]; + register int i, j; + memset(sum, 0, N); + + for (i = 0; i < (N + 1) * 8; ++i) + { + register const swift_int16_t *AsRow; + register int AShift; + + if (!(output[i >> 3] & (1 << (i & 7)))) + { + continue; + } + + AsRow = As + N * M + (i & ~(N - 1)) ; + AShift = i & 63; + + for (j = AShift; j < N; ++j) + { + sum[j] += AsRow[j - AShift]; + } + + for(j = 0; j < AShift; ++j) + { + sum[j] -= AsRow[N - AShift + j]; + } + } + + for (i = 0; i < N; ++i) + { + output[i] = sum[i]; + } + + output[N] = 0; + } +} diff --git a/stratum/algos/SWIFFTX/SWIFFTX.h b/stratum/algos/SWIFFTX/SWIFFTX.h new file mode 100644 index 000000000..8b9aff639 --- /dev/null +++ b/stratum/algos/SWIFFTX/SWIFFTX.h @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// +// SWIFFTX ANSI C OPTIMIZED 32BIT IMPLEMENTATION FOR NIST SHA-3 COMPETITION +// +// SWIFFTX.h +// +// October 2008 +// +// This file is the exact copy from the reference implementation. +// +/////////////////////////////////////////////////////////////////////////////////////////////// +#ifndef __SWIFFTX__ +#define __SWIFFTX__ + +#ifdef __cplusplus +extern "C"{ +#endif + +// See the remarks concerning compatibility issues inside stdint.h. +#include "stdint.h" +#include "stdbool.h" + +// The size of SWIFFTX input in bytes. +#define SWIFFTX_INPUT_BLOCK_SIZE 256 + +// The size of output block in bytes. The compression function of SWIFFT outputs a block of +// this size (i.e., this is the size of the resulting hash value). +#define SWIFFTX_OUTPUT_BLOCK_SIZE 65 + +// Computes the result of a single SWIFFT operation. +// This is the simple implementation, where our main concern is to show our design principles. +// It is made more efficient in the optimized version, by using FFT instead of DFT, and +// through other speed-up techniques. +// +// Parameters: +// - input: the input string. Consists of 8*m input bytes, where each octet passes the DFT +// processing. +// - m: the length of the input in bytes. +// - output: the resulting hash value of SWIFFT, of size 65 bytes (520 bit). This is the +// result of summing the dot products of the DFTS with the A's after applying the base +// change transformation +// - A: the A's coefficients to work with (since every SWIFFT in SWIFFTX uses different As). +// A single application of SWIFFT uses 64*m A's. +void ComputeSingleSWIFFT(unsigned char *input, unsigned short m, + unsigned char output[SWIFFTX_OUTPUT_BLOCK_SIZE], + const swift_int16_t *a); + +// Computes the result of a single SWIFFTX operation. +// NOTE: for simplicity we use 'ComputeSingleSWIFFT()' as a subroutine. This is only to show +// the design idea. In the optimized versions we don't do this for efficiency concerns, since +// there we compute the first part (which doesn't involve the A coefficients) only once for all +// of the 3 invocations of SWIFFT. This enables us to introduce a significant speedup. +// +// Parameters: +// - input: the input input of 256 bytes (2048 bit). +// - output: the resulting hash value of SWIFFT, of size 64 bytes (512 bit). +// - doSMooth: if true, a final smoothing stage is performed and the output is of size 512 bits. +// +// Returns: +// - Success value. +void ComputeSingleSWIFFTX(unsigned char input[SWIFFTX_INPUT_BLOCK_SIZE], + unsigned char output[SWIFFTX_OUTPUT_BLOCK_SIZE], + bool doSmooth); + +// Calculates the powers of OMEGA and generates the bit reversal permutation. +// You must call this function before doing SWIFFT/X, otherwise you will get zeroes everywhere. +void InitializeSWIFFTX(); + +#ifdef __cplusplus +} +#endif + +#endif // __SWIFFTX__ diff --git a/stratum/algos/SWIFFTX/inttypes.h b/stratum/algos/SWIFFTX/inttypes.h new file mode 100644 index 000000000..2b6b941b7 --- /dev/null +++ b/stratum/algos/SWIFFTX/inttypes.h @@ -0,0 +1,39 @@ + /* + inttypes.h + + Contributors: + Created by Marek Michalkiewicz + + THIS SOFTWARE IS NOT COPYRIGHTED + + This source code is offered for use in the public domain. You may + use, modify or distribute it freely. + + This code is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + DISCLAIMED. This includes but is not limited to warranties of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + #ifndef __INTTYPES_H_ + #define __INTTYPES_H_ + + /* Use [u]intN_t if you need exactly N bits. + XXX - doesn't handle the -mint8 option. */ + + typedef signed char swift_int8_t; + typedef unsigned char swift_uint8_t; + + typedef int swift_int16_t; + typedef unsigned int swift_uint16_t; + + typedef long swift_int32_t; + typedef unsigned long swift_uint32_t; + + typedef long long swift_int64_t; + typedef unsigned long long swift_uint64_t; + + //typedef swift_int16_t intptr_t; + //typedef swift_uint16_t uintptr_t; + + #endif diff --git a/stratum/algos/SWIFFTX/stdbool.h b/stratum/algos/SWIFFTX/stdbool.h new file mode 100644 index 000000000..8b10960fb --- /dev/null +++ b/stratum/algos/SWIFFTX/stdbool.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2000 Jeroen Ruigrok van der Werven + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/include/stdbool.h,v 1.6 2002/08/16 07:33:14 alfred Exp $ + */ + +#ifndef _STDBOOL_H_ +#define _STDBOOL_H_ + +#define __bool_true_false_are_defined 1 + +#ifndef __cplusplus + +#define false 0 +#define true 1 + +#define bool _Bool +#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 +typedef int _Bool; +#endif + +#endif /* !__cplusplus */ + +#endif /* !_STDBOOL_H_ */ diff --git a/stratum/algos/SWIFFTX/stdint.h b/stratum/algos/SWIFFTX/stdint.h new file mode 100644 index 000000000..59f4cfc93 --- /dev/null +++ b/stratum/algos/SWIFFTX/stdint.h @@ -0,0 +1,54 @@ +#ifndef _SWIFFT_STDINT_H +#define _SWIFFT_STDINT_H + +/////////////////////////////////////////////////////////////////////////////////////////////// +// +// A note from SWIFFTX implementers: +// +// Although the submission was targeted for Microsoft Visual Studio 2005 compiler, we strived +// to make the code as portable as possible. This is why we preferred to use the types defined +// here, instead of Microsoft-specific types. We compiled the code with gcc to make this sure. +// However, we couldn't use this header as is, due to VS2005 compiler objections. This is why +// we commented out certain defines and clearly marked it. +// To compile our code on gcc you may define SYS_STDINT. +// +/////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef SYS_STDINT + +#include + +#else + +#include "inttypes.h" +// The following was commented out by SWIFFTX implementers: +// __BEGIN_DECLS + +typedef swift_int8_t swifftx_int_least8_t; +typedef swift_int16_t swifftx_int_least16_t; +typedef swift_int32_t swifftx_int_least32_t; +typedef swift_uint8_t swifftx_uint_least8_t; +typedef swift_uint16_t swifftx_uint_least16_t; +typedef swift_uint32_t swifftx_uint_least32_t; + +#ifndef __STRICT_ANSI__ +typedef swift_int64_t swifftx_int_least64_t; +typedef swift_uint64_t swifftx_uint_least64_t; +#endif + +/*typedef signed char int_fast8_t; +typedef signed long int int_fast16_t; +typedef signed long int int_fast32_t; +typedef signed long long int int_fast64_t; + +typedef unsigned char uint_fast8_t; +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long long int uint_fast64_t;*/ + +// The following was commented out by SWIFFTX implementers: +// #include +// __END_DECLS +#endif + +#endif diff --git a/stratum/algos/a5a.c b/stratum/algos/a5a.c new file mode 100644 index 000000000..fbf608b46 --- /dev/null +++ b/stratum/algos/a5a.c @@ -0,0 +1,260 @@ +#include +#include +#include +#include +#include +#include +#include +#include "a5amath.h" + +#include "../sha3/sph_sha2.h" +#include "../sha3/sph_keccak.h" +#include "../sha3/sph_whirlpool.h" +#include "../sha3/sph_ripemd.h" + +static void mpz_set_uint256(mpz_t r, uint8_t *u) +{ + mpz_import(r, 32 / sizeof(unsigned long), -1, sizeof(unsigned long), -1, 0, u); +} + +static void mpz_get_uint256(mpz_t r, uint8_t *u) +{ + u=0; + mpz_export(u, 0, -1, sizeof(unsigned long), -1, 0, r); +} + +static void mpz_set_uint512(mpz_t r, uint8_t *u) +{ + mpz_import(r, 64 / sizeof(unsigned long), -1, sizeof(unsigned long), -1, 0, u); +} + +static void set_one_if_zero(uint8_t *hash512) { + int i; + for (i = 0; i < 32; i++) { + if (hash512[i] != 0) { + return; + } + } + hash512[0] = 1; +} + +#define BITS_PER_DIGIT 3.32192809488736234787 +//#define EPS (std::numeric_limits::epsilon()) +#define EPS (DBL_EPSILON) + +#define Na5a 5 +#define SW_DIVS 5 +//#define SW_MAX 1000 + +void a5a_hash(const char* input, char* output, uint32_t len) +{ + unsigned int nnNonce; + uint32_t pdata[32]; + memcpy(pdata, input, 80); +// memcpy(&nnNonce, input+76, 4); + + int i, j, bytes, nnNonce2; + nnNonce2 = (int)(pdata[19]/2); + size_t sz = 80; + uint8_t bhash[5][64]; + uint32_t hash[6]; + memset(bhash, 0, 5 * 64); + + sph_sha256_context ctx_final_sha256; + + sph_sha256_context ctx_sha256; + sph_sha512_context ctx_sha512; + sph_keccak512_context ctx_keccak; + sph_whirlpool_context ctx_whirlpool; + sph_ripemd160_context ctx_ripemd; + + sph_sha256_init(&ctx_sha256); + // ZSHA256; + sph_sha256 (&ctx_sha256, input, sz); + sph_sha256_close(&ctx_sha256, (void*)(bhash[0])); + + sph_sha512_init(&ctx_sha512); + // ZSHA512; + sph_sha512 (&ctx_sha512, input, sz); + sph_sha512_close(&ctx_sha512, (void*)(bhash[1])); + + sph_keccak512_init(&ctx_keccak); + // ZKECCAK; + sph_keccak512 (&ctx_keccak, input, sz); + sph_keccak512_close(&ctx_keccak, (void*)(bhash[2])); + + sph_whirlpool_init(&ctx_whirlpool); + // ZWHIRLPOOL; + sph_whirlpool (&ctx_whirlpool, input, sz); + sph_whirlpool_close(&ctx_whirlpool, (void*)(bhash[3])); + + sph_ripemd160_init(&ctx_ripemd); + // ZRIPEMD; + sph_ripemd160 (&ctx_ripemd, input, sz); + sph_ripemd160_close(&ctx_ripemd, (void*)(bhash[4])); + +// printf("%s\n", hash[4].GetHex().c_str()); + + mpz_t bns[6]; + for(i=0; i < 6; i++){ + mpz_init(bns[i]); + } + //Take care of zeros and load gmp + for(i=0; i < 5; i++){ + set_one_if_zero(bhash[i]); + mpz_set_uint512(bns[i],bhash[i]); + } + + mpz_set_ui(bns[5],0); + for(i=0; i < 5; i++) + mpz_add(bns[5], bns[5], bns[i]); + + mpz_t product; + mpz_init(product); + mpz_set_ui(product,1); +// mpz_pow_ui(bns[5], bns[5], 2); + for(i=0; i < 6; i++){ + mpz_mul(product,product,bns[i]); + } + mpz_pow_ui(product, product, 2); + + bytes = mpz_sizeinbase(product, 256); +// printf("a5a data space: %iB\n", bytes); + char *data = (char*)malloc(bytes); + mpz_export(data, NULL, -1, 1, 0, 0, product); + + sph_sha256_init(&ctx_final_sha256); + // ZSHA256; + sph_sha256 (&ctx_final_sha256, data, bytes); + sph_sha256_close(&ctx_final_sha256, (void*)(hash)); + free(data); + + int digits=(int)((sqrt((double)(nnNonce2))*(1.+EPS))/9000+75); +// int iterations=(int)((sqrt((double)(nnNonce2))+EPS)/500+350); // <= 500 +// int digits=100; + int iterations=20; // <= 500 + mpf_set_default_prec((long int)(digits*BITS_PER_DIGIT+16)); + + mpz_t a5api; + mpz_t a5asw; + mpf_t a5afpi; + mpf_t mpa1, mpb1, mpt1, mpp1; + mpf_t mpa2, mpb2, mpt2, mpp2; + mpf_t mpsft; + + mpz_init(a5api); + mpz_init(a5asw); + mpf_init(a5afpi); + mpf_init(mpsft); + mpf_init(mpa1); + mpf_init(mpb1); + mpf_init(mpt1); + mpf_init(mpp1); + + mpf_init(mpa2); + mpf_init(mpb2); + mpf_init(mpt2); + mpf_init(mpp2); + + uint32_t usw_; + usw_ = sw_(nnNonce2, SW_DIVS); + if (usw_ < 1) usw_ = 1; +// if(fDebuga5a) printf("usw_: %d\n", usw_); + mpz_set_ui(a5asw, usw_); + uint32_t mpzscale=mpz_size(a5asw); +for(i=0; i < Na5a; i++) +{ + if (mpzscale > 1000) { + mpzscale = 1000; + } + else if (mpzscale < 1) { + mpzscale = 1; + } +// if(fDebuga5a) printf("mpzscale: %d\n", mpzscale); + + mpf_set_ui(mpa1, 1); + mpf_set_ui(mpb1, 2); + mpf_set_d(mpt1, 0.25*mpzscale); + mpf_set_ui(mpp1, 1); + mpf_sqrt(mpb1, mpb1); + mpf_ui_div(mpb1, 1, mpb1); + mpf_set_ui(mpsft, 10); + + for(j=0; j <= iterations; j++) + { + mpf_add(mpa2, mpa1, mpb1); + mpf_div_ui(mpa2, mpa2, 2); + mpf_mul(mpb2, mpa1, mpb1); + mpf_abs(mpb2, mpb2); + mpf_sqrt(mpb2, mpb2); + mpf_sub(mpt2, mpa1, mpa2); + mpf_abs(mpt2, mpt2); + mpf_sqrt(mpt2, mpt2); + mpf_mul(mpt2, mpt2, mpp1); + mpf_sub(mpt2, mpt1, mpt2); + mpf_mul_ui(mpp2, mpp1, 2); + mpf_swap(mpa1, mpa2); + mpf_swap(mpb1, mpb2); + mpf_swap(mpt1, mpt2); + mpf_swap(mpp1, mpp2); + } + mpf_add(a5afpi, mpa1, mpb1); + mpf_pow_ui(a5afpi, a5afpi, 2); + mpf_div_ui(a5afpi, a5afpi, 4); + mpf_abs(mpt1, mpt1); + mpf_div(a5afpi, a5afpi, mpt1); + +// mpf_out_str(stdout, 10, digits+2, a5afpi); + + mpf_pow_ui(mpsft, mpsft, digits/2); + mpf_mul(a5afpi, a5afpi, mpsft); + + mpz_set_f(a5api, a5afpi); + +//mpz_set_ui(a5api,1); + + mpz_add(product,product,a5api); + mpz_add(product,product,a5asw); + + mpz_set_uint256(bns[0], (void*)(hash)); + mpz_add(bns[5], bns[5], bns[0]); + + mpz_mul(product,product,bns[5]); + mpz_cdiv_q (product, product, bns[0]); + if (mpz_sgn(product) <= 0) mpz_set_ui(product,1); + + bytes = mpz_sizeinbase(product, 256); + mpzscale=bytes; +// printf("a5a data space: %iB\n", bytes); + char *bdata = (char*)malloc(bytes); + mpz_export(bdata, NULL, -1, 1, 0, 0, product); + + sph_sha256_init(&ctx_final_sha256); + // ZSHA256; + sph_sha256 (&ctx_final_sha256, bdata, bytes); + sph_sha256_close(&ctx_final_sha256, (void*)(hash)); + free(bdata); +} + //Free the memory + for(i=0; i < 6; i++){ + mpz_clear(bns[i]); + } +// mpz_clear(dSpectralWeight); + mpz_clear(product); + + mpz_clear(a5api); + mpz_clear(a5asw); + mpf_clear(a5afpi); + mpf_clear(mpsft); + mpf_clear(mpa1); + mpf_clear(mpb1); + mpf_clear(mpt1); + mpf_clear(mpp1); + + mpf_clear(mpa2); + mpf_clear(mpb2); + mpf_clear(mpt2); + mpf_clear(mpp2); + + memcpy(output, hash, 32); +} \ No newline at end of file diff --git a/stratum/algos/a5a.h b/stratum/algos/a5a.h new file mode 100644 index 000000000..3470d8f3c --- /dev/null +++ b/stratum/algos/a5a.h @@ -0,0 +1,14 @@ +#ifndef SCRYPT_H +#define SCRYPT_H +#include +#ifdef __cplusplus +extern "C" { +#endif + +void a5a_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/stratum/algos/a5amath.c b/stratum/algos/a5amath.c new file mode 100644 index 000000000..1c61c5fe6 --- /dev/null +++ b/stratum/algos/a5amath.c @@ -0,0 +1,116 @@ +// Copyright (c) 2014 The a5a developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include +#include +#include +#include +#include +//#include +#include "a5amath.h" + +//#define EPS1 (std::numeric_limits::epsilon()) +#define EPS1 (DBL_EPSILON) +#define EPS2 3.0e-11 + +double exp_n(double xt) +{ + double p1 = -700.0, p3 = -0.8e-8, p4 = 0.8e-8, p6 = 700.0; + if(xt < p1) + return 0; + else if(xt > p6) + return 1e200; + else if(xt > p3 && xt < p4) + return (1.0 + xt); + else + return exp(xt); +} + +// 1 / (1 + exp(x1-x2)) +double exp_n2(double x1, double x2) +{ + double p1 = -700., p2 = -37., p3 = -0.8e-8, p4 = 0.8e-8, p5 = 37., p6 = 700.; + double xt = x1 - x2; + if (xt < p1+1.e-200) + return 1.; + else if (xt > p1 && xt < p2 + 1.e-200) + return ( 1. - exp(xt) ); + else if (xt > p2 && xt < p3 + 1.e-200) + return ( 1. / (1. + exp(xt)) ); + else if (xt > p3 && xt < p4) + return ( 1. / (2. + xt) ); + else if (xt > p4 - 1.e-200 && xt < p5) + return ( exp(-xt) / (1. + exp(-xt)) ); + else if (xt > p5 - 1.e-200 && xt < p6) + return ( exp(-xt) ); + else if (xt > p6 - 1.e-200) + return 0.; +} + +void gauleg(double x1, double x2, double x[], double w[], int n) +{ + int m,j,i; + double z1, z, xm, xl, pp, p3, p2, p1; + m=(n+1)/2; + xm=0.5*(x2+x1); + xl=0.5*(x2-x1); + for (i=1;i<=m;i++) { + z=cos(3.141592654*(i-0.25)/(n+0.5)); + do { + p1=1.0; + p2=0.0; + for (j=1;j<=n;j++) { + p3=p2; + p2=p1; + p1=((2.0*j-1.0)*z*p2-(j-1.0)*p3)/j; + } + pp=n*(z*p1-p2)/(z*z-1.0); + z1=z; + z=z1-p1/pp; + } while (fabs(z-z1) > EPS2); + x[i]=xm-xl*z; + x[n+1-i]=xm+xl*z; + w[i]=2.0*xl/((1.0-z*z)*pp*pp); + w[n+1-i]=w[i]; + } +} + +double GaussianQuad_N(double func(const double), const double a2, const double b2, int NptGQ) +{ + double s=0.0; + double x[NptGQ], w[NptGQ]; + int j; +// double dh=(b2-a2)/double(divs); + gauleg(a2, b2, x, w, NptGQ); + for (j=1; j<=NptGQ; j++) { + s += w[j]*func(x[j]); + } +/* + for (i=1; i<=divs; i++) + { + a0 = a2 + (i-1)*dh; + b0 = a0 + dh; + gauleg(a0, b0, x, w, NptGQ); + for (j=1; j<=NptGQ; j++) + { + s += w[j]*func(x[j]); + } + } +*/ + return s; +} + +double swit_(double wvnmb) +{ + return pow( (5.55243*(exp_n(-0.3*wvnmb/15.762) - exp_n(-0.6*wvnmb/15.762)))*wvnmb, 0.5) + / 1034.66 * pow(sin(wvnmb/65.), 2.); +} + +uint32_t sw_(int nnounce, int divs) +{ + double wmax = ((sqrt((double)(nnounce))*(1.+EPS1))/450+100); + return ((uint32_t)(GaussianQuad_N(swit_, 0., wmax, divs)*(1.+EPS1)*1.e6)); +} \ No newline at end of file diff --git a/stratum/algos/a5amath.h b/stratum/algos/a5amath.h new file mode 100644 index 000000000..d2f4ca8f5 --- /dev/null +++ b/stratum/algos/a5amath.h @@ -0,0 +1,16 @@ +// Copyright (c) 2014 The a5a developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef a5a_MATH_H +#define a5a_MATH_H + +double exp_n(double xt); +double exp_n2(double x1, double x2); +void gauleg(double x1, double x2, double x[], double w[], int n); +double GaussianQuad_N(double func(const double), const double a2, const double b2, int NptGQ); +double swit_(double wvnmb); +uint32_t sw_(int nnounce, int divs); + + + +#endif \ No newline at end of file diff --git a/stratum/algos/aergo.c b/stratum/algos/aergo.c new file mode 100644 index 000000000..7a791846c --- /dev/null +++ b/stratum/algos/aergo.c @@ -0,0 +1,162 @@ +#include "aergo.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gost.h" + +#include "common.h" + +void aergo_hash(const char* input, char* output, uint32_t len) +{ + uint32_t hash[16]; + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_skein512_context ctx_skein; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_hamsi512_context ctx_hamsi; + sph_fugue512_context ctx_fugue; + sph_shabal512_context ctx_shabal; + sph_gost512_context ctx_gost; + sph_whirlpool_context ctx_whirlpool; + sph_haval256_5_context ctx_haval; + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, input, len); + sph_echo512_close(&ctx_echo, hash); + + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, hash, 64); + sph_blake512_close(&ctx_blake, hash); + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, hash, 64); + sph_whirlpool_close(&ctx_whirlpool, hash); + + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, hash, 64); + sph_gost512_close(&ctx_gost, hash); + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, hash, 64); + sph_gost512_close(&ctx_gost, hash); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_haval256_5_init(&ctx_haval); + sph_haval256_5(&ctx_haval,(const void*) hash, 64); + sph_haval256_5_close(&ctx_haval, hash); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, hash, 64); + sph_gost512_close(&ctx_gost, hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, hash, 64); + sph_blake512_close(&ctx_blake, hash); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/aergo.h b/stratum/algos/aergo.h new file mode 100644 index 000000000..ad129b32a --- /dev/null +++ b/stratum/algos/aergo.h @@ -0,0 +1,17 @@ + +#ifndef AERGO_H +#define AERGO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void aergo_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/stratum/algos/allium.c b/stratum/algos/allium.c new file mode 100644 index 000000000..4c3569d36 --- /dev/null +++ b/stratum/algos/allium.c @@ -0,0 +1,46 @@ +#include + +#include "sha3/sph_blake.h" +#include "sha3/sph_groestl.h" +#include "sha3/sph_skein.h" +#include "sha3/sph_keccak.h" +#include "sha3/sph_cubehash.h" + +#include "Lyra2.h" + +void allium_hash(const char* input, char* output, uint32_t len) +{ + uint32_t hashA[8], hashB[8]; + + sph_blake256_context ctx_blake; + sph_keccak256_context ctx_keccak; + sph_cubehash512_context ctx_cubehash; + sph_skein256_context ctx_skein; + sph_groestl256_context ctx_groestl; + + sph_blake256_init(&ctx_blake); + sph_blake256(&ctx_blake, input, 80); + sph_blake256_close(&ctx_blake, hashA); + + sph_keccak256_init(&ctx_keccak); + sph_keccak256(&ctx_keccak, hashA, 32); + sph_keccak256_close(&ctx_keccak, hashB); + + LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8); + + sph_cubehash256_init(&ctx_cubehash); + sph_cubehash256(&ctx_cubehash, hashA, 32); + sph_cubehash256_close(&ctx_cubehash, hashB); + + LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8); + + sph_skein256_init(&ctx_skein); + sph_skein256(&ctx_skein, hashA, 32); + sph_skein256_close(&ctx_skein, hashB); + + sph_groestl256_init(&ctx_groestl); + sph_groestl256(&ctx_groestl, hashB, 32); + sph_groestl256_close(&ctx_groestl, hashA); + + memcpy(output, hashA, 32); +} diff --git a/stratum/algos/allium.h b/stratum/algos/allium.h new file mode 100644 index 000000000..3705161f7 --- /dev/null +++ b/stratum/algos/allium.h @@ -0,0 +1,16 @@ +#ifndef ALLIUM_H +#define ALLIUM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void allium_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/ar2/argon2.c b/stratum/algos/ar2/argon2.c index 58ef79faf..665f8b7f2 100644 --- a/stratum/algos/ar2/argon2.c +++ b/stratum/algos/ar2/argon2.c @@ -1,279 +1,378 @@ /* - * Argon2 source code package + * Argon2 reference source code package - reference C implementations * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. */ -#include #include +#include #include -#include #include "argon2.h" -#include "cores.h" - -/* Error messages */ -static const char *Argon2_ErrorMessage[] = { - /*{ARGON2_OK, */ "OK", - /*}, - - {ARGON2_OUTPUT_PTR_NULL, */ "Output pointer is NULL", - /*}, - -{ARGON2_OUTPUT_TOO_SHORT, */ "Output is too short", - /*}, -{ARGON2_OUTPUT_TOO_LONG, */ "Output is too long", - /*}, - -{ARGON2_PWD_TOO_SHORT, */ "Password is too short", - /*}, -{ARGON2_PWD_TOO_LONG, */ "Password is too long", - /*}, - -{ARGON2_SALT_TOO_SHORT, */ "Salt is too short", - /*}, -{ARGON2_SALT_TOO_LONG, */ "Salt is too long", - /*}, - -{ARGON2_AD_TOO_SHORT, */ "Associated data is too short", - /*}, -{ARGON2_AD_TOO_LONG, */ "Associated date is too long", - /*}, - -{ARGON2_SECRET_TOO_SHORT, */ "Secret is too short", - /*}, -{ARGON2_SECRET_TOO_LONG, */ "Secret is too long", - /*}, - -{ARGON2_TIME_TOO_SMALL, */ "Time cost is too small", - /*}, -{ARGON2_TIME_TOO_LARGE, */ "Time cost is too large", - /*}, - -{ARGON2_MEMORY_TOO_LITTLE, */ "Memory cost is too small", - /*}, -{ARGON2_MEMORY_TOO_MUCH, */ "Memory cost is too large", - /*}, - -{ARGON2_LANES_TOO_FEW, */ "Too few lanes", - /*}, -{ARGON2_LANES_TOO_MANY, */ "Too many lanes", - /*}, - -{ARGON2_PWD_PTR_MISMATCH, */ "Password pointer is NULL, but password length is not 0", - /*}, -{ARGON2_SALT_PTR_MISMATCH, */ "Salt pointer is NULL, but salt length is not 0", - /*}, -{ARGON2_SECRET_PTR_MISMATCH, */ "Secret pointer is NULL, but secret length is not 0", - /*}, -{ARGON2_AD_PTR_MISMATCH, */ "Associated data pointer is NULL, but ad length is not 0", - /*}, - -{ARGON2_MEMORY_ALLOCATION_ERROR, */ "Memory allocation error", - /*}, - -{ARGON2_FREE_MEMORY_CBK_NULL, */ "The free memory callback is NULL", - /*}, -{ARGON2_ALLOCATE_MEMORY_CBK_NULL, */ "The allocate memory callback is NULL", - /*}, - -{ARGON2_INCORRECT_PARAMETER, */ "Argon2_Context context is NULL", - /*}, -{ARGON2_INCORRECT_TYPE, */ "There is no such version of Argon2", - /*}, - -{ARGON2_OUT_PTR_MISMATCH, */ "Output pointer mismatch", - /*}, - -{ARGON2_THREADS_TOO_FEW, */ "Not enough threads", - /*}, -{ARGON2_THREADS_TOO_MANY, */ "Too many threads", - /*}, -{ARGON2_MISSING_ARGS, */ "Missing arguments", /*},*/ -}; - -int argon2d(argon2_context *context) { return argon2_core(context, Argon2_d); } - -int argon2i(argon2_context *context) { return argon2_core(context, Argon2_i); } - -int verify_d(argon2_context *context, const char *hash) { - int result; - /*if (0 == context->outlen || NULL == hash) { - return ARGON2_OUT_PTR_MISMATCH; - }*/ +#include "encoding.h" +#include "core.h" + +const char *argon2_type2string(argon2_type type, int uppercase) { + switch (type) { + case Argon2_d: + return uppercase ? "Argon2d" : "argon2d"; + } + + return NULL; +} + +int argon2_ctx(argon2_context *context, argon2_type type) { + /* 1. Validate all inputs */ + int result = validate_inputs(context); + uint32_t memory_blocks, segment_length; + argon2_instance_t instance; + + if (ARGON2_OK != result) { + return result; + } + + if (Argon2_d != type) { + return ARGON2_INCORRECT_TYPE; + } + + /* 2. Align memory size */ + /* Minimum memory_blocks = 8L blocks, where L is the number of lanes */ + memory_blocks = context->m_cost; + + if (memory_blocks < 2 * ARGON2_SYNC_POINTS * context->lanes) { + memory_blocks = 2 * ARGON2_SYNC_POINTS * context->lanes; + } + + segment_length = memory_blocks / (context->lanes * ARGON2_SYNC_POINTS); + /* Ensure that all segments have equal length */ + memory_blocks = segment_length * (context->lanes * ARGON2_SYNC_POINTS); + + instance.memory = NULL; + instance.passes = context->t_cost; + instance.memory_blocks = memory_blocks; + instance.segment_length = segment_length; + instance.lane_length = segment_length * ARGON2_SYNC_POINTS; + instance.lanes = context->lanes; + instance.threads = context->threads; + instance.type = type; + + if (instance.threads > instance.lanes) { + instance.threads = instance.lanes; + } - result = argon2_core(context, Argon2_d); + /* 3. Initialization: Hashing inputs, allocating memory, filling first + * blocks + */ + result = initialize(&instance, context); if (ARGON2_OK != result) { return result; } - return 0 == memcmp(hash, context->out, 32); + /* 4. Filling memory */ + result = fill_memory_blocks(&instance); + + if (ARGON2_OK != result) { + return result; + } + /* 5. Finalization */ + finalize(context, &instance); + + return ARGON2_OK; } -const char *error_message(int error_code) { - enum { - /* Make sure---at compile time---that the enum size matches the array - size */ - ERROR_STRING_CHECK = - 1 / - !!((sizeof(Argon2_ErrorMessage) / sizeof(Argon2_ErrorMessage[0])) == - ARGON2_ERROR_CODES_LENGTH) - }; - if (error_code < ARGON2_ERROR_CODES_LENGTH) { - return Argon2_ErrorMessage[(argon2_error_codes)error_code]; +int argon2_hash(const uint32_t t_cost, const uint32_t m_cost, + const uint32_t parallelism, const void *pwd, + const size_t pwdlen, const void *salt, const size_t saltlen, + void *hash, const size_t hashlen, char *encoded, + const size_t encodedlen, argon2_type type){ + + argon2_context context; + int result; + uint8_t *out; + + if (pwdlen > ARGON2_MAX_PWD_LENGTH) { + return ARGON2_PWD_TOO_LONG; + } + + if (saltlen > ARGON2_MAX_SALT_LENGTH) { + return ARGON2_SALT_TOO_LONG; + } + + if (hashlen > ARGON2_MAX_OUTLEN) { + return ARGON2_OUTPUT_TOO_LONG; + } + + if (hashlen < ARGON2_MIN_OUTLEN) { + return ARGON2_OUTPUT_TOO_SHORT; + } + + out = malloc(hashlen); + if (!out) { + return ARGON2_MEMORY_ALLOCATION_ERROR; + } + + context.out = (uint8_t *)out; + context.outlen = (uint32_t)hashlen; + context.pwd = CONST_CAST(uint8_t *)pwd; + context.pwdlen = (uint32_t)pwdlen; + context.salt = CONST_CAST(uint8_t *)salt; + context.saltlen = (uint32_t)saltlen; + context.secret = NULL; + context.secretlen = 0; + context.ad = NULL; + context.adlen = 0; + context.t_cost = t_cost; + context.m_cost = m_cost; + context.lanes = parallelism; + context.threads = parallelism; + context.allocate_cbk = NULL; + context.free_cbk = NULL; + context.flags = ARGON2_DEFAULT_FLAGS; + + result = argon2_ctx(&context, type); + + if (result != ARGON2_OK) { + clear_internal_memory(out, hashlen); + free(out); + return result; + } + + /* if raw hash requested, write it */ + if (hash) { + memcpy(hash, out, hashlen); + } + + /* if encoding requested, write it */ + if (encoded && encodedlen) { + if (encode_string(encoded, encodedlen, &context, type) != ARGON2_OK) { + clear_internal_memory(out, hashlen); /* wipe buffers if error */ + clear_internal_memory(encoded, encodedlen); + free(out); + return ARGON2_ENCODING_FAIL; + } } - return "Unknown error code."; + clear_internal_memory(out, hashlen); + free(out); + + return ARGON2_OK; } -/* encoding/decoding helpers */ +int argon2d_hash_encoded(const uint32_t t_cost, const uint32_t m_cost, + const uint32_t parallelism, const void *pwd, + const size_t pwdlen, const void *salt, + const size_t saltlen, const size_t hashlen, + char *encoded, const size_t encodedlen) { -/* - * Some macros for constant-time comparisons. These work over values in - * the 0..255 range. Returned value is 0x00 on "false", 0xFF on "true". - */ -#define EQ(x, y) ((((0U - ((unsigned)(x) ^ (unsigned)(y))) >> 8) & 0xFF) ^ 0xFF) -#define GT(x, y) ((((unsigned)(y) - (unsigned)(x)) >> 8) & 0xFF) -#define GE(x, y) (GT(y, x) ^ 0xFF) -#define LT(x, y) GT(y, x) -#define LE(x, y) GE(y, x) + return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, + NULL, hashlen, encoded, encodedlen, Argon2_d); +} -/* - * Convert value x (0..63) to corresponding Base64 character. - */ -static int b64_byte_to_char(unsigned x) { - return (LT(x, 26) & (x + 'A')) | - (GE(x, 26) & LT(x, 52) & (x + ('a' - 26))) | - (GE(x, 52) & LT(x, 62) & (x + ('0' - 52))) | (EQ(x, 62) & '+') | - (EQ(x, 63) & '/'); +int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost, + const uint32_t parallelism, const void *pwd, + const size_t pwdlen, const void *salt, + const size_t saltlen, void *hash, const size_t hashlen) { + + return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, + hash, hashlen, NULL, 0, Argon2_d); } -/* - * Convert some bytes to Base64. 'dst_len' is the length (in characters) - * of the output buffer 'dst'; if that buffer is not large enough to - * receive the result (including the terminating 0), then (size_t)-1 - * is returned. Otherwise, the zero-terminated Base64 string is written - * in the buffer, and the output length (counted WITHOUT the terminating - * zero) is returned. - */ -static size_t to_base64(char *dst, size_t dst_len, const void *src) { - size_t olen; - const unsigned char *buf; - unsigned acc, acc_len; - - olen = 43; - /*switch (32 % 3) { - case 2: - olen++;*/ - /* fall through */ - /*case 1: - olen += 2; - break; - }*/ - if (dst_len <= olen) { - return (size_t)-1; +static int argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) { + size_t i; + uint8_t d = 0U; + + for (i = 0U; i < len; i++) { + d |= b1[i] ^ b2[i]; } - acc = 0; - acc_len = 0; - buf = (const unsigned char *)src; - size_t src_len = 32; - while (src_len-- > 0) { - acc = (acc << 8) + (*buf++); - acc_len += 8; - while (acc_len >= 6) { - acc_len -= 6; - *dst++ = b64_byte_to_char((acc >> acc_len) & 0x3F); - } + return (int)((1 & ((d - 1) >> 8)) - 1); +} + +int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen, + argon2_type type) { + + argon2_context ctx; + uint8_t *desired_result = NULL; + + int ret = ARGON2_OK; + + size_t encoded_len; + uint32_t max_field_len; + + if (pwdlen > ARGON2_MAX_PWD_LENGTH) { + return ARGON2_PWD_TOO_LONG; + } + + if (encoded == NULL) { + return ARGON2_DECODING_FAIL; + } + + encoded_len = strlen(encoded); + if (encoded_len > UINT32_MAX) { + return ARGON2_DECODING_FAIL; + } + + /* No field can be longer than the encoded length */ + max_field_len = (uint32_t)encoded_len; + + ctx.saltlen = max_field_len; + ctx.outlen = max_field_len; + + ctx.salt = malloc(ctx.saltlen); + ctx.out = malloc(ctx.outlen); + if (!ctx.salt || !ctx.out) { + ret = ARGON2_MEMORY_ALLOCATION_ERROR; + goto fail; + } + + ctx.pwd = (uint8_t *)pwd; + ctx.pwdlen = (uint32_t)pwdlen; + + ret = decode_string(&ctx, encoded, type); + if (ret != ARGON2_OK) { + goto fail; } - if (acc_len > 0) { - *dst++ = b64_byte_to_char((acc << (6 - acc_len)) & 0x3F); + + /* Set aside the desired result, and get a new buffer. */ + desired_result = ctx.out; + ctx.out = malloc(ctx.outlen); + if (!ctx.out) { + ret = ARGON2_MEMORY_ALLOCATION_ERROR; + goto fail; } - *dst++ = 0; - return olen; + + ret = argon2_verify_ctx(&ctx, (char *)desired_result, type); + if (ret != ARGON2_OK) { + goto fail; + } + +fail: + free(ctx.salt); + free(ctx.out); + free(desired_result); + + return ret; } -/* ==================================================================== */ -/* - * Code specific to Argon2i. - * - * The code below applies the following format: - * - * $argon2i$m=,t=,p=[,keyid=][,data=][$[$]] - * - * where is a decimal integer (positive, fits in an 'unsigned long') - * and is Base64-encoded data (no '=' padding characters, no newline - * or whitespace). The "keyid" is a binary identifier for a key (up to 8 - * bytes); "data" is associated data (up to 32 bytes). When the 'keyid' - * (resp. the 'data') is empty, then it is ommitted from the output. - * - * The last two binary chunks (encoded in Base64) are, in that order, - * the salt and the output. Both are optional, but you cannot have an - * output without a salt. The binary salt length is between 8 and 48 bytes. - * The output length is always exactly 32 bytes. - */ +int argon2d_verify(const char *encoded, const void *pwd, const size_t pwdlen) { -int encode_string(char *dst, size_t dst_len, argon2_context *ctx) { -#define SS(str) \ - do { \ - size_t pp_len = strlen(str); \ - if (pp_len >= dst_len) { \ - return 0; \ - } \ - memcpy(dst, str, pp_len + 1); \ - dst += pp_len; \ - dst_len -= pp_len; \ - } while (0) - -#define SX(x) \ - do { \ - char tmp[30]; \ - sprintf(tmp, "%lu", (unsigned long)(x)); \ - SS(tmp); \ - } while (0); - -#define SB(buf) \ - do { \ - size_t sb_len = to_base64(dst, dst_len, buf); \ - if (sb_len == (size_t)-1) { \ - return 0; \ - } \ - dst += sb_len; \ - dst_len -= sb_len; \ - } while (0); - - SS("$argon2i$m="); - SX(16); - SS(",t="); - SX(2); - SS(",p="); - SX(1); - - /*if (ctx->adlen > 0) { - SS(",data="); - SB(ctx->ad, ctx->adlen); - }*/ - - /*if (ctx->saltlen == 0) - return 1;*/ - - SS("$"); - SB(ctx->salt); - - /*if (ctx->outlen32 == 0) - return 1;*/ - - SS("$"); - SB(ctx->out); - return 1; - -#undef SS -#undef SX -#undef SB + return argon2_verify(encoded, pwd, pwdlen, Argon2_d); } + +int argon2d_ctx(argon2_context *context) { + return argon2_ctx(context, Argon2_d); +} + +int argon2_verify_ctx(argon2_context *context, const char *hash, + argon2_type type) { + int ret = argon2_ctx(context, type); + if (ret != ARGON2_OK) { + return ret; + } + + if (argon2_compare((uint8_t *)hash, context->out, context->outlen)) { + return ARGON2_VERIFY_MISMATCH; + } + + return ARGON2_OK; +} + +int argon2d_verify_ctx(argon2_context *context, const char *hash) { + return argon2_verify_ctx(context, hash, Argon2_d); +} + +const char *argon2_error_message(int error_code) { + switch (error_code) { + case ARGON2_OK: + return "OK"; + case ARGON2_OUTPUT_PTR_NULL: + return "Output pointer is NULL"; + case ARGON2_OUTPUT_TOO_SHORT: + return "Output is too short"; + case ARGON2_OUTPUT_TOO_LONG: + return "Output is too long"; + case ARGON2_PWD_TOO_SHORT: + return "Password is too short"; + case ARGON2_PWD_TOO_LONG: + return "Password is too long"; + case ARGON2_SALT_TOO_SHORT: + return "Salt is too short"; + case ARGON2_SALT_TOO_LONG: + return "Salt is too long"; + case ARGON2_AD_TOO_SHORT: + return "Associated data is too short"; + case ARGON2_AD_TOO_LONG: + return "Associated data is too long"; + case ARGON2_SECRET_TOO_SHORT: + return "Secret is too short"; + case ARGON2_SECRET_TOO_LONG: + return "Secret is too long"; + case ARGON2_TIME_TOO_SMALL: + return "Time cost is too small"; + case ARGON2_TIME_TOO_LARGE: + return "Time cost is too large"; + case ARGON2_MEMORY_TOO_LITTLE: + return "Memory cost is too small"; + case ARGON2_MEMORY_TOO_MUCH: + return "Memory cost is too large"; + case ARGON2_LANES_TOO_FEW: + return "Too few lanes"; + case ARGON2_LANES_TOO_MANY: + return "Too many lanes"; + case ARGON2_PWD_PTR_MISMATCH: + return "Password pointer is NULL, but password length is not 0"; + case ARGON2_SALT_PTR_MISMATCH: + return "Salt pointer is NULL, but salt length is not 0"; + case ARGON2_SECRET_PTR_MISMATCH: + return "Secret pointer is NULL, but secret length is not 0"; + case ARGON2_AD_PTR_MISMATCH: + return "Associated data pointer is NULL, but ad length is not 0"; + case ARGON2_MEMORY_ALLOCATION_ERROR: + return "Memory allocation error"; + case ARGON2_FREE_MEMORY_CBK_NULL: + return "The free memory callback is NULL"; + case ARGON2_ALLOCATE_MEMORY_CBK_NULL: + return "The allocate memory callback is NULL"; + case ARGON2_INCORRECT_PARAMETER: + return "Argon2_Context context is NULL"; + case ARGON2_INCORRECT_TYPE: + return "There is no such version of Argon2"; + case ARGON2_OUT_PTR_MISMATCH: + return "Output pointer mismatch"; + case ARGON2_THREADS_TOO_FEW: + return "Not enough threads"; + case ARGON2_THREADS_TOO_MANY: + return "Too many threads"; + case ARGON2_MISSING_ARGS: + return "Missing arguments"; + case ARGON2_ENCODING_FAIL: + return "Encoding failed"; + case ARGON2_DECODING_FAIL: + return "Decoding failed"; + case ARGON2_THREAD_FAIL: + return "Threading failure"; + case ARGON2_DECODING_LENGTH_FAIL: + return "Some of encoded parameters are too long or too short"; + case ARGON2_VERIFY_MISMATCH: + return "The password does not match the supplied hash"; + default: + return "Unknown error code"; + } +} + +size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, uint32_t parallelism, + uint32_t saltlen, uint32_t hashlen, argon2_type type) { + return strlen("$$v=$m=,t=,p=$$") + strlen(argon2_type2string(type, 0)) + + numlen(t_cost) + numlen(m_cost) + numlen(parallelism) + + b64len(saltlen) + b64len(hashlen); +} \ No newline at end of file diff --git a/stratum/algos/ar2/argon2.h b/stratum/algos/ar2/argon2.h index cecb2c7c9..35e524303 100644 --- a/stratum/algos/ar2/argon2.h +++ b/stratum/algos/ar2/argon2.h @@ -1,18 +1,27 @@ /* - * Argon2 source code package + * Argon2 reference source code package - reference C implementations * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. */ + #ifndef ARGON2_H #define ARGON2_H +#if defined(HAVE_CONFIG_H) +#include "config/dynamic-config.h" +#endif + #include #include #include @@ -21,8 +30,18 @@ extern "C" { #endif -/*************************Argon2 input parameter - * restrictions**************************************************/ +/* Symbols visibility control */ +#ifdef A2_VISCTL +#define ARGON2_PUBLIC __attribute__((visibility("default"))) +#elif _MSC_VER +#define ARGON2_PUBLIC __declspec(dllexport) +#else +#define ARGON2_PUBLIC +#endif + +/* + * Argon2 input parameter restrictions + */ /* Minimum and maximum number of lanes (degree of parallelism) */ #define ARGON2_MIN_LANES UINT32_C(1) @@ -43,8 +62,7 @@ extern "C" { #define ARGON2_MIN_MEMORY (2 * ARGON2_SYNC_POINTS) /* 2 blocks per slice */ #define ARGON2_MIN(a, b) ((a) < (b) ? (a) : (b)) -/* Max memory size is half the addressing space, topping at 2^32 blocks (4 TB) - */ +/* Max memory size is addressing-space/2, topping at 2^32 blocks (4 TB) */ #define ARGON2_MAX_MEMORY_BITS \ ARGON2_MIN(UINT32_C(32), (sizeof(void *) * CHAR_BIT - 10 - 1)) #define ARGON2_MAX_MEMORY \ @@ -70,65 +88,74 @@ extern "C" { #define ARGON2_MIN_SECRET UINT32_C(0) #define ARGON2_MAX_SECRET UINT32_C(0xFFFFFFFF) +/* Flags to determine which fields are securely wiped (default = no wipe). */ +#define ARGON2_DEFAULT_FLAGS UINT32_C(0) #define ARGON2_FLAG_CLEAR_PASSWORD (UINT32_C(1) << 0) #define ARGON2_FLAG_CLEAR_SECRET (UINT32_C(1) << 1) -#define ARGON2_FLAG_CLEAR_MEMORY (UINT32_C(1) << 2) -#define ARGON2_DEFAULT_FLAGS \ - (ARGON2_FLAG_CLEAR_PASSWORD | ARGON2_FLAG_CLEAR_MEMORY) + +/* Global flag to determine if we are wiping internal memory buffers. This flag + * is defined in core.c and deafults to 1 (wipe internal memory). */ +extern int FLAG_clear_internal_memory; /* Error codes */ typedef enum Argon2_ErrorCodes { ARGON2_OK = 0, - ARGON2_OUTPUT_PTR_NULL = 1, + ARGON2_OUTPUT_PTR_NULL = -1, + + ARGON2_OUTPUT_TOO_SHORT = -2, + ARGON2_OUTPUT_TOO_LONG = -3, + + ARGON2_PWD_TOO_SHORT = -4, + ARGON2_PWD_TOO_LONG = -5, + + ARGON2_SALT_TOO_SHORT = -6, + ARGON2_SALT_TOO_LONG = -7, + + ARGON2_AD_TOO_SHORT = -8, + ARGON2_AD_TOO_LONG = -9, - ARGON2_OUTPUT_TOO_SHORT = 2, - ARGON2_OUTPUT_TOO_LONG = 3, + ARGON2_SECRET_TOO_SHORT = -10, + ARGON2_SECRET_TOO_LONG = -11, - ARGON2_PWD_TOO_SHORT = 4, - ARGON2_PWD_TOO_LONG = 5, + ARGON2_TIME_TOO_SMALL = -12, + ARGON2_TIME_TOO_LARGE = -13, - ARGON2_SALT_TOO_SHORT = 6, - ARGON2_SALT_TOO_LONG = 7, + ARGON2_MEMORY_TOO_LITTLE = -14, + ARGON2_MEMORY_TOO_MUCH = -15, - ARGON2_AD_TOO_SHORT = 8, - ARGON2_AD_TOO_LONG = 9, + ARGON2_LANES_TOO_FEW = -16, + ARGON2_LANES_TOO_MANY = -17, - ARGON2_SECRET_TOO_SHORT = 10, - ARGON2_SECRET_TOO_LONG = 11, + ARGON2_PWD_PTR_MISMATCH = -18, /* NULL ptr with non-zero length */ + ARGON2_SALT_PTR_MISMATCH = -19, /* NULL ptr with non-zero length */ + ARGON2_SECRET_PTR_MISMATCH = -20, /* NULL ptr with non-zero length */ + ARGON2_AD_PTR_MISMATCH = -21, /* NULL ptr with non-zero length */ - ARGON2_TIME_TOO_SMALL = 12, - ARGON2_TIME_TOO_LARGE = 13, + ARGON2_MEMORY_ALLOCATION_ERROR = -22, - ARGON2_MEMORY_TOO_LITTLE = 14, - ARGON2_MEMORY_TOO_MUCH = 15, + ARGON2_FREE_MEMORY_CBK_NULL = -23, + ARGON2_ALLOCATE_MEMORY_CBK_NULL = -24, - ARGON2_LANES_TOO_FEW = 16, - ARGON2_LANES_TOO_MANY = 17, + ARGON2_INCORRECT_PARAMETER = -25, + ARGON2_INCORRECT_TYPE = -26, - ARGON2_PWD_PTR_MISMATCH = 18, /* NULL ptr with non-zero length */ - ARGON2_SALT_PTR_MISMATCH = 19, /* NULL ptr with non-zero length */ - ARGON2_SECRET_PTR_MISMATCH = 20, /* NULL ptr with non-zero length */ - ARGON2_AD_PTR_MISMATCH = 21, /* NULL ptr with non-zero length */ + ARGON2_OUT_PTR_MISMATCH = -27, - ARGON2_MEMORY_ALLOCATION_ERROR = 22, + ARGON2_THREADS_TOO_FEW = -28, + ARGON2_THREADS_TOO_MANY = -29, - ARGON2_FREE_MEMORY_CBK_NULL = 23, - ARGON2_ALLOCATE_MEMORY_CBK_NULL = 24, + ARGON2_MISSING_ARGS = -30, - ARGON2_INCORRECT_PARAMETER = 25, - ARGON2_INCORRECT_TYPE = 26, + ARGON2_ENCODING_FAIL = -31, - ARGON2_OUT_PTR_MISMATCH = 27, + ARGON2_DECODING_FAIL = -32, - ARGON2_THREADS_TOO_FEW = 28, - ARGON2_THREADS_TOO_MANY = 29, + ARGON2_THREAD_FAIL = -33, - ARGON2_MISSING_ARGS = 30, + ARGON2_DECODING_LENGTH_FAIL = -34, - ARGON2_ERROR_CODES_LENGTH /* Do NOT remove; Do NOT add error codes after - this - error code */ + ARGON2_VERIFY_MISMATCH = -35 } argon2_error_codes; /* Memory allocator types --- for external allocation */ @@ -138,155 +165,173 @@ typedef void (*deallocate_fptr)(uint8_t *memory, size_t bytes_to_allocate); /* Argon2 external data structures */ /* - *****Context: structure to hold Argon2 inputs: - * output array and its length, - * password and its length, - * salt and its length, - * secret and its length, - * associated data and its length, - * number of passes, amount of used memory (in KBytes, can be rounded up a bit) - * number of parallel threads that will be run. + ***** + * Context: structure to hold Argon2 inputs: + * output array and its length, + * password and its length, + * salt and its length, + * secret and its length, + * associated data and its length, + * number of passes, amount of used memory (in KBytes, can be rounded up a bit) + * number of parallel threads that will be run. * All the parameters above affect the output hash value. * Additionally, two function pointers can be provided to allocate and - deallocate the memory (if NULL, memory will be allocated internally). + * deallocate the memory (if NULL, memory will be allocated internally). * Also, three flags indicate whether to erase password, secret as soon as they - are pre-hashed (and thus not needed anymore), and the entire memory - **************************** - Simplest situation: you have output array out[8], password is stored in - pwd[32], salt is stored in salt[16], you do not have keys nor associated data. - You need to spend 1 GB of RAM and you run 5 passes of Argon2d with 4 parallel - lanes. - You want to erase the password, but you're OK with last pass not being erased. - You want to use the default memory allocator. + * are pre-hashed (and thus not needed anymore), and the entire memory + ***** + * Simplest situation: you have output array out[8], password is stored in + * pwd[32], salt is stored in salt[16], you do not have keys nor associated + * data. You need to spend 1 GB of RAM and you run 5 passes of Argon2d with + * 4 parallel lanes. + * You want to erase the password, but you're OK with last pass not being + * erased. You want to use the default memory allocator. + * Then you initialize: + Argon2_Context(out,8,pwd,32,salt,16,NULL,0,NULL,0,5,1<<20,4,4,NULL,NULL,true,false,false,false) */ typedef struct Argon2_Context { uint8_t *out; /* output array */ + uint32_t outlen; /* digest length */ + uint8_t *pwd; /* password array */ + uint32_t pwdlen; /* password length */ + uint8_t *salt; /* salt array */ - /*uint8_t *secret;*/ /* key array */ - /*uint8_t *ad;*/ /* associated data array */ + uint32_t saltlen; /* salt length */ + + uint8_t *secret; /* key array */ + uint32_t secretlen; /* key length */ + + uint8_t *ad; /* associated data array */ + uint32_t adlen; /* associated data length */ + + uint32_t t_cost; /* number of passes */ + uint32_t m_cost; /* amount of memory requested (KB) */ + uint32_t lanes; /* number of lanes */ + uint32_t threads; /* maximum number of threads */ allocate_fptr allocate_cbk; /* pointer to memory allocator */ deallocate_fptr free_cbk; /* pointer to memory deallocator */ - /*uint32_t outlen;*/ /* digest length */ - uint32_t pwdlen; /* password length */ - /*uint32_t saltlen;*/ /* salt length */ - /*uint32_t secretlen;*/ /* key length */ - /*uint32_t adlen;*/ /* associated data length */ - /*uint32_t t_cost;*/ /* number of passes */ - /*uint32_t m_cost;*/ /* amount of memory requested (KB) */ - /*uint32_t lanes;*/ /* number of lanes */ - /*uint32_t threads;*/ /* maximum number of threads */ - /*uint32_t flags;*/ /* array of bool options */ - + uint32_t flags; /* array of bool options */ } argon2_context; -/** - * Function to hash the inputs in the memory-hard fashion (uses Argon2i) - * @param out Pointer to the memory where the hash digest will be written - * @param outlen Digest length in bytes - * @param in Pointer to the input (password) - * @param inlen Input length in bytes - * @param salt Pointer to the salt - * @param saltlen Salt length in bytes - * @pre @a out must have at least @a outlen bytes allocated - * @pre @a in must be at least @inlen bytes long - * @pre @a saltlen must be at least @saltlen bytes long - * @return Zero if successful, 1 otherwise. - */ -/*int hash_argon2i(void *out, size_t outlen, const void *in, size_t inlen, - const void *salt, size_t saltlen, unsigned int t_cost, - unsigned int m_cost);*/ - -/* same for argon2d */ -/*int hash_argon2d(void *out, size_t outlen, const void *in, size_t inlen, - const void *salt, size_t saltlen, unsigned int t_cost, - unsigned int m_cost);*/ +/* Argon2 primitive type */ +typedef enum Argon2_type { + Argon2_d = 0 +} argon2_type; /* - * **************Argon2d: Version of Argon2 that picks memory blocks depending - * on the password and salt. Only for side-channel-free - * environment!!*************** - * @param context Pointer to current Argon2 context - * @return Zero if successful, a non zero error code otherwise + * Function that gives the string representation of an argon2_type. + * @param type The argon2_type that we want the string for + * @param uppercase Whether the string should have the first letter uppercase + * @return NULL if invalid type, otherwise the string representation. */ -int argon2d(argon2_context *context); +ARGON2_PUBLIC const char *argon2_type2string(argon2_type type, int uppercase); /* - * * **************Argon2i: Version of Argon2 that picks memory blocks - *independent on the password and salt. Good for side-channels, - ******************* but worse w.r.t. tradeoff attacks if - *******************only one pass is used*************** - * @param context Pointer to current Argon2 context - * @return Zero if successful, a non zero error code otherwise + * Function that performs memory-hard hashing with certain degree of parallelism + * @param context Pointer to the Argon2 internal structure + * @return Error code if smth is wrong, ARGON2_OK otherwise */ -int argon2i(argon2_context *context); +ARGON2_PUBLIC int argon2_ctx(argon2_context *context, argon2_type type); -/* - * * **************Argon2di: Reserved name*************** - * @param context Pointer to current Argon2 context - * @return Zero if successful, a non zero error code otherwise +/** + * Hashes a password with Argon2i, producing a raw hash by allocating memory at + * @hash + * @param t_cost Number of iterations + * @param m_cost Sets memory usage to m_cost kibibytes + * @param parallelism Number of threads and compute lanes + * @param pwd Pointer to password + * @param pwdlen Password size in bytes + * @param salt Pointer to salt + * @param saltlen Salt size in bytes + * @param hash Buffer where to write the raw hash - updated by the function + * @param hashlen Desired length of the hash in bytes + * @pre Different parallelism levels will give different results + * @pre Returns ARGON2_OK if successful */ -int argon2di(argon2_context *context); +ARGON2_PUBLIC int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost, + const uint32_t parallelism, const void *pwd, + const size_t pwdlen, const void *salt, + const size_t saltlen, void *hash, + const size_t hashlen); + +ARGON2_PUBLIC int argon2d_hash_encoded(const uint32_t t_cost, + const uint32_t m_cost, + const uint32_t parallelism, + const void *pwd, const size_t pwdlen, + const void *salt, const size_t saltlen, + const size_t hashlen, char *encoded, + const size_t encodedlen); + +/* generic function underlying the above ones */ +ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost, + const uint32_t parallelism, const void *pwd, + const size_t pwdlen, const void *salt, + const size_t saltlen, void *hash, + const size_t hashlen, char *encoded, + const size_t encodedlen, argon2_type type); -/* - * * **************Argon2ds: Argon2d hardened against GPU attacks, 20% - * slower*************** - * @param context Pointer to current Argon2 context - * @return Zero if successful, a non zero error code otherwise +/** + * Verifies a password against an encoded string + * Encoded string is restricted as in validate_inputs() + * @param encoded String encoding parameters, salt, hash + * @param pwd Pointer to password + * @pre Returns ARGON2_OK if successful */ -int argon2ds(argon2_context *context); +ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd, + const size_t pwdlen); -/* - * * **************Argon2id: First half-pass over memory is - *password-independent, the rest are password-dependent - ********************OK against side channels: they reduce to 1/2-pass - *Argon2i*************** +/* generic function underlying the above ones */ +ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, + const size_t pwdlen, argon2_type type); + +/** + * Argon2d: Version of Argon2 that picks memory blocks depending + * on the password and salt. Only for side-channel-free + * environment!! + ***** * @param context Pointer to current Argon2 context * @return Zero if successful, a non zero error code otherwise */ -int argon2id(argon2_context *context); +ARGON2_PUBLIC int argon2d_ctx(argon2_context *context); -/* +/** * Verify if a given password is correct for Argon2d hashing * @param context Pointer to current Argon2 context * @param hash The password hash to verify. The length of the hash is * specified by the context outlen member * @return Zero if successful, a non zero error code otherwise */ -int verify_d(argon2_context *context, const char *hash); +ARGON2_PUBLIC int argon2d_verify_ctx(argon2_context *context, const char *hash); -/* +/* generic function underlying the above ones */ +ARGON2_PUBLIC int argon2_verify_ctx(argon2_context *context, const char *hash, + argon2_type type); + +/** * Get the associated error message for given error code * @return The error message associated with the given error code */ -const char *error_message(int error_code); +ARGON2_PUBLIC const char *argon2_error_message(int error_code); -/* ==================================================================== */ -/* - * Code specific to Argon2i. - * - * The code below applies the following format: - * - * $argon2i$m=,t=,p=[,keyid=][,data=][$[$]] - * - * where is a decimal integer (positive, fits in an 'unsigned long') - * and is Base64-encoded data (no '=' padding characters, no newline - * or whitespace). The "keyid" is a binary identifier for a key (up to 8 - * bytes); "data" is associated data (up to 32 bytes). When the 'keyid' - * (resp. the 'data') is empty, then it is ommitted from the output. - * - * The last two binary chunks (encoded in Base64) are, in that order, - * the salt and the output. Both are optional, but you cannot have an - * output without a salt. The binary salt length is between 8 and 48 bytes. - * The output length is always exactly 32 bytes. +/** + * Returns the encoded hash length for the given input parameters + * @param t_cost Number of iterations + * @param m_cost Memory usage in kibibytes + * @param parallelism Number of threads; used to compute lanes + * @param saltlen Salt size in bytes + * @param hashlen Hash size in bytes + * @param type The argon2_type that we want the encoded length for + * @return The encoded hash length in bytes */ - -int encode_string(char *dst, size_t dst_len, argon2_context *ctx); +ARGON2_PUBLIC size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, + uint32_t parallelism, uint32_t saltlen, + uint32_t hashlen, argon2_type type); #if defined(__cplusplus) } #endif -#endif +#endif \ No newline at end of file diff --git a/stratum/algos/ar2/bench.c b/stratum/algos/ar2/bench.c deleted file mode 100644 index 7a6edc5d3..000000000 --- a/stratum/algos/ar2/bench.c +++ /dev/null @@ -1,111 +0,0 @@ -#include -#include -#include -#include -#include -#ifdef _MSC_VER -#include -#endif - -#include "argon2.h" - -static uint64_t rdtsc(void) { -#ifdef _MSC_VER - return __rdtsc(); -#else -#if defined(__amd64__) || defined(__x86_64__) - uint64_t rax, rdx; - __asm__ __volatile__("rdtsc" : "=a"(rax), "=d"(rdx) : :); - return (rdx << 32) | rax; -#elif defined(__i386__) || defined(__i386) || defined(__X86__) - uint64_t rax; - __asm__ __volatile__("rdtsc" : "=A"(rax) : :); - return rax; -#else -#error "Not implemented!" -#endif -#endif -} - -/* - * Benchmarks Argon2 with salt length 16, password length 16, t_cost 1, - and different m_cost and threads - */ -static void benchmark() { -#define BENCH_OUTLEN 16 -#define BENCH_INLEN 16 - const uint32_t inlen = BENCH_INLEN; - const unsigned outlen = BENCH_OUTLEN; - unsigned char out[BENCH_OUTLEN]; - unsigned char pwd_array[BENCH_INLEN]; - unsigned char salt_array[BENCH_INLEN]; -#undef BENCH_INLEN -#undef BENCH_OUTLEN - - uint32_t t_cost = 1; - uint32_t m_cost; - uint32_t thread_test[6] = {1, 2, 4, 6, 8, 16}; - - memset(pwd_array, 0, inlen); - memset(salt_array, 1, inlen); - - for (m_cost = (uint32_t)1 << 10; m_cost <= (uint32_t)1 << 22; m_cost *= 2) { - unsigned i; - for (i = 0; i < 6; ++i) { - argon2_context context; - uint32_t thread_n = thread_test[i]; - uint64_t stop_cycles, stop_cycles_i; - clock_t stop_time; - uint64_t delta_d, delta_i; - double mcycles_d, mcycles_i, run_time; - - clock_t start_time = clock(); - uint64_t start_cycles = rdtsc(); - - context.out = out; - context.outlen = outlen; - context.pwd = pwd_array; - context.pwdlen = inlen; - context.salt = salt_array; - context.saltlen = inlen; - context.secret = NULL; - context.secretlen = 0; - context.ad = NULL; - context.adlen = 0; - context.t_cost = t_cost; - context.m_cost = m_cost; - context.lanes = thread_n; - context.threads = thread_n; - context.allocate_cbk = NULL; - context.free_cbk = NULL; - context.flags = 0; - - argon2d(&context); - stop_cycles = rdtsc(); - argon2i(&context); - stop_cycles_i = rdtsc(); - stop_time = clock(); - - delta_d = (stop_cycles - start_cycles) / (m_cost); - delta_i = (stop_cycles_i - stop_cycles) / (m_cost); - mcycles_d = (double)(stop_cycles - start_cycles) / (1UL << 20); - mcycles_i = (double)(stop_cycles_i - stop_cycles) / (1UL << 20); - printf("Argon2d %d iterations %d MiB %d threads: %2.2f cpb %2.2f " - "Mcycles \n", - t_cost, m_cost >> 10, thread_n, (float)delta_d / 1024, - mcycles_d); - printf("Argon2i %d iterations %d MiB %d threads: %2.2f cpb %2.2f " - "Mcycles \n", - t_cost, m_cost >> 10, thread_n, (float)delta_i / 1024, - mcycles_i); - - run_time = ((double)stop_time - start_time) / (CLOCKS_PER_SEC); - printf("%2.4f seconds\n\n", run_time); - } - } -} - -int main() { - benchmark(); - return ARGON2_OK; -} diff --git a/stratum/algos/ar2/blake2/blamka-round-opt.h b/stratum/algos/ar2/blake2/blamka-round-opt.h deleted file mode 100644 index 690686d9e..000000000 --- a/stratum/algos/ar2/blake2/blamka-round-opt.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef BLAKE_ROUND_MKA_OPT_H -#define BLAKE_ROUND_MKA_OPT_H - -#include "blake2-impl.h" - -#if defined(_MSC_VER) -#include -#endif - -#include -#if defined(__XOP__) && (defined(__GNUC__) || defined(__clang__)) -#include -#endif - -#if !defined(__XOP__) -#if defined(__SSSE3__) -#define r16 \ - (_mm_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9)) -#define r24 \ - (_mm_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10)) -#define _mm_roti_epi64(x, c) \ - (-(c) == 32) \ - ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2, 3, 0, 1)) \ - : (-(c) == 24) \ - ? _mm_shuffle_epi8((x), r24) \ - : (-(c) == 16) \ - ? _mm_shuffle_epi8((x), r16) \ - : (-(c) == 63) \ - ? _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ - _mm_add_epi64((x), (x))) \ - : _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ - _mm_slli_epi64((x), 64 - (-(c)))) -#else /* defined(__SSE2__) */ -#define _mm_roti_epi64(r, c) \ - _mm_xor_si128(_mm_srli_epi64((r), -(c)), _mm_slli_epi64((r), 64 - (-(c)))) -#endif -#else -#endif - -static BLAKE2_INLINE __m128i fBlaMka(__m128i x, __m128i y) { - const __m128i z = _mm_mul_epu32(x, y); - return _mm_add_epi64(_mm_add_epi64(x, y), _mm_add_epi64(z, z)); -} - -#define G1(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - A0 = fBlaMka(A0, B0); \ - A1 = fBlaMka(A1, B1); \ - \ - D0 = _mm_xor_si128(D0, A0); \ - D1 = _mm_xor_si128(D1, A1); \ - \ - D0 = _mm_roti_epi64(D0, -32); \ - D1 = _mm_roti_epi64(D1, -32); \ - \ - C0 = fBlaMka(C0, D0); \ - C1 = fBlaMka(C1, D1); \ - \ - B0 = _mm_xor_si128(B0, C0); \ - B1 = _mm_xor_si128(B1, C1); \ - \ - B0 = _mm_roti_epi64(B0, -24); \ - B1 = _mm_roti_epi64(B1, -24); \ - } while ((void)0, 0) - -#define G2(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - A0 = fBlaMka(A0, B0); \ - A1 = fBlaMka(A1, B1); \ - \ - D0 = _mm_xor_si128(D0, A0); \ - D1 = _mm_xor_si128(D1, A1); \ - \ - D0 = _mm_roti_epi64(D0, -16); \ - D1 = _mm_roti_epi64(D1, -16); \ - \ - C0 = fBlaMka(C0, D0); \ - C1 = fBlaMka(C1, D1); \ - \ - B0 = _mm_xor_si128(B0, C0); \ - B1 = _mm_xor_si128(B1, C1); \ - \ - B0 = _mm_roti_epi64(B0, -63); \ - B1 = _mm_roti_epi64(B1, -63); \ - } while ((void)0, 0) - -#if defined(__SSSE3__) -#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0 = _mm_alignr_epi8(B1, B0, 8); \ - __m128i t1 = _mm_alignr_epi8(B0, B1, 8); \ - B0 = t0; \ - B1 = t1; \ - \ - t0 = C0; \ - C0 = C1; \ - C1 = t0; \ - \ - t0 = _mm_alignr_epi8(D1, D0, 8); \ - t1 = _mm_alignr_epi8(D0, D1, 8); \ - D0 = t1; \ - D1 = t0; \ - } while ((void)0, 0) - -#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0 = _mm_alignr_epi8(B0, B1, 8); \ - __m128i t1 = _mm_alignr_epi8(B1, B0, 8); \ - B0 = t0; \ - B1 = t1; \ - \ - t0 = C0; \ - C0 = C1; \ - C1 = t0; \ - \ - t0 = _mm_alignr_epi8(D0, D1, 8); \ - t1 = _mm_alignr_epi8(D1, D0, 8); \ - D0 = t1; \ - D1 = t0; \ - } while ((void)0, 0) -#else /* SSE2 */ -#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0 = D0; \ - __m128i t1 = B0; \ - D0 = C0; \ - C0 = C1; \ - C1 = D0; \ - D0 = _mm_unpackhi_epi64(D1, _mm_unpacklo_epi64(t0, t0)); \ - D1 = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(D1, D1)); \ - B0 = _mm_unpackhi_epi64(B0, _mm_unpacklo_epi64(B1, B1)); \ - B1 = _mm_unpackhi_epi64(B1, _mm_unpacklo_epi64(t1, t1)); \ - } while ((void)0, 0) - -#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0 = C0; \ - C0 = C1; \ - C1 = t0; \ - t0 = B0; \ - __m128i t1 = D0; \ - B0 = _mm_unpackhi_epi64(B1, _mm_unpacklo_epi64(B0, B0)); \ - B1 = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(B1, B1)); \ - D0 = _mm_unpackhi_epi64(D0, _mm_unpacklo_epi64(D1, D1)); \ - D1 = _mm_unpackhi_epi64(D1, _mm_unpacklo_epi64(t1, t1)); \ - } while ((void)0, 0) -#endif - -#define BLAKE2_ROUND(A0, A1, B0, B1, C0, C1, D0, D1) \ - do { \ - G1(A0, B0, C0, D0, A1, B1, C1, D1); \ - G2(A0, B0, C0, D0, A1, B1, C1, D1); \ - \ - DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ - \ - G1(A0, B0, C0, D0, A1, B1, C1, D1); \ - G2(A0, B0, C0, D0, A1, B1, C1, D1); \ - \ - UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ - } while ((void)0, 0) - -#endif diff --git a/stratum/algos/ar2/blake2b.c b/stratum/algos/ar2/blake2b.c deleted file mode 100644 index be691b153..000000000 --- a/stratum/algos/ar2/blake2b.c +++ /dev/null @@ -1,305 +0,0 @@ -#include -#include -#include -#include - -#include "blake2/blake2.h" -#include "blake2/blake2-impl.h" - -static const uint64_t blake2b_IV[8] = { - UINT64_C(0x6a09e667f3bcc908), UINT64_C(0xbb67ae8584caa73b), - UINT64_C(0x3c6ef372fe94f82b), UINT64_C(0xa54ff53a5f1d36f1), - UINT64_C(0x510e527fade682d1), UINT64_C(0x9b05688c2b3e6c1f), - UINT64_C(0x1f83d9abfb41bd6b), UINT64_C(0x5be0cd19137e2179) -}; - -static const unsigned int blake2b_sigma[12][16] = { - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3}, - {11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4}, - {7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8}, - {9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13}, - {2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9}, - {12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11}, - {13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10}, - {6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5}, - {10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3}, -}; - -static BLAKE2_INLINE void blake2b_set_lastnode(blake2b_state *S) { - S->f[1] = (uint64_t)-1; -} - -static BLAKE2_INLINE void blake2b_set_lastblock(blake2b_state *S) { - if (S->last_node) { - blake2b_set_lastnode(S); - } - S->f[0] = (uint64_t)-1; -} - -static BLAKE2_INLINE void blake2b_increment_counter(blake2b_state *S, - uint64_t inc) { - S->t[0] += inc; - S->t[1] += (S->t[0] < inc); -} - -static BLAKE2_INLINE void blake2b_invalidate_state(blake2b_state *S) { - burn(S, sizeof(*S)); /* wipe */ - blake2b_set_lastblock(S); /* invalidate for further use */ -} - -static BLAKE2_INLINE void blake2b_init0(blake2b_state *S) { - memset(S, 0, sizeof(*S)); - memcpy(S->h, blake2b_IV, sizeof(S->h)); -} - - -/*void print_state(blake2b_state BlakeHash) { - printf(".h = {UINT64_C(%" PRIu64 "), UINT64_C(%" PRIu64 "),\n" - "UINT64_C(%" PRIu64 "), UINT64_C(%" PRIu64 "),\n" - "UINT64_C(%" PRIu64 "), UINT64_C(%" PRIu64 "),\n" - "UINT64_C(%" PRIu64 "), UINT64_C(%" PRIu64 ")},\n" - ".t = {UINT64_C(%" PRIu64 "), UINT64_C(%" PRIu64 ")},\n" - ".f = {UINT64_C(%" PRIu64 "), UINT64_C(%" PRIu64 ")}\n", - BlakeHash.h[0], BlakeHash.h[1], BlakeHash.h[2], BlakeHash.h[3], - BlakeHash.h[4], BlakeHash.h[5], BlakeHash.h[6], BlakeHash.h[7], - BlakeHash.t[0], BlakeHash.t[1], - BlakeHash.f[0], BlakeHash.f[1]); - printf(".buf = {"); - for (register uint8_t i = 0; i < BLAKE2B_BLOCKBYTES; i++) - printf("%" PRIu8 ", ", BlakeHash.buf[i]); - puts("\n"); - printf("}\n.buflen = %d\n.outlen = %d\n", - BlakeHash.buflen, BlakeHash.outlen); - printf(".last_node = %" PRIu8 "\n", BlakeHash.last_node); - fflush(stdout); -}*/ - -static const blake2b_state miou = { - .h = { - UINT64_C(7640891576939301128), UINT64_C(13503953896175478587), - UINT64_C(4354685564936845355), UINT64_C(11912009170470909681), - UINT64_C(5840696475078001361), UINT64_C(11170449401992604703), - UINT64_C(2270897969802886507), UINT64_C(6620516959819538809) - }, - .t = {UINT64_C(0), UINT64_C(0)}, - .f = {UINT64_C(0), UINT64_C(0)}, - .buf = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }, - .buflen = 0, - .outlen = 64, - .last_node = 0 -}; - - -int blake2b_init_param(blake2b_state *S, const blake2b_param *P) { - const unsigned char *p = (const unsigned char *)P; - unsigned int i; - - if (NULL == P || NULL == S) { - return -1; - } - - blake2b_init0(S); - - /* IV XOR Parameter Block */ - for (i = 0; i < 8; ++i) { - S->h[i] ^= load64(&p[i * sizeof(S->h[i])]); - } - S->outlen = P->digest_length; - return 0; -} - -void compare_buffs(uint64_t *h, size_t outlen) -{ - // printf("CMP : %d", memcmp(h, miou.h, 8*(sizeof(uint64_t)))); - printf("miou : %" PRIu64 " - h : %" PRIu64 " - outlen : %ld\n", miou.h[0], h[0], outlen); - fflush(stdout); -} - -/* Sequential blake2b initialization */ -int blake2b_init(blake2b_state *S, size_t outlen) { - memcpy(S, &miou, sizeof(*S)); - S->h[0] += outlen; - return 0; -} - - -void print64(const char *name, const uint64_t *array, uint16_t size) { - printf("%s = {", name); - for (uint8_t i = 0; i < size; i++) printf("UINT64_C(%" PRIu64 "), ", array[i]); - printf("};\n"); -} -int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, - size_t keylen) { - return 0; -} - -static void blake2b_compress(blake2b_state *S, const uint8_t *block) { - uint64_t m[16]; - uint64_t v[16]; - unsigned int i, r; - - for (i = 0; i < 16; ++i) { - m[i] = load64(block + i * 8); - } - - for (i = 0; i < 8; ++i) { - v[i] = S->h[i]; - } - - v[8] = blake2b_IV[0]; - v[9] = blake2b_IV[1]; - v[10] = blake2b_IV[2]; - v[11] = blake2b_IV[3]; - v[12] = blake2b_IV[4] ^ S->t[0]; - v[13] = blake2b_IV[5]/* ^ S->t[1]*/; - v[14] = blake2b_IV[6] ^ S->f[0]; - v[15] = blake2b_IV[7]/* ^ S->f[1]*/; - -#define G(r, i, a, b, c, d) \ - do { \ - a = a + b + m[blake2b_sigma[r][2 * i + 0]]; \ - d = rotr64(d ^ a, 32); \ - c = c + d; \ - b = rotr64(b ^ c, 24); \ - a = a + b + m[blake2b_sigma[r][2 * i + 1]]; \ - d = rotr64(d ^ a, 16); \ - c = c + d; \ - b = rotr64(b ^ c, 63); \ - } while ((void)0, 0) - -#define ROUND(r) \ - do { \ - G(r, 0, v[0], v[4], v[8], v[12]); \ - G(r, 1, v[1], v[5], v[9], v[13]); \ - G(r, 2, v[2], v[6], v[10], v[14]); \ - G(r, 3, v[3], v[7], v[11], v[15]); \ - G(r, 4, v[0], v[5], v[10], v[15]); \ - G(r, 5, v[1], v[6], v[11], v[12]); \ - G(r, 6, v[2], v[7], v[8], v[13]); \ - G(r, 7, v[3], v[4], v[9], v[14]); \ - } while ((void)0, 0) - - for (r = 0; r < 12; ++r) ROUND(r); - - for (i = 0; i < 8; ++i) S->h[i] = S->h[i] ^ v[i] ^ v[i + 8]; - -#undef G -#undef ROUND -} - -int blake2b_update(blake2b_state *S, const void *in, size_t inlen) { - const uint8_t *pin = (const uint8_t *)in; - /* Complete current block */ - memcpy(&S->buf[4], pin, 124); - blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); - blake2b_compress(S, S->buf); - S->buflen = 0; - pin += 124; - - register int8_t i = 7; - /* Avoid buffer copies when possible */ - while (i--) { - blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); - blake2b_compress(S, pin); - pin += BLAKE2B_BLOCKBYTES; - } - memcpy(&S->buf[S->buflen], pin, 4); - S->buflen += 4; - return 0; -} - -void my_blake2b_update(blake2b_state *S, const void *in, size_t inlen) { - - memcpy(&S->buf[S->buflen], in, inlen); - S->buflen += (unsigned int)inlen; -} - -int blake2b_final(blake2b_state *S, void *out, size_t outlen) { - uint8_t buffer[BLAKE2B_OUTBYTES] = {0}; - unsigned int i; - - blake2b_increment_counter(S, S->buflen); - blake2b_set_lastblock(S); - memset(&S->buf[S->buflen], 0, BLAKE2B_BLOCKBYTES - S->buflen); /* Padding */ - blake2b_compress(S, S->buf); - - for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */ - store64(buffer + sizeof(S->h[i]) * i, S->h[i]); - } - - memcpy(out, buffer, S->outlen); - - burn(buffer, sizeof(buffer)); - burn(S->buf, sizeof(S->buf)); - burn(S->h, sizeof(S->h)); - return 0; -} - -int blake2b(void *out, const void *in, const void *key, size_t keylen) -{ - blake2b_state S; - - blake2b_init(&S, 64); - my_blake2b_update(&S, in, 64); - blake2b_final(&S, out, 64); - burn(&S, sizeof(S)); - return 0; -} - -void blake2b_too(void *pout, const void *in) -{ - uint8_t *out = (uint8_t *)pout; - uint8_t out_buffer[64]; - uint8_t in_buffer[64]; - - blake2b_state blake_state; - blake2b_init(&blake_state, 64); - blake_state.buflen = blake_state.buf[1] = 4; - my_blake2b_update(&blake_state, in, 72); - blake2b_final(&blake_state, out_buffer, 64); - memcpy(out, out_buffer, 32); - out += 32; - - register uint8_t i = 29; - while (i--) { - memcpy(in_buffer, out_buffer, 64); - blake2b(out_buffer, in_buffer, NULL, 0); - memcpy(out, out_buffer, 32); - out += 32; - } - - memcpy(in_buffer, out_buffer, 64); - blake2b(out_buffer, in_buffer, NULL, 0); - memcpy(out, out_buffer, 64); - - burn(&blake_state, sizeof(blake_state)); -} - -/* Argon2 Team - Begin Code */ -int blake2b_long(void *pout, const void *in) -{ - uint8_t *out = (uint8_t *)pout; - blake2b_state blake_state; - uint8_t outlen_bytes[sizeof(uint32_t)] = {0}; - - store32(outlen_bytes, 32); - - blake2b_init(&blake_state, 32); - my_blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes)); - blake2b_update(&blake_state, in, 1024); - blake2b_final(&blake_state, out, 32); - burn(&blake_state, sizeof(blake_state)); - return 0; - -} -/* Argon2 Team - End Code */ diff --git a/stratum/algos/ar2/core.c b/stratum/algos/ar2/core.c new file mode 100644 index 000000000..9256ce507 --- /dev/null +++ b/stratum/algos/ar2/core.c @@ -0,0 +1,615 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + +/*For memory wiping*/ +#ifdef _MSC_VER +#include +#include /* For SecureZeroMemory */ +#endif +#if defined __STDC_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 +#endif +#define VC_GE_2005(version) (version >= 1400) + +#include +#include +#include + +#include "core.h" +#include "thread.h" +#include "../blake2/blake2.h" +#include "../blake2/blake2-impl.h" + +#if defined(__clang__) +#if __has_attribute(optnone) +#define NOT_OPTIMIZED __attribute__((optnone)) +#endif +#elif defined(__GNUC__) +#define GCC_VERSION \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#if GCC_VERSION >= 40400 +#define NOT_OPTIMIZED __attribute__((optimize("O0"))) +#endif +#endif +#ifndef NOT_OPTIMIZED +#define NOT_OPTIMIZED +#endif + +/***************Instance and Position constructors**********/ +void init_block_value(block *b, uint8_t in) { memset(b->v, in, sizeof(b->v)); } + +void copy_block(block *dst, const block *src) { + memcpy(dst->v, src->v, sizeof(uint64_t) * ARGON2_QWORDS_IN_BLOCK); +} + +void xor_block(block *dst, const block *src) { + int i; + for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { + dst->v[i] ^= src->v[i]; + } +} + +static void load_block(block *dst, const void *input) { + unsigned i; + for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { + dst->v[i] = load64((const uint8_t *)input + i * sizeof(dst->v[i])); + } +} + +static void store_block(void *output, const block *src) { + unsigned i; + for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { + store64((uint8_t *)output + i * sizeof(src->v[i]), src->v[i]); + } +} + +/***************Memory functions*****************/ + +int allocate_memory(const argon2_context *context, uint8_t **memory, + size_t num, size_t size) { + size_t memory_size = num*size; + if (memory == NULL) { + return ARGON2_MEMORY_ALLOCATION_ERROR; + } + + /* 1. Check for multiplication overflow */ + if (size != 0 && memory_size / size != num) { + return ARGON2_MEMORY_ALLOCATION_ERROR; + } + + /* 2. Try to allocate with appropriate allocator */ + if (context->allocate_cbk) { + (context->allocate_cbk)(memory, memory_size); + } else { + *memory = malloc(memory_size); + } + + if (*memory == NULL) { + return ARGON2_MEMORY_ALLOCATION_ERROR; + } + + return ARGON2_OK; +} + +void free_memory(const argon2_context *context, uint8_t *memory, + size_t num, size_t size) { + size_t memory_size = num*size; + clear_internal_memory(memory, memory_size); + if (context->free_cbk) { + (context->free_cbk)(memory, memory_size); + } else { + free(memory); + } +} + +void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) { +#if defined(_MSC_VER) && VC_GE_2005(_MSC_VER) + SecureZeroMemory(v, n); +#elif defined memset_s + memset_s(v, n, 0, n); +#elif defined(__OpenBSD__) + explicit_bzero(v, n); +#else + static void *(*const volatile memset_sec)(void *, int, size_t) = &memset; + memset_sec(v, 0, n); +#endif +} + +/* Memory clear flag defaults to true. */ +int FLAG_clear_internal_memory = 1; +void clear_internal_memory(void *v, size_t n) { + if (FLAG_clear_internal_memory && v) { + secure_wipe_memory(v, n); + } +} + +void finalize(const argon2_context *context, argon2_instance_t *instance) { + if (context != NULL && instance != NULL) { + block blockhash; + uint32_t l; + + copy_block(&blockhash, instance->memory + instance->lane_length - 1); + + /* XOR the last blocks */ + for (l = 1; l < instance->lanes; ++l) { + uint32_t last_block_in_lane = + l * instance->lane_length + (instance->lane_length - 1); + xor_block(&blockhash, instance->memory + last_block_in_lane); + } + + /* Hash the result */ + { + uint8_t blockhash_bytes[ARGON2_BLOCK_SIZE]; + store_block(blockhash_bytes, &blockhash); + blake2b_long(context->out, context->outlen, blockhash_bytes, + ARGON2_BLOCK_SIZE); + /* clear blockhash and blockhash_bytes */ + clear_internal_memory(blockhash.v, ARGON2_BLOCK_SIZE); + clear_internal_memory(blockhash_bytes, ARGON2_BLOCK_SIZE); + } + + free_memory(context, (uint8_t *)instance->memory, + instance->memory_blocks, sizeof(block)); + } +} + +uint32_t index_alpha(const argon2_instance_t *instance, + const argon2_position_t *position, uint32_t pseudo_rand, + int same_lane) { + /* + * Pass 0: + * This lane : all already finished segments plus already constructed + * blocks in this segment + * Other lanes : all already finished segments + * Pass 1+: + * This lane : (SYNC_POINTS - 1) last segments plus already constructed + * blocks in this segment + * Other lanes : (SYNC_POINTS - 1) last segments + */ + uint32_t reference_area_size; + uint64_t relative_position; + uint32_t start_position, absolute_position; + + if (0 == position->pass) { + /* First pass */ + if (0 == position->slice) { + /* First slice */ + reference_area_size = + position->index - 1; /* all but the previous */ + } else { + if (same_lane) { + /* The same lane => add current segment */ + reference_area_size = + position->slice * instance->segment_length + + position->index - 1; + } else { + reference_area_size = + position->slice * instance->segment_length + + ((position->index == 0) ? (-1) : 0); + } + } + } else { + /* Second pass */ + if (same_lane) { + reference_area_size = instance->lane_length - + instance->segment_length + position->index - + 1; + } else { + reference_area_size = instance->lane_length - + instance->segment_length + + ((position->index == 0) ? (-1) : 0); + } + } + + /* 1.2.4. Mapping pseudo_rand to 0.. and produce + * relative position */ + relative_position = pseudo_rand; + relative_position = relative_position * relative_position >> 32; + relative_position = reference_area_size - 1 - + (reference_area_size * relative_position >> 32); + + /* 1.2.5 Computing starting position */ + start_position = 0; + + if (0 != position->pass) { + start_position = (position->slice == ARGON2_SYNC_POINTS - 1) + ? 0 + : (position->slice + 1) * instance->segment_length; + } + + /* 1.2.6. Computing absolute position */ + absolute_position = (start_position + relative_position) % + instance->lane_length; /* absolute position */ + return absolute_position; +} + +/* Single-threaded version for p=1 case */ +static int fill_memory_blocks_st(argon2_instance_t *instance) { + uint32_t r, s, l; + + for (r = 0; r < instance->passes; ++r) { + for (s = 0; s < ARGON2_SYNC_POINTS; ++s) { + for (l = 0; l < instance->lanes; ++l) { + argon2_position_t position = {r, l, (uint8_t)s, 0}; + fill_segment(instance, position); + } + } + } + return ARGON2_OK; +} + +#if !defined(ARGON2_NO_THREADS) + +#ifdef _WIN32 +static unsigned __stdcall fill_segment_thr(void *thread_data) +#else +static void *fill_segment_thr(void *thread_data) +#endif +{ + argon2_thread_data *my_data = thread_data; + fill_segment(my_data->instance_ptr, my_data->pos); + argon2_thread_exit(); + return 0; +} + +/* Multi-threaded version for p > 1 case */ +static int fill_memory_blocks_mt(argon2_instance_t *instance) { + uint32_t r, s; + argon2_thread_handle_t *thread = NULL; + argon2_thread_data *thr_data = NULL; + int rc = ARGON2_OK; + + /* 1. Allocating space for threads */ + thread = calloc(instance->lanes, sizeof(argon2_thread_handle_t)); + if (thread == NULL) { + rc = ARGON2_MEMORY_ALLOCATION_ERROR; + goto fail; + } + + thr_data = calloc(instance->lanes, sizeof(argon2_thread_data)); + if (thr_data == NULL) { + rc = ARGON2_MEMORY_ALLOCATION_ERROR; + goto fail; + } + + for (r = 0; r < instance->passes; ++r) { + for (s = 0; s < ARGON2_SYNC_POINTS; ++s) { + uint32_t l; + + /* 2. Calling threads */ + for (l = 0; l < instance->lanes; ++l) { + argon2_position_t position; + + /* 2.1 Join a thread if limit is exceeded */ + if (l >= instance->threads) { + if (argon2_thread_join(thread[l - instance->threads])) { + rc = ARGON2_THREAD_FAIL; + goto fail; + } + } + + /* 2.2 Create thread */ + position.pass = r; + position.lane = l; + position.slice = (uint8_t)s; + position.index = 0; + thr_data[l].instance_ptr = + instance; /* preparing the thread input */ + memcpy(&(thr_data[l].pos), &position, + sizeof(argon2_position_t)); + if (argon2_thread_create(&thread[l], &fill_segment_thr, + (void *)&thr_data[l])) { + rc = ARGON2_THREAD_FAIL; + goto fail; + } + + /* fill_segment(instance, position); */ + /*Non-thread equivalent of the lines above */ + } + + /* 3. Joining remaining threads */ + for (l = instance->lanes - instance->threads; l < instance->lanes; + ++l) { + if (argon2_thread_join(thread[l])) { + rc = ARGON2_THREAD_FAIL; + goto fail; + } + } + } + } + +fail: + if (thread != NULL) { + free(thread); + } + if (thr_data != NULL) { + free(thr_data); + } + return rc; +} + +#endif /* ARGON2_NO_THREADS */ + +int fill_memory_blocks(argon2_instance_t *instance) { + if (instance == NULL || instance->lanes == 0) { + return ARGON2_INCORRECT_PARAMETER; + } +#if defined(ARGON2_NO_THREADS) + return fill_memory_blocks_st(instance); +#else + return instance->threads == 1 ? + fill_memory_blocks_st(instance) : fill_memory_blocks_mt(instance); +#endif +} + +int validate_inputs(const argon2_context *context) { + if (NULL == context) { + return ARGON2_INCORRECT_PARAMETER; + } + + if (NULL == context->out) { + return ARGON2_OUTPUT_PTR_NULL; + } + + /* Validate output length */ + if (ARGON2_MIN_OUTLEN > context->outlen) { + return ARGON2_OUTPUT_TOO_SHORT; + } + + if (ARGON2_MAX_OUTLEN < context->outlen) { + return ARGON2_OUTPUT_TOO_LONG; + } + + /* Validate password (required param) */ + if (NULL == context->pwd) { + if (0 != context->pwdlen) { + return ARGON2_PWD_PTR_MISMATCH; + } + } + + if (ARGON2_MIN_PWD_LENGTH > context->pwdlen) { + return ARGON2_PWD_TOO_SHORT; + } + + if (ARGON2_MAX_PWD_LENGTH < context->pwdlen) { + return ARGON2_PWD_TOO_LONG; + } + + /* Validate salt (required param) */ + if (NULL == context->salt) { + if (0 != context->saltlen) { + return ARGON2_SALT_PTR_MISMATCH; + } + } + + if (ARGON2_MIN_SALT_LENGTH > context->saltlen) { + return ARGON2_SALT_TOO_SHORT; + } + + if (ARGON2_MAX_SALT_LENGTH < context->saltlen) { + return ARGON2_SALT_TOO_LONG; + } + + /* Validate secret (optional param) */ + if (NULL == context->secret) { + if (0 != context->secretlen) { + return ARGON2_SECRET_PTR_MISMATCH; + } + } else { + if (ARGON2_MIN_SECRET > context->secretlen) { + return ARGON2_SECRET_TOO_SHORT; + } + if (ARGON2_MAX_SECRET < context->secretlen) { + return ARGON2_SECRET_TOO_LONG; + } + } + + /* Validate associated data (optional param) */ + if (NULL == context->ad) { + if (0 != context->adlen) { + return ARGON2_AD_PTR_MISMATCH; + } + } else { + if (ARGON2_MIN_AD_LENGTH > context->adlen) { + return ARGON2_AD_TOO_SHORT; + } + if (ARGON2_MAX_AD_LENGTH < context->adlen) { + return ARGON2_AD_TOO_LONG; + } + } + + /* Validate memory cost */ + if (ARGON2_MIN_MEMORY > context->m_cost) { + return ARGON2_MEMORY_TOO_LITTLE; + } + + if (ARGON2_MAX_MEMORY < context->m_cost) { + return ARGON2_MEMORY_TOO_MUCH; + } + + if (context->m_cost < 8 * context->lanes) { + return ARGON2_MEMORY_TOO_LITTLE; + } + + /* Validate time cost */ + if (ARGON2_MIN_TIME > context->t_cost) { + return ARGON2_TIME_TOO_SMALL; + } + + if (ARGON2_MAX_TIME < context->t_cost) { + return ARGON2_TIME_TOO_LARGE; + } + + /* Validate lanes */ + if (ARGON2_MIN_LANES > context->lanes) { + return ARGON2_LANES_TOO_FEW; + } + + if (ARGON2_MAX_LANES < context->lanes) { + return ARGON2_LANES_TOO_MANY; + } + + /* Validate threads */ + if (ARGON2_MIN_THREADS > context->threads) { + return ARGON2_THREADS_TOO_FEW; + } + + if (ARGON2_MAX_THREADS < context->threads) { + return ARGON2_THREADS_TOO_MANY; + } + + if (NULL != context->allocate_cbk && NULL == context->free_cbk) { + return ARGON2_FREE_MEMORY_CBK_NULL; + } + + if (NULL == context->allocate_cbk && NULL != context->free_cbk) { + return ARGON2_ALLOCATE_MEMORY_CBK_NULL; + } + + return ARGON2_OK; +} + +void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance) { + uint32_t l; + /* Make the first and second block in each lane as G(H0||0||i) or + G(H0||1||i) */ + uint8_t blockhash_bytes[ARGON2_BLOCK_SIZE]; + for (l = 0; l < instance->lanes; ++l) { + + store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 0); + store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH + 4, l); + blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, + ARGON2_PREHASH_SEED_LENGTH); + load_block(&instance->memory[l * instance->lane_length + 0], + blockhash_bytes); + + store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 1); + blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, + ARGON2_PREHASH_SEED_LENGTH); + load_block(&instance->memory[l * instance->lane_length + 1], + blockhash_bytes); + } + clear_internal_memory(blockhash_bytes, ARGON2_BLOCK_SIZE); +} + +void initial_hash(uint8_t *blockhash, argon2_context *context, + argon2_type type) { + blake2b_state BlakeHash; + uint8_t value[sizeof(uint32_t)]; + + if (NULL == context || NULL == blockhash) { + return; + } + + blake2b_init(&BlakeHash, ARGON2_PREHASH_DIGEST_LENGTH); + + store32(&value, context->lanes); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + store32(&value, context->outlen); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + store32(&value, context->m_cost); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + store32(&value, context->t_cost); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + store32(&value, ARGON2_VERSION_NUMBER); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + store32(&value, (uint32_t)type); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + store32(&value, context->pwdlen); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + if (context->pwd != NULL) { + blake2b_update(&BlakeHash, (const uint8_t *)context->pwd, + context->pwdlen); + + if (context->flags & ARGON2_FLAG_CLEAR_PASSWORD) { + secure_wipe_memory(context->pwd, context->pwdlen); + context->pwdlen = 0; + } + } + + store32(&value, context->saltlen); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + if (context->salt != NULL) { + blake2b_update(&BlakeHash, (const uint8_t *)context->salt, + context->saltlen); + } + + store32(&value, context->secretlen); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + if (context->secret != NULL) { + blake2b_update(&BlakeHash, (const uint8_t *)context->secret, + context->secretlen); + + if (context->flags & ARGON2_FLAG_CLEAR_SECRET) { + secure_wipe_memory(context->secret, context->secretlen); + context->secretlen = 0; + } + } + + store32(&value, context->adlen); + blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); + + if (context->ad != NULL) { + blake2b_update(&BlakeHash, (const uint8_t *)context->ad, + context->adlen); + } + + blake2b_final(&BlakeHash, blockhash, ARGON2_PREHASH_DIGEST_LENGTH); +} + +int initialize(argon2_instance_t *instance, argon2_context *context) { + uint8_t blockhash[ARGON2_PREHASH_SEED_LENGTH]; + int result = ARGON2_OK; + + if (instance == NULL || context == NULL) + return ARGON2_INCORRECT_PARAMETER; + instance->context_ptr = context; + + /* 1. Memory allocation */ + result = allocate_memory(context, (uint8_t **)&(instance->memory), + instance->memory_blocks, sizeof(block)); + if (result != ARGON2_OK) { + return result; + } + + /* 2. Initial hashing */ + /* H_0 + 8 extra bytes to produce the first blocks */ + /* uint8_t blockhash[ARGON2_PREHASH_SEED_LENGTH]; */ + /* Hashing all inputs */ + initial_hash(blockhash, context, instance->type); + /* Zeroing 8 extra bytes */ + clear_internal_memory(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, + ARGON2_PREHASH_SEED_LENGTH - + ARGON2_PREHASH_DIGEST_LENGTH); + + /* 3. Creating first blocks, we always have at least two blocks in a slice + */ + fill_first_blocks(blockhash, instance); + /* Clearing the hash */ + clear_internal_memory(blockhash, ARGON2_PREHASH_SEED_LENGTH); + + return ARGON2_OK; +} \ No newline at end of file diff --git a/stratum/algos/ar2/cores.h b/stratum/algos/ar2/core.h similarity index 62% rename from stratum/algos/ar2/cores.h rename to stratum/algos/ar2/core.h index 8cf5dda9e..be5a787ab 100644 --- a/stratum/algos/ar2/cores.h +++ b/stratum/algos/ar2/core.h @@ -1,39 +1,39 @@ /* - * Argon2 source code package + * Argon2 reference source code package - reference C implementations * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. */ -#ifndef ARGON2_CORES_H -#define ARGON2_CORES_H +#ifndef ARGON2_CORE_H +#define ARGON2_CORE_H + +#include "argon2.h" -#if defined(_MSC_VER) -#define ALIGN(n) __declspec(align(16)) -#elif defined(__GNUC__) || defined(__clang) -#define ALIGN(x) __attribute__((__aligned__(x))) -#else -#define ALIGN(x) -#endif +#define CONST_CAST(x) (x)(uintptr_t) -/*************************Argon2 internal - * constants**************************************************/ +/**********************Argon2 internal constants*******************************/ enum argon2_core_constants { - /* Version of the algorithm */ + /* Version of the algorithm */ ARGON2_VERSION_NUMBER = 0x10, - /* Memory block size in bytes */ ARGON2_BLOCK_SIZE = 1024, - ARGON2_WORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 8, - ARGON2_QWORDS_IN_BLOCK = 64, - + ARGON2_QWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 8, + ARGON2_OWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 16, + ARGON2_HWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 32, + ARGON2_512BIT_WORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 64, + /* Number of pseudo-random values generated by one call to Blake in Argon2i to generate reference block positions */ @@ -44,18 +44,14 @@ enum argon2_core_constants { ARGON2_PREHASH_SEED_LENGTH = 72 }; -/* Argon2 primitive type */ -typedef enum Argon2_type { Argon2_d = 0, Argon2_i = 1 } argon2_type; - -/*************************Argon2 internal data - * types**************************************************/ +/*************************Argon2 internal data types***********************/ /* * Structure for the (1KB) memory block implemented as 128 64-bit words. * Memory blocks can be copied, XORed. Internal words can be accessed by [] (no * bounds checking). */ -typedef struct _block { uint64_t v[ARGON2_WORDS_IN_BLOCK]; } __attribute__ ((aligned (16))) block; +typedef struct block_ { uint64_t v[ARGON2_QWORDS_IN_BLOCK]; } block; /*****************Functions that work with the block******************/ @@ -76,8 +72,16 @@ void xor_block(block *dst, const block *src); */ typedef struct Argon2_instance_t { block *memory; /* Memory pointer */ + uint32_t version; + uint32_t passes; /* Number of passes */ + uint32_t memory_blocks; /* Number of blocks in memory */ + uint32_t segment_length; + uint32_t lane_length; + uint32_t lanes; + uint32_t threads; argon2_type type; int print_internals; /* whether to print the memory blocks */ + argon2_context *context_ptr; /* points back to original context */ } argon2_instance_t; /* @@ -97,32 +101,43 @@ typedef struct Argon2_thread_data { argon2_position_t pos; } argon2_thread_data; -/*************************Argon2 core - * functions**************************************************/ +/*************************Argon2 core functions********************************/ -/* Allocates memory to the given pointer +/* Allocates memory to the given pointer, uses the appropriate allocator as + * specified in the context. Total allocated memory is num*size. + * @param context argon2_context which specifies the allocator * @param memory pointer to the pointer to the memory - * @param m_cost number of blocks to allocate in the memory + * @param size the size in bytes for each element to be allocated + * @param num the number of elements to be allocated * @return ARGON2_OK if @memory is a valid pointer and memory is allocated */ -int allocate_memory(block **memory, uint32_t m_cost); +int allocate_memory(const argon2_context *context, uint8_t **memory, + size_t num, size_t size); -/* Function that securely cleans the memory +/* + * Frees memory at the given pointer, uses the appropriate deallocator as + * specified in the context. Also cleans the memory using clear_internal_memory. + * @param context argon2_context which specifies the deallocator + * @param memory pointer to buffer to be freed + * @param size the size in bytes for each element to be deallocated + * @param num the number of elements to be deallocated + */ +void free_memory(const argon2_context *context, uint8_t *memory, + size_t num, size_t size); + +/* Function that securely cleans the memory. This ignores any flags set + * regarding clearing memory. Usually one just calls clear_internal_memory. * @param mem Pointer to the memory * @param s Memory size in bytes */ void secure_wipe_memory(void *v, size_t n); -/* Clears memory - * @param instance pointer to the current instance - * @param clear_memory indicates if we clear the memory with zeros. - */ -void clear_memory(argon2_instance_t *instance, int clear); - -/* Deallocates memory - * @param memory pointer to the blocks +/* Function that securely clears the memory if FLAG_clear_internal_memory is + * set. If the flag isn't set, this function does nothing. + * @param mem Pointer to the memory + * @param s Memory size in bytes */ -void free_memory(block *memory); +void clear_internal_memory(void *v, size_t n); /* * Computes absolute position of reference block in the lane following a skewed @@ -166,7 +181,7 @@ void initial_hash(uint8_t *blockhash, argon2_context *context, * @param blockhash Pointer to the pre-hashing digest * @pre blockhash must point to @a PREHASH_SEED_LENGTH allocated values */ -void fill_firsts_blocks(uint8_t *blockhash, const argon2_instance_t *instance); +void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance); /* * Function allocates memory, hashes the inputs with Blake, and creates first @@ -196,6 +211,7 @@ void finalize(const argon2_context *context, argon2_instance_t *instance); /* * Function that fills the segment using previous segments also from other * threads + * @param context current context * @param instance Pointer to the current instance * @param position Current position * @pre all block pointers must be valid @@ -207,14 +223,8 @@ void fill_segment(const argon2_instance_t *instance, * Function that fills the entire memory t_cost times based on the first two * blocks in each lane * @param instance Pointer to the current instance + * @return ARGON2_OK if successful, @context->state */ -void fill_memory_blocks(argon2_instance_t *instance); - -/* - * Function that performs memory-hard hashing with certain degree of parallelism - * @param context Pointer to the Argon2 internal structure - * @return Error code if smth is wrong, ARGON2_OK otherwise - */ -int argon2_core(argon2_context *context, argon2_type type); +int fill_memory_blocks(argon2_instance_t *instance); -#endif +#endif \ No newline at end of file diff --git a/stratum/algos/ar2/cores.c b/stratum/algos/ar2/cores.c deleted file mode 100644 index f4b287825..000000000 --- a/stratum/algos/ar2/cores.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Argon2 source code package - * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 - * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. - * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . - */ - -/*For memory wiping*/ -#ifdef _MSC_VER -#include -#include /* For SecureZeroMemory */ -#endif -#if defined __STDC_LIB_EXT1__ -#define __STDC_WANT_LIB_EXT1__ 1 -#endif -#define VC_GE_2005(version) (version >= 1400) - -#include -#include -#include -#include - -#include "argon2.h" -#include "cores.h" -#include "blake2/blake2.h" -#include "blake2/blake2-impl.h" - -#ifdef GENKAT -#include "genkat.h" -#endif - -#if defined(__clang__) -#if __has_attribute(optnone) -#define NOT_OPTIMIZED __attribute__((optnone)) -#endif -#elif defined(__GNUC__) -#define GCC_VERSION \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#if GCC_VERSION >= 40400 -#define NOT_OPTIMIZED __attribute__((optimize("O0"))) -#endif -#endif -#ifndef NOT_OPTIMIZED -#define NOT_OPTIMIZED -#endif - -/***************Instance and Position constructors**********/ -void init_block_value(block *b, uint8_t in) { memset(b->v, in, sizeof(b->v)); } - -void copy_block(block *dst, const block *src) { - memcpy(dst->v, src->v, sizeof(uint64_t) * ARGON2_WORDS_IN_BLOCK); -} - -void xor_block(block *dst, const block *src) { - int i; - for (i = 0; i < ARGON2_WORDS_IN_BLOCK; ++i) { - dst->v[i] ^= src->v[i]; - } -} - -static void load_block(block *dst, const void *input) { - unsigned i; - for (i = 0; i < ARGON2_WORDS_IN_BLOCK; ++i) { - dst->v[i] = load64((const uint8_t *)input + i * sizeof(dst->v[i])); - } -} - -static void store_block(void *output, const block *src) { - unsigned i; - for (i = 0; i < ARGON2_WORDS_IN_BLOCK; ++i) { - store64((uint8_t *)output + i * sizeof(src->v[i]), src->v[i]); - } -} - -/***************Memory allocators*****************/ -int allocate_memory(block **memory, uint32_t m_cost) { - if (memory != NULL) { - size_t memory_size = sizeof(block) * m_cost; - if (m_cost != 0 && - memory_size / m_cost != - sizeof(block)) { /*1. Check for multiplication overflow*/ - return ARGON2_MEMORY_ALLOCATION_ERROR; - } - - *memory = (block *)malloc(memory_size); /*2. Try to allocate*/ - - if (!*memory) { - return ARGON2_MEMORY_ALLOCATION_ERROR; - } - - return ARGON2_OK; - } else { - return ARGON2_MEMORY_ALLOCATION_ERROR; - } -} - -void secure_wipe_memory(void *v, size_t n) { memset(v, 0, n); } - -/*********Memory functions*/ - -void clear_memory(argon2_instance_t *instance, int clear) { - if (instance->memory != NULL && clear) { - secure_wipe_memory(instance->memory, - sizeof(block) * /*instance->memory_blocks*/16); - } -} - -void free_memory(block *memory) { free(memory); } - -void finalize(const argon2_context *context, argon2_instance_t *instance) { - if (context != NULL && instance != NULL) { - block blockhash; - copy_block(&blockhash, instance->memory + 15); - - /* Hash the result */ - { - uint8_t blockhash_bytes[ARGON2_BLOCK_SIZE]; - store_block(blockhash_bytes, &blockhash); - blake2b_long(context->out, blockhash_bytes); - secure_wipe_memory(blockhash.v, ARGON2_BLOCK_SIZE); - secure_wipe_memory(blockhash_bytes, ARGON2_BLOCK_SIZE); /* clear blockhash_bytes */ - } - -#ifdef GENKAT - print_tag(context->out, context->outlen); -#endif - - /* Clear memory */ - clear_memory(instance, 1); - - free_memory(instance->memory); - } -} - -uint32_t index_alpha(const argon2_instance_t *instance, - const argon2_position_t *position, uint32_t pseudo_rand, - int same_lane) { - /* - * Pass 0: - * This lane : all already finished segments plus already constructed - * blocks in this segment - * Other lanes : all already finished segments - * Pass 1+: - * This lane : (SYNC_POINTS - 1) last segments plus already constructed - * blocks in this segment - * Other lanes : (SYNC_POINTS - 1) last segments - */ - uint32_t reference_area_size; - uint64_t relative_position; - uint32_t start_position, absolute_position; - - if (0 == position->pass) { - /* First pass */ - if (0 == position->slice) { - /* First slice */ - reference_area_size = - position->index - 1; /* all but the previous */ - } else { - if (same_lane) { - /* The same lane => add current segment */ - reference_area_size = - position->slice * 4 + - position->index - 1; - } else { - reference_area_size = - position->slice * 4 + - ((position->index == 0) ? (-1) : 0); - } - } - } else { - /* Second pass */ - if (same_lane) {reference_area_size = 11 + position->index;} - else {reference_area_size = 12 - (position->index == 0);} - } - - /* 1.2.4. Mapping pseudo_rand to 0.. and produce - * relative position */ - relative_position = pseudo_rand; - relative_position = relative_position * relative_position >> 32; - relative_position = reference_area_size - 1 - - (reference_area_size * relative_position >> 32); - - /* 1.2.5 Computing starting position */ - start_position = 0; - - if (0 != position->pass) { - start_position = (position->slice == ARGON2_SYNC_POINTS - 1) - ? 0 : (position->slice + 1) * 4; - } - - /* 1.2.6. Computing absolute position */ - absolute_position = (start_position + relative_position) % 16; - return absolute_position; -} - -void fill_memory_blocks(argon2_instance_t *instance) { - uint32_t r, s; - - for (r = 0; r < 2; ++r) { - for (s = 0; s < ARGON2_SYNC_POINTS; ++s) { - - argon2_position_t position; - position.pass = r; - position.lane = 0; - position.slice = (uint8_t)s; - position.index = 0; - fill_segment(instance, position); - } - -#ifdef GENKAT - internal_kat(instance, r); /* Print all memory blocks */ -#endif - } -} - -void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance) { - /* Make the first and second block in each lane as G(H0||i||0) or - G(H0||i||1) */ - uint8_t blockhash_bytes[ARGON2_BLOCK_SIZE]; - store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 0); - store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH + 4, 0); - blake2b_too(blockhash_bytes, blockhash); - load_block(&instance->memory[0], blockhash_bytes); - - store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 1); - blake2b_too(blockhash_bytes, blockhash); - load_block(&instance->memory[1], blockhash_bytes); - secure_wipe_memory(blockhash_bytes, ARGON2_BLOCK_SIZE); -} - - -static const blake2b_state base_hash = { - .h = { - UINT64_C(7640891576939301192), UINT64_C(13503953896175478587), - UINT64_C(4354685564936845355), UINT64_C(11912009170470909681), - UINT64_C(5840696475078001361), UINT64_C(11170449401992604703), - UINT64_C(2270897969802886507), UINT64_C(6620516959819538809) - }, - .t = {UINT64_C(0),UINT64_C(0)}, - .f = {UINT64_C(0),UINT64_C(0)}, - .buf = { - 1, 0, 0, 0, 32, 0, 0, 0, 16, 0, 0, 0, 2, 0, 0, 0, 16, 0, 0, 0, 1, 0, - 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - .buflen = 28, - .outlen = 64, - .last_node = 0 -}; - -#define PWDLEN 32 -#define SALTLEN 32 -#define SECRETLEN 0 -#define ADLEN 0 -void initial_hash(uint8_t *blockhash, argon2_context *context, - argon2_type type) { - - uint8_t value[sizeof(uint32_t)]; - - /* Is it generating cache invalidation between cores ? */ - blake2b_state BlakeHash = base_hash; - BlakeHash.buf[20] = (uint8_t) type; - my_blake2b_update(&BlakeHash, (const uint8_t *)context->pwd, - PWDLEN); - - - secure_wipe_memory(context->pwd, PWDLEN); - context->pwdlen = 0; - - store32(&value, SALTLEN); - my_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - my_blake2b_update(&BlakeHash, (const uint8_t *)context->salt, - SALTLEN); - - store32(&value, SECRETLEN); - my_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - store32(&value, ADLEN); - my_blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - blake2b_final(&BlakeHash, blockhash, ARGON2_PREHASH_DIGEST_LENGTH); -} - -int initialize(argon2_instance_t *instance, argon2_context *context) { - /* 1. Memory allocation */ - - - allocate_memory(&(instance->memory), 16); - - /* 2. Initial hashing */ - /* H_0 + 8 extra bytes to produce the first blocks */ - /* Hashing all inputs */ - uint8_t blockhash[ARGON2_PREHASH_SEED_LENGTH]; - initial_hash(blockhash, context, instance->type); - /* Zeroing 8 extra bytes */ - secure_wipe_memory(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, - ARGON2_PREHASH_SEED_LENGTH - - ARGON2_PREHASH_DIGEST_LENGTH); - -#ifdef GENKAT - initial_kat(blockhash, context, instance->type); -#endif - - /* 3. Creating first blocks, we always have at least two blocks in a slice - */ - fill_first_blocks(blockhash, instance); - /* Clearing the hash */ - secure_wipe_memory(blockhash, ARGON2_PREHASH_SEED_LENGTH); - - return ARGON2_OK; -} - -int argon2_core(argon2_context *context, argon2_type type) { - argon2_instance_t instance; - instance.memory = NULL; - instance.type = type; - - /* 3. Initialization: Hashing inputs, allocating memory, filling first - * blocks - */ - - int result = initialize(&instance, context); - if (ARGON2_OK != result) return result; - - /* 4. Filling memory */ - fill_memory_blocks(&instance); - - /* 5. Finalization */ - finalize(context, &instance); - - return ARGON2_OK; -} diff --git a/stratum/algos/ar2/encoding.c b/stratum/algos/ar2/encoding.c new file mode 100644 index 000000000..fae47f734 --- /dev/null +++ b/stratum/algos/ar2/encoding.c @@ -0,0 +1,455 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + +#include +#include +#include +#include +#include "encoding.h" +#include "core.h" + +/* + * Example code for a decoder and encoder of "hash strings", with Argon2 + * parameters. + * + * This code comprises three sections: + * + * -- The first section contains generic Base64 encoding and decoding + * functions. It is conceptually applicable to any hash function + * implementation that uses Base64 to encode and decode parameters, + * salts and outputs. It could be made into a library, provided that + * the relevant functions are made public (non-static) and be given + * reasonable names to avoid collisions with other functions. + * + * -- The second section is specific to Argon2. It encodes and decodes + * the parameters, salts and outputs. It does not compute the hash + * itself. + * + * The code was originally written by Thomas Pornin , + * to whom comments and remarks may be sent. It is released under what + * should amount to Public Domain or its closest equivalent; the + * following mantra is supposed to incarnate that fact with all the + * proper legal rituals: + * + * --------------------------------------------------------------------- + * This file is provided under the terms of Creative Commons CC0 1.0 + * Public Domain Dedication. To the extent possible under law, the + * author (Thomas Pornin) has waived all copyright and related or + * neighboring rights to this file. This work is published from: Canada. + * --------------------------------------------------------------------- + * + * Copyright (c) 2015 Thomas Pornin + */ + +/* ==================================================================== */ +/* + * Common code; could be shared between different hash functions. + * + * Note: the Base64 functions below assume that uppercase letters (resp. + * lowercase letters) have consecutive numerical codes, that fit on 8 + * bits. All modern systems use ASCII-compatible charsets, where these + * properties are true. If you are stuck with a dinosaur of a system + * that still defaults to EBCDIC then you already have much bigger + * interoperability issues to deal with. + */ + +/* + * Some macros for constant-time comparisons. These work over values in + * the 0..255 range. Returned value is 0x00 on "false", 0xFF on "true". + */ +#define EQ(x, y) ((((0U - ((unsigned)(x) ^ (unsigned)(y))) >> 8) & 0xFF) ^ 0xFF) +#define GT(x, y) ((((unsigned)(y) - (unsigned)(x)) >> 8) & 0xFF) +#define GE(x, y) (GT(y, x) ^ 0xFF) +#define LT(x, y) GT(y, x) +#define LE(x, y) GE(y, x) + +/* + * Convert value x (0..63) to corresponding Base64 character. + */ +static int b64_byte_to_char(unsigned x) { + return (LT(x, 26) & (x + 'A')) | + (GE(x, 26) & LT(x, 52) & (x + ('a' - 26))) | + (GE(x, 52) & LT(x, 62) & (x + ('0' - 52))) | (EQ(x, 62) & '+') | + (EQ(x, 63) & '/'); +} + +/* + * Convert character c to the corresponding 6-bit value. If character c + * is not a Base64 character, then 0xFF (255) is returned. + */ +static unsigned b64_char_to_byte(int c) { + unsigned x; + + x = (GE(c, 'A') & LE(c, 'Z') & (c - 'A')) | + (GE(c, 'a') & LE(c, 'z') & (c - ('a' - 26))) | + (GE(c, '0') & LE(c, '9') & (c - ('0' - 52))) | (EQ(c, '+') & 62) | + (EQ(c, '/') & 63); + return x | (EQ(x, 0) & (EQ(c, 'A') ^ 0xFF)); +} + +/* + * Convert some bytes to Base64. 'dst_len' is the length (in characters) + * of the output buffer 'dst'; if that buffer is not large enough to + * receive the result (including the terminating 0), then (size_t)-1 + * is returned. Otherwise, the zero-terminated Base64 string is written + * in the buffer, and the output length (counted WITHOUT the terminating + * zero) is returned. + */ +static size_t to_base64(char *dst, size_t dst_len, const void *src, + size_t src_len) { + size_t olen; + const unsigned char *buf; + unsigned acc, acc_len; + + olen = (src_len / 3) << 2; + switch (src_len % 3) { + case 2: + olen++; + /* fall through */ + case 1: + olen += 2; + break; + } + if (dst_len <= olen) { + return (size_t)-1; + } + acc = 0; + acc_len = 0; + buf = (const unsigned char *)src; + while (src_len-- > 0) { + acc = (acc << 8) + (*buf++); + acc_len += 8; + while (acc_len >= 6) { + acc_len -= 6; + *dst++ = (char)b64_byte_to_char((acc >> acc_len) & 0x3F); + } + } + if (acc_len > 0) { + *dst++ = (char)b64_byte_to_char((acc << (6 - acc_len)) & 0x3F); + } + *dst++ = 0; + return olen; +} + +/* + * Decode Base64 chars into bytes. The '*dst_len' value must initially + * contain the length of the output buffer '*dst'; when the decoding + * ends, the actual number of decoded bytes is written back in + * '*dst_len'. + * + * Decoding stops when a non-Base64 character is encountered, or when + * the output buffer capacity is exceeded. If an error occurred (output + * buffer is too small, invalid last characters leading to unprocessed + * buffered bits), then NULL is returned; otherwise, the returned value + * points to the first non-Base64 character in the source stream, which + * may be the terminating zero. + */ +static const char *from_base64(void *dst, size_t *dst_len, const char *src) { + size_t len; + unsigned char *buf; + unsigned acc, acc_len; + + buf = (unsigned char *)dst; + len = 0; + acc = 0; + acc_len = 0; + for (;;) { + unsigned d; + + d = b64_char_to_byte(*src); + if (d == 0xFF) { + break; + } + src++; + acc = (acc << 6) + d; + acc_len += 6; + if (acc_len >= 8) { + acc_len -= 8; + if ((len++) >= *dst_len) { + return NULL; + } + *buf++ = (acc >> acc_len) & 0xFF; + } + } + + /* + * If the input length is equal to 1 modulo 4 (which is + * invalid), then there will remain 6 unprocessed bits; + * otherwise, only 0, 2 or 4 bits are buffered. The buffered + * bits must also all be zero. + */ + if (acc_len > 4 || (acc & (((unsigned)1 << acc_len) - 1)) != 0) { + return NULL; + } + *dst_len = len; + return src; +} + +/* + * Decode decimal integer from 'str'; the value is written in '*v'. + * Returned value is a pointer to the next non-decimal character in the + * string. If there is no digit at all, or the value encoding is not + * minimal (extra leading zeros), or the value does not fit in an + * 'unsigned long', then NULL is returned. + */ +static const char *decode_decimal(const char *str, unsigned long *v) { + const char *orig; + unsigned long acc; + + acc = 0; + for (orig = str;; str++) { + int c; + + c = *str; + if (c < '0' || c > '9') { + break; + } + c -= '0'; + if (acc > (ULONG_MAX / 10)) { + return NULL; + } + acc *= 10; + if ((unsigned long)c > (ULONG_MAX - acc)) { + return NULL; + } + acc += (unsigned long)c; + } + if (str == orig || (*orig == '0' && str != (orig + 1))) { + return NULL; + } + *v = acc; + return str; +} + +/* ==================================================================== */ +/* + * Code specific to Argon2. + * + * The code below applies the following format: + * + * $argon2[$v=]$m=,t=,p=$$ + * + * where is either 'd', 'id', or 'i', is a decimal integer (positive, + * fits in an 'unsigned long'), and is Base64-encoded data (no '=' padding + * characters, no newline or whitespace). + * + * The last two binary chunks (encoded in Base64) are, in that order, + * the salt and the output. Both are required. The binary salt length and the + * output length must be in the allowed ranges defined in argon2.h. + * + * The ctx struct must contain buffers large enough to hold the salt and pwd + * when it is fed into decode_string. + */ + +int decode_string(argon2_context *ctx, const char *str, argon2_type type) { + +/* check for prefix */ +#define CC(prefix) \ + do { \ + size_t cc_len = strlen(prefix); \ + if (strncmp(str, prefix, cc_len) != 0) { \ + return ARGON2_DECODING_FAIL; \ + } \ + str += cc_len; \ + } while ((void)0, 0) + +/* optional prefix checking with supplied code */ +#define CC_opt(prefix, code) \ + do { \ + size_t cc_len = strlen(prefix); \ + if (strncmp(str, prefix, cc_len) == 0) { \ + str += cc_len; \ + { code; } \ + } \ + } while ((void)0, 0) + +/* Decoding prefix into decimal */ +#define DECIMAL(x) \ + do { \ + unsigned long dec_x; \ + str = decode_decimal(str, &dec_x); \ + if (str == NULL) { \ + return ARGON2_DECODING_FAIL; \ + } \ + (x) = dec_x; \ + } while ((void)0, 0) + + +/* Decoding prefix into uint32_t decimal */ +#define DECIMAL_U32(x) \ + do { \ + unsigned long dec_x; \ + str = decode_decimal(str, &dec_x); \ + if (str == NULL || dec_x > UINT32_MAX) { \ + return ARGON2_DECODING_FAIL; \ + } \ + (x) = (uint32_t)dec_x; \ + } while ((void)0, 0) + + +/* Decoding base64 into a binary buffer */ +#define BIN(buf, max_len, len) \ + do { \ + size_t bin_len = (max_len); \ + str = from_base64(buf, &bin_len, str); \ + if (str == NULL || bin_len > UINT32_MAX) { \ + return ARGON2_DECODING_FAIL; \ + } \ + (len) = (uint32_t)bin_len; \ + } while ((void)0, 0) + + size_t maxsaltlen = ctx->saltlen; + size_t maxoutlen = ctx->outlen; + int validation_result; + const char* type_string; + + /* We should start with the argon2_type we are using */ + type_string = argon2_type2string(type, 0); + if (!type_string) { + return ARGON2_INCORRECT_TYPE; + } + + CC("$"); + CC(type_string); + + CC("$m="); + DECIMAL_U32(ctx->m_cost); + CC(",t="); + DECIMAL_U32(ctx->t_cost); + CC(",p="); + DECIMAL_U32(ctx->lanes); + ctx->threads = ctx->lanes; + + CC("$"); + BIN(ctx->salt, maxsaltlen, ctx->saltlen); + CC("$"); + BIN(ctx->out, maxoutlen, ctx->outlen); + + /* The rest of the fields get the default values */ + ctx->secret = NULL; + ctx->secretlen = 0; + ctx->ad = NULL; + ctx->adlen = 0; + ctx->allocate_cbk = NULL; + ctx->free_cbk = NULL; + ctx->flags = ARGON2_DEFAULT_FLAGS; + + /* On return, must have valid context */ + validation_result = validate_inputs(ctx); + if (validation_result != ARGON2_OK) { + return validation_result; + } + + /* Can't have any additional characters */ + if (*str == 0) { + return ARGON2_OK; + } else { + return ARGON2_DECODING_FAIL; + } +#undef CC +#undef CC_opt +#undef DECIMAL +#undef BIN +} + +int encode_string(char *dst, size_t dst_len, argon2_context *ctx, + argon2_type type) { +#define SS(str) \ + do { \ + size_t pp_len = strlen(str); \ + if (pp_len >= dst_len) { \ + return ARGON2_ENCODING_FAIL; \ + } \ + memcpy(dst, str, pp_len + 1); \ + dst += pp_len; \ + dst_len -= pp_len; \ + } while ((void)0, 0) + +#define SX(x) \ + do { \ + char tmp[30]; \ + sprintf(tmp, "%lu", (unsigned long)(x)); \ + SS(tmp); \ + } while ((void)0, 0) + +#define SB(buf, len) \ + do { \ + size_t sb_len = to_base64(dst, dst_len, buf, len); \ + if (sb_len == (size_t)-1) { \ + return ARGON2_ENCODING_FAIL; \ + } \ + dst += sb_len; \ + dst_len -= sb_len; \ + } while ((void)0, 0) + + const char* type_string = argon2_type2string(type, 0); + int validation_result = validate_inputs(ctx); + + if (!type_string) { + return ARGON2_ENCODING_FAIL; + } + + if (validation_result != ARGON2_OK) { + return validation_result; + } + + + SS("$"); + SS(type_string); + + SS("$m="); + SX(ctx->m_cost); + SS(",t="); + SX(ctx->t_cost); + SS(",p="); + SX(ctx->lanes); + + SS("$"); + SB(ctx->salt, ctx->saltlen); + + SS("$"); + SB(ctx->out, ctx->outlen); + return ARGON2_OK; + +#undef SS +#undef SX +#undef SB +} + +size_t b64len(uint32_t len) { + size_t olen = ((size_t)len / 3) << 2; + + switch (len % 3) { + case 2: + olen++; + /* fall through */ + case 1: + olen += 2; + break; + } + + return olen; +} + +size_t numlen(uint32_t num) { + size_t len = 1; + while (num >= 10) { + ++len; + num = num / 10; + } + return len; +} diff --git a/stratum/algos/ar2/encoding.h b/stratum/algos/ar2/encoding.h new file mode 100644 index 000000000..580af7580 --- /dev/null +++ b/stratum/algos/ar2/encoding.h @@ -0,0 +1,57 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + +#ifndef ENCODING_H +#define ENCODING_H +#include "argon2.h" + +#define ARGON2_MAX_DECODED_LANES UINT32_C(255) +#define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8) +#define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12) + +/* +* encode an Argon2 hash string into the provided buffer. 'dst_len' +* contains the size, in characters, of the 'dst' buffer; if 'dst_len' +* is less than the number of required characters (including the +* terminating 0), then this function returns ARGON2_ENCODING_ERROR. +* +* on success, ARGON2_OK is returned. +*/ +int encode_string(char *dst, size_t dst_len, argon2_context *ctx, + argon2_type type); + +/* +* Decodes an Argon2 hash string into the provided structure 'ctx'. +* The only fields that must be set prior to this call are ctx.saltlen and +* ctx.outlen (which must be the maximal salt and out length values that are +* allowed), ctx.salt and ctx.out (which must be buffers of the specified +* length), and ctx.pwd and ctx.pwdlen which must hold a valid password. +* +* Invalid input string causes an error. On success, the ctx is valid and all +* fields have been initialized. +* +* Returned value is ARGON2_OK on success, other ARGON2_ codes on error. +*/ +int decode_string(argon2_context *ctx, const char *str, argon2_type type); + +/* Returns the length of the encoded byte stream with length len */ +size_t b64len(uint32_t len); + +/* Returns the length of the encoded number num */ +size_t numlen(uint32_t num); + +#endif \ No newline at end of file diff --git a/stratum/algos/ar2/genkat.c b/stratum/algos/ar2/genkat.c deleted file mode 100644 index 7aa482d88..000000000 --- a/stratum/algos/ar2/genkat.c +++ /dev/null @@ -1,182 +0,0 @@ -#include -#include -#include -#include - -#include "argon2.h" -#include "cores.h" - -void initial_kat(const uint8_t *blockhash, const argon2_context *context, - argon2_type type) { - unsigned i; - - if (blockhash != NULL && context != NULL) { - printf("======================================="); - - switch (type) { - case Argon2_d: - printf("Argon2d\n"); - break; - - case Argon2_i: - printf("Argon2i\n"); - break; - - default: - break; - } - - printf("Memory: %u KiB, Iterations: %u, Parallelism: %u lanes, Tag " - "length: %u bytes\n", - context->m_cost, context->t_cost, context->lanes, - context->outlen); - - printf("Password[%u]: ", context->pwdlen); - - if (context->flags & ARGON2_FLAG_CLEAR_PASSWORD) { - printf("CLEARED\n"); - } else { - for (i = 0; i < context->pwdlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->pwd)[i]); - } - - printf("\n"); - } - - printf("Salt[%u]: ", context->saltlen); - - for (i = 0; i < context->saltlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->salt)[i]); - } - - printf("\n"); - - printf("Secret[%u]: ", context->secretlen); - - if (context->flags & ARGON2_FLAG_CLEAR_SECRET) { - printf("CLEARED\n"); - } else { - for (i = 0; i < context->secretlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->secret)[i]); - } - - printf("\n"); - } - - printf("Associated data[%u]: ", context->adlen); - - for (i = 0; i < context->adlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->ad)[i]); - } - - printf("\n"); - - printf("Pre-hashing digest: "); - - for (i = 0; i < ARGON2_PREHASH_DIGEST_LENGTH; ++i) { - printf("%2.2x ", ((unsigned char *)blockhash)[i]); - } - - printf("\n"); - } -} - -void print_tag(const void *out, uint32_t outlen) { - unsigned i; - if (out != NULL) { - printf("Tag: "); - - for (i = 0; i < outlen; ++i) { - printf("%2.2x ", ((uint8_t *)out)[i]); - } - - printf("\n"); - } -} - -void internal_kat(const argon2_instance_t *instance, uint32_t pass) { - - if (instance != NULL) { - uint32_t i, j; - printf("\n After pass %u:\n", pass); - - for (i = 0; i < instance->memory_blocks; ++i) { - uint32_t how_many_words = - (instance->memory_blocks > ARGON2_WORDS_IN_BLOCK) - ? 1 - : ARGON2_WORDS_IN_BLOCK; - - for (j = 0; j < how_many_words; ++j) - printf("Block %.4u [%3u]: %016" PRIx64 "\n", i, j, - instance->memory[i].v[j]); - } - } -} - -static void fatal(const char *error) { - fprintf(stderr, "Error: %s\n", error); - exit(1); -} - -static void generate_testvectors(const char *type) { -#define TEST_OUTLEN 32 -#define TEST_PWDLEN 32 -#define TEST_SALTLEN 16 -#define TEST_SECRETLEN 8 -#define TEST_ADLEN 12 - argon2_context context; - - unsigned char out[TEST_OUTLEN]; - unsigned char pwd[TEST_PWDLEN]; - unsigned char salt[TEST_SALTLEN]; - unsigned char secret[TEST_SECRETLEN]; - unsigned char ad[TEST_ADLEN]; - const allocate_fptr myown_allocator = NULL; - const deallocate_fptr myown_deallocator = NULL; - - unsigned t_cost = 3; - unsigned m_cost = 16; - unsigned lanes = 4; - - memset(pwd, 1, TEST_OUTLEN); - memset(salt, 2, TEST_SALTLEN); - memset(secret, 3, TEST_SECRETLEN); - memset(ad, 4, TEST_ADLEN); - - context.out = out; - context.outlen = TEST_OUTLEN; - context.pwd = pwd; - context.pwdlen = TEST_PWDLEN; - context.salt = salt; - context.saltlen = TEST_SALTLEN; - context.secret = secret; - context.secretlen = TEST_SECRETLEN; - context.ad = ad; - context.adlen = TEST_ADLEN; - context.t_cost = t_cost; - context.m_cost = m_cost; - context.lanes = lanes; - context.threads = lanes; - context.allocate_cbk = myown_allocator; - context.free_cbk = myown_deallocator; - context.flags = 0; - -#undef TEST_OUTLEN -#undef TEST_PWDLEN -#undef TEST_SALTLEN -#undef TEST_SECRETLEN -#undef TEST_ADLEN - - if (!strcmp(type, "d")) { - argon2d(&context); - } else if (!strcmp(type, "i")) { - argon2i(&context); - } else - fatal("wrong Argon2 type"); -} - -int main(int argc, char *argv[]) { - const char *type = (argc > 1) ? argv[1] : "i"; - generate_testvectors(type); - return ARGON2_OK; -} diff --git a/stratum/algos/ar2/genkat.h b/stratum/algos/ar2/genkat.h deleted file mode 100644 index 9c776bf52..000000000 --- a/stratum/algos/ar2/genkat.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Argon2 source code package - * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 - * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. - * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . - */ - -#ifndef ARGON2_KAT_H -#define ARGON2_KAT_H - -/* - * Initial KAT function that prints the inputs to the file - * @param blockhash Array that contains pre-hashing digest - * @param context Holds inputs - * @param type Argon2 type - * @pre blockhash must point to INPUT_INITIAL_HASH_LENGTH bytes - * @pre context member pointers must point to allocated memory of size according - * to the length values - */ -void initial_kat(const uint8_t *blockhash, const argon2_context *context, - argon2_type type); - -/* - * Function that prints the output tag - * @param out output array pointer - * @param outlen digest length - * @pre out must point to @a outlen bytes - **/ -void print_tag(const void *out, uint32_t outlen); - -/* - * Function that prints the internal state at given moment - * @param instance pointer to the current instance - * @param pass current pass number - * @pre instance must have necessary memory allocated - **/ -void internal_kat(const argon2_instance_t *instance, uint32_t pass); - -#endif diff --git a/stratum/algos/ar2/opt.c b/stratum/algos/ar2/opt.c index 755a89444..2ff7b3f50 100644 --- a/stratum/algos/ar2/opt.c +++ b/stratum/algos/ar2/opt.c @@ -1,150 +1,214 @@ /* - * Argon2 source code package + * Argon2 reference source code package - reference C implementations * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. */ #include #include #include -#include -#include - -#include #include "argon2.h" -#include "cores.h" -#include "opt.h" - -#include "blake2/blake2.h" -#include "blake2/blamka-round-opt.h" - -void fill_block(__m128i *state, __m128i const *ref_block, __m128i *next_block) -{ - __m128i block_XY[ARGON2_QWORDS_IN_BLOCK] __attribute__ ((aligned (16))); - uint32_t i; - for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; i++) { - block_XY[i] = state[i] = _mm_xor_si128( - state[i], _mm_load_si128(&ref_block[i])); - } - - BLAKE2_ROUND(state[0], state[1], state[2], state[3], state[4], state[5], state[6], state[7]); - BLAKE2_ROUND(state[8], state[9], state[10], state[11], state[12], state[13], state[14], state[15]); - BLAKE2_ROUND(state[16], state[17], state[18], state[19], state[20], state[21], state[22], state[23]); - BLAKE2_ROUND(state[24], state[25], state[26], state[27], state[28], state[29], state[30], state[31]); - BLAKE2_ROUND(state[32], state[33], state[34], state[35], state[36], state[37], state[38], state[39]); - BLAKE2_ROUND(state[40], state[41], state[42], state[43], state[44], state[45], state[46], state[47]); - BLAKE2_ROUND(state[48], state[49], state[50], state[51], state[52], state[53], state[54], state[55]); - BLAKE2_ROUND(state[56], state[57], state[58], state[59], state[60], state[61], state[62], state[63]); - /*for (i = 0; i < 8; ++i) { - BLAKE2_ROUND(state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], - state[8 * i + 3], state[8 * i + 4], state[8 * i + 5], - state[8 * i + 6], state[8 * i + 7]); - }*/ - - BLAKE2_ROUND(state[0], state[8], state[16], state[24], state[32], state[40], state[48], state[56]); - BLAKE2_ROUND(state[1], state[9], state[17], state[25], state[33], state[41], state[49], state[57]); - BLAKE2_ROUND(state[2], state[10], state[18], state[26], state[34], state[42], state[50], state[58]); - BLAKE2_ROUND(state[3], state[11], state[19], state[27], state[35], state[43], state[51], state[59]); - BLAKE2_ROUND(state[4], state[12], state[20], state[28], state[36], state[44], state[52], state[60]); - BLAKE2_ROUND(state[5], state[13], state[21], state[29], state[37], state[45], state[53], state[61]); - BLAKE2_ROUND(state[6], state[14], state[22], state[30], state[38], state[46], state[54], state[62]); - BLAKE2_ROUND(state[7], state[15], state[23], state[31], state[39], state[47], state[55], state[63]); - /*for (i = 0; i < 8; ++i) { - BLAKE2_ROUND(state[8 * 0 + i], state[8 * 1 + i], state[8 * 2 + i], - state[8 * 3 + i], state[8 * 4 + i], state[8 * 5 + i], - state[8 * 6 + i], state[8 * 7 + i]); - }*/ +#include "core.h" - for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; i++) { - state[i] = _mm_xor_si128(state[i], block_XY[i]); - _mm_storeu_si128(&next_block[i], state[i]); - } -} +#include "../blake2/blake2.h" +#include "../blake2/blamka-round-opt.h" -static const uint64_t bad_rands[32] = { - UINT64_C(17023632018251376180), UINT64_C(4911461131397773491), - UINT64_C(15927076453364631751), UINT64_C(7860239898779391109), +/* + * Function fills a new memory block and optionally XORs the old block over the new one. + * Memory must be initialized. + * @param state Pointer to the just produced block. Content will be updated(!) + * @param ref_block Pointer to the reference block + * @param next_block Pointer to the block to be XORed over. May coincide with @ref_block + * @param with_xor Whether to XOR into the new block (1) or just overwrite (0) + * @pre all block pointers must be valid + */ +#if defined(__AVX512F__) +static void fill_block(__m512i *state, const block *ref_block, + block *next_block, int with_xor) { + __m512i block_XY[ARGON2_512BIT_WORDS_IN_BLOCK]; + unsigned int i; + + if (with_xor) { + for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { + state[i] = _mm512_xor_si512( + state[i], _mm512_loadu_si512((const __m512i *)ref_block->v + i)); + block_XY[i] = _mm512_xor_si512( + state[i], _mm512_loadu_si512((const __m512i *)next_block->v + i)); + } + } else { + for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { + block_XY[i] = state[i] = _mm512_xor_si512( + state[i], _mm512_loadu_si512((const __m512i *)ref_block->v + i)); + } + } - UINT64_C(11820267568857244377), UINT64_C(12188179869468676617), - UINT64_C(3732913385414474778), UINT64_C(7651458777762572084), + for (i = 0; i < 2; ++i) { + BLAKE2_ROUND_1( + state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], state[8 * i + 3], + state[8 * i + 4], state[8 * i + 5], state[8 * i + 6], state[8 * i + 7]); + } - UINT64_C(3062274162574341415), UINT64_C(17922653540258786897), - UINT64_C(17393848266100524980), UINT64_C(8539695715554563839), + for (i = 0; i < 2; ++i) { + BLAKE2_ROUND_2( + state[2 * 0 + i], state[2 * 1 + i], state[2 * 2 + i], state[2 * 3 + i], + state[2 * 4 + i], state[2 * 5 + i], state[2 * 6 + i], state[2 * 7 + i]); + } - UINT64_C(13824538050656654359), UINT64_C(12078939433126460936), - UINT64_C(15331979418564540430), UINT64_C(12058346794217174273), + for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { + state[i] = _mm512_xor_si512(state[i], block_XY[i]); + _mm512_storeu_si512((__m512i *)next_block->v + i, state[i]); + } +} +#elif defined(__AVX2__) +static void fill_block(__m256i *state, const block *ref_block, + block *next_block, int with_xor) { + __m256i block_XY[ARGON2_HWORDS_IN_BLOCK]; + unsigned int i; + + if (with_xor) { + for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { + state[i] = _mm256_xor_si256( + state[i], _mm256_loadu_si256((const __m256i *)ref_block->v + i)); + block_XY[i] = _mm256_xor_si256( + state[i], _mm256_loadu_si256((const __m256i *)next_block->v + i)); + } + } else { + for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { + block_XY[i] = state[i] = _mm256_xor_si256( + state[i], _mm256_loadu_si256((const __m256i *)ref_block->v + i)); + } + } - UINT64_C(13593922096015221049), UINT64_C(18356682276374416500), - UINT64_C(4968040514092703824), UINT64_C(11202790346130235567), + for (i = 0; i < 4; ++i) { + BLAKE2_ROUND_1(state[8 * i + 0], state[8 * i + 4], state[8 * i + 1], state[8 * i + 5], + state[8 * i + 2], state[8 * i + 6], state[8 * i + 3], state[8 * i + 7]); + } - UINT64_C(2276229735041314644), UINT64_C(220837743321691382), - UINT64_C(4861211596230784273), UINT64_C(6330592584132590331), + for (i = 0; i < 4; ++i) { + BLAKE2_ROUND_2(state[ 0 + i], state[ 4 + i], state[ 8 + i], state[12 + i], + state[16 + i], state[20 + i], state[24 + i], state[28 + i]); + } - UINT64_C(3515580430960296763), UINT64_C(9869356316971855173), - UINT64_C(485533243489193056), UINT64_C(14596447761048148032), + for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { + state[i] = _mm256_xor_si256(state[i], block_XY[i]); + _mm256_storeu_si256((__m256i *)next_block->v + i, state[i]); + } +} +#else +static void fill_block(__m128i *state, const block *ref_block, + block *next_block, int with_xor) { + __m128i block_XY[ARGON2_OWORDS_IN_BLOCK]; + unsigned int i; + + if (with_xor) { + for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { + state[i] = _mm_xor_si128( + state[i], _mm_loadu_si128((const __m128i *)ref_block->v + i)); + block_XY[i] = _mm_xor_si128( + state[i], _mm_loadu_si128((const __m128i *)next_block->v + i)); + } + } else { + for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { + block_XY[i] = state[i] = _mm_xor_si128( + state[i], _mm_loadu_si128((const __m128i *)ref_block->v + i)); + } + } - UINT64_C(16531790085730132900), UINT64_C(17328824500878824371), - UINT64_C(8548260058287621283), UINT64_C(8641748798041936364) -}; + for (i = 0; i < 8; ++i) { + BLAKE2_ROUND(state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], + state[8 * i + 3], state[8 * i + 4], state[8 * i + 5], + state[8 * i + 6], state[8 * i + 7]); + } -void generate_addresses(const argon2_instance_t *instance, - const argon2_position_t *position, - uint64_t *pseudo_rands) -{ - uint8_t offset = position->pass * 16 + position->slice * 4; - pseudo_rands[0] = bad_rands[offset++]; - pseudo_rands[1] = bad_rands[offset++]; - pseudo_rands[2] = bad_rands[offset++]; - pseudo_rands[3] = bad_rands[offset++]; + for (i = 0; i < 8; ++i) { + BLAKE2_ROUND(state[8 * 0 + i], state[8 * 1 + i], state[8 * 2 + i], + state[8 * 3 + i], state[8 * 4 + i], state[8 * 5 + i], + state[8 * 6 + i], state[8 * 7 + i]); + } - /*if ((position->pass == 1 && position->slice == 3)) - print64("pseudo_rands", pseudo_rands, 4);*/ + for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { + state[i] = _mm_xor_si128(state[i], block_XY[i]); + _mm_storeu_si128((__m128i *)next_block->v + i, state[i]); + } +} +#endif + +static void next_addresses(block *address_block, block *input_block) { + /*Temporary zero-initialized blocks*/ +#if defined(__AVX512F__) + __m512i zero_block[ARGON2_512BIT_WORDS_IN_BLOCK]; + __m512i zero2_block[ARGON2_512BIT_WORDS_IN_BLOCK]; +#elif defined(__AVX2__) + __m256i zero_block[ARGON2_HWORDS_IN_BLOCK]; + __m256i zero2_block[ARGON2_HWORDS_IN_BLOCK]; +#else + __m128i zero_block[ARGON2_OWORDS_IN_BLOCK]; + __m128i zero2_block[ARGON2_OWORDS_IN_BLOCK]; +#endif + + memset(zero_block, 0, sizeof(zero_block)); + memset(zero2_block, 0, sizeof(zero2_block)); + + /*Increasing index counter*/ + input_block->v[6]++; + + /*First iteration of G*/ + fill_block(zero_block, input_block, address_block, 0); + + /*Second iteration of G*/ + fill_block(zero2_block, address_block, address_block, 0); } - -#define SEGMENT_LENGTH 4 -#define LANE_LENGTH 16 -#define POS_LANE 0 void fill_segment(const argon2_instance_t *instance, - argon2_position_t position) -{ + argon2_position_t position) { block *ref_block = NULL, *curr_block = NULL; - uint64_t pseudo_rand, ref_index; + block address_block, input_block; + uint64_t pseudo_rand, ref_index, ref_lane; uint32_t prev_offset, curr_offset; - uint8_t i; - __m128i state[64]; - int data_independent_addressing = (instance->type == Argon2_i); - - /* Pseudo-random values that determine the reference block position */ - uint64_t *pseudo_rands = NULL; - - pseudo_rands = (uint64_t *)malloc(/*sizeof(uint64_t) * 4*/32); - - if (data_independent_addressing) { - generate_addresses(instance, &position, pseudo_rands); + uint32_t starting_index, i; +#if defined(__AVX512F__) + __m512i state[ARGON2_512BIT_WORDS_IN_BLOCK]; +#elif defined(__AVX2__) + __m256i state[ARGON2_HWORDS_IN_BLOCK]; +#else + __m128i state[ARGON2_OWORDS_IN_BLOCK]; +#endif + int data_independent_addressing; + + if (instance == NULL) { + return; } - i = 0; + starting_index = 0; if ((0 == position.pass) && (0 == position.slice)) { - i = 2; /* we have already generated the first two blocks */ + starting_index = 2; /* we have already generated the first two blocks */ + + /* Don't forget to generate the first block of addresses: */ + if (data_independent_addressing) { + next_addresses(&address_block, &input_block); + } } - /*printf("Position.lane = %d\nPosition.slice = %d\nStarting index : %d\n", position.lane, position.slice, starting_index);*/ /* Offset of the current block */ - curr_offset = position.slice * 4 + i; + curr_offset = position.lane * instance->lane_length + + position.slice * instance->segment_length + starting_index; - if (0 == curr_offset % 16) { + if (0 == curr_offset % instance->lane_length) { /* Last block in this lane */ - prev_offset = curr_offset + /*instance->lane_length - 1*/15; + prev_offset = curr_offset + instance->lane_length - 1; } else { /* Previous block */ prev_offset = curr_offset - 1; @@ -152,34 +216,45 @@ void fill_segment(const argon2_instance_t *instance, memcpy(state, ((instance->memory + prev_offset)->v), ARGON2_BLOCK_SIZE); - for (; i < SEGMENT_LENGTH; + for (i = starting_index; i < instance->segment_length; ++i, ++curr_offset, ++prev_offset) { /*1.1 Rotating prev_offset if needed */ - if (curr_offset % LANE_LENGTH == 1) { + if (curr_offset % instance->lane_length == 1) { prev_offset = curr_offset - 1; } /* 1.2 Computing the index of the reference block */ /* 1.2.1 Taking pseudo-random value from the previous block */ if (data_independent_addressing) { - pseudo_rand = pseudo_rands[i]; + if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) { + next_addresses(&address_block, &input_block); + } + pseudo_rand = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK]; } else { pseudo_rand = instance->memory[prev_offset].v[0]; } /* 1.2.2 Computing the lane of the reference block */ + ref_lane = ((pseudo_rand >> 32)) % instance->lanes; + + if ((position.pass == 0) && (position.slice == 0)) { + /* Can not reference other lanes yet */ + ref_lane = position.lane; + } /* 1.2.3 Computing the number of possible reference block within the * lane. */ position.index = i; - ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF,1); + ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF, + ref_lane == position.lane); /* 2 Creating a new block */ - ref_block = instance->memory + ref_index; + ref_block = + instance->memory + instance->lane_length * ref_lane + ref_index; curr_block = instance->memory + curr_offset; - fill_block(state, (__m128i const *)ref_block->v, (__m128i *)curr_block->v); - } + + fill_block(state, ref_block, curr_block, 0); - free(pseudo_rands); -} + } +} \ No newline at end of file diff --git a/stratum/algos/ar2/opt.h b/stratum/algos/ar2/opt.h deleted file mode 100644 index ec89b960e..000000000 --- a/stratum/algos/ar2/opt.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Argon2 source code package - * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 - * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. - * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . - */ - -#ifndef ARGON2_OPT_H -#define ARGON2_OPT_H - -/* - * Function fills a new memory block. Differs from the - * @param state Pointer to the just produced block. Content will be updated(!) - * @param ref_block Pointer to the reference block - * @param next_block Pointer to the block to be constructed - * @pre all block pointers must be valid - */ -void fill_block(__m128i *state, __m128i const *ref_block, __m128i *next_block); - -/* - * Generate pseudo-random values to reference blocks in the segment and puts - * them into the array - * @param instance Pointer to the current instance - * @param position Pointer to the current position - * @param pseudo_rands Pointer to the array of 64-bit values - * @pre pseudo_rands must point to @a instance->segment_length allocated values - */ -void generate_addresses(const argon2_instance_t *instance, - const argon2_position_t *position, - uint64_t *pseudo_rands); - -/* - * Function that fills the segment using previous segments also from other - * threads. - * Identical to the reference code except that it calls optimized FillBlock() - * @param instance Pointer to the current instance - * @param position Current position - * @pre all block pointers must be valid - */ -void fill_segment(const argon2_instance_t *instance, - argon2_position_t position); - -#endif /* ARGON2_OPT_H */ diff --git a/stratum/algos/ar2/ref.c b/stratum/algos/ar2/ref.c deleted file mode 100644 index 98ae07c9a..000000000 --- a/stratum/algos/ar2/ref.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Argon2 source code package - * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 - * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. - * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . - */ - -#include -#include -#include - -#include "argon2.h" -#include "cores.h" -#include "ref.h" - -#include "blake2/blamka-round-ref.h" -#include "blake2/blake2-impl.h" -#include "blake2/blake2.h" - -void fill_block(const block *prev_block, const block *ref_block, - block *next_block) { - block blockR, block_tmp; - unsigned i; - - copy_block(&blockR, ref_block); - xor_block(&blockR, prev_block); - copy_block(&block_tmp, &blockR); - - /* Apply Blake2 on columns of 64-bit words: (0,1,...,15) , then - (16,17,..31)... finally (112,113,...127) */ - for (i = 0; i < 8; ++i) { - BLAKE2_ROUND_NOMSG( - blockR.v[16 * i], blockR.v[16 * i + 1], blockR.v[16 * i + 2], - blockR.v[16 * i + 3], blockR.v[16 * i + 4], blockR.v[16 * i + 5], - blockR.v[16 * i + 6], blockR.v[16 * i + 7], blockR.v[16 * i + 8], - blockR.v[16 * i + 9], blockR.v[16 * i + 10], blockR.v[16 * i + 11], - blockR.v[16 * i + 12], blockR.v[16 * i + 13], blockR.v[16 * i + 14], - blockR.v[16 * i + 15]); - } - - /* Apply Blake2 on rows of 64-bit words: (0,1,16,17,...112,113), then - (2,3,18,19,...,114,115).. finally (14,15,30,31,...,126,127) */ - for (i = 0; i < 8; i++) { - BLAKE2_ROUND_NOMSG( - blockR.v[2 * i], blockR.v[2 * i + 1], blockR.v[2 * i + 16], - blockR.v[2 * i + 17], blockR.v[2 * i + 32], blockR.v[2 * i + 33], - blockR.v[2 * i + 48], blockR.v[2 * i + 49], blockR.v[2 * i + 64], - blockR.v[2 * i + 65], blockR.v[2 * i + 80], blockR.v[2 * i + 81], - blockR.v[2 * i + 96], blockR.v[2 * i + 97], blockR.v[2 * i + 112], - blockR.v[2 * i + 113]); - } - - copy_block(next_block, &block_tmp); - xor_block(next_block, &blockR); -} - -void generate_addresses(const argon2_instance_t *instance, - const argon2_position_t *position, - uint64_t *pseudo_rands) { - block zero_block, input_block, address_block; - uint32_t i; - - init_block_value(&zero_block, 0); - init_block_value(&input_block, 0); - init_block_value(&address_block, 0); - - if (instance != NULL && position != NULL) { - input_block.v[0] = position->pass; - input_block.v[1] = position->lane; - input_block.v[2] = position->slice; - input_block.v[3] = 16; - input_block.v[4] = 2; - input_block.v[5] = instance->type; - - for (i = 0; i < 4; ++i) { - if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) { - input_block.v[6]++; - fill_block(&zero_block, &input_block, &address_block); - fill_block(&zero_block, &address_block, &address_block); - } - - pseudo_rands[i] = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK]; - } - } -} - -void fill_segment(const argon2_instance_t *instance, - argon2_position_t position) { - block *ref_block = NULL, *curr_block = NULL; - uint64_t pseudo_rand, ref_index, ref_lane; - uint32_t prev_offset, curr_offset; - uint32_t starting_index; - uint32_t i; - int data_independent_addressing = (instance->type == Argon2_i); - /* Pseudo-random values that determine the reference block position */ - uint64_t *pseudo_rands = NULL; - - if (instance == NULL) { - return; - } - - pseudo_rands = - (uint64_t *)malloc(sizeof(uint64_t) * 4); - - if (pseudo_rands == NULL) { - return; - } - - if (data_independent_addressing) { - generate_addresses(instance, &position, pseudo_rands); - } - - starting_index = 0; - - if ((0 == position.pass) && (0 == position.slice)) { - starting_index = 2; /* we have already generated the first two blocks */ - } - - /* Offset of the current block */ - curr_offset = position.lane * 16 + - position.slice * 4 + starting_index; - - if (0 == curr_offset % 16) { - /* Last block in this lane */ - prev_offset = curr_offset + 16 - 1; - } else { - /* Previous block */ - prev_offset = curr_offset - 1; - } - - for (i = starting_index; i < 4; ++i, ++curr_offset, ++prev_offset) { - /*1.1 Rotating prev_offset if needed */ - if (curr_offset % 16 == 1) { - prev_offset = curr_offset - 1; - } - - /* 1.2 Computing the index of the reference block */ - /* 1.2.1 Taking pseudo-random value from the previous block */ - if (data_independent_addressing) { - pseudo_rand = pseudo_rands[i]; - } else { - pseudo_rand = instance->memory[prev_offset].v[0]; - } - - /* 1.2.2 Computing the lane of the reference block */ - ref_lane = ((pseudo_rand >> 32)) % 1; - - if ((position.pass == 0) && (position.slice == 0)) { - /* Can not reference other lanes yet */ - ref_lane = position.lane; - } - - /* 1.2.3 Computing the number of possible reference block within the - * lane. - */ - position.index = i; - ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF, - ref_lane == position.lane); - - /* 2 Creating a new block */ - ref_block = - instance->memory + 16 * ref_lane + ref_index; - curr_block = instance->memory + curr_offset; - fill_block(instance->memory + prev_offset, ref_block, curr_block); - } - - free(pseudo_rands); -} diff --git a/stratum/algos/ar2/ref.h b/stratum/algos/ar2/ref.h deleted file mode 100644 index 7ee22eef9..000000000 --- a/stratum/algos/ar2/ref.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Argon2 source code package - * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 - * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. - * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . - */ - -#ifndef ARGON2_REF_H -#define ARGON2_REF_H - -/* - * Function fills a new memory block - * @param prev_block Pointer to the previous block - * @param ref_block Pointer to the reference block - * @param next_block Pointer to the block to be constructed - * @pre all block pointers must be valid - */ -void fill_block(const block *prev_block, const block *ref_block, - block *next_block); - -/* - * Generate pseudo-random values to reference blocks in the segment and puts - * them into the array - * @param instance Pointer to the current instance - * @param position Pointer to the current position - * @param pseudo_rands Pointer to the array of 64-bit values - * @pre pseudo_rands must point to @a instance->segment_length allocated values - */ -void generate_addresses(const argon2_instance_t *instance, - const argon2_position_t *position, - uint64_t *pseudo_rands); - -/* - * Function that fills the segment using previous segments also from other - * threads - * @param instance Pointer to the current instance - * @param position Current position - * @pre all block pointers must be valid - */ -void fill_segment(const argon2_instance_t *instance, - argon2_position_t position); - -#endif /* ARGON2_REF_H */ diff --git a/stratum/algos/ar2/run.c b/stratum/algos/ar2/run.c deleted file mode 100644 index 2b1b30a37..000000000 --- a/stratum/algos/ar2/run.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Argon2 source code package - * - * Written by Daniel Dinu and Dmitry Khovratovich, 2015 - * - * This work is licensed under a Creative Commons CC0 1.0 License/Waiver. - * - * You should have received a copy of the CC0 Public Domain Dedication along - * with - * this software. If not, see - * . - */ - -#include -#include -#include -#include -#include -#include - -#include "argon2.h" -#include "cores.h" - -#define T_COST_DEF 3 -#define LOG_M_COST_DEF 12 /* 2^12 = 4 MiB */ -#define LANES_DEF 1 -#define THREADS_DEF 1 -#define OUT_LEN 32 -#define SALT_LEN 16 - -#define UNUSED_PARAMETER(x) (void)(x) - -static void usage(const char *cmd) { - printf("Usage: %s pwd salt [-y version] [-t iterations] [-m memory] [-p " - "parallelism]\n", - cmd); - - printf("Parameters:\n"); - printf("\tpwd\t\tThe password to hash\n"); - printf("\tsalt\t\tThe salt to use, at most 16 characters\n"); - printf("\t-d\t\tUse Argon2d instead of Argon2i (which is the default)\n"); - printf("\t-t N\t\tSets the number of iterations to N (default = %d)\n", - T_COST_DEF); - printf("\t-m N\t\tSets the memory usage of 2^N KiB (default %d)\n", - LOG_M_COST_DEF); - printf("\t-p N\t\tSets parallelism to N threads (default %d)\n", - THREADS_DEF); -} - -static void fatal(const char *error) { - fprintf(stderr, "Error: %s\n", error); - exit(1); -} - -/* -Runs Argon2 with certain inputs and parameters, inputs not cleared. Prints the -Base64-encoded hash string -@out output array with at least 32 bytes allocated -@pwd NULL-terminated string, presumably from argv[] -@salt salt array with at least SALTLEN_DEF bytes allocated -@t_cost number of iterations -@m_cost amount of requested memory in KB -@lanes amount of requested parallelism -@threads actual parallelism -@type String, only "d" and "i" are accepted -*/ -static void run(uint8_t *out, char *pwd, uint8_t *salt, uint32_t t_cost, - uint32_t m_cost, uint32_t lanes, uint32_t threads, - const char *type) { - clock_t start_time, stop_time; - unsigned pwd_length; - argon2_context context; - int i; - - start_time = clock(); - - if (!pwd) { - fatal("password missing"); - } - - if (!salt) { - secure_wipe_memory(pwd, strlen(pwd)); - fatal("salt missing"); - } - - pwd_length = strlen(pwd); - - UNUSED_PARAMETER(threads); - - context.out = out; - context.outlen = OUT_LEN; - context.pwd = (uint8_t *)pwd; - context.pwdlen = pwd_length; - context.salt = salt; - context.saltlen = SALT_LEN; - context.secret = NULL; - context.secretlen = 0; - context.ad = NULL; - context.adlen = 0; - context.t_cost = t_cost; - context.m_cost = m_cost; - context.lanes = lanes; - context.threads = lanes; - context.allocate_cbk = NULL; - context.free_cbk = NULL; - context.flags = ARGON2_FLAG_CLEAR_PASSWORD; - - if (!strcmp(type, "d")) { - int result = argon2d(&context); - if (result != ARGON2_OK) - fatal(error_message(result)); - } else if (!strcmp(type, "i")) { - int result = argon2i(&context); - if (result != ARGON2_OK) - fatal(error_message(result)); - } else { - secure_wipe_memory(pwd, strlen(pwd)); - fatal("wrong Argon2 type"); - } - - stop_time = clock(); - - /* add back when proper decoding */ - /* - char encoded[300]; - encode_string(encoded, sizeof encoded, &context); - printf("%s\n", encoded); - */ - printf("Hash:\t\t"); - for (i = 0; i < context.outlen; ++i) { - printf("%02x", context.out[i]); - } - printf("\n"); - - printf("%2.3f seconds\n", - ((double)stop_time - start_time) / (CLOCKS_PER_SEC)); -} - -int main(int argc, char *argv[]) { - unsigned char out[OUT_LEN]; - uint32_t m_cost = 1 << LOG_M_COST_DEF; - uint32_t t_cost = T_COST_DEF; - uint32_t lanes = LANES_DEF; - uint32_t threads = THREADS_DEF; - char *pwd = NULL; - uint8_t salt[SALT_LEN]; - const char *type = "i"; - int i; - - if (argc < 3) { - usage(argv[0]); - return ARGON2_MISSING_ARGS; - } - - /* get password and salt from command line */ - pwd = argv[1]; - if (strlen(argv[2]) > SALT_LEN) { - fatal("salt too long"); - } - memset(salt, 0x00, SALT_LEN); /* pad with null bytes */ - memcpy(salt, argv[2], strlen(argv[2])); - - /* parse options */ - for (i = 3; i < argc; i++) { - const char *a = argv[i]; - unsigned long input = 0; - if (!strcmp(a, "-m")) { - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - if (input == 0 || input == ULONG_MAX || - input > ARGON2_MAX_MEMORY_BITS) { - fatal("bad numeric input for -m"); - } - m_cost = ARGON2_MIN(UINT64_C(1) << input, UINT32_C(0xFFFFFFFF)); - if (m_cost > ARGON2_MAX_MEMORY) { - fatal("m_cost overflow"); - } - continue; - } else { - fatal("missing -m argument"); - } - } else if (!strcmp(a, "-t")) { - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - if (input == 0 || input == ULONG_MAX || - input > ARGON2_MAX_TIME) { - fatal("bad numeric input for -t"); - } - t_cost = input; - continue; - } else { - fatal("missing -t argument"); - } - } else if (!strcmp(a, "-p")) { - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - if (input == 0 || input == ULONG_MAX || - input > ARGON2_MAX_THREADS || input > ARGON2_MAX_LANES) { - fatal("bad numeric input for -p"); - } - threads = input; - lanes = threads; - continue; - } else { - fatal("missing -p argument"); - } - } else if (!strcmp(a, "-d")) { - type = "d"; - } else { - fatal("unknown argument"); - } - } - printf("Type:\t\tArgon2%c\n", type[0]); - printf("Iterations:\t%" PRIu32 " \n", t_cost); - printf("Memory:\t\t%" PRIu32 " KiB\n", m_cost); - printf("Parallelism:\t%" PRIu32 " \n", lanes); - run(out, pwd, salt, t_cost, m_cost, lanes, threads, type); - - return ARGON2_OK; -} diff --git a/stratum/algos/ar2/thread.c b/stratum/algos/ar2/thread.c new file mode 100644 index 000000000..75d71db37 --- /dev/null +++ b/stratum/algos/ar2/thread.c @@ -0,0 +1,57 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + +#if !defined(ARGON2_NO_THREADS) + +#include "thread.h" +#if defined(_WIN32) +#include +#endif + +int argon2_thread_create(argon2_thread_handle_t *handle, + argon2_thread_func_t func, void *args) { + if (NULL == handle || func == NULL) { + return -1; + } +#if defined(_WIN32) + *handle = _beginthreadex(NULL, 0, func, args, 0, NULL); + return *handle != 0 ? 0 : -1; +#else + return pthread_create(handle, NULL, func, args); +#endif +} + +int argon2_thread_join(argon2_thread_handle_t handle) { +#if defined(_WIN32) + if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) { + return CloseHandle((HANDLE)handle) != 0 ? 0 : -1; + } + return -1; +#else + return pthread_join(handle, NULL); +#endif +} + +void argon2_thread_exit(void) { +#if defined(_WIN32) + _endthreadex(0); +#else + pthread_exit(NULL); +#endif +} + +#endif /* ARGON2_NO_THREADS */ \ No newline at end of file diff --git a/stratum/algos/ar2/thread.h b/stratum/algos/ar2/thread.h new file mode 100644 index 000000000..098ba6430 --- /dev/null +++ b/stratum/algos/ar2/thread.h @@ -0,0 +1,67 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + +#ifndef ARGON2_THREAD_H +#define ARGON2_THREAD_H + +#if !defined(ARGON2_NO_THREADS) + +/* + Here we implement an abstraction layer for the simpĺe requirements + of the Argon2 code. We only require 3 primitives---thread creation, + joining, and termination---so full emulation of the pthreads API + is unwarranted. Currently we wrap pthreads and Win32 threads. + + The API defines 2 types: the function pointer type, + argon2_thread_func_t, + and the type of the thread handle---argon2_thread_handle_t. +*/ +#if defined(_WIN32) +#include +typedef unsigned(__stdcall *argon2_thread_func_t)(void *); +typedef uintptr_t argon2_thread_handle_t; +#else +#include +typedef void *(*argon2_thread_func_t)(void *); +typedef pthread_t argon2_thread_handle_t; +#endif + +/* Creates a thread + * @param handle pointer to a thread handle, which is the output of this + * function. Must not be NULL. + * @param func A function pointer for the thread's entry point. Must not be + * NULL. + * @param args Pointer that is passed as an argument to @func. May be NULL. + * @return 0 if @handle and @func are valid pointers and a thread is successfuly + * created. + */ +int argon2_thread_create(argon2_thread_handle_t *handle, + argon2_thread_func_t func, void *args); + +/* Waits for a thread to terminate + * @param handle Handle to a thread created with argon2_thread_create. + * @return 0 if @handle is a valid handle, and joining completed successfully. +*/ +int argon2_thread_join(argon2_thread_handle_t handle); + +/* Terminate the current thread. Must be run inside a thread created by + * argon2_thread_create. +*/ +void argon2_thread_exit(void); + +#endif /* ARGON2_NO_THREADS */ +#endif \ No newline at end of file diff --git a/stratum/algos/argon2a.c b/stratum/algos/argon2a.c index eab0d81a9..e32b0b8f1 100644 --- a/stratum/algos/argon2a.c +++ b/stratum/algos/argon2a.c @@ -5,8 +5,9 @@ #include "sysendian.h" +#include "argon2a.h" #include "ar2/argon2.h" -#include "ar2/cores.h" +#include "ar2/core.h" #include "ar2/ar2-scrypt-jane.h" #define _ALIGN(x) __attribute__ ((aligned(x))) @@ -24,10 +25,10 @@ inline void argon_call(void *out, void *in, void *salt, int type) context.pwd = (uint8_t *)in; context.salt = (uint8_t *)salt; - argon2_core(&context, type); + argon2_ctx(&context, type); } -void argon2_hash(const char* input, char* output, uint32_t len) +void argon2a_hash(const char* input, char* output, uint32_t len) { uint32_t _ALIGN(32) hashA[8], hashB[8]; diff --git a/stratum/algos/argon2a.h b/stratum/algos/argon2a.h index 05238ffea..2cfe3f0d5 100644 --- a/stratum/algos/argon2a.h +++ b/stratum/algos/argon2a.h @@ -7,7 +7,7 @@ extern "C" { #include -void argon2_hash(const char* input, char* output, uint32_t len); +void argon2a_hash(const char* input, char* output, uint32_t len); #ifdef __cplusplus } diff --git a/stratum/algos/argon2d-dyn.c b/stratum/algos/argon2d-dyn.c new file mode 100644 index 000000000..c9c6a5677 --- /dev/null +++ b/stratum/algos/argon2d-dyn.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +#include "sysendian.h" + +#include "ar2/argon2.h" +#include "ar2/core.h" + +static const size_t INPUT_BYTES = 80; // Lenth of a block header in bytes. Input Length = Salt Length (salt = input) +static const size_t OUTPUT_BYTES = 32; // Length of output needed for a 256-bit hash +static const unsigned int DEFAULT_ARGON2_FLAG = 2; //Same as ARGON2_DEFAULT_FLAGS + +void argon2d_call(const void *input, void *output) +{ + argon2_context context; + context.out = (uint8_t *)output; + context.outlen = (uint32_t)OUTPUT_BYTES; + context.pwd = (uint8_t *)input; + context.pwdlen = (uint32_t)INPUT_BYTES; + context.salt = (uint8_t *)input; //salt = input + context.saltlen = (uint32_t)INPUT_BYTES; + context.secret = NULL; + context.secretlen = 0; + context.ad = NULL; + context.adlen = 0; + context.allocate_cbk = NULL; + context.free_cbk = NULL; + context.flags = DEFAULT_ARGON2_FLAG; // = ARGON2_DEFAULT_FLAGS + // main configurable Argon2 hash parameters + context.m_cost = 500; // Memory in KiB (512KB) + context.lanes = 8; // Degree of Parallelism + context.threads = 1; // Threads + context.t_cost = 2; // Iterations + + argon2_ctx(&context, Argon2_d); +} + +void argon2d_dyn_hash(const unsigned char* input, unsigned char* output, unsigned int len) +{ + argon2d_call(input, output); +} \ No newline at end of file diff --git a/stratum/algos/argon2d-dyn.h b/stratum/algos/argon2d-dyn.h new file mode 100644 index 000000000..1d5f99ca6 --- /dev/null +++ b/stratum/algos/argon2d-dyn.h @@ -0,0 +1,16 @@ +#ifndef ARGON2D_H +#define ARGON2D_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void argon2d_dyn_hash(const char* input, char* output, unsigned int len); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/stratum/algos/bastion.c b/stratum/algos/bastion.c new file mode 100644 index 000000000..839f0541e --- /dev/null +++ b/stratum/algos/bastion.c @@ -0,0 +1,102 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define _ALIGN(x) __attribute__ ((aligned(x))) + +void bastion_hash(const char* input, char* output, uint32_t len) +{ + unsigned char _ALIGN(128) hash[64] = { 0 }; + + sph_echo512_context ctx_echo; + sph_luffa512_context ctx_luffa; + sph_fugue512_context ctx_fugue; + sph_whirlpool_context ctx_whirlpool; + sph_shabal512_context ctx_shabal; + sph_skein512_context ctx_skein; + sph_hamsi512_context ctx_hamsi; + + HEFTY1(input, len, hash); + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + if (hash[0] & 0x8) + { + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + } else { + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + } + + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, hash, 64); + sph_whirlpool_close(&ctx_whirlpool, hash); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + if (hash[0] & 0x8) + { + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + } else { + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + } + + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + if (hash[0] & 0x8) + { + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + } else { + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, hash, 64); + sph_whirlpool_close(&ctx_whirlpool, hash); + } + + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + if (hash[0] & 0x8) + { + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + } else { + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + } + + memcpy(output, hash, 32); +} + diff --git a/stratum/algos/bastion.h b/stratum/algos/bastion.h new file mode 100644 index 000000000..4de219ad0 --- /dev/null +++ b/stratum/algos/bastion.h @@ -0,0 +1,16 @@ +#ifndef BASTION_H +#define BASTION_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void bastion_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/bitcore.c b/stratum/algos/bitcore.c new file mode 100644 index 000000000..c0ef31e9a --- /dev/null +++ b/stratum/algos/bitcore.c @@ -0,0 +1,171 @@ +#include +#include +#include + +#define HASH_FUNC_BASE_TIMESTAMP 1492973331U // BitCore: Genesis Timestamp +#define HASH_FUNC_COUNT 10 +#define HASH_FUNC_COUNT_PERMUTATIONS 40320 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define _ALIGN(x) __attribute__ ((aligned(x))) + +// helpers +inline void swap(int *a, int *b) { + int c = *a; + *a = *b; + *b = c; +} + +static void reverse(int *pbegin, int *pend) { + while ( (pbegin != pend) && (pbegin != --pend) ) + swap(pbegin++, pend); +} + +static void next_permutation(int *pbegin, int *pend) { + if (pbegin == pend) + return; + + int *i = pbegin; + ++i; + if (i == pend) + return; + + i = pend; + --i; + + while (1) { + int *j = i; + --i; + + if (*i < *j) { + int *k = pend; + + while (!(*i < *--k)) + /* pass */; + + swap(i, k); + reverse(j, pend); + return; // true + } + + if (i == pbegin) { + reverse(pbegin, pend); + return; // false + } + } +} +// helpers + +void timetravel10_hash(const char* input, char* output, uint32_t len) +{ + uint32_t _ALIGN(64) hash[16 * HASH_FUNC_COUNT]; + uint32_t *hashA, *hashB; + uint32_t dataLen = 64; + uint32_t *work_data = (uint32_t *)input; + const uint32_t timestamp = work_data[17]; + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + + // We want to permute algorithms. To get started we + // initialize an array with a sorted sequence of unique + // integers where every integer represents its own algorithm. + uint32_t permutation[HASH_FUNC_COUNT]; + for (uint32_t i = 0; i < HASH_FUNC_COUNT; i++) { + permutation[i]=i; + } + + // Compute the next permuation + uint32_t steps = (timestamp - HASH_FUNC_BASE_TIMESTAMP) % HASH_FUNC_COUNT_PERMUTATIONS; + for (uint32_t i = 0; i < steps; i++) { + next_permutation(permutation, permutation + HASH_FUNC_COUNT); + } + + for (uint32_t i = 0; i < HASH_FUNC_COUNT; i++) { + if (i == 0) { + dataLen = len; + hashA = work_data; + } else { + dataLen = 64; + hashA = &hash[16 * (i - 1)]; + } + hashB = &hash[16 * i]; + + switch(permutation[i]) { + case 0: + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, hashA, dataLen); + sph_blake512_close(&ctx_blake, hashB); + break; + case 1: + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hashA, dataLen); + sph_bmw512_close(&ctx_bmw, hashB); + break; + case 2: + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, hashA, dataLen); + sph_groestl512_close(&ctx_groestl, hashB); + break; + case 3: + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hashA, dataLen); + sph_skein512_close(&ctx_skein, hashB); + break; + case 4: + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hashA, dataLen); + sph_jh512_close(&ctx_jh, hashB); + break; + case 5: + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, hashA, dataLen); + sph_keccak512_close(&ctx_keccak, hashB); + break; + case 6: + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hashA, dataLen); + sph_luffa512_close(&ctx_luffa, hashB); + break; + case 7: + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, hashA, dataLen); + sph_cubehash512_close(&ctx_cubehash, hashB); + break; + case 8: + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, hashA, dataLen); + sph_shavite512_close(&ctx_shavite, hashB); + break; + case 9: + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, hashA, dataLen); + sph_simd512_close(&ctx_simd, hashB); + break; + default: + break; + } + } + + memcpy(output, &hash[16 * (HASH_FUNC_COUNT - 1)], 32); +} + diff --git a/stratum/algos/bitcore.h b/stratum/algos/bitcore.h new file mode 100644 index 000000000..12795dd80 --- /dev/null +++ b/stratum/algos/bitcore.h @@ -0,0 +1,16 @@ +#ifndef TIMETRAVEL10_H +#define TIMETRAVEL10_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void timetravel10_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/ar2/blake2/blake2-impl.h b/stratum/algos/blake2/blake2-impl.h similarity index 82% rename from stratum/algos/ar2/blake2/blake2-impl.h rename to stratum/algos/blake2/blake2-impl.h index 115a192db..241f0beb3 100644 --- a/stratum/algos/ar2/blake2/blake2-impl.h +++ b/stratum/algos/blake2/blake2-impl.h @@ -1,3 +1,20 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + #ifndef PORTABLE_BLAKE2_IMPL_H #define PORTABLE_BLAKE2_IMPL_H @@ -134,10 +151,6 @@ static BLAKE2_INLINE uint64_t rotr64(const uint64_t w, const unsigned c) { return (w >> c) | (w << (64 - c)); } -/* prevents compiler optimizing out memset() */ -static BLAKE2_INLINE void burn(void *v, size_t n) { - static void *(*const volatile memset_v)(void *, int, size_t) = &memset; - memset_v(v, 0, n); -} +void clear_internal_memory(void *v, size_t n); #endif diff --git a/stratum/algos/ar2/blake2/blake2.h b/stratum/algos/blake2/blake2.h similarity index 70% rename from stratum/algos/ar2/blake2/blake2.h rename to stratum/algos/blake2/blake2.h index 7d8d5eb51..12533d1e7 100644 --- a/stratum/algos/ar2/blake2/blake2.h +++ b/stratum/algos/blake2/blake2.h @@ -1,3 +1,20 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + #ifndef PORTABLE_BLAKE2_H #define PORTABLE_BLAKE2_H @@ -37,10 +54,10 @@ typedef struct __blake2b_state { uint64_t h[8]; uint64_t t[2]; uint64_t f[2]; + uint8_t buf[BLAKE2B_BLOCKBYTES]; unsigned buflen; unsigned outlen; uint8_t last_node; - uint8_t buf[BLAKE2B_BLOCKBYTES]; } blake2b_state; /* Ensure param structs have not been wrongly padded */ @@ -57,17 +74,15 @@ int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, size_t keylen); int blake2b_init_param(blake2b_state *S, const blake2b_param *P); int blake2b_update(blake2b_state *S, const void *in, size_t inlen); -void my_blake2b_update(blake2b_state *S, const void *in, size_t inlen); int blake2b_final(blake2b_state *S, void *out, size_t outlen); /* Simple API */ -int blake2b(void *out, const void *in, const void *key, size_t keylen); +int blake2b(void *out, size_t outlen, const void *in, size_t inlen, + const void *key, size_t keylen); /* Argon2 Team - Begin Code */ -int blake2b_long(void *out, const void *in); +int blake2b_long(void *out, size_t outlen, const void *in, size_t inlen); /* Argon2 Team - End Code */ -/* Miouyouyou */ -void blake2b_too(void *out, const void *in); #if defined(__cplusplus) } diff --git a/stratum/algos/blake2/blake2b.c b/stratum/algos/blake2/blake2b.c new file mode 100644 index 000000000..ca05df598 --- /dev/null +++ b/stratum/algos/blake2/blake2b.c @@ -0,0 +1,390 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + +#include +#include +#include + +#include "blake2.h" +#include "blake2-impl.h" + +static const uint64_t blake2b_IV[8] = { + UINT64_C(0x6a09e667f3bcc908), UINT64_C(0xbb67ae8584caa73b), + UINT64_C(0x3c6ef372fe94f82b), UINT64_C(0xa54ff53a5f1d36f1), + UINT64_C(0x510e527fade682d1), UINT64_C(0x9b05688c2b3e6c1f), + UINT64_C(0x1f83d9abfb41bd6b), UINT64_C(0x5be0cd19137e2179)}; + +static const unsigned int blake2b_sigma[12][16] = { + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3}, + {11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4}, + {7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8}, + {9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13}, + {2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9}, + {12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11}, + {13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10}, + {6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5}, + {10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0}, + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, + {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3}, +}; + +static BLAKE2_INLINE void blake2b_set_lastnode(blake2b_state *S) { + S->f[1] = (uint64_t)-1; +} + +static BLAKE2_INLINE void blake2b_set_lastblock(blake2b_state *S) { + if (S->last_node) { + blake2b_set_lastnode(S); + } + S->f[0] = (uint64_t)-1; +} + +static BLAKE2_INLINE void blake2b_increment_counter(blake2b_state *S, + uint64_t inc) { + S->t[0] += inc; + S->t[1] += (S->t[0] < inc); +} + +static BLAKE2_INLINE void blake2b_invalidate_state(blake2b_state *S) { + clear_internal_memory(S, sizeof(*S)); /* wipe */ + blake2b_set_lastblock(S); /* invalidate for further use */ +} + +static BLAKE2_INLINE void blake2b_init0(blake2b_state *S) { + memset(S, 0, sizeof(*S)); + memcpy(S->h, blake2b_IV, sizeof(S->h)); +} + +int blake2b_init_param(blake2b_state *S, const blake2b_param *P) { + const unsigned char *p = (const unsigned char *)P; + unsigned int i; + + if (NULL == P || NULL == S) { + return -1; + } + + blake2b_init0(S); + /* IV XOR Parameter Block */ + for (i = 0; i < 8; ++i) { + S->h[i] ^= load64(&p[i * sizeof(S->h[i])]); + } + S->outlen = P->digest_length; + return 0; +} + +/* Sequential blake2b initialization */ +int blake2b_init(blake2b_state *S, size_t outlen) { + blake2b_param P; + + if (S == NULL) { + return -1; + } + + if ((outlen == 0) || (outlen > BLAKE2B_OUTBYTES)) { + blake2b_invalidate_state(S); + return -1; + } + + /* Setup Parameter Block for unkeyed BLAKE2 */ + P.digest_length = (uint8_t)outlen; + P.key_length = 0; + P.fanout = 1; + P.depth = 1; + P.leaf_length = 0; + P.node_offset = 0; + P.node_depth = 0; + P.inner_length = 0; + memset(P.reserved, 0, sizeof(P.reserved)); + memset(P.salt, 0, sizeof(P.salt)); + memset(P.personal, 0, sizeof(P.personal)); + + return blake2b_init_param(S, &P); +} + +int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, + size_t keylen) { + blake2b_param P; + + if (S == NULL) { + return -1; + } + + if ((outlen == 0) || (outlen > BLAKE2B_OUTBYTES)) { + blake2b_invalidate_state(S); + return -1; + } + + if ((key == 0) || (keylen == 0) || (keylen > BLAKE2B_KEYBYTES)) { + blake2b_invalidate_state(S); + return -1; + } + + /* Setup Parameter Block for keyed BLAKE2 */ + P.digest_length = (uint8_t)outlen; + P.key_length = (uint8_t)keylen; + P.fanout = 1; + P.depth = 1; + P.leaf_length = 0; + P.node_offset = 0; + P.node_depth = 0; + P.inner_length = 0; + memset(P.reserved, 0, sizeof(P.reserved)); + memset(P.salt, 0, sizeof(P.salt)); + memset(P.personal, 0, sizeof(P.personal)); + + if (blake2b_init_param(S, &P) < 0) { + blake2b_invalidate_state(S); + return -1; + } + + { + uint8_t block[BLAKE2B_BLOCKBYTES]; + memset(block, 0, BLAKE2B_BLOCKBYTES); + memcpy(block, key, keylen); + blake2b_update(S, block, BLAKE2B_BLOCKBYTES); + /* Burn the key from stack */ + clear_internal_memory(block, BLAKE2B_BLOCKBYTES); + } + return 0; +} + +static void blake2b_compress(blake2b_state *S, const uint8_t *block) { + uint64_t m[16]; + uint64_t v[16]; + unsigned int i, r; + + for (i = 0; i < 16; ++i) { + m[i] = load64(block + i * sizeof(m[i])); + } + + for (i = 0; i < 8; ++i) { + v[i] = S->h[i]; + } + + v[8] = blake2b_IV[0]; + v[9] = blake2b_IV[1]; + v[10] = blake2b_IV[2]; + v[11] = blake2b_IV[3]; + v[12] = blake2b_IV[4] ^ S->t[0]; + v[13] = blake2b_IV[5] ^ S->t[1]; + v[14] = blake2b_IV[6] ^ S->f[0]; + v[15] = blake2b_IV[7] ^ S->f[1]; + +#define G(r, i, a, b, c, d) \ + do { \ + a = a + b + m[blake2b_sigma[r][2 * i + 0]]; \ + d = rotr64(d ^ a, 32); \ + c = c + d; \ + b = rotr64(b ^ c, 24); \ + a = a + b + m[blake2b_sigma[r][2 * i + 1]]; \ + d = rotr64(d ^ a, 16); \ + c = c + d; \ + b = rotr64(b ^ c, 63); \ + } while ((void)0, 0) + +#define ROUND(r) \ + do { \ + G(r, 0, v[0], v[4], v[8], v[12]); \ + G(r, 1, v[1], v[5], v[9], v[13]); \ + G(r, 2, v[2], v[6], v[10], v[14]); \ + G(r, 3, v[3], v[7], v[11], v[15]); \ + G(r, 4, v[0], v[5], v[10], v[15]); \ + G(r, 5, v[1], v[6], v[11], v[12]); \ + G(r, 6, v[2], v[7], v[8], v[13]); \ + G(r, 7, v[3], v[4], v[9], v[14]); \ + } while ((void)0, 0) + + for (r = 0; r < 12; ++r) { + ROUND(r); + } + + for (i = 0; i < 8; ++i) { + S->h[i] = S->h[i] ^ v[i] ^ v[i + 8]; + } + +#undef G +#undef ROUND +} + +int blake2b_update(blake2b_state *S, const void *in, size_t inlen) { + const uint8_t *pin = (const uint8_t *)in; + + if (inlen == 0) { + return 0; + } + + /* Sanity check */ + if (S == NULL || in == NULL) { + return -1; + } + + /* Is this a reused state? */ + if (S->f[0] != 0) { + return -1; + } + + if (S->buflen + inlen > BLAKE2B_BLOCKBYTES) { + /* Complete current block */ + size_t left = S->buflen; + size_t fill = BLAKE2B_BLOCKBYTES - left; + memcpy(&S->buf[left], pin, fill); + blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); + blake2b_compress(S, S->buf); + S->buflen = 0; + inlen -= fill; + pin += fill; + /* Avoid buffer copies when possible */ + while (inlen > BLAKE2B_BLOCKBYTES) { + blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); + blake2b_compress(S, pin); + inlen -= BLAKE2B_BLOCKBYTES; + pin += BLAKE2B_BLOCKBYTES; + } + } + memcpy(&S->buf[S->buflen], pin, inlen); + S->buflen += (unsigned int)inlen; + return 0; +} + +int blake2b_final(blake2b_state *S, void *out, size_t outlen) { + uint8_t buffer[BLAKE2B_OUTBYTES] = {0}; + unsigned int i; + + /* Sanity checks */ + if (S == NULL || out == NULL || outlen < S->outlen) { + return -1; + } + + /* Is this a reused state? */ + if (S->f[0] != 0) { + return -1; + } + + blake2b_increment_counter(S, S->buflen); + blake2b_set_lastblock(S); + memset(&S->buf[S->buflen], 0, BLAKE2B_BLOCKBYTES - S->buflen); /* Padding */ + blake2b_compress(S, S->buf); + + for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */ + store64(buffer + sizeof(S->h[i]) * i, S->h[i]); + } + + memcpy(out, buffer, S->outlen); + clear_internal_memory(buffer, sizeof(buffer)); + clear_internal_memory(S->buf, sizeof(S->buf)); + clear_internal_memory(S->h, sizeof(S->h)); + return 0; +} + +int blake2b(void *out, size_t outlen, const void *in, size_t inlen, + const void *key, size_t keylen) { + blake2b_state S; + int ret = -1; + + /* Verify parameters */ + if (NULL == in && inlen > 0) { + goto fail; + } + + if (NULL == out || outlen == 0 || outlen > BLAKE2B_OUTBYTES) { + goto fail; + } + + if ((NULL == key && keylen > 0) || keylen > BLAKE2B_KEYBYTES) { + goto fail; + } + + if (keylen > 0) { + if (blake2b_init_key(&S, outlen, key, keylen) < 0) { + goto fail; + } + } else { + if (blake2b_init(&S, outlen) < 0) { + goto fail; + } + } + + if (blake2b_update(&S, in, inlen) < 0) { + goto fail; + } + ret = blake2b_final(&S, out, outlen); + +fail: + clear_internal_memory(&S, sizeof(S)); + return ret; +} + +/* Argon2 Team - Begin Code */ +int blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) { + uint8_t *out = (uint8_t *)pout; + blake2b_state blake_state; + uint8_t outlen_bytes[sizeof(uint32_t)] = {0}; + int ret = -1; + + if (outlen > UINT32_MAX) { + goto fail; + } + + /* Ensure little-endian byte order! */ + store32(outlen_bytes, (uint32_t)outlen); + +#define TRY(statement) \ + do { \ + ret = statement; \ + if (ret < 0) { \ + goto fail; \ + } \ + } while ((void)0, 0) + + if (outlen <= BLAKE2B_OUTBYTES) { + TRY(blake2b_init(&blake_state, outlen)); + TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); + TRY(blake2b_update(&blake_state, in, inlen)); + TRY(blake2b_final(&blake_state, out, outlen)); + } else { + uint32_t toproduce; + uint8_t out_buffer[BLAKE2B_OUTBYTES]; + uint8_t in_buffer[BLAKE2B_OUTBYTES]; + TRY(blake2b_init(&blake_state, BLAKE2B_OUTBYTES)); + TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); + TRY(blake2b_update(&blake_state, in, inlen)); + TRY(blake2b_final(&blake_state, out_buffer, BLAKE2B_OUTBYTES)); + memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); + out += BLAKE2B_OUTBYTES / 2; + toproduce = (uint32_t)outlen - BLAKE2B_OUTBYTES / 2; + + while (toproduce > BLAKE2B_OUTBYTES) { + memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); + TRY(blake2b(out_buffer, BLAKE2B_OUTBYTES, in_buffer, + BLAKE2B_OUTBYTES, NULL, 0)); + memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); + out += BLAKE2B_OUTBYTES / 2; + toproduce -= BLAKE2B_OUTBYTES / 2; + } + + memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); + TRY(blake2b(out_buffer, toproduce, in_buffer, BLAKE2B_OUTBYTES, NULL, + 0)); + memcpy(out, out_buffer, toproduce); + } +fail: + clear_internal_memory(&blake_state, sizeof(blake_state)); + return ret; +#undef TRY +} +/* Argon2 Team - End Code */ diff --git a/stratum/algos/blake2/blamka-round-opt.h b/stratum/algos/blake2/blamka-round-opt.h new file mode 100644 index 000000000..faf96662e --- /dev/null +++ b/stratum/algos/blake2/blamka-round-opt.h @@ -0,0 +1,476 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + +#ifndef BLAKE_ROUND_MKA_OPT_H +#define BLAKE_ROUND_MKA_OPT_H + +#if defined(HAVE_CONFIG_H) +#include "config/dynamic-config.h" +#endif + +#include "blake2-impl.h" + +#include +#if defined(__SSSE3__) +#include /* for _mm_shuffle_epi8 and _mm_alignr_epi8 */ +#endif + +#if defined(__XOP__) && (defined(__GNUC__) || defined(__clang__)) +#include +#endif + +#if !defined(__AVX512F__) +#if !defined(__AVX2__) +#if !defined(__XOP__) +#if defined(__SSSE3__) +#define r16 \ + (_mm_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9)) +#define r24 \ + (_mm_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10)) +#define _mm_roti_epi64(x, c) \ + (-(c) == 32) \ + ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2, 3, 0, 1)) \ + : (-(c) == 24) \ + ? _mm_shuffle_epi8((x), r24) \ + : (-(c) == 16) \ + ? _mm_shuffle_epi8((x), r16) \ + : (-(c) == 63) \ + ? _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ + _mm_add_epi64((x), (x))) \ + : _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ + _mm_slli_epi64((x), 64 - (-(c)))) +#else /* defined(__SSE2__) */ +#define _mm_roti_epi64(r, c) \ + _mm_xor_si128(_mm_srli_epi64((r), -(c)), _mm_slli_epi64((r), 64 - (-(c)))) +#endif +#else +#endif + +static BLAKE2_INLINE __m128i fBlaMka(__m128i x, __m128i y) { + const __m128i z = _mm_mul_epu32(x, y); + return _mm_add_epi64(_mm_add_epi64(x, y), _mm_add_epi64(z, z)); +} + +#define G1(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + A0 = fBlaMka(A0, B0); \ + A1 = fBlaMka(A1, B1); \ + \ + D0 = _mm_xor_si128(D0, A0); \ + D1 = _mm_xor_si128(D1, A1); \ + \ + D0 = _mm_roti_epi64(D0, -32); \ + D1 = _mm_roti_epi64(D1, -32); \ + \ + C0 = fBlaMka(C0, D0); \ + C1 = fBlaMka(C1, D1); \ + \ + B0 = _mm_xor_si128(B0, C0); \ + B1 = _mm_xor_si128(B1, C1); \ + \ + B0 = _mm_roti_epi64(B0, -24); \ + B1 = _mm_roti_epi64(B1, -24); \ + } while ((void)0, 0) + +#define G2(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + A0 = fBlaMka(A0, B0); \ + A1 = fBlaMka(A1, B1); \ + \ + D0 = _mm_xor_si128(D0, A0); \ + D1 = _mm_xor_si128(D1, A1); \ + \ + D0 = _mm_roti_epi64(D0, -16); \ + D1 = _mm_roti_epi64(D1, -16); \ + \ + C0 = fBlaMka(C0, D0); \ + C1 = fBlaMka(C1, D1); \ + \ + B0 = _mm_xor_si128(B0, C0); \ + B1 = _mm_xor_si128(B1, C1); \ + \ + B0 = _mm_roti_epi64(B0, -63); \ + B1 = _mm_roti_epi64(B1, -63); \ + } while ((void)0, 0) + +#if defined(__SSSE3__) +#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + __m128i t0 = _mm_alignr_epi8(B1, B0, 8); \ + __m128i t1 = _mm_alignr_epi8(B0, B1, 8); \ + B0 = t0; \ + B1 = t1; \ + \ + t0 = C0; \ + C0 = C1; \ + C1 = t0; \ + \ + t0 = _mm_alignr_epi8(D1, D0, 8); \ + t1 = _mm_alignr_epi8(D0, D1, 8); \ + D0 = t1; \ + D1 = t0; \ + } while ((void)0, 0) + +#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + __m128i t0 = _mm_alignr_epi8(B0, B1, 8); \ + __m128i t1 = _mm_alignr_epi8(B1, B0, 8); \ + B0 = t0; \ + B1 = t1; \ + \ + t0 = C0; \ + C0 = C1; \ + C1 = t0; \ + \ + t0 = _mm_alignr_epi8(D0, D1, 8); \ + t1 = _mm_alignr_epi8(D1, D0, 8); \ + D0 = t1; \ + D1 = t0; \ + } while ((void)0, 0) +#else /* SSE2 */ +#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + __m128i t0 = D0; \ + __m128i t1 = B0; \ + D0 = C0; \ + C0 = C1; \ + C1 = D0; \ + D0 = _mm_unpackhi_epi64(D1, _mm_unpacklo_epi64(t0, t0)); \ + D1 = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(D1, D1)); \ + B0 = _mm_unpackhi_epi64(B0, _mm_unpacklo_epi64(B1, B1)); \ + B1 = _mm_unpackhi_epi64(B1, _mm_unpacklo_epi64(t1, t1)); \ + } while ((void)0, 0) + +#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + __m128i t0, t1; \ + t0 = C0; \ + C0 = C1; \ + C1 = t0; \ + t0 = B0; \ + t1 = D0; \ + B0 = _mm_unpackhi_epi64(B1, _mm_unpacklo_epi64(B0, B0)); \ + B1 = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(B1, B1)); \ + D0 = _mm_unpackhi_epi64(D0, _mm_unpacklo_epi64(D1, D1)); \ + D1 = _mm_unpackhi_epi64(D1, _mm_unpacklo_epi64(t1, t1)); \ + } while ((void)0, 0) +#endif + +#define BLAKE2_ROUND(A0, A1, B0, B1, C0, C1, D0, D1) \ + do { \ + G1(A0, B0, C0, D0, A1, B1, C1, D1); \ + G2(A0, B0, C0, D0, A1, B1, C1, D1); \ + \ + DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ + \ + G1(A0, B0, C0, D0, A1, B1, C1, D1); \ + G2(A0, B0, C0, D0, A1, B1, C1, D1); \ + \ + UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ + } while ((void)0, 0) + +#else /* __AVX2__ */ + +#include + +#define rotr32(x) _mm256_shuffle_epi32(x, _MM_SHUFFLE(2, 3, 0, 1)) +#define rotr24(x) _mm256_shuffle_epi8(x, _mm256_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10, 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10)) +#define rotr16(x) _mm256_shuffle_epi8(x, _mm256_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9, 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9)) +#define rotr63(x) _mm256_xor_si256(_mm256_srli_epi64((x), 63), _mm256_add_epi64((x), (x))) + +#define G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + do { \ + __m256i ml = _mm256_mul_epu32(A0, B0); \ + ml = _mm256_add_epi64(ml, ml); \ + A0 = _mm256_add_epi64(A0, _mm256_add_epi64(B0, ml)); \ + D0 = _mm256_xor_si256(D0, A0); \ + D0 = rotr32(D0); \ + \ + ml = _mm256_mul_epu32(C0, D0); \ + ml = _mm256_add_epi64(ml, ml); \ + C0 = _mm256_add_epi64(C0, _mm256_add_epi64(D0, ml)); \ + \ + B0 = _mm256_xor_si256(B0, C0); \ + B0 = rotr24(B0); \ + \ + ml = _mm256_mul_epu32(A1, B1); \ + ml = _mm256_add_epi64(ml, ml); \ + A1 = _mm256_add_epi64(A1, _mm256_add_epi64(B1, ml)); \ + D1 = _mm256_xor_si256(D1, A1); \ + D1 = rotr32(D1); \ + \ + ml = _mm256_mul_epu32(C1, D1); \ + ml = _mm256_add_epi64(ml, ml); \ + C1 = _mm256_add_epi64(C1, _mm256_add_epi64(D1, ml)); \ + \ + B1 = _mm256_xor_si256(B1, C1); \ + B1 = rotr24(B1); \ + } while((void)0, 0); + +#define G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + do { \ + __m256i ml = _mm256_mul_epu32(A0, B0); \ + ml = _mm256_add_epi64(ml, ml); \ + A0 = _mm256_add_epi64(A0, _mm256_add_epi64(B0, ml)); \ + D0 = _mm256_xor_si256(D0, A0); \ + D0 = rotr16(D0); \ + \ + ml = _mm256_mul_epu32(C0, D0); \ + ml = _mm256_add_epi64(ml, ml); \ + C0 = _mm256_add_epi64(C0, _mm256_add_epi64(D0, ml)); \ + B0 = _mm256_xor_si256(B0, C0); \ + B0 = rotr63(B0); \ + \ + ml = _mm256_mul_epu32(A1, B1); \ + ml = _mm256_add_epi64(ml, ml); \ + A1 = _mm256_add_epi64(A1, _mm256_add_epi64(B1, ml)); \ + D1 = _mm256_xor_si256(D1, A1); \ + D1 = rotr16(D1); \ + \ + ml = _mm256_mul_epu32(C1, D1); \ + ml = _mm256_add_epi64(ml, ml); \ + C1 = _mm256_add_epi64(C1, _mm256_add_epi64(D1, ml)); \ + B1 = _mm256_xor_si256(B1, C1); \ + B1 = rotr63(B1); \ + } while((void)0, 0); + +#define DIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + B0 = _mm256_permute4x64_epi64(B0, _MM_SHUFFLE(0, 3, 2, 1)); \ + C0 = _mm256_permute4x64_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ + D0 = _mm256_permute4x64_epi64(D0, _MM_SHUFFLE(2, 1, 0, 3)); \ + \ + B1 = _mm256_permute4x64_epi64(B1, _MM_SHUFFLE(0, 3, 2, 1)); \ + C1 = _mm256_permute4x64_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ + D1 = _mm256_permute4x64_epi64(D1, _MM_SHUFFLE(2, 1, 0, 3)); \ + } while((void)0, 0); + +#define DIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ + do { \ + __m256i tmp1 = _mm256_blend_epi32(B0, B1, 0xCC); \ + __m256i tmp2 = _mm256_blend_epi32(B0, B1, 0x33); \ + B1 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ + B0 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ + \ + tmp1 = C0; \ + C0 = C1; \ + C1 = tmp1; \ + \ + tmp1 = _mm256_blend_epi32(D0, D1, 0xCC); \ + tmp2 = _mm256_blend_epi32(D0, D1, 0x33); \ + D0 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ + D1 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ + } while(0); + +#define UNDIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + B0 = _mm256_permute4x64_epi64(B0, _MM_SHUFFLE(2, 1, 0, 3)); \ + C0 = _mm256_permute4x64_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ + D0 = _mm256_permute4x64_epi64(D0, _MM_SHUFFLE(0, 3, 2, 1)); \ + \ + B1 = _mm256_permute4x64_epi64(B1, _MM_SHUFFLE(2, 1, 0, 3)); \ + C1 = _mm256_permute4x64_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ + D1 = _mm256_permute4x64_epi64(D1, _MM_SHUFFLE(0, 3, 2, 1)); \ + } while((void)0, 0); + +#define UNDIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ + do { \ + __m256i tmp1 = _mm256_blend_epi32(B0, B1, 0xCC); \ + __m256i tmp2 = _mm256_blend_epi32(B0, B1, 0x33); \ + B0 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ + B1 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ + \ + tmp1 = C0; \ + C0 = C1; \ + C1 = tmp1; \ + \ + tmp1 = _mm256_blend_epi32(D0, D1, 0x33); \ + tmp2 = _mm256_blend_epi32(D0, D1, 0xCC); \ + D0 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ + D1 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ + } while((void)0, 0); + +#define BLAKE2_ROUND_1(A0, A1, B0, B1, C0, C1, D0, D1) \ + do{ \ + G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + \ + DIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ + \ + G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + \ + UNDIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ + } while((void)0, 0); + +#define BLAKE2_ROUND_2(A0, A1, B0, B1, C0, C1, D0, D1) \ + do{ \ + G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + \ + DIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ + \ + G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ + \ + UNDIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ + } while((void)0, 0); + +#endif /* __AVX2__ */ + +#else /* __AVX512F__ */ + +#include + +#define ror64(x, n) _mm512_ror_epi64((x), (n)) + +static __m512i muladd(__m512i x, __m512i y) +{ + __m512i z = _mm512_mul_epu32(x, y); + return _mm512_add_epi64(_mm512_add_epi64(x, y), _mm512_add_epi64(z, z)); +} + +#define G1(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + A0 = muladd(A0, B0); \ + A1 = muladd(A1, B1); \ +\ + D0 = _mm512_xor_si512(D0, A0); \ + D1 = _mm512_xor_si512(D1, A1); \ +\ + D0 = ror64(D0, 32); \ + D1 = ror64(D1, 32); \ +\ + C0 = muladd(C0, D0); \ + C1 = muladd(C1, D1); \ +\ + B0 = _mm512_xor_si512(B0, C0); \ + B1 = _mm512_xor_si512(B1, C1); \ +\ + B0 = ror64(B0, 24); \ + B1 = ror64(B1, 24); \ + } while ((void)0, 0) + +#define G2(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + A0 = muladd(A0, B0); \ + A1 = muladd(A1, B1); \ +\ + D0 = _mm512_xor_si512(D0, A0); \ + D1 = _mm512_xor_si512(D1, A1); \ +\ + D0 = ror64(D0, 16); \ + D1 = ror64(D1, 16); \ +\ + C0 = muladd(C0, D0); \ + C1 = muladd(C1, D1); \ +\ + B0 = _mm512_xor_si512(B0, C0); \ + B1 = _mm512_xor_si512(B1, C1); \ +\ + B0 = ror64(B0, 63); \ + B1 = ror64(B1, 63); \ + } while ((void)0, 0) + +#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + B0 = _mm512_permutex_epi64(B0, _MM_SHUFFLE(0, 3, 2, 1)); \ + B1 = _mm512_permutex_epi64(B1, _MM_SHUFFLE(0, 3, 2, 1)); \ +\ + C0 = _mm512_permutex_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ + C1 = _mm512_permutex_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ +\ + D0 = _mm512_permutex_epi64(D0, _MM_SHUFFLE(2, 1, 0, 3)); \ + D1 = _mm512_permutex_epi64(D1, _MM_SHUFFLE(2, 1, 0, 3)); \ + } while ((void)0, 0) + +#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + B0 = _mm512_permutex_epi64(B0, _MM_SHUFFLE(2, 1, 0, 3)); \ + B1 = _mm512_permutex_epi64(B1, _MM_SHUFFLE(2, 1, 0, 3)); \ +\ + C0 = _mm512_permutex_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ + C1 = _mm512_permutex_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ +\ + D0 = _mm512_permutex_epi64(D0, _MM_SHUFFLE(0, 3, 2, 1)); \ + D1 = _mm512_permutex_epi64(D1, _MM_SHUFFLE(0, 3, 2, 1)); \ + } while ((void)0, 0) + +#define BLAKE2_ROUND(A0, B0, C0, D0, A1, B1, C1, D1) \ + do { \ + G1(A0, B0, C0, D0, A1, B1, C1, D1); \ + G2(A0, B0, C0, D0, A1, B1, C1, D1); \ +\ + DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ +\ + G1(A0, B0, C0, D0, A1, B1, C1, D1); \ + G2(A0, B0, C0, D0, A1, B1, C1, D1); \ +\ + UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ + } while ((void)0, 0) + +#define SWAP_HALVES(A0, A1) \ + do { \ + __m512i t0, t1; \ + t0 = _mm512_shuffle_i64x2(A0, A1, _MM_SHUFFLE(1, 0, 1, 0)); \ + t1 = _mm512_shuffle_i64x2(A0, A1, _MM_SHUFFLE(3, 2, 3, 2)); \ + A0 = t0; \ + A1 = t1; \ + } while((void)0, 0) + +#define SWAP_QUARTERS(A0, A1) \ + do { \ + SWAP_HALVES(A0, A1); \ + A0 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A0); \ + A1 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A1); \ + } while((void)0, 0) + +#define UNSWAP_QUARTERS(A0, A1) \ + do { \ + A0 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A0); \ + A1 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A1); \ + SWAP_HALVES(A0, A1); \ + } while((void)0, 0) + +#define BLAKE2_ROUND_1(A0, C0, B0, D0, A1, C1, B1, D1) \ + do { \ + SWAP_HALVES(A0, B0); \ + SWAP_HALVES(C0, D0); \ + SWAP_HALVES(A1, B1); \ + SWAP_HALVES(C1, D1); \ + BLAKE2_ROUND(A0, B0, C0, D0, A1, B1, C1, D1); \ + SWAP_HALVES(A0, B0); \ + SWAP_HALVES(C0, D0); \ + SWAP_HALVES(A1, B1); \ + SWAP_HALVES(C1, D1); \ + } while ((void)0, 0) + +#define BLAKE2_ROUND_2(A0, A1, B0, B1, C0, C1, D0, D1) \ + do { \ + SWAP_QUARTERS(A0, A1); \ + SWAP_QUARTERS(B0, B1); \ + SWAP_QUARTERS(C0, C1); \ + SWAP_QUARTERS(D0, D1); \ + BLAKE2_ROUND(A0, B0, C0, D0, A1, B1, C1, D1); \ + UNSWAP_QUARTERS(A0, A1); \ + UNSWAP_QUARTERS(B0, B1); \ + UNSWAP_QUARTERS(C0, C1); \ + UNSWAP_QUARTERS(D0, D1); \ + } while ((void)0, 0) + +#endif /* __AVX512F__ */ +#endif /* BLAKE_ROUND_MKA_OPT_H */ \ No newline at end of file diff --git a/stratum/algos/ar2/blake2/blamka-round-ref.h b/stratum/algos/blake2/blamka-round-ref.h similarity index 75% rename from stratum/algos/ar2/blake2/blamka-round-ref.h rename to stratum/algos/blake2/blamka-round-ref.h index f497e10c2..2238959e1 100644 --- a/stratum/algos/ar2/blake2/blamka-round-ref.h +++ b/stratum/algos/blake2/blamka-round-ref.h @@ -1,3 +1,20 @@ +/* + * Argon2 reference source code package - reference C implementations + * + * Copyright 2015 + * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves + * + * You may use this work under the terms of a Creative Commons CC0 1.0 + * License/Waiver or the Apache Public License 2.0, at your option. The terms of + * these licenses can be found at: + * + * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 + * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 + * + * You should have received a copy of both of these licenses along with this + * software. If not, they may be obtained at the above URLs. + */ + #ifndef BLAKE_ROUND_MKA_H #define BLAKE_ROUND_MKA_H @@ -36,4 +53,4 @@ static BLAKE2_INLINE uint64_t fBlaMka(uint64_t x, uint64_t y) { G(v3, v4, v9, v14); \ } while ((void)0, 0) -#endif +#endif \ No newline at end of file diff --git a/stratum/algos/blake2b.c b/stratum/algos/blake2b.c new file mode 100644 index 000000000..e65d2d1e4 --- /dev/null +++ b/stratum/algos/blake2b.c @@ -0,0 +1,23 @@ +/** + * Blake2-B Implementation + * tpruvot@github 2016-2018 + */ + +#include +#include + +#include +#include + +void blake2b_hash(const char* input, char* output, uint32_t len) +{ + uint32_t ALIGN(64) hash[8]; + blake2b_ctx ctx; + + blake2b_init(&ctx, 32, NULL, 0); + blake2b_update(&ctx, input, len); + blake2b_final(&ctx, hash); + + memcpy(output, hash, 32); +} + diff --git a/stratum/algos/blake2b.h b/stratum/algos/blake2b.h new file mode 100644 index 000000000..eeda45c91 --- /dev/null +++ b/stratum/algos/blake2b.h @@ -0,0 +1,16 @@ +#ifndef BLAKE2B_H +#define BLAKE2B_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void blake2b_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/blake2.c b/stratum/algos/blake2s.c similarity index 100% rename from stratum/algos/blake2.c rename to stratum/algos/blake2s.c diff --git a/stratum/algos/blake2.h b/stratum/algos/blake2s.h similarity index 100% rename from stratum/algos/blake2.h rename to stratum/algos/blake2s.h diff --git a/stratum/algos/common.h b/stratum/algos/common.h new file mode 100644 index 000000000..eeaf89d9e --- /dev/null +++ b/stratum/algos/common.h @@ -0,0 +1,4 @@ +#define _ALIGN(x) __attribute__ ((aligned(x))) + +extern void debuglog_hex(void *data, int len); + diff --git a/stratum/algos/deep.c b/stratum/algos/deep.c new file mode 100644 index 000000000..9b572ac27 --- /dev/null +++ b/stratum/algos/deep.c @@ -0,0 +1,29 @@ +#include +#include + +#include +#include +#include + +void deep_hash(const char* input, char* output, uint32_t len) +{ + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_echo512_context ctx_echo; + + char hash1[64], hash2[64]; + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, (const void*) input, len); + sph_luffa512_close(&ctx_luffa, (void*) &hash1); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, (const void*) &hash1, 64); + sph_cubehash512_close(&ctx_cubehash, (void*) &hash2); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, (const void*) &hash2, 64); + sph_echo512_close(&ctx_echo, (void*) &hash1); + + memcpy(output, &hash1, 32); +} diff --git a/stratum/algos/deep.h b/stratum/algos/deep.h new file mode 100644 index 000000000..d15db00f4 --- /dev/null +++ b/stratum/algos/deep.h @@ -0,0 +1,17 @@ +#ifndef DEEP_H +#define DEEP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void deep_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/stratum/algos/exosis.c b/stratum/algos/exosis.c new file mode 100644 index 000000000..48a5477f4 --- /dev/null +++ b/stratum/algos/exosis.c @@ -0,0 +1,157 @@ +#include +#include +#include + +#define HASH_FUNC_BASE_TIMESTAMP 1538556426 // Exosis: Genesis Timestamp +#define HASH_FUNC_COUNT 8 +#define HASH_FUNC_COUNT_PERMUTATIONS 40320 + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define _ALIGN(x) __attribute__ ((aligned(x))) + +// helpers +inline void swap(int *a, int *b) { + int c = *a; + *a = *b; + *b = c; +} + +static void reverse(int *pbegin, int *pend) { + while ( (pbegin != pend) && (pbegin != --pend) ) + swap(pbegin++, pend); +} + +static void next_permutation(int *pbegin, int *pend) { + if (pbegin == pend) + return; + + int *i = pbegin; + ++i; + if (i == pend) + return; + + i = pend; + --i; + + while (1) { + int *j = i; + --i; + + if (*i < *j) { + int *k = pend; + + while (!(*i < *--k)) + /* pass */; + + swap(i, k); + reverse(j, pend); + return; // true + } + + if (i == pbegin) { + reverse(pbegin, pend); + return; // false + } + } +} +// helpers + +void exosis_hash(const char* input, char* output, uint32_t len) +{ + uint32_t _ALIGN(64) hash[16 * HASH_FUNC_COUNT]; + uint32_t *hashA, *hashB; + uint32_t dataLen = 64; + uint32_t *work_data = (uint32_t *)input; + const uint32_t timestamp = work_data[17]; + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + + // We want to permute algorithms. To get started we + // initialize an array with a sorted sequence of unique + // integers where every integer represents its own algorithm. + uint32_t permutation[HASH_FUNC_COUNT]; + for (uint32_t i = 0; i < HASH_FUNC_COUNT; i++) { + permutation[i]=i; + } + + // Compute the next permuation + uint32_t steps = (timestamp - HASH_FUNC_BASE_TIMESTAMP) % HASH_FUNC_COUNT_PERMUTATIONS; + for (uint32_t i = 0; i < steps; i++) { + next_permutation(permutation, permutation + HASH_FUNC_COUNT); + } + + for (uint32_t i = 0; i < HASH_FUNC_COUNT; i++) { + if (i == 0) { + dataLen = len; + hashA = work_data; + } else { + dataLen = 64; + hashA = &hash[16 * (i - 1)]; + } + hashB = &hash[16 * i]; + + switch(permutation[i]) { + case 0: + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, hashA, dataLen); + sph_blake512_close(&ctx_blake, hashB); + break; + case 1: + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hashA, dataLen); + sph_bmw512_close(&ctx_bmw, hashB); + break; + case 2: + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, hashA, dataLen); + sph_groestl512_close(&ctx_groestl, hashB); + break; + case 3: + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hashA, dataLen); + sph_skein512_close(&ctx_skein, hashB); + break; + case 4: + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hashA, dataLen); + sph_jh512_close(&ctx_jh, hashB); + break; + case 5: + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, hashA, dataLen); + sph_keccak512_close(&ctx_keccak, hashB); + break; + case 6: + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hashA, dataLen); + sph_luffa512_close(&ctx_luffa, hashB); + break; + case 7: + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, hashA, dataLen); + sph_cubehash512_close(&ctx_cubehash, hashB); + break; + default: + break; + } + } + + memcpy(output, &hash[16 * (HASH_FUNC_COUNT - 1)], 32); +} + diff --git a/stratum/algos/exosis.h b/stratum/algos/exosis.h new file mode 100644 index 000000000..fcda52383 --- /dev/null +++ b/stratum/algos/exosis.h @@ -0,0 +1,16 @@ +#ifndef EXOSIS_H +#define EXOSIS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void exosis_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/hex.c b/stratum/algos/hex.c new file mode 100644 index 000000000..9a294d119 --- /dev/null +++ b/stratum/algos/hex.c @@ -0,0 +1,180 @@ +// Copyright (c) 2018 The XDNA Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include +#include + +#include "hex.h" + +#include "../sha3/sph_blake.h" +#include "../sha3/sph_bmw.h" +#include "../sha3/sph_groestl.h" +#include "../sha3/sph_skein.h" +#include "../sha3/sph_jh.h" +#include "../sha3/sph_keccak.h" + +#include "../sha3/sph_luffa.h" +#include "../sha3/sph_cubehash.h" +#include "../sha3/sph_shavite.h" +#include "../sha3/sph_simd.h" +#include "../sha3/sph_echo.h" + +#include "../sha3/sph_hamsi.h" +#include "../sha3/sph_fugue.h" +#include "../sha3/sph_shabal.h" +#include "../sha3/sph_whirlpool.h" +#include "../sha3/sph_sha2.h" + +enum Algo { + BLAKE = 0, + BMW, + GROESTL, + JH, + KECCAK, + SKEIN, + LUFFA, + CUBEHASH, + SHAVITE, + SIMD, + ECHO, + HAMSI, + FUGUE, + SHABAL, + WHIRLPOOL, + SHA512, + HASH_FUNC_COUNT +}; + +static const int TOTAL_CYCLES = 16; + +static uint8_t get_first_algo(const uint32_t* prevblock) { + uint8_t* data = (uint8_t*)prevblock; + return data[7] >> 4; +} + +void hex_hash(const char* input, char* output, uint32_t len) +{ + unsigned char hash[128]; + uint8_t curr_algo; + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_skein512_context ctx_skein; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_hamsi512_context ctx_hamsi; + sph_fugue512_context ctx_fugue; + sph_shabal512_context ctx_shabal; + sph_whirlpool_context ctx_whirlpool; + sph_sha512_context ctx_sha512; + + const void *in = input; + int size = len; + + uint32_t *in32 = (uint32_t*) input; + + // initial algo = first digit of prev block hashorder (cheers, x16r) + curr_algo = get_first_algo(&in32[1]); + + for (int i = 0; i < TOTAL_CYCLES; i++) + { + // Only 4 test algos yet + switch (curr_algo) { + case BLAKE: + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, in, size); + sph_blake512_close(&ctx_blake, hash); + break; + case BMW: + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, in, size); + sph_bmw512_close(&ctx_bmw, hash); + break; + case GROESTL: + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, in, size); + sph_groestl512_close(&ctx_groestl, hash); + break; + case JH: + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, in, size); + sph_jh512_close(&ctx_jh, hash); + break; + case KECCAK: + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, in, size); + sph_keccak512_close(&ctx_keccak, hash); + break; + case SKEIN: + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, in, size); + sph_skein512_close(&ctx_skein, hash); + break; + case LUFFA: + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, in, size); + sph_luffa512_close(&ctx_luffa, hash); + break; + case CUBEHASH: + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, in, size); + sph_cubehash512_close(&ctx_cubehash, hash); + break; + case SHAVITE: + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, in, size); + sph_shavite512_close(&ctx_shavite, hash); + break; + case SIMD: + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, in, size); + sph_simd512_close(&ctx_simd, hash); + break; + + case ECHO: + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, in, size); + sph_echo512_close(&ctx_echo, hash); + break; + case HAMSI: + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, in, size); + sph_hamsi512_close(&ctx_hamsi, hash); + break; + case FUGUE: + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, in, size); + sph_fugue512_close(&ctx_fugue, hash); + break; + case SHABAL: + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, in, size); + sph_shabal512_close(&ctx_shabal, hash); + break; + case WHIRLPOOL: + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, in, size); + sph_whirlpool_close(&ctx_whirlpool, hash); + break; + case SHA512: + sph_sha512_init(&ctx_sha512); + sph_sha512(&ctx_sha512,(const void*) in, size); + sph_sha512_close(&ctx_sha512,(void*) hash); + break; + } + // next algos = first digit on prev hash + curr_algo = (uint8_t)hash[0] % HASH_FUNC_COUNT; + in = (void*)hash; + size = 64; + } + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/hex.h b/stratum/algos/hex.h new file mode 100644 index 000000000..101f1a17d --- /dev/null +++ b/stratum/algos/hex.h @@ -0,0 +1,20 @@ +// Copyright (c) 2018 The XDNA Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef HEXHASH_H +#define HEXHASH_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void hex_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif // HEXHASH_H diff --git a/stratum/algos/hmq17.c b/stratum/algos/hmq17.c new file mode 100644 index 000000000..17ed4baae --- /dev/null +++ b/stratum/algos/hmq17.c @@ -0,0 +1,218 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct +{ + sph_blake512_context blake1, blake2; + sph_bmw512_context bmw1, bmw2, bmw3; + sph_groestl512_context groestl1, groestl2; + sph_skein512_context skein1, skein2; + sph_jh512_context jh1, jh2; + sph_keccak512_context keccak1, keccak2; + sph_luffa512_context luffa1, luffa2; + sph_cubehash512_context cubehash; + sph_shavite512_context shavite1, shavite2; + sph_simd512_context simd1, simd2; + sph_echo512_context echo1, echo2; + sph_hamsi512_context hamsi; + sph_fugue512_context fugue1, fugue2; + sph_shabal512_context shabal; + sph_whirlpool_context whirlpool1, whirlpool2, whirlpool3, whirlpool4; + sph_sha512_context sha1, sha2; + sph_haval256_5_context haval1, haval2; +} hmq_contexts; + +static __thread hmq_contexts base_contexts; +static __thread int hmq_context_init = 0; + +static void init_contexts(hmq_contexts *ctx) +{ + sph_bmw512_init(&ctx->bmw1); + sph_bmw512_init(&ctx->bmw2); + sph_bmw512_init(&ctx->bmw2); + sph_bmw512_init(&ctx->bmw3); + sph_whirlpool_init(&ctx->whirlpool1); + sph_whirlpool_init(&ctx->whirlpool2); + sph_whirlpool_init(&ctx->whirlpool3); + sph_whirlpool_init(&ctx->whirlpool4); + sph_groestl512_init(&ctx->groestl1); + sph_groestl512_init(&ctx->groestl2); + sph_skein512_init(&ctx->skein1); + sph_skein512_init(&ctx->skein2); + sph_jh512_init(&ctx->jh1); + sph_jh512_init(&ctx->jh2); + sph_keccak512_init(&ctx->keccak1); + sph_keccak512_init(&ctx->keccak2); + sph_blake512_init(&ctx->blake1); + sph_blake512_init(&ctx->blake2); + sph_luffa512_init(&ctx->luffa1); + sph_luffa512_init(&ctx->luffa2); + sph_cubehash512_init(&ctx->cubehash); + sph_shavite512_init(&ctx->shavite1); + sph_shavite512_init(&ctx->shavite2); + sph_simd512_init(&ctx->simd1); + sph_simd512_init(&ctx->simd2); + sph_echo512_init(&ctx->echo1); + sph_echo512_init(&ctx->echo2); + sph_hamsi512_init(&ctx->hamsi); + sph_fugue512_init(&ctx->fugue1); + sph_fugue512_init(&ctx->fugue2); + sph_shabal512_init(&ctx->shabal); + sph_sha512_init(&ctx->sha1); + sph_sha512_init(&ctx->sha2); + sph_haval256_5_init(&ctx->haval1); + sph_haval256_5_init(&ctx->haval2); +} + +void hmq17_hash(const char* input, char* output, uint32_t len) +{ + uint32_t hash[32]; + + const uint32_t mask = 24; + + hmq_contexts ctx; + + if (!hmq_context_init) { + init_contexts(&base_contexts); + hmq_context_init = 1; + } + memcpy(&ctx, &base_contexts, sizeof(hmq_contexts)); + + sph_bmw512(&ctx.bmw1, input, len); + sph_bmw512_close(&ctx.bmw1, hash); + + sph_whirlpool(&ctx.whirlpool1, hash, 64); + sph_whirlpool_close(&ctx.whirlpool1, hash); + + if (hash[0] & mask) { + sph_groestl512(&ctx.groestl1, hash, 64); + sph_groestl512_close(&ctx.groestl1, hash); + } else { + sph_skein512(&ctx.skein1, hash, 64); + sph_skein512_close(&ctx.skein1, hash); + } + + sph_jh512(&ctx.jh1, hash, 64); + sph_jh512_close(&ctx.jh1, hash); + + sph_keccak512(&ctx.keccak1, hash, 64); + sph_keccak512_close(&ctx.keccak1, hash); + + if (hash[0] & mask) { + sph_blake512(&ctx.blake1, hash, 64); + sph_blake512_close(&ctx.blake1, hash); + } else { + sph_bmw512 (&ctx.bmw2, hash, 64); + sph_bmw512_close(&ctx.bmw2, hash); + } + + sph_luffa512(&ctx.luffa1, hash, 64); + sph_luffa512_close(&ctx.luffa1, hash); + + sph_cubehash512(&ctx.cubehash, hash, 64); + sph_cubehash512_close(&ctx.cubehash, hash); + + if (hash[0] & mask) { + sph_keccak512(&ctx.keccak2, hash, 64); + sph_keccak512_close(&ctx.keccak2, hash); + } else { + sph_jh512(&ctx.jh2, hash, 64); + sph_jh512_close(&ctx.jh2, hash); + } + + sph_shavite512(&ctx.shavite1, hash, 64); + sph_shavite512_close(&ctx.shavite1, hash); + + sph_simd512(&ctx.simd1, hash, 64); + sph_simd512_close(&ctx.simd1, hash); + + if (hash[0] & mask) { + sph_whirlpool(&ctx.whirlpool2, hash, 64); + sph_whirlpool_close(&ctx.whirlpool2, hash); + } else { + sph_haval256_5(&ctx.haval1, hash, 64); + sph_haval256_5_close(&ctx.haval1, hash); + memset(&hash[8], 0, 32); + } + + sph_echo512(&ctx.echo1, hash, 64); + sph_echo512_close(&ctx.echo1, hash); + + sph_blake512(&ctx.blake2, hash, 64); + sph_blake512_close(&ctx.blake2, hash); + + if (hash[0] & mask) { + sph_shavite512(&ctx.shavite2, hash, 64); + sph_shavite512_close(&ctx.shavite2, hash); + } else { + sph_luffa512 (&ctx.luffa2, hash, 64); + sph_luffa512_close(&ctx.luffa2, hash); + } + + sph_hamsi512(&ctx.hamsi, hash, 64); + sph_hamsi512_close(&ctx.hamsi, hash); + + sph_fugue512(&ctx.fugue1, hash, 64); + sph_fugue512_close(&ctx.fugue1, hash); + + if (hash[0] & mask) { + sph_echo512(&ctx.echo2, hash, 64); + sph_echo512_close(&ctx.echo2, hash); + } else { + sph_simd512(&ctx.simd2, hash, 64); + sph_simd512_close(&ctx.simd2, hash); + } + + sph_shabal512(&ctx.shabal, hash, 64); + sph_shabal512_close(&ctx.shabal, hash); + + sph_whirlpool(&ctx.whirlpool3, hash, 64); + sph_whirlpool_close(&ctx.whirlpool3, hash); + + if (hash[0] & mask) { + sph_fugue512(&ctx.fugue2, hash, 64); + sph_fugue512_close(&ctx.fugue2, hash); + } else { + sph_sha512(&ctx.sha1, hash, 64); + sph_sha512_close(&ctx.sha1, hash); + } + + sph_groestl512(&ctx.groestl2, hash, 64); + sph_groestl512_close(&ctx.groestl2, hash); + + sph_sha512(&ctx.sha2, hash, 64); + sph_sha512_close(&ctx.sha2, hash); + + if (hash[0] & mask) { + sph_haval256_5(&ctx.haval2, hash, 64); + sph_haval256_5_close(&ctx.haval2, hash); + memset(&hash[8], 0, 32); + } else { + sph_whirlpool(&ctx.whirlpool4, hash, 64); + sph_whirlpool_close(&ctx.whirlpool4, hash); + } + + sph_bmw512(&ctx.bmw3, hash, 64); + sph_bmw512_close(&ctx.bmw3, hash); + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/hmq17.h b/stratum/algos/hmq17.h new file mode 100644 index 000000000..99847379d --- /dev/null +++ b/stratum/algos/hmq17.h @@ -0,0 +1,16 @@ +#ifndef HMQ17_H +#define HMQ17_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void hmq17_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/hsr14.c b/stratum/algos/hsr14.c new file mode 100644 index 000000000..b31decdb4 --- /dev/null +++ b/stratum/algos/hsr14.c @@ -0,0 +1,101 @@ +#include +#include +#include +#include + +#include "../sha3/sph_blake.h" +#include "../sha3/sph_bmw.h" +#include "../sha3/sph_groestl.h" +#include "../sha3/sph_jh.h" +#include "../sha3/sph_keccak.h" +#include "../sha3/sph_skein.h" +#include "../sha3/sph_luffa.h" +#include "../sha3/sph_cubehash.h" +#include "../sha3/sph_shavite.h" +#include "../sha3/sph_simd.h" +#include "../sha3/sph_echo.h" +#include "../sha3/sph_hamsi.h" +#include "../sha3/sph_fugue.h" + +#include "sm3.h" + +#include "common.h" + +void hsr_hash(const char* input, char* output, uint32_t len) +{ + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_luffa512_context ctx_luffa1; + sph_cubehash512_context ctx_cubehash1; + sph_shavite512_context ctx_shavite1; + sph_simd512_context ctx_simd1; + sph_echo512_context ctx_echo1; + sm3_ctx_t ctx_sm3; + sph_hamsi512_context ctx_hamsi1; + sph_fugue512_context ctx_fugue1; + + uint8_t _ALIGN(128) hash[64]; + + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, input, len); + sph_blake512_close(&ctx_blake, hash); + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close (&ctx_skein, hash); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512_init(&ctx_luffa1); + sph_luffa512(&ctx_luffa1, hash, 64); + sph_luffa512_close(&ctx_luffa1, hash); + + sph_cubehash512_init(&ctx_cubehash1); + sph_cubehash512(&ctx_cubehash1, hash, 64); + sph_cubehash512_close(&ctx_cubehash1, hash); + + sph_shavite512_init(&ctx_shavite1); + sph_shavite512(&ctx_shavite1, hash, 64); + sph_shavite512_close(&ctx_shavite1, hash); + + sph_simd512_init(&ctx_simd1); + sph_simd512(&ctx_simd1, hash, 64); + sph_simd512_close(&ctx_simd1, hash); + + sph_echo512_init (&ctx_echo1); + sph_echo512(&ctx_echo1, hash, 64); + sph_echo512_close(&ctx_echo1, hash); + + sm3_init(&ctx_sm3); + sm3_update(&ctx_sm3, hash, 64); + memset(hash, 0, sizeof hash); + sm3_close(&ctx_sm3, hash); + + sph_hamsi512_init(&ctx_hamsi1); + sph_hamsi512(&ctx_hamsi1, hash, 64); + sph_hamsi512_close(&ctx_hamsi1, hash); + + sph_fugue512_init(&ctx_fugue1); + sph_fugue512(&ctx_fugue1, hash, 64); + sph_fugue512_close(&ctx_fugue1, hash); + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/hsr14.h b/stratum/algos/hsr14.h new file mode 100644 index 000000000..d2dd89e49 --- /dev/null +++ b/stratum/algos/hsr14.h @@ -0,0 +1,16 @@ +#ifndef HSR14_H +#define HSR14_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void hsr_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/jha.c b/stratum/algos/jha.c index e5d75a44e..4901c4c76 100644 --- a/stratum/algos/jha.c +++ b/stratum/algos/jha.c @@ -1,135 +1,56 @@ -#include "jha.h" - #include #include #include #include -#include "../sha3/sph_blake.h" -#include "../sha3/sph_groestl.h" -#include "../sha3/sph_jh.h" -#include "../sha3/sph_keccak.h" -#include "../sha3/sph_skein.h" - - -void jha_hash(const char* input, char* output, uint32_t len) { - - sph_blake512_context ctx_blake; - sph_groestl512_context ctx_groestl; - sph_jh512_context ctx_jh; - sph_keccak512_context ctx_keccak; - sph_skein512_context ctx_skein; - - uint32_t hash[16]; - - unsigned int round_mask = ( - (unsigned int)(((unsigned char *)input)[84]) << 0 | - (unsigned int)(((unsigned char *)input)[85]) << 8 | - (unsigned int)(((unsigned char *)input)[86]) << 16 | - (unsigned int)(((unsigned char *)input)[87]) << 24 ); - - // - // JHA V7 - // - if (round_mask == 7) { - - // - // Input Hashing with SHA3 512, 88 bytes - // - sph_keccak512_init(&ctx_keccak); - sph_keccak512 (&ctx_keccak, input, 88); - sph_keccak512_close(&ctx_keccak, hash); - - // - // Variable Rounds Loop - // - unsigned int rounds = hash[0] & 7; - unsigned int round; - for (round = 0; round < rounds; round++) { - switch (hash[0] & 3) { - case 0: - sph_blake512_init(&ctx_blake); - sph_blake512 (&ctx_blake, hash, 64); - sph_blake512_close(&ctx_blake, hash); - break; - case 1: - sph_groestl512_init(&ctx_groestl); - sph_groestl512 (&ctx_groestl, hash, 64); - sph_groestl512_close(&ctx_groestl, hash); - break; - case 2: - sph_jh512_init(&ctx_jh); - sph_jh512 (&ctx_jh, hash, 64); - sph_jh512_close(&ctx_jh, hash); - break; - case 3: - sph_skein512_init(&ctx_skein); - sph_skein512 (&ctx_skein, hash, 64); - sph_skein512_close(&ctx_skein, hash); - break; - } - } - - // - // Return 256bit(32x8) - // - memcpy(output, hash, 32); - - } - - // - // JHA V8 - // - else if (round_mask == 8) { - - // - // Input Hashing with SHA3 512, 80 bytes - // - sph_keccak512_init(&ctx_keccak); - sph_keccak512 (&ctx_keccak, input, 80); - sph_keccak512_close(&ctx_keccak, (&hash)); - - // - // Heavy & Light Pair Loop - // - unsigned int round; - for (round = 0; round < 3; round++) { - if (hash[0] & 0x01) { - sph_groestl512_init(&ctx_groestl); - sph_groestl512 (&ctx_groestl, (&hash), 64); - sph_groestl512_close(&ctx_groestl, (&hash)); - } - else { - sph_skein512_init(&ctx_skein); - sph_skein512 (&ctx_skein, (&hash), 64); - sph_skein512_close(&ctx_skein, (&hash)); - } - if (hash[0] & 0x01) { - sph_blake512_init(&ctx_blake); - sph_blake512 (&ctx_blake, (&hash), 64); - sph_blake512_close(&ctx_blake, (&hash)); - } - else { - sph_jh512_init(&ctx_jh); - sph_jh512 (&ctx_jh, (&hash), 64); - sph_jh512_close(&ctx_jh, (&hash)); - } - } - - // - // Return 256bit(32x8) - // - memcpy(output, hash, 32); - - } - - // - // Wrong Round Mask Data - // - else { - - memset(output, 0xFF, 32); - - } +#include +#include +#include +#include +#include +#include "jha.h" +#include "common.h" + +void jha_hash(const char* input, char* output, uint32_t len) +{ + sph_blake512_context ctx_blake; + sph_groestl512_context ctx_groestl; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_skein512_context ctx_skein; + + uint32_t _ALIGN(64) hash[16]; + + // JHA v8: SHA3 512, on 80 bytes (not 88) + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, input, 80); + sph_keccak512_close(&ctx_keccak, (&hash)); + + // Heavy & Light Pair Loop + for (int round = 0; round < 3; round++) + { + if (hash[0] & 0x01) { + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, (&hash), 64); + sph_groestl512_close(&ctx_groestl, (&hash)); + } else { + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, (&hash), 64); + sph_skein512_close(&ctx_skein, (&hash)); + } + + if (hash[0] & 0x01) { + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, (&hash), 64); + sph_blake512_close(&ctx_blake, (&hash)); + } else { + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, (&hash), 64); + sph_jh512_close(&ctx_jh, (&hash)); + } + } + + // Return 256 bits (32x8) + memcpy(output, hash, 32); } diff --git a/stratum/algos/lbk3.c b/stratum/algos/lbk3.c new file mode 100644 index 000000000..fbedd75d6 --- /dev/null +++ b/stratum/algos/lbk3.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +#include +#include +#include + +#define _ALIGN(x) __attribute__ ((aligned(x))) + +extern uint64_t lbk3_height; + +void lbk3_hash(const char* input, char* output, uint32_t len) +{ + sph_bmw256_context ctx_bmw; + sph_blake256_context ctx_blake; + sph_keccak256_context ctx_keccak; + + uint8_t _ALIGN(128) hash[96]; + memset(&hash[32], 0, 64); + + sph_bmw256_init(&ctx_bmw); + sph_bmw256 (&ctx_bmw, input, 80); + sph_bmw256_close(&ctx_bmw, &hash[0]); + + sph_blake256_init(&ctx_blake); + sph_blake256 (&ctx_blake, &hash[0], 64); + sph_blake256_close(&ctx_blake, &hash[32]); + + sph_keccak256_init(&ctx_keccak); + sph_keccak256 (&ctx_keccak, &hash[32], 64); + sph_keccak256_close(&ctx_keccak, &hash[64]); + + memcpy(output, &hash[64], 32); +} diff --git a/stratum/algos/lbk3.h b/stratum/algos/lbk3.h new file mode 100644 index 000000000..7d4272289 --- /dev/null +++ b/stratum/algos/lbk3.h @@ -0,0 +1,16 @@ +#ifndef LBK3_H +#define LBK3_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void lbk3_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/lyra2z.c b/stratum/algos/lyra2z.c new file mode 100644 index 000000000..0d946def4 --- /dev/null +++ b/stratum/algos/lyra2z.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +#include "Lyra2-z.h" + +#include + +#define _ALIGN(x) __attribute__ ((aligned(x))) + +extern uint64_t lyra2z_height; + +void lyra2z_hash(const char* input, char* output, uint32_t len) +{ + uint32_t _ALIGN(64) hashB[8], hash[8]; + sph_blake256_context ctx_blake; +/* + uint64_t height = lyra2z_height; + // initial implementation was pure lyra2 (no blake) + + if (height < 100) { + fprintf(stderr, "submit error, height=%u, len=%u\n", (uint32_t) height, len); + memset(hash, 0xff, 32); + return; + } + LYRA2z((void*)hash, 32, (void*)input, len, (void*)input, len, 2, height, 256); +*/ + sph_blake256_set_rounds(14); + + sph_blake256_init(&ctx_blake); + sph_blake256(&ctx_blake, input, len); + sph_blake256_close(&ctx_blake, hashB); + + LYRA2z(hash, 32, hashB, 32, hashB, 32, 8, 8, 8); + + memcpy(output, hash, 32); +} + diff --git a/stratum/algos/lyra2z.h b/stratum/algos/lyra2z.h new file mode 100644 index 000000000..3de6f4244 --- /dev/null +++ b/stratum/algos/lyra2z.h @@ -0,0 +1,16 @@ +#ifndef LYRA2Z_H +#define LYRA2Z_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void lyra2z_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/makefile b/stratum/algos/makefile index 8b3e32887..61999a4b9 100644 --- a/stratum/algos/makefile +++ b/stratum/algos/makefile @@ -8,16 +8,19 @@ CXXFLAGS = -O2 -I.. -march=native CFLAGS= $(CXXFLAGS) -std=gnu99 LDFLAGS=-O2 -lgmp -SOURCES=lyra2re.c lyra2v2.c Lyra2.c Sponge.c blake.c scrypt.c c11.c x11.c x13.c sha256.c keccak.c \ - x14.c x15.c x17.c nist5.c fresh.c quark.c neoscrypt.c scryptn.c qubit.c skein.c groestl.c \ - xevan.c \ - skein2.c zr5.c bmw.c luffa.c pentablake.c whirlpool.c whirlpoolx.c blakecoin.c \ - blake2.c \ - yescrypt.c yescrypt-opt.c sha256_Y.c lbry.c \ - m7m.c magimath.cpp velvet.c \ - argon2a.c ar2/blake2b.c ar2/argon2.c ar2/ref.c ar2/cores.c ar2/ar2-scrypt-jane.c \ - hive.c pomelo.c \ - sib.c veltor.c gost.c x11evo.c +SOURCES=lyra2re.c lyra2v2.c Lyra2.c lyra2z.c Lyra2-z.c Sponge.c allium.c \ + c11.c x11.c x12.c x13.c hsr14.c sm3.c x14.c x15.c x17.c \ + x22i.c SWIFFTX/SWIFFTX.c \ + blake.c blakecoin.c blake2b.c blake2s.c jha.c keccak.c lbry.c tribus.c exosis.c \ + deep.c fresh.c groestl.c neoscrypt.c nist5.c quark.c qubit.c skein.c skein2.c \ + bitcore.c timetravel.c x11evo.c x16r.c x16s.c xevan.c bastion.c hmq17.c sonoa.c \ + bmw.c luffa.c pentablake.c vitalium.c whirlpool.c whirlpoolx.c zr5.c \ + scrypt.c scryptn.c sha256.c sha256t.c \ + yescrypt.c yescrypt-opt.c sha256_Y.c \ + a5a.c a5amath.c m7m.c magimath.cpp velvet.c \ + argon2a.c blake2/blake2b.c ar2/argon2.c ar2/core.c ar2/encoding.c ar2/opt.c ar2/thread.c ar2/ar2-scrypt-jane.c \ + hive.c pomelo.c hex.c argon2d-dyn.c \ + phi.c phi2.c polytimos.c rainforest.c skunk.c sib.c veltor.c gost.c aergo.c lbk3.c OBJECTS=$(SOURCES:%.c=%.o) $(SOURCES:%.cpp=%.o) OUTPUT=libalgos.a @@ -39,4 +42,5 @@ $(OUTPUT): $(OBJECTS) clean: rm -f *.o rm -f ar2/*.o - + rm -f blake2/*.o + rm -f SWIFFTX/*.o diff --git a/stratum/algos/phi.c b/stratum/algos/phi.c new file mode 100644 index 000000000..eca2272e0 --- /dev/null +++ b/stratum/algos/phi.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "gost.h" + +#include "common.h" + +void phi_hash(const char* input, char* output, uint32_t len) +{ + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_cubehash512_context ctx_cubehash; + sph_fugue512_context ctx_fugue; + sph_gost512_context ctx_gost; + sph_echo512_context ctx_echo; + + uint8_t _ALIGN(128) hash[64]; + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, input, len); + sph_skein512_close(&ctx_skein, (void*) hash); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, (const void*) hash, 64); + sph_jh512_close(&ctx_jh, (void*) hash); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, (const void*) hash, 64); + sph_cubehash512_close(&ctx_cubehash, (void*) hash); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, (const void*) hash, 64); + sph_fugue512_close(&ctx_fugue, (void*) hash); + + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, (const void*) hash, 64); + sph_gost512_close(&ctx_gost, (void*) hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, (const void*) hash, 64); + sph_echo512_close(&ctx_echo, (void*) hash); + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/phi.h b/stratum/algos/phi.h new file mode 100644 index 000000000..4e4242438 --- /dev/null +++ b/stratum/algos/phi.h @@ -0,0 +1,16 @@ +#ifndef PHI_H +#define PHI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void phi_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/phi2.c b/stratum/algos/phi2.c new file mode 100644 index 000000000..1aad37200 --- /dev/null +++ b/stratum/algos/phi2.c @@ -0,0 +1,62 @@ +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "gost.h" + +#include "Lyra2.h" + +#include "common.h" + +void phi2_hash(const char* input, char* output, uint32_t len) +{ + unsigned char _ALIGN(128) hash[64]; + unsigned char _ALIGN(128) hashA[64]; + unsigned char _ALIGN(128) hashB[64]; + + sph_cubehash512_context ctx_cubehash; + sph_jh512_context ctx_jh; + sph_gost512_context ctx_gost; + sph_echo512_context ctx_echo; + sph_skein512_context ctx_skein; + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, input, len); + sph_cubehash512_close(&ctx_cubehash, (void*)hashB); + + LYRA2(&hashA[ 0], 32, &hashB[ 0], 32, &hashB[ 0], 32, 1, 8, 8); + LYRA2(&hashA[32], 32, &hashB[32], 32, &hashB[32], 32, 1, 8, 8); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, (const void*)hashA, 64); + sph_jh512_close(&ctx_jh, (void*)hash); + + if (hash[0] & 1) { + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, (const void*)hash, 64); + sph_gost512_close(&ctx_gost, (void*)hash); + } else { + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, (const void*)hash, 64); + sph_echo512_close(&ctx_echo, (void*)hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, (const void*)hash, 64); + sph_echo512_close(&ctx_echo, (void*)hash); + } + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, (const void*)hash, 64); + sph_skein512_close(&ctx_skein, (void*)hash); + + for (int i=0; i<32; i++) + hash[i] ^= hash[i+32]; + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/phi2.h b/stratum/algos/phi2.h new file mode 100644 index 000000000..d551d2849 --- /dev/null +++ b/stratum/algos/phi2.h @@ -0,0 +1,16 @@ +#ifndef PHI2_H +#define PHI2_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void phi2_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/polytimos.c b/stratum/algos/polytimos.c new file mode 100644 index 000000000..808042d6b --- /dev/null +++ b/stratum/algos/polytimos.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include "gost.h" + +#include "common.h" + +void polytimos_hash(const char *input, char* output, uint32_t len) +{ + uint32_t _ALIGN(64) hash[16]; + + sph_skein512_context ctx_skein; + sph_shabal512_context ctx_shabal; + sph_echo512_context ctx_echo; + sph_luffa512_context ctx_luffa; + sph_fugue512_context ctx_fugue; + sph_gost512_context ctx_gost; + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, input, 80); + sph_skein512_close(&ctx_skein, (void*) hash); + + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, (const void*) hash, 64); + sph_gost512_close(&ctx_gost, (void*) hash); + + memcpy(output, hash, 32); +} + diff --git a/stratum/algos/polytimos.h b/stratum/algos/polytimos.h new file mode 100644 index 000000000..ec89cd303 --- /dev/null +++ b/stratum/algos/polytimos.h @@ -0,0 +1,16 @@ +#ifndef POLYTIMOS_H +#define POLYTIMOS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void polytimos_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/rainforest.c b/stratum/algos/rainforest.c new file mode 100644 index 000000000..685c36311 --- /dev/null +++ b/stratum/algos/rainforest.c @@ -0,0 +1,802 @@ +// RainForest hash algorithm +// Author: Bill Schneider +// Date: Feb 13th, 2018 +// +// RainForest uses native integer operations which are extremely fast on +// modern 64-bit processors, significantly slower on 32-bit processors such +// as GPUs, and extremely slow if at all implementable on FPGAs and ASICs. +// It makes an intensive use of the L1 cache to maintain a heavy intermediary +// state favoring modern CPUs compared to GPUs (small L1 cache shared by many +// shaders) or FPGAs (very hard to implement the required low-latency cache) +// when scanning ranges for nonces. The purpose is to create a fair balance +// between all mining equipments, from mobile phones to extreme performance +// GPUs and to rule out farming factories relying on ASICs and FPGAs. The +// CRC32 instruction is used a lot as it is extremely fast on low-power ARM +// chips and allows such devices to rival high-end PCs mining performance. +// +// Tests on various devices have shown the following performance : +// +--------------------------------------------------------------------------+ +// | CPU/GPU Clock Threads Full hash Nonce scan Watts Cost | +// | (MHz) (80 bytes) (4 bytes) total | +// | Core i7-6700k 4000 8 390 kH/s 1642 kH/s 200 ~$350+PC | +// | Radeon RX560 1300 1024 1100 kH/s 1650 kH/s 300 ~$180+PC | +// | RK3368 (8*A53) 1416 8 534 kH/s 1582 kH/s 6 $60 (Geekbox) | +// +--------------------------------------------------------------------------+ +// +// Build instructions on Ubuntu 16.04 : +// - on x86: use gcc -march=native or -maes to enable AES-NI +// - on ARMv8: use gcc -march=native or -march=armv8-a+crypto+crc to enable +// CRC32 and AES extensions. +// +// Note: always use the same options to build all files! + +#include +#include +#include +#include + +//#define DEBUG_ALGO + +/* Rijndael's substitution box for sub_bytes step */ +static uint8_t SBOX[256] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 +}; + +/*--- The parts below are not used when crypto extensions are available ---*/ +/* Use -march=armv8-a+crypto on ARMv8 to use crypto extensions */ +/* Use -maes on x86_64 to use AES-NI */ +#if defined(RF_NOASM) || (!defined(__aarch64__) || !defined(__ARM_FEATURE_CRYPTO)) && (!defined(__x86_64__) || !defined(__AES__)) + +/* shifts to do for shift_rows step */ +static uint8_t shifts[16] = { + 0, 5, 10, 15, + 4, 9, 14, 3, + 8, 13, 2, 7, + 12, 1, 6, 11 +}; + +/* add the round key to the state with simple XOR operation */ +static void add_round_key(uint8_t * state, uint8_t * rkey) { + uint8_t i; + for (i = 0; i < 16; i++) + state[i] ^= rkey[i]; +} + +/* substitute all bytes using Rijndael's substitution box */ +static void sub_bytes(uint8_t * state) { + uint8_t i; + for (i = 0; i < 16; i++) + state[i] = SBOX[state[i]]; +} + +/* imagine the state not as 1-dimensional, but a 4x4 grid; + * this step shifts the rows of this grid around */ +static void shift_rows(uint8_t * state) { + uint8_t temp[16]; + uint8_t i; + + for (i = 0; i < 16; i++) { + temp[i] = state[shifts[i]]; + } + + for (i = 0; i < 16; i++) { + state[i] = temp[i]; + } +} + +/* mix columns */ +static void mix_columns(uint8_t * state) { + uint8_t a[4]; + uint8_t b[4]; + uint8_t h, i, k; + + for (k = 0; k < 4; k++) { + for (i = 0; i < 4; i++) { + a[i] = state[i + 4 * k]; + h = state[i + 4 * k] & 0x80; /* hi bit */ + b[i] = state[i + 4 * k] << 1; + + if (h == 0x80) { + b[i] ^= 0x1b; /* Rijndael's Galois field */ + } + } + + state[4 * k] = b[0] ^ a[3] ^ a[2] ^ b[1] ^ a[1]; + state[1 + 4 * k] = b[1] ^ a[0] ^ a[3] ^ b[2] ^ a[2]; + state[2 + 4 * k] = b[2] ^ a[1] ^ a[0] ^ b[3] ^ a[3]; + state[3 + 4 * k] = b[3] ^ a[2] ^ a[1] ^ b[0] ^ a[0]; + } +} +#endif // (!defined(__aarch64__) || !defined(__ARM_FEATURE_CRYPTO)) && (!defined(__x86_64__) || !defined(__AES__)) + + +/* key schedule stuff */ + +/* simple function to rotate 4 byte array */ +static inline uint32_t rotate32(uint32_t in) { +#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + in = (in >> 8) | (in << 24); +#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + in = (in << 8) | (in >> 24); +#else + uint8_t *b = (uint8_t *)&in, temp = b[0]; + b[0] = b[1]; b[1] = b[2]; b[2] = b[3]; b[3] = temp; +#endif + return in; +} + +/* key schedule core operation */ +static inline uint32_t sbox(uint32_t in, uint8_t n) { + in = (SBOX[in & 255]) | (SBOX[(in >> 8) & 255] << 8) | (SBOX[(in >> 16) & 255] << 16) | (SBOX[(in >> 24) & 255] << 24); +#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + in ^= n; +#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + in ^= n << 24; +#else + *(uint8_t *)&in ^= n; +#endif + return in; +} + +// this version is optimized for exactly two rounds. +// _state_ must be 16-byte aligned. +static void aes2r_encrypt(uint8_t * state, uint8_t * key) { + uint32_t key_schedule[12] __attribute__((aligned(16))); + uint32_t t; + + /* initialize key schedule; its first 16 bytes are the key */ + key_schedule[0] = ((uint32_t *)key)[0]; + key_schedule[1] = ((uint32_t *)key)[1]; + key_schedule[2] = ((uint32_t *)key)[2]; + key_schedule[3] = ((uint32_t *)key)[3]; + t = key_schedule[3]; + + t = rotate32(t); + t = sbox(t, 1); + t = key_schedule[4] = key_schedule[0] ^ t; + t = key_schedule[5] = key_schedule[1] ^ t; + t = key_schedule[6] = key_schedule[2] ^ t; + t = key_schedule[7] = key_schedule[3] ^ t; + + t = rotate32(t); + t = sbox(t, 2); + t = key_schedule[8] = key_schedule[4] ^ t; + t = key_schedule[9] = key_schedule[5] ^ t; + t = key_schedule[10] = key_schedule[6] ^ t; + t = key_schedule[11] = key_schedule[7] ^ t; + +// Use -march=armv8-a+crypto+crc to get this one +#if defined(__aarch64__) && defined(__ARM_FEATURE_CRYPTO) + asm volatile( + "ld1 {v0.16b},[%0] \n" + "ld1 {v1.16b,v2.16b,v3.16b},[%1] \n" + "aese v0.16b,v1.16b \n" // round1: add_round_key,sub_bytes,shift_rows + "aesmc v0.16b,v0.16b \n" // round1: mix_columns + "aese v0.16b,v2.16b \n" // round2: add_round_key,sub_bytes,shift_rows + "eor v0.16b,v0.16b,v3.16b \n" // finish: add_round_key + "st1 {v0.16b},[%0] \n" + : /* only output is in *state */ + : "r"(state), "r"(key_schedule) + : "v0", "v1", "v2", "v3", "cc", "memory"); + +// Use -maes to get this one +#elif defined(__x86_64__) && defined(__AES__) + asm volatile( + "movups (%0), %%xmm0 \n" + "movups (%1), %%xmm1 \n" + "pxor %%xmm1,%%xmm0 \n" // add_round_key(state, key_schedule) + "movups 16(%1),%%xmm2 \n" + "movups 32(%1),%%xmm1 \n" + "aesenc %%xmm2,%%xmm0 \n" // first round + "aesenclast %%xmm1,%%xmm0 \n" // final round + "movups %%xmm0, (%0) \n" + : /* only output is in *state */ + : "r"(state), "r" (key_schedule) + : "xmm0", "xmm1", "xmm2", "cc", "memory"); + +#else + /* first round of the algorithm */ + add_round_key(state, (void*)&key_schedule[0]); + sub_bytes(state); + shift_rows(state); + mix_columns(state); + add_round_key(state, (void*)&key_schedule[4]); + + /* final round of the algorithm */ + sub_bytes(state); + shift_rows(state); + add_round_key(state, (void*)&key_schedule[8]); + +#endif +} + +// this seems necessary only for gcc, otherwise hash is bogus +typedef __attribute__((may_alias)) uint8_t rf_u8; +typedef __attribute__((may_alias)) uint16_t rf_u16; +typedef __attribute__((may_alias)) uint32_t rf_u32; +typedef __attribute__((may_alias)) uint64_t rf_u64; + +// 2048 entries for the rambox => 16kB +#define RAMBOX_SIZE 2048 +#define RAMBOX_LOOPS 4 + +typedef union { + rf_u8 b[32]; + rf_u16 w[16]; + rf_u32 d[8]; + rf_u64 q[4]; +} hash256_t; + +typedef struct __attribute__((aligned(16))) rf_ctx { + uint64_t rambox[RAMBOX_SIZE]; + hash256_t hash; + uint32_t crc; + uint32_t word; // LE pending message + uint32_t len; // total message length +} rf256_ctx_t; + +// these archs are fine with unaligned reads +#if defined(__x86_64__)||defined(__aarch64__) +#define RF_UNALIGNED_LE64 +#define RF_UNALIGNED_LE32 +#elif defined(__i386__)||defined(__ARM_ARCH_7A__) +#define RF_UNALIGNED_LE32 +#endif + +#define RF256_INIT_CRC 20180213 + +// the table is used as an 8 bit-aligned array of uint64_t for the first word, +// and as a 16 bit-aligned array of uint64_t for the second word. It is filled +// with the sha256 of "RainForestProCpuAntiAsic", iterated over and over until +// the table is filled. The highest offset being ((uint16_t *)table)[255] we +// need to add 6 extra bytes at the end to read an uint64_t. Maybe calculated +// on a UNIX system with this loop : +// +// ref="RainForestProCpuAntiAsic" +// for ((i=0;i<18;i++)); do +// set $(echo -n $ref|sha256sum) +// echo $1|sed 's/\(..\)/0x\1,/g' +// ref=$(printf $(echo $1|sed 's/\(..\)/\\x\1/g')) +// done + +const uint8_t rf_table[256*2+6] = { + 0x8e,0xc1,0xa8,0x04,0x38,0x78,0x7c,0x54,0x29,0x23,0x1b,0x78,0x9f,0xf9,0x27,0x54, + 0x11,0x78,0x95,0xb6,0xaf,0x78,0x45,0x16,0x2b,0x9e,0x91,0xe8,0x97,0x25,0xf8,0x63, + 0x82,0x56,0xcf,0x48,0x6f,0x82,0x14,0x0d,0x61,0xbe,0x47,0xd1,0x37,0xee,0x30,0xa9, + 0x28,0x1e,0x4b,0xbf,0x07,0xcd,0x41,0xdf,0x23,0x21,0x12,0xb8,0x81,0x99,0x1d,0xe6, + 0x68,0xcf,0xfa,0x2d,0x8e,0xb9,0x88,0xa7,0x15,0xce,0x9e,0x2f,0xeb,0x1b,0x0f,0x67, + 0x20,0x68,0x6c,0xa9,0x5d,0xc1,0x7c,0x76,0xdf,0xbd,0x98,0x61,0xb4,0x14,0x65,0x40, + 0x1e,0x72,0x51,0x74,0x93,0xd3,0xad,0xbe,0x46,0x0a,0x25,0xfb,0x6a,0x5e,0x1e,0x8a, + 0x5a,0x03,0x3c,0xab,0x12,0xc2,0xd4,0x07,0x91,0xab,0xc9,0xdf,0x92,0x2c,0x85,0x6a, + 0xa6,0x25,0x1e,0x66,0x50,0x26,0x4e,0xa8,0xbd,0xda,0x88,0x1b,0x95,0xd4,0x00,0xeb, + 0x0d,0x1c,0x9b,0x3c,0x86,0xc7,0xb2,0xdf,0xb4,0x5a,0x36,0x15,0x8e,0x04,0xd2,0x54, + 0x79,0xd2,0x3e,0x3d,0x99,0x50,0xa6,0x12,0x4c,0x32,0xc8,0x51,0x14,0x4d,0x4b,0x0e, + 0xbb,0x17,0x80,0x8f,0xa4,0xc4,0x99,0x72,0xd7,0x14,0x4b,0xef,0xed,0x14,0xe9,0x17, + 0xfa,0x9b,0x5d,0x37,0xd6,0x2f,0xef,0x02,0xd6,0x71,0x0a,0xbd,0xc5,0x40,0x11,0x90, + 0x90,0x4e,0xb4,0x4c,0x72,0x51,0x7a,0xd8,0xba,0x30,0x4d,0x8c,0xe2,0x11,0xbb,0x6d, + 0x4b,0xbc,0x6f,0x14,0x0c,0x9f,0xfa,0x5e,0x66,0x40,0x45,0xcb,0x7d,0x1b,0x3a,0xc5, + 0x5e,0x9c,0x1e,0xcc,0xbd,0x16,0x3b,0xcf,0xfb,0x2a,0xd2,0x08,0x2a,0xf8,0x3d,0x46, + 0x93,0x90,0xb3,0x66,0x81,0x34,0x7f,0x6d,0x9b,0x8c,0x99,0x03,0xc5,0x27,0xa3,0xd9, + 0xce,0x90,0x88,0x0f,0x55,0xc3,0xa1,0x60,0x53,0xc8,0x0d,0x25,0xae,0x61,0xd9,0x72, + 0x48,0x1d,0x6c,0x61,0xd2,0x87,0xdd,0x3d,0x23,0xf5,0xde,0x93,0x39,0x4c,0x43,0x9a, + 0xf9,0x37,0xf2,0x61,0xd7,0xf8,0xea,0x65,0xf0,0xf1,0xde,0x3f,0x05,0x57,0x83,0x81, + 0xde,0x02,0x62,0x49,0xd4,0x32,0x7e,0x4a,0xd4,0x9f,0x40,0x7e,0xb9,0x91,0xb1,0x35, + 0xf7,0x62,0x3f,0x65,0x9e,0x4d,0x2b,0x10,0xde,0xd4,0x77,0x64,0x0f,0x84,0xad,0x92, + 0xe7,0xa3,0x8a,0x10,0xc1,0x14,0xeb,0x57,0xc4,0xad,0x8e,0xc2,0xc7,0x32,0xa3,0x7e, + 0x50,0x1f,0x7c,0xbb,0x2e,0x5f,0xf5,0x18,0x22,0xea,0xec,0x9d,0xa4,0x77,0xcd,0x85, + 0x04,0x2f,0x20,0x61,0x72,0xa7,0x0c,0x92,0x06,0x4d,0x01,0x70,0x9b,0x35,0xa1,0x27, + 0x32,0x6e,0xb9,0x78,0xe0,0xaa,0x5f,0x91,0xa6,0x51,0xe3,0x63,0xf8,0x97,0x2f,0x60, + 0xd9,0xfb,0x15,0xe5,0x59,0xcf,0x31,0x3c,0x61,0xc7,0xb5,0x61,0x2a,0x6b,0xdd,0xd1, + 0x09,0x70,0xc0,0xcf,0x94,0x7a,0xcc,0x31,0x94,0xb1,0xa2,0xf6,0x95,0xc0,0x38,0x3d, + 0xef,0x19,0x30,0x70,0xdd,0x62,0x32,0x8f,0x7c,0x30,0xb9,0x18,0xf8,0xe7,0x8f,0x0a, + 0xaa,0xb6,0x00,0x86,0xf2,0xe0,0x30,0x5f,0xa2,0xe8,0x00,0x8e,0x05,0xa0,0x22,0x18, + 0x9f,0x83,0xd4,0x3a,0x85,0x10,0xb9,0x51,0x8d,0x07,0xf0,0xb3,0xcd,0x9b,0x55,0xa1, + 0x14,0xce,0x0f,0xb2,0xcf,0xb8,0xce,0x2d,0xe6,0xe8,0x35,0x32,0x1f,0x22,0xb5,0xec, + 0xd0,0xb9,0x72,0xa8,0xb4,0x97 + //,0x6e,0x0a,0x47,0xcd,0x5a,0xf0,0xdc,0xeb,0xfd,0x46, + //0xe5,0x6e,0x83,0xe6,0x1a,0xcc,0x4a,0x8b,0xa5,0x28,0x9e,0x50,0x48,0xa9,0xa2,0x6b, +}; + +// this is made of the last iteration of the rf_table (18th transformation) +const uint8_t rf256_iv[32] = { + 0x78,0xe9,0x90,0xd3,0xb3,0xc8,0x9b,0x7b,0x0a,0xc4,0x86,0x6e,0x4e,0x38,0xb3,0x6b, + 0x33,0x68,0x7c,0xed,0x73,0x35,0x4b,0x0a,0x97,0x25,0x4c,0x77,0x7a,0xaa,0x61,0x1b +}; + +// crc32 lookup tables +const uint32_t rf_crc32_table[256] = { + /* 0x00 */ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, + /* 0x04 */ 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, + /* 0x08 */ 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + /* 0x0c */ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, + /* 0x10 */ 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, + /* 0x14 */ 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + /* 0x18 */ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, + /* 0x1c */ 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, + /* 0x20 */ 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + /* 0x24 */ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, + /* 0x28 */ 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, + /* 0x2c */ 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + /* 0x30 */ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, + /* 0x34 */ 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, + /* 0x38 */ 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + /* 0x3c */ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, + /* 0x40 */ 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, + /* 0x44 */ 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + /* 0x48 */ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, + /* 0x4c */ 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, + /* 0x50 */ 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + /* 0x54 */ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, + /* 0x58 */ 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, + /* 0x5c */ 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + /* 0x60 */ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, + /* 0x64 */ 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, + /* 0x68 */ 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + /* 0x6c */ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, + /* 0x70 */ 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, + /* 0x74 */ 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + /* 0x78 */ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, + /* 0x7c */ 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, + /* 0x80 */ 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + /* 0x84 */ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, + /* 0x88 */ 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, + /* 0x8c */ 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + /* 0x90 */ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, + /* 0x94 */ 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, + /* 0x98 */ 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + /* 0x9c */ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, + /* 0xa0 */ 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, + /* 0xa4 */ 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + /* 0xa8 */ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, + /* 0xac */ 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, + /* 0xb0 */ 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + /* 0xb4 */ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, + /* 0xb8 */ 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, + /* 0xbc */ 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + /* 0xc0 */ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, + /* 0xc4 */ 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, + /* 0xc8 */ 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + /* 0xcc */ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, + /* 0xd0 */ 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, + /* 0xd4 */ 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + /* 0xd8 */ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, + /* 0xdc */ 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, + /* 0xe0 */ 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + /* 0xe4 */ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, + /* 0xe8 */ 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, + /* 0xec */ 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + /* 0xf0 */ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, + /* 0xf4 */ 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, + /* 0xf8 */ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + /* 0xfc */ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, +}; + +// compute the crc32 of 32-bit message _msg_ from previous crc _crc_. +// build with -mcpu=cortex-a53+crc to enable native CRC instruction on ARM +static inline uint32_t rf_crc32_32(uint32_t crc, uint32_t msg) { +#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) + asm("crc32w %w0,%w0,%w1\n":"+r"(crc):"r"(msg)); +#else + crc=crc^msg; + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); +#endif + return crc; +} + +//static inline uint32_t rf_crc32_24(uint32_t crc, uint32_t msg) { +//#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) +// asm("crc32b %w0,%w0,%w1\n":"+r"(crc):"r"(msg)); +// asm("crc32h %w0,%w0,%w1\n":"+r"(crc):"r"(msg>>8)); +//#else +// crc=crc^msg; +// crc=rf_crc32_table[crc&0xff]^(crc>>8); +// crc=rf_crc32_table[crc&0xff]^(crc>>8); +// crc=rf_crc32_table[crc&0xff]^(crc>>8); +//#endif +// return crc; +//} +// +//static inline uint32_t rf_crc32_16(uint32_t crc, uint32_t msg) { +//#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) +// asm("crc32h %w0,%w0,%w1\n":"+r"(crc):"r"(msg)); +//#else +// crc=crc^msg; +// crc=rf_crc32_table[crc&0xff]^(crc>>8); +// crc=rf_crc32_table[crc&0xff]^(crc>>8); +//#endif +// return crc; +//} +// +//static inline uint32_t rf_crc32_8(uint32_t crc, uint32_t msg) { +//#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) +// asm("crc32b %w0,%w0,%w1\n":"+r"(crc):"r"(msg)); +//#else +// crc=crc^msg; +// crc=rf_crc32_table[crc&0xff]^(crc>>8); +//#endif +// return crc; +//} + +// add to _msg_ its own crc32. use -mcpu=cortex-a53+crc to enable native CRC +// instruction on ARM. +static inline uint64_t rf_add64_crc32(uint64_t msg) { + uint64_t crc=0; +#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) + asm("crc32x %w0,%w0,%x1\n":"+r"(crc):"r"(msg)); +#else + crc^=(uint32_t)msg; + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); + + crc^=msg>>32; + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); + crc=rf_crc32_table[crc&0xff]^(crc>>8); +#endif + return msg+crc; +} + +// mix the current state with the crc and return the new crc +static inline uint32_t rf_crc32x4(rf_u32 *state, uint32_t crc) { + crc=state[0]=rf_crc32_32(crc, state[0]); + crc=state[1]=rf_crc32_32(crc, state[1]); + crc=state[2]=rf_crc32_32(crc, state[2]); + crc=state[3]=rf_crc32_32(crc, state[3]); + return crc; +} + +// read 64 bit from possibly unaligned memory address _p_ in little endian mode +static inline uint64_t rf_memr64(const uint8_t *p) { +#ifdef RF_UNALIGNED_LE64 + return *(uint64_t *)p; +#else + uint64_t ret; + int byte; + for (ret=byte=0; byte<8; byte++) + ret+=(uint64_t)p[byte]<<(byte*8); + return ret; +#endif +} + +// return rainforest lower word entry for index +static inline uint64_t rf_wltable(uint8_t index) { + return rf_memr64(&rf_table[index]); +} + +// return rainforest upper word entry for _index_ +static inline uint64_t rf_whtable(uint8_t index) { + return rf_memr64(&rf_table[index*2]); +} + +// rotate left vector _v_ by _bits_ bits +static inline uint64_t rf_rotl64(uint64_t v, uint8_t bits) { +#if !defined(__ARM_ARCH_8A) && !defined(__AARCH64EL__) && !defined(x86_64) + bits&=63; +#endif + return (v<>(64-bits)); +} + +// rotate right vector _v_ by _bits_ bits +static inline uint64_t rf_rotr64(uint64_t v, uint8_t bits) { +#if !defined(__ARM_ARCH_8A) && !defined(__AARCH64EL__) && !defined(x86_64) + bits&=63; +#endif + return (v>>bits)|(v<<(64-bits)); +} + +// reverse all bytes in the word _v_ +static inline uint64_t rf_bswap64(uint64_t v) { +#if defined(__x86_64__) + asm("bswap %0":"+r"(v)); +#elif defined(__aarch64__) + asm("rev %0,%0\n":"+r"(v)); +#else + v=((v&0xff00ff00ff00ff00ULL)>>8)|((v&0x00ff00ff00ff00ffULL)<<8); + v=((v&0xffff0000ffff0000ULL)>>16)|((v&0x0000ffff0000ffffULL)<<16); + v=(v>>32)|(v<<32); +#endif + return v; +} + +// lookup _old_ in _rambox_, update it and perform a substitution if a matching +// value is found. +static inline uint32_t rf_rambox(uint64_t *rambox, uint64_t old) { + uint64_t *p; + int loops; + + for (loops=0; loops>56)<0x80) + *p = old; + } + return old; +} + +// write (_x_,_y_) at cell _cell_ for offset _ofs_ +static inline void rf_w128(uint64_t *cell, ulong ofs, uint64_t x, uint64_t y) { +#if defined(__ARM_ARCH_8A) || defined(__AARCH64EL__) + // 128 bit at once is faster when exactly two parallelizable instructions are + // used between two calls to keep the pipe full. + asm volatile("stp %0, %1, [%2,#%3]\n\t" + : /* no output */ + : "r"(x), "r"(y), "r" (cell), "I" (ofs*8)); +#else + cell[ofs+0] = x; + cell[ofs+1] = y; +#endif +} + +// initialize the ram box +static __attribute__((noinline)) void rf_raminit(uint64_t *rambox) { + uint64_t pat1 = 0x0123456789ABCDEFULL; + uint64_t pat2 = 0xFEDCBA9876543210ULL; + uint64_t pat3; + uint32_t pos; + + // Note: no need to mask the higher bits on armv8 nor x86 : + // + // From ARMv8's ref manual : + // The register that is specified for a shift can be 32-bit or + // 64-bit. The amount to be shifted can be specified either as + // an immediate, that is up to register size minus one, or by + // a register where the value is taken only from the bottom five + // (modulo-32) or six (modulo-64) bits. + // + // Here we rotate pat2 by pat1's bits and put it into pat1, and in + // parallel we rotate pat1 by pat2's bits and put it into pat2. Thus + // the two data blocks are exchanged in addition to being rotated. + // What is stored each time is the previous and the rotated blocks, + // which only requires one rotate and a register rename. + + for (pos = 0; pos < RAMBOX_SIZE; pos += 16) { + pat3 = pat1; + pat1 = rf_rotr64(pat2, pat3) + 0x111; + rf_w128(rambox + pos, 0, pat1, pat3); + + pat3 = pat2; + pat2 = rf_rotr64(pat1, pat3) + 0x222; + rf_w128(rambox + pos, 2, pat2, pat3); + + pat3 = pat1; + pat1 = rf_rotr64(pat2, pat3) + 0x333; + rf_w128(rambox + pos, 4, pat1, pat3); + + pat3 = pat2; + pat2 = rf_rotr64(pat1, pat3) + 0x444; + rf_w128(rambox + pos, 6, pat2, pat3); + + pat3 = pat1; + pat1 = rf_rotr64(pat2, pat3) + 0x555; + rf_w128(rambox + pos, 8, pat1, pat3); + + pat3 = pat2; + pat2 = rf_rotr64(pat1, pat3) + 0x666; + rf_w128(rambox + pos, 10, pat2, pat3); + + pat3 = pat1; + pat1 = rf_rotr64(pat2, pat3) + 0x777; + rf_w128(rambox + pos, 12, pat1, pat3); + + pat3 = pat2; + pat2 = rf_rotr64(pat1, pat3) + 0x888; + rf_w128(rambox + pos, 14, pat2, pat3); + } +} + +// exec the div/mod box. _v0_ and _v1_ must be aligned. +static inline void rf256_divbox(rf_u64 *v0, rf_u64 *v1) { + uint64_t pl, ql, ph, qh; + + //---- low word ---- ---- high word ---- + pl=~*v0; ph=~*v1; + ql=rf_bswap64(*v0); qh=rf_bswap64(*v1); + + if (!pl||!ql) { pl=ql=0; } + else if (pl>ql) { uint64_t p=pl; pl=p/ql; ql=p%ql; } + else { uint64_t p=pl; pl=ql/p; ql=ql%p; } + + if (!ph||!qh) { ph=qh=0; } + else if (ph>qh) { uint64_t p=ph; ph=p/qh; qh=p%qh; } + else { uint64_t p=ph; ph=qh/p; qh=qh%p; } + + pl+=qh; ph+=ql; + *v0-=pl; *v1-=ph; +} + +// exec the rotation/add box. _v0_ and _v1_ must be aligned. +static inline void rf256_rotbox(rf_u64 *v0, rf_u64 *v1, uint8_t b0, uint8_t b1) { + uint64_t l, h; + + //---- low word ---- ---- high word ---- + l=*v0; h=*v1; + l=rf_rotr64(l,b0); h=rf_rotl64(h,b1); + l+=rf_wltable(b0); h+=rf_whtable(b1); + b0=l; b1=h; + l=rf_rotl64(l,b1); h=rf_rotr64(h,b0); + b0=l; b1=h; + l=rf_rotr64(l,b1); h=rf_rotl64(h,b0); + *v0=l; *v1=h; +} + +// mix the current state with the current crc +static inline uint32_t rf256_scramble(rf256_ctx_t *ctx) { + return ctx->crc=rf_crc32x4(ctx->hash.d, ctx->crc); +} + +// mix the state with the crc and the pending text, and update the crc +static inline void rf256_inject(rf256_ctx_t *ctx) { + // BS: never <4 bytes with 80 input bytes + //ctx->crc= + // (ctx->bytes&3)==0?rf_crc32_32(rf256_scramble(ctx), ctx->word): + // (ctx->bytes&3)==3?rf_crc32_24(rf256_scramble(ctx), ctx->word): + // (ctx->bytes&3)==2?rf_crc32_16(rf256_scramble(ctx), ctx->word): + // rf_crc32_8(rf256_scramble(ctx), ctx->word); + ctx->crc=rf_crc32_32(rf256_scramble(ctx), ctx->word); + ctx->word=0; +} + +// rotate the hash by 32 bits. Not using streaming instructions (SSE/NEON) is +// faster because the compiler can follow moves an use register renames. +static inline void rf256_rot32x256(hash256_t *hash) { +#if defined(__x86_64__) || defined(__aarch64__) || defined(__ARM_ARCH_7A__) + uint32_t t0, t1, t2; + + t0=hash->d[0]; + t1=hash->d[1]; + t2=hash->d[2]; + hash->d[1]=t0; + hash->d[2]=t1; + + t0=hash->d[3]; + t1=hash->d[4]; + hash->d[3]=t2; + hash->d[4]=t0; + + t2=hash->d[5]; + t0=hash->d[6]; + hash->d[5]=t1; + hash->d[6]=t2; + + t1=hash->d[7]; + hash->d[7]=t0; + hash->d[0]=t1; +#else + uint32_t tmp=hash->d[7]; + + memmove(&hash->d[1], &hash->d[0], 28); + hash->d[0]=tmp; +#endif +} + +// encrypt the first 128 bits of the hash using the last 128 bits as the key +static inline void rf256_aesenc(rf256_ctx_t *ctx) { + aes2r_encrypt((uint8_t *)ctx->hash.b, (uint8_t *)ctx->hash.b+16); +} + +// each new round consumes exactly 32 bits of text at once and perturbates +// 128 bits of output, 96 of which overlap with the previous round, and 32 +// of which are new. With 5 rounds or more each output bit depends on every +// input bit. +static inline void rf256_one_round(rf256_ctx_t *ctx) { + uint64_t carry; + + rf256_rot32x256(&ctx->hash); + + carry=((uint64_t)ctx->len << 32) + ctx->crc; + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_scramble(ctx); + + carry=rf_rambox(ctx->rambox, carry); + rf256_rotbox(ctx->hash.q, ctx->hash.q+1, carry, carry>>56); + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_scramble(ctx); + + carry=rf_rambox(ctx->rambox, carry); + rf256_rotbox(ctx->hash.q, ctx->hash.q+1, carry>>8, carry>>48); + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_scramble(ctx); + + carry=rf_rambox(ctx->rambox, carry); + rf256_rotbox(ctx->hash.q, ctx->hash.q+1, carry>>16, carry>>40); + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_scramble(ctx); + + carry=rf_rambox(ctx->rambox,carry); + rf256_rotbox(ctx->hash.q, ctx->hash.q+1, carry>>24, carry>>32); + rf256_scramble(ctx); + rf256_divbox(ctx->hash.q, ctx->hash.q+1); + rf256_inject(ctx); + rf256_aesenc(ctx); + rf256_scramble(ctx); +} + +// initialize the hash state +static void rf256_init(rf256_ctx_t *ctx) { + rf_raminit(ctx->rambox); + memcpy(ctx->hash.b, rf256_iv, sizeof(ctx->hash.b)); + ctx->crc=RF256_INIT_CRC; + ctx->word=ctx->len=0; +} + +// update the hash context _ctx_ with _len_ bytes from message _msg_ +static void rf256_update(rf256_ctx_t *ctx, const void *msg, size_t len) { + while (len > 0) { +#ifdef RF_UNALIGNED_LE32 + if (!(ctx->len&3) && len>=4) { + ctx->word=*(uint32_t *)msg; + ctx->len+=4; + rf256_one_round(ctx); + msg+=4; + len-=4; + continue; + } +#endif + ctx->word|=((uint32_t)*(uint8_t *)msg++)<<(8*(ctx->len++&3)); + len--; + if (!(ctx->len&3)) + rf256_one_round(ctx); + } +} + +// finalize the hash and copy the result into _out_ if not null (256 bits) +static void rf256_final(void *out, rf256_ctx_t *ctx) { + // BS: never happens with 80 input bytes + //uint32_t pad; + + //if (ctx->len&3) + // rf256_one_round(ctx); + + // always work on at least 256 bits of input + //for (pad=0; pad+ctx->len < 32;pad+=4) + // rf256_one_round(ctx); + + // always run 4 extra rounds to complete the last 128 bits + rf256_one_round(ctx); + rf256_one_round(ctx); + rf256_one_round(ctx); + rf256_one_round(ctx); + //if (out) + memcpy(out, ctx->hash.b, 32); +} + +// hash _len_ bytes from _in_ into _out_ +void rf256_hash(void *out, const void *in, size_t len) { + rf256_ctx_t ctx; + rf256_init(&ctx); + rf256_update(&ctx, in, len); + rf256_final(out, &ctx); +} diff --git a/stratum/algos/rainforest.h b/stratum/algos/rainforest.h new file mode 100644 index 000000000..2f5b4948b --- /dev/null +++ b/stratum/algos/rainforest.h @@ -0,0 +1,19 @@ +#ifndef RAINFOREST_H +#define RAINFOREST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void rf256_hash(void *out, const void *in, size_t len); +static inline void rainforest_hash(const char* input, char* output, uint32_t len) { + rf256_hash(output, input, len); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/sha256t.c b/stratum/algos/sha256t.c new file mode 100644 index 000000000..fcbd6cfc5 --- /dev/null +++ b/stratum/algos/sha256t.c @@ -0,0 +1,28 @@ + +#include +#include +#include +#include + +#include "sha256.h" + +#include + +void sha256t_hash(const char* input, char* output, uint32_t len) +{ + unsigned char hash[64]; + + SHA256_CTX ctx_sha256; + SHA256_Init(&ctx_sha256); + SHA256_Update(&ctx_sha256, input, len); + SHA256_Final(hash, &ctx_sha256); + + SHA256_Init(&ctx_sha256); + SHA256_Update(&ctx_sha256, hash, 32); + SHA256_Final(hash, &ctx_sha256); + + SHA256_Init(&ctx_sha256); + SHA256_Update(&ctx_sha256, hash, 32); + SHA256_Final((unsigned char*)output, &ctx_sha256); +} + diff --git a/stratum/algos/sha256t.h b/stratum/algos/sha256t.h new file mode 100644 index 000000000..421770f06 --- /dev/null +++ b/stratum/algos/sha256t.h @@ -0,0 +1,16 @@ +#ifndef SHA256T_H +#define SHA256T_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void sha256t_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/skunk.c b/stratum/algos/skunk.c new file mode 100644 index 000000000..8af24d0be --- /dev/null +++ b/stratum/algos/skunk.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +#include +#include +#include +#include "gost.h" + +#include "common.h" + +void skunk_hash(const char *input, char* output, uint32_t len) +{ + uint32_t _ALIGN(64) hash[16]; + + sph_skein512_context ctx_skein; + sph_cubehash512_context ctx_cube; + sph_fugue512_context ctx_fugue; + sph_gost512_context ctx_gost; + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, input, 80); + sph_skein512_close(&ctx_skein, (void*) hash); + + sph_cubehash512_init(&ctx_cube); + sph_cubehash512(&ctx_cube, hash, 64); + sph_cubehash512_close(&ctx_cube, hash); + + sph_fugue512_init (&ctx_fugue); + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, (const void*) hash, 64); + sph_gost512_close(&ctx_gost, (void*) hash); + + memcpy(output, hash, 32); +} + diff --git a/stratum/algos/skunk.h b/stratum/algos/skunk.h new file mode 100644 index 000000000..8e8f88254 --- /dev/null +++ b/stratum/algos/skunk.h @@ -0,0 +1,16 @@ +#ifndef SKUNK_H +#define SKUNK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void skunk_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/sm3.c b/stratum/algos/sm3.c new file mode 100644 index 000000000..b627cb8e1 --- /dev/null +++ b/stratum/algos/sm3.c @@ -0,0 +1,220 @@ +/* ==================================================================== + * Copyright (c) 2014 - 2017 The GmSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the GmSSL Project. + * (http://gmssl.org/)" + * + * 4. The name "GmSSL Project" must not be used to endorse or promote + * products derived from this software without prior written + * permission. For written permission, please contact + * guanzhi1980@gmail.com. + * + * 5. Products derived from this software may not be called "GmSSL" + * nor may "GmSSL" appear in their names without prior written + * permission of the GmSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the GmSSL Project + * (http://gmssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + */ + +#include + +#include "sm3.h" + +void sm3_init(sm3_ctx_t *ctx) +{ + ctx->digest[0] = 0x7380166F; + ctx->digest[1] = 0x4914B2B9; + ctx->digest[2] = 0x172442D7; + ctx->digest[3] = 0xDA8A0600; + ctx->digest[4] = 0xA96F30BC; + ctx->digest[5] = 0x163138AA; + ctx->digest[6] = 0xE38DEE4D; + ctx->digest[7] = 0xB0FB0E4E; + + ctx->nblocks = 0; + ctx->num = 0; +} + +void sm3_update(sm3_ctx_t *ctx, const unsigned char* data, size_t data_len) +{ + if (ctx->num) { + unsigned int left = SM3_BLOCK_SIZE - ctx->num; + if (data_len < left) { + memcpy(ctx->block + ctx->num, data, data_len); + ctx->num += data_len; + return; + } else { + memcpy(ctx->block + ctx->num, data, left); + sm3_compress(ctx->digest, ctx->block); + ctx->nblocks++; + data += left; + data_len -= left; + } + } + while (data_len >= SM3_BLOCK_SIZE) { + sm3_compress(ctx->digest, data); + ctx->nblocks++; + data += SM3_BLOCK_SIZE; + data_len -= SM3_BLOCK_SIZE; + } + ctx->num = data_len; + if (data_len) { + memcpy(ctx->block, data, data_len); + } +} + +void sm3_close(void *cc, void *dst) +{ + sm3_final(cc, dst); + memset(cc, 0, sizeof(sm3_ctx_t)); +} + +void sm3_final(sm3_ctx_t *ctx, unsigned char *digest) +{ + int i; + uint32_t *pdigest = (uint32_t *)digest; + uint32_t *count = (uint32_t *)(ctx->block + SM3_BLOCK_SIZE - 8); + + ctx->block[ctx->num] = 0x80; + + if (ctx->num + 9 <= SM3_BLOCK_SIZE) { + memset(ctx->block + ctx->num + 1, 0, SM3_BLOCK_SIZE - ctx->num - 9); + } else { + memset(ctx->block + ctx->num + 1, 0, SM3_BLOCK_SIZE - ctx->num - 1); + sm3_compress(ctx->digest, ctx->block); + memset(ctx->block, 0, SM3_BLOCK_SIZE - 8); + } + + count[0] = cpu_to_be32((ctx->nblocks) >> 23); + count[1] = cpu_to_be32((ctx->nblocks << 9) + (ctx->num << 3)); + + sm3_compress(ctx->digest, ctx->block); + for (i = 0; i < sizeof(ctx->digest)/sizeof(ctx->digest[0]); i++) { + pdigest[i] = cpu_to_be32(ctx->digest[i]); + } +} + +#define ROTATELEFT(X,n) (((X)<<(n)) | ((X)>>(32-(n)))) + +#define P0(x) ((x) ^ ROTATELEFT((x),9) ^ ROTATELEFT((x),17)) +#define P1(x) ((x) ^ ROTATELEFT((x),15) ^ ROTATELEFT((x),23)) + +#define FF0(x,y,z) ( (x) ^ (y) ^ (z)) +#define FF1(x,y,z) (((x) & (y)) | ( (x) & (z)) | ( (y) & (z))) + +#define GG0(x,y,z) ( (x) ^ (y) ^ (z)) +#define GG1(x,y,z) (((x) & (y)) | ( (~(x)) & (z)) ) + + +void sm3_compress(uint32_t digest[8], const unsigned char block[64]) +{ + int j; + uint32_t W[68], W1[64]; + const uint32_t *pblock = (const uint32_t *)block; + + uint32_t A = digest[0]; + uint32_t B = digest[1]; + uint32_t C = digest[2]; + uint32_t D = digest[3]; + uint32_t E = digest[4]; + uint32_t F = digest[5]; + uint32_t G = digest[6]; + uint32_t H = digest[7]; + uint32_t SS1,SS2,TT1,TT2,T[64]; + + for(j = 0; j < 16; j++) { + W[j] = cpu_to_be32(pblock[j]); + } + for(j = 16; j < 68; j++) { + W[j] = P1( W[j-16] ^ W[j-9] ^ ROTATELEFT(W[j-3],15)) ^ ROTATELEFT(W[j - 13],7 ) ^ W[j-6];; + } + for(j = 0; j < 64; j++) { + W1[j] = W[j] ^ W[j+4]; + } + + for(j = 0; j < 16; j++) { + + T[j] = 0x79CC4519; + SS1 = ROTATELEFT((ROTATELEFT(A,12) + E + ROTATELEFT(T[j],j)), 7); + SS2 = SS1 ^ ROTATELEFT(A,12); + TT1 = FF0(A,B,C) + D + SS2 + W1[j]; + TT2 = GG0(E,F,G) + H + SS1 + W[j]; + D = C; + C = ROTATELEFT(B,9); + B = A; + A = TT1; + H = G; + G = ROTATELEFT(F,19); + F = E; + E = P0(TT2); + } + + for(j = 16; j < 64; j++) { + + T[j] = 0x7A879D8A; + SS1 = ROTATELEFT((ROTATELEFT(A,12) + E + ROTATELEFT(T[j],j&31)), 7); + SS2 = SS1 ^ ROTATELEFT(A,12); + TT1 = FF1(A,B,C) + D + SS2 + W1[j]; + TT2 = GG1(E,F,G) + H + SS1 + W[j]; + D = C; + C = ROTATELEFT(B,9); + B = A; + A = TT1; + H = G; + G = ROTATELEFT(F,19); + F = E; + E = P0(TT2); + } + + digest[0] ^= A; + digest[1] ^= B; + digest[2] ^= C; + digest[3] ^= D; + digest[4] ^= E; + digest[5] ^= F; + digest[6] ^= G; + digest[7] ^= H; +} + +void sm3(const unsigned char *msg, size_t msglen, + unsigned char dgst[SM3_DIGEST_LENGTH]) +{ + sm3_ctx_t ctx; + + sm3_init(&ctx); + sm3_update(&ctx, msg, msglen); + sm3_final(&ctx, dgst); + + memset(&ctx, 0, sizeof(sm3_ctx_t)); +} diff --git a/stratum/algos/sm3.h b/stratum/algos/sm3.h new file mode 100644 index 000000000..05c6595d9 --- /dev/null +++ b/stratum/algos/sm3.h @@ -0,0 +1,109 @@ +/* ==================================================================== + * Copyright (c) 2014 - 2016 The GmSSL Project. All rights reserved. + * Copyright (c) 2017 - YiiMP (cleaned hmac dead stuff) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the GmSSL Project. + * (http://gmssl.org/)" + * + * 4. The name "GmSSL Project" must not be used to endorse or promote + * products derived from this software without prior written + * permission. For written permission, please contact + * guanzhi1980@gmail.com. + * + * 5. Products derived from this software may not be called "GmSSL" + * nor may "GmSSL" appear in their names without prior written + * permission of the GmSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the GmSSL Project + * (http://gmssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE GmSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE GmSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + */ + +#ifndef _SM3_H +#define _SM3_H + +#define SM3_DIGEST_LENGTH 32 +#define SM3_BLOCK_SIZE 64 +#define SM3_CBLOCK (SM3_BLOCK_SIZE) +#define SM3_HMAC_SIZE (SM3_DIGEST_LENGTH) + + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct { + uint32_t digest[8]; + int nblocks; + unsigned char block[64]; + int num; +} sm3_ctx_t; + +void sm3_init(sm3_ctx_t *ctx); +void sm3_update(sm3_ctx_t *ctx, const unsigned char* data, size_t data_len); +void sm3_close(void *cc, void *dst); + +void sm3_final(sm3_ctx_t *ctx, unsigned char digest[SM3_DIGEST_LENGTH]); +void sm3_compress(uint32_t digest[8], const unsigned char block[SM3_BLOCK_SIZE]); +void sm3(const unsigned char *data, size_t datalen, + unsigned char digest[SM3_DIGEST_LENGTH]); + +#ifdef CPU_BIGENDIAN + +#define cpu_to_be16(v) (v) +#define cpu_to_be32(v) (v) +#define be16_to_cpu(v) (v) +#define be32_to_cpu(v) (v) + +#else + +#define cpu_to_le16(v) (v) +#define cpu_to_le32(v) (v) +#define le16_to_cpu(v) (v) +#define le32_to_cpu(v) (v) + +#define cpu_to_be16(v) (((v)<< 8) | ((v)>>8)) +#define cpu_to_be32(v) (((v)>>24) | (((v)>>8)&0xff00) | (((v)<<8)&0xff0000) | ((v)<<24)) +#define be16_to_cpu(v) cpu_to_be16(v) +#define be32_to_cpu(v) cpu_to_be32(v) + +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/stratum/algos/sonoa.c b/stratum/algos/sonoa.c new file mode 100644 index 000000000..ade6ef973 --- /dev/null +++ b/stratum/algos/sonoa.c @@ -0,0 +1,369 @@ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" + +void sonoa_hash(const char* input, char* output, uint32_t len) +{ + uint8_t _ALIGN(128) hash[64]; + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_skein512_context ctx_skein; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_hamsi512_context ctx_hamsi; + sph_fugue512_context ctx_fugue; + sph_shabal512_context ctx_shabal; + sph_whirlpool_context ctx_whirlpool; + sph_sha512_context ctx_sha512; + sph_haval256_5_context ctx_haval; + + + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, input, 80); + sph_blake512_close(&ctx_blake, hash); + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, hash, 64); + sph_whirlpool_close(&ctx_whirlpool, hash); + + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_whirlpool(&ctx_whirlpool, hash, 64); + sph_whirlpool_close(&ctx_whirlpool, hash); + + sph_sha512_init(&ctx_sha512); + sph_sha512(&ctx_sha512,(const void*) hash, 64); + sph_sha512_close(&ctx_sha512,(void*) hash); + + sph_whirlpool(&ctx_whirlpool, hash, 64); + sph_whirlpool_close(&ctx_whirlpool, hash); + + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_shabal512(&ctx_shabal, hash, 64); + sph_shabal512_close(&ctx_shabal, hash); + + sph_whirlpool(&ctx_whirlpool, hash, 64); + sph_whirlpool_close(&ctx_whirlpool, hash); + + sph_sha512(&ctx_sha512,(const void*) hash, 64); + sph_sha512_close(&ctx_sha512,(void*) hash); + + sph_haval256_5_init(&ctx_haval); + sph_haval256_5(&ctx_haval,(const void*) hash, 64); + sph_haval256_5_close(&ctx_haval, hash); + + memcpy(output, hash, 32); +} + diff --git a/stratum/algos/sonoa.h b/stratum/algos/sonoa.h new file mode 100644 index 000000000..c4b6b88f9 --- /dev/null +++ b/stratum/algos/sonoa.h @@ -0,0 +1,16 @@ +#ifndef SONOA_H +#define SONOA_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void sonoa_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/timetravel.c b/stratum/algos/timetravel.c new file mode 100644 index 000000000..c715eb748 --- /dev/null +++ b/stratum/algos/timetravel.c @@ -0,0 +1,183 @@ +#include +#include +#include + +#define HASH_FUNC_BASE_TIMESTAMP 1389040865 // Machinecoin: Genesis Timestamp +#define HASH_FUNC_COUNT 8 // Machinecoin: HASH_FUNC_COUNT of 11 +#define HASH_FUNC_COUNT_PERMUTATIONS 40320 // Machinecoin: HASH_FUNC_COUNT! + +#include +#include +#include +#include +#include +#include +#include +#include +#if HASH_FUNC_COUNT > 8 +#include +#include +#include +#endif + +#define _ALIGN(x) __attribute__ ((aligned(x))) + +// helpers +inline void swap(int *a, int *b) { + int c = *a; + *a = *b; + *b = c; +} + +static void reverse(int *pbegin, int *pend) { + while ( (pbegin != pend) && (pbegin != --pend) ) + swap(pbegin++, pend); +} + +static void next_permutation(int *pbegin, int *pend) { + if (pbegin == pend) + return; + + int *i = pbegin; + ++i; + if (i == pend) + return; + + i = pend; + --i; + + while (1) { + int *j = i; + --i; + + if (*i < *j) { + int *k = pend; + + while (!(*i < *--k)) + /* pass */; + + swap(i, k); + reverse(j, pend); + return; // true + } + + if (i == pbegin) { + reverse(pbegin, pend); + return; // false + } + } +} +// helpers + +void timetravel_hash(const char* input, char* output, uint32_t len) +{ + uint32_t _ALIGN(64) hash[16 * HASH_FUNC_COUNT]; + uint32_t *hashA, *hashB; + uint32_t dataLen = 64; + uint32_t *work_data = (uint32_t *)input; + const uint32_t timestamp = work_data[17]; + + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; +#if HASH_FUNC_COUNT > 8 + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; +#endif + // We want to permute algorithms. To get started we + // initialize an array with a sorted sequence of unique + // integers where every integer represents its own algorithm. + uint32_t permutation[HASH_FUNC_COUNT]; + for (uint32_t i = 0; i < HASH_FUNC_COUNT; i++) { + permutation[i]=i; + } + + // Compute the next permuation + uint32_t steps = (timestamp - HASH_FUNC_BASE_TIMESTAMP) % HASH_FUNC_COUNT_PERMUTATIONS; + for (uint32_t i = 0; i < steps; i++) { + next_permutation(permutation, permutation + HASH_FUNC_COUNT); + } + + for (uint32_t i = 0; i < HASH_FUNC_COUNT; i++) { + if (i == 0) { + dataLen = len; + hashA = work_data; + } else { + dataLen = 64; + hashA = &hash[16 * (i - 1)]; + } + hashB = &hash[16 * i]; + + switch(permutation[i]) { + case 0: + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, hashA, dataLen); + sph_blake512_close(&ctx_blake, hashB); + break; + case 1: + sph_bmw512_init(&ctx_bmw); + sph_bmw512 (&ctx_bmw, hashA, dataLen); + sph_bmw512_close(&ctx_bmw, hashB); + break; + case 2: + sph_groestl512_init(&ctx_groestl); + sph_groestl512 (&ctx_groestl, hashA, dataLen); + sph_groestl512_close(&ctx_groestl, hashB); + break; + case 3: + sph_skein512_init(&ctx_skein); + sph_skein512 (&ctx_skein, hashA, dataLen); + sph_skein512_close(&ctx_skein, hashB); + break; + case 4: + sph_jh512_init(&ctx_jh); + sph_jh512 (&ctx_jh, hashA, dataLen); + sph_jh512_close(&ctx_jh, hashB); + break; + case 5: + sph_keccak512_init(&ctx_keccak); + sph_keccak512 (&ctx_keccak, hashA, dataLen); + sph_keccak512_close(&ctx_keccak, hashB); + break; + case 6: + sph_luffa512_init(&ctx_luffa); + sph_luffa512 (&ctx_luffa, hashA, dataLen); + sph_luffa512_close(&ctx_luffa, hashB); + break; + case 7: + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512 (&ctx_cubehash, hashA, dataLen); + sph_cubehash512_close(&ctx_cubehash, hashB); + break; +#if HASH_FUNC_COUNT > 8 + case 8: + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, hashA, dataLen); + sph_shavite512_close(&ctx_shavite, hashB); + break; + case 9: + sph_simd512_init(&ctx_simd); + sph_simd512 (&ctx_simd, hashA, dataLen); + sph_simd512_close(&ctx_simd, hashB); + break; + case 10: + sph_echo512_init(&ctx_echo); + sph_echo512 (&ctx_echo, hashA, dataLen); + sph_echo512_close(&ctx_echo, hashB); + break; +#endif + default: + break; + } + } + + memcpy(output, &hash[16 * (HASH_FUNC_COUNT - 1)], 32); +} + diff --git a/stratum/algos/timetravel.h b/stratum/algos/timetravel.h new file mode 100644 index 000000000..4a6cae1fe --- /dev/null +++ b/stratum/algos/timetravel.h @@ -0,0 +1,16 @@ +#ifndef TIMETRAVEL_H +#define TIMETRAVEL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void timetravel_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/tribus.c b/stratum/algos/tribus.c new file mode 100644 index 000000000..fbe2e637a --- /dev/null +++ b/stratum/algos/tribus.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "common.h" + +void tribus_hash(const char* input, char* output, uint32_t len) +{ + uint8_t _ALIGN(64) hash[64]; + + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_echo512_context ctx_echo; + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, input, 80); + sph_jh512_close(&ctx_jh, (void*) hash); + + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, (const void*) hash, 64); + sph_keccak512_close(&ctx_keccak, (void*) hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, (const void*) hash, 64); + sph_echo512_close(&ctx_echo, (void*) hash); + + memcpy(output, hash, 32); +} + diff --git a/stratum/algos/tribus.h b/stratum/algos/tribus.h new file mode 100644 index 000000000..b1fd9ae40 --- /dev/null +++ b/stratum/algos/tribus.h @@ -0,0 +1,16 @@ +#ifndef TRIBUS_H +#define TRIBUS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void tribus_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/vitalium.c b/stratum/algos/vitalium.c new file mode 100644 index 000000000..2a3b27cbb --- /dev/null +++ b/stratum/algos/vitalium.c @@ -0,0 +1,87 @@ +#include "vitalium.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include "gost.h" + +#include "common.h" + +void vitalium_hash(const char* input, char* output, uint32_t len) +{ + sph_skein512_context ctx_skein; + sph_cubehash512_context ctx_cubehash; + sph_fugue512_context ctx_fugue; + sph_gost512_context ctx_gost; + sph_echo512_context ctx_echo; + sph_shavite512_context ctx_shavite; + sph_luffa512_context ctx_luffa; + + //these uint512 in the c++ source of the client are backed by an array of uint32 + uint32_t hashA[16], hashB[16]; + + sph_skein512_init(&ctx_skein); + sph_skein512 (&ctx_skein, input, len); + sph_skein512_close (&ctx_skein, hashA); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512 (&ctx_cubehash, hashA, 64); + sph_cubehash512_close(&ctx_cubehash, hashB); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512 (&ctx_fugue, hashB, 64); + sph_fugue512_close(&ctx_fugue, hashA); + + sph_gost512_init(&ctx_gost); + sph_gost512 (&ctx_gost, hashA, 64); + sph_gost512_close (&ctx_gost, hashB); + + sph_echo512_init(&ctx_echo); + sph_echo512 (&ctx_echo, hashB, 64); + sph_echo512_close(&ctx_echo, hashA); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512 (&ctx_shavite, hashA, 64); + sph_shavite512_close(&ctx_shavite, hashB); + + sph_luffa512_init (&ctx_luffa); + sph_luffa512 (&ctx_luffa, hashB, 64); + sph_luffa512_close (&ctx_luffa, hashA); + + sph_gost512_init(&ctx_gost); + sph_gost512 (&ctx_gost, hashA, 64); + sph_gost512_close (&ctx_gost, hashB); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512 (&ctx_cubehash, hashB, 64); + sph_cubehash512_close(&ctx_cubehash, hashA); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512 (&ctx_fugue, hashA, 64); + sph_fugue512_close(&ctx_fugue, hashB); + + sph_gost512_init(&ctx_gost); + sph_gost512 (&ctx_gost, hashB, 64); + sph_gost512_close (&ctx_gost, hashA); + + sph_echo512_init(&ctx_echo); + sph_echo512 (&ctx_echo, hashA, 64); + sph_echo512_close(&ctx_echo, hashB); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512 (&ctx_shavite, hashB, 64); + sph_shavite512_close(&ctx_shavite, hashA); + + sph_luffa512_init (&ctx_luffa); + sph_luffa512 (&ctx_luffa, hashA, 64); + sph_luffa512_close (&ctx_luffa, hashB); + + memcpy(output, hashB, 32); +} diff --git a/stratum/algos/vitalium.h b/stratum/algos/vitalium.h new file mode 100644 index 000000000..e29b3bcb4 --- /dev/null +++ b/stratum/algos/vitalium.h @@ -0,0 +1,16 @@ +#ifndef VITALITY_H +#define VITALITY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void vitalium_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/x12.c b/stratum/algos/x12.c new file mode 100644 index 000000000..07346a1a7 --- /dev/null +++ b/stratum/algos/x12.c @@ -0,0 +1,85 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void x12_hash(const char* input, char* output, uint32_t len) +{ + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_hamsi512_context ctx_hamsi; + + uint32_t hash[16]; + + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, input, len); + sph_blake512_close(&ctx_blake, hash); + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close(&ctx_luffa, hash); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/x12.h b/stratum/algos/x12.h new file mode 100644 index 000000000..1b7ee985f --- /dev/null +++ b/stratum/algos/x12.h @@ -0,0 +1,16 @@ +#ifndef X12_H +#define X12_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void x12_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/x16r.c b/stratum/algos/x16r.c new file mode 100644 index 000000000..2b7a44f83 --- /dev/null +++ b/stratum/algos/x16r.c @@ -0,0 +1,178 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" + +enum Algo { + BLAKE = 0, + BMW, + GROESTL, + JH, + KECCAK, + SKEIN, + LUFFA, + CUBEHASH, + SHAVITE, + SIMD, + ECHO, + HAMSI, + FUGUE, + SHABAL, + WHIRLPOOL, + SHA512, + HASH_FUNC_COUNT +}; + +static void getAlgoString(const uint8_t* prevblock, char *output) +{ + char *sptr = output; + + for (int j = 0; j < HASH_FUNC_COUNT; j++) { + char b = (15 - j) >> 1; // 16 ascii hex chars, reversed + uint8_t algoDigit = (j & 1) ? prevblock[b] & 0xF : prevblock[b] >> 4; + if (algoDigit >= 10) + sprintf(sptr, "%c", 'A' + (algoDigit - 10)); + else + sprintf(sptr, "%u", (uint32_t) algoDigit); + sptr++; + } + *sptr = '\0'; +} + +void x16r_hash(const char* input, char* output, uint32_t len) +{ + uint32_t hash[64/4]; + char hashOrder[HASH_FUNC_COUNT + 1] = { 0 }; + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_hamsi512_context ctx_hamsi; + sph_fugue512_context ctx_fugue; + sph_shabal512_context ctx_shabal; + sph_whirlpool_context ctx_whirlpool; + sph_sha512_context ctx_sha512; + + void *in = (void*) input; + int size = len; + + getAlgoString(&input[4], hashOrder); + + for (int i = 0; i < 16; i++) + { + const char elem = hashOrder[i]; + const uint8_t algo = elem >= 'A' ? elem - 'A' + 10 : elem - '0'; + + switch (algo) { + case BLAKE: + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, in, size); + sph_blake512_close(&ctx_blake, hash); + break; + case BMW: + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, in, size); + sph_bmw512_close(&ctx_bmw, hash); + break; + case GROESTL: + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, in, size); + sph_groestl512_close(&ctx_groestl, hash); + break; + case SKEIN: + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, in, size); + sph_skein512_close(&ctx_skein, hash); + break; + case JH: + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, in, size); + sph_jh512_close(&ctx_jh, hash); + break; + case KECCAK: + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, in, size); + sph_keccak512_close(&ctx_keccak, hash); + break; + case LUFFA: + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, in, size); + sph_luffa512_close(&ctx_luffa, hash); + break; + case CUBEHASH: + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, in, size); + sph_cubehash512_close(&ctx_cubehash, hash); + break; + case SHAVITE: + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, in, size); + sph_shavite512_close(&ctx_shavite, hash); + break; + case SIMD: + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, in, size); + sph_simd512_close(&ctx_simd, hash); + break; + case ECHO: + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, in, size); + sph_echo512_close(&ctx_echo, hash); + break; + case HAMSI: + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, in, size); + sph_hamsi512_close(&ctx_hamsi, hash); + break; + case FUGUE: + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, in, size); + sph_fugue512_close(&ctx_fugue, hash); + break; + case SHABAL: + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, in, size); + sph_shabal512_close(&ctx_shabal, hash); + break; + case WHIRLPOOL: + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, in, size); + sph_whirlpool_close(&ctx_whirlpool, hash); + break; + case SHA512: + sph_sha512_init(&ctx_sha512); + sph_sha512(&ctx_sha512,(const void*) in, size); + sph_sha512_close(&ctx_sha512,(void*) hash); + break; + } + in = (void*) hash; + size = 64; + } + memcpy(output, hash, 32); +} diff --git a/stratum/algos/x16r.h b/stratum/algos/x16r.h new file mode 100644 index 000000000..4a41ec85b --- /dev/null +++ b/stratum/algos/x16r.h @@ -0,0 +1,16 @@ +#ifndef X16R_H +#define X16R_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void x16r_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/x16s.c b/stratum/algos/x16s.c new file mode 100644 index 000000000..d3f329136 --- /dev/null +++ b/stratum/algos/x16s.c @@ -0,0 +1,180 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" + +enum Algo { + BLAKE = 0, + BMW, + GROESTL, + JH, + KECCAK, + SKEIN, + LUFFA, + CUBEHASH, + SHAVITE, + SIMD, + ECHO, + HAMSI, + FUGUE, + SHABAL, + WHIRLPOOL, + SHA512, + HASH_FUNC_COUNT +}; + +static void getAlgoString(const uint8_t* prevblock, char *output) +{ + strcpy(output, "0123456789ABCDEF"); + + for(int i = 0; i < 16; i++){ + uint8_t b = (15 - i) >> 1; // 16 ascii hex chars, reversed + uint8_t algoDigit = (i & 1) ? prevblock[b] & 0xF : prevblock[b] >> 4; + + int offset = algoDigit; + // insert the nth character at the front + char oldVal = output[offset]; + for(int j=offset; j-->0;) { + output[j+1] = output[j]; + } + output[0] = oldVal; + } +} + +void x16s_hash(const char* input, char* output, uint32_t len) +{ + uint32_t hash[64/4]; + char hashOrder[HASH_FUNC_COUNT + 1] = { 0 }; + + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_hamsi512_context ctx_hamsi; + sph_fugue512_context ctx_fugue; + sph_shabal512_context ctx_shabal; + sph_whirlpool_context ctx_whirlpool; + sph_sha512_context ctx_sha512; + + void *in = (void*) input; + int size = len; + + getAlgoString(&input[4], hashOrder); + + for (int i = 0; i < 16; i++) + { + const char elem = hashOrder[i]; + const uint8_t algo = elem >= 'A' ? elem - 'A' + 10 : elem - '0'; + + switch (algo) { + case BLAKE: + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, in, size); + sph_blake512_close(&ctx_blake, hash); + break; + case BMW: + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, in, size); + sph_bmw512_close(&ctx_bmw, hash); + break; + case GROESTL: + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, in, size); + sph_groestl512_close(&ctx_groestl, hash); + break; + case SKEIN: + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, in, size); + sph_skein512_close(&ctx_skein, hash); + break; + case JH: + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, in, size); + sph_jh512_close(&ctx_jh, hash); + break; + case KECCAK: + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, in, size); + sph_keccak512_close(&ctx_keccak, hash); + break; + case LUFFA: + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, in, size); + sph_luffa512_close(&ctx_luffa, hash); + break; + case CUBEHASH: + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, in, size); + sph_cubehash512_close(&ctx_cubehash, hash); + break; + case SHAVITE: + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, in, size); + sph_shavite512_close(&ctx_shavite, hash); + break; + case SIMD: + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, in, size); + sph_simd512_close(&ctx_simd, hash); + break; + case ECHO: + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, in, size); + sph_echo512_close(&ctx_echo, hash); + break; + case HAMSI: + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, in, size); + sph_hamsi512_close(&ctx_hamsi, hash); + break; + case FUGUE: + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, in, size); + sph_fugue512_close(&ctx_fugue, hash); + break; + case SHABAL: + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, in, size); + sph_shabal512_close(&ctx_shabal, hash); + break; + case WHIRLPOOL: + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, in, size); + sph_whirlpool_close(&ctx_whirlpool, hash); + break; + case SHA512: + sph_sha512_init(&ctx_sha512); + sph_sha512(&ctx_sha512,(const void*) in, size); + sph_sha512_close(&ctx_sha512,(void*) hash); + break; + } + in = (void*) hash; + size = 64; + } + memcpy(output, hash, 32); +} diff --git a/stratum/algos/x16s.h b/stratum/algos/x16s.h new file mode 100644 index 000000000..ec9201c57 --- /dev/null +++ b/stratum/algos/x16s.h @@ -0,0 +1,16 @@ +#ifndef X16S_H +#define X16S_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void x16s_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/x22i.c b/stratum/algos/x22i.c new file mode 100644 index 000000000..02a1aa3d5 --- /dev/null +++ b/stratum/algos/x22i.c @@ -0,0 +1,146 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SWIFFTX/SWIFFTX.h" +#include "gost.h" +#include "Lyra2.h" + +#include "common.h" + + +void x22i_hash(const char* input, char* output, uint32_t len) +{ + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_skein512_context ctx_skein; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_hamsi512_context ctx_hamsi; + sph_fugue512_context ctx_fugue; + sph_shabal512_context ctx_shabal; + sph_whirlpool_context ctx_whirlpool; + sph_sha512_context ctx_sha512; + sph_haval256_5_context ctx_haval; + sph_tiger_context ctx_tiger; + sph_gost512_context ctx_gost; + sph_sha256_context ctx_sha; + + unsigned char _ALIGN(128) hash[64 * 4] = {0}; + unsigned char _ALIGN(128) hash2[64]; + + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, input, len); + sph_blake512_close (&ctx_blake, hash); + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, hash, 64); + sph_bmw512_close(&ctx_bmw, hash); + + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, hash, 64); + sph_groestl512_close(&ctx_groestl, hash); + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, hash, 64); + sph_skein512_close(&ctx_skein, hash); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, hash, 64); + sph_jh512_close(&ctx_jh, hash); + + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, hash, 64); + sph_keccak512_close(&ctx_keccak, hash); + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, hash, 64); + sph_luffa512_close (&ctx_luffa, hash); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, hash, 64); + sph_cubehash512_close(&ctx_cubehash, hash); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, hash, 64); + sph_shavite512_close(&ctx_shavite, hash); + + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, hash, 64); + sph_simd512_close(&ctx_simd, hash); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, hash, 64); + sph_echo512_close(&ctx_echo, hash); + + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, hash, 64); + sph_hamsi512_close(&ctx_hamsi, hash); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, hash, 64); + sph_fugue512_close(&ctx_fugue, hash); + + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, (const void*) hash, 64); + sph_shabal512_close(&ctx_shabal, &hash[64]); + + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool (&ctx_whirlpool, (const void*) &hash[64], 64); + sph_whirlpool_close(&ctx_whirlpool, &hash[128]); + + sph_sha512_init(&ctx_sha512); + sph_sha512(&ctx_sha512,(const void*) &hash[128], 64); + sph_sha512_close(&ctx_sha512,(void*) &hash[192]); + + InitializeSWIFFTX(); + ComputeSingleSWIFFTX((unsigned char*)hash, (unsigned char*)hash2, false); + + memset(hash, 0, 64); + sph_haval256_5_init(&ctx_haval); + sph_haval256_5(&ctx_haval,(const void*) hash2, 64); + sph_haval256_5_close(&ctx_haval,hash); + + memset(hash2, 0, 64); + sph_tiger_init(&ctx_tiger); + sph_tiger (&ctx_tiger, (const void*) hash, 64); + sph_tiger_close(&ctx_tiger, (void*) hash2); + + memset(hash, 0, 64); + LYRA2((void*) hash, 32, (const void*) hash2, 32, (const void*) hash2, 32, 1, 4, 4); + + sph_gost512_init(&ctx_gost); + sph_gost512 (&ctx_gost, (const void*) hash, 64); + sph_gost512_close(&ctx_gost, (void*) hash); + + sph_sha256_init(&ctx_sha); + sph_sha256 (&ctx_sha, (const void*) hash, 64); + sph_sha256_close(&ctx_sha, (void*) hash); + + memcpy(output, hash, 32); +} diff --git a/stratum/algos/x22i.h b/stratum/algos/x22i.h new file mode 100644 index 000000000..502b8941f --- /dev/null +++ b/stratum/algos/x22i.h @@ -0,0 +1,16 @@ +#ifndef X22I_H +#define X22I_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void x22i_hash(const char* input, char* output, uint32_t len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/stratum/algos/yescrypt-opt.c b/stratum/algos/yescrypt-opt.c index 4b42e85e8..c96190bab 100644 --- a/stratum/algos/yescrypt-opt.c +++ b/stratum/algos/yescrypt-opt.c @@ -942,7 +942,15 @@ yescrypt_kdf(const yescrypt_shared_t * shared, yescrypt_local_t * local, { HMAC_SHA256_CTX_Y ctx; HMAC_SHA256_Init_Y(&ctx, buf, buflen); - HMAC_SHA256_Update_Y(&ctx, salt, saltlen); + if (r == 32) { // yescryptR32 + HMAC_SHA256_Update_Y(&ctx, "WaviBanana", 10); + } else + if (r == 16) { // yescryptR16 + HMAC_SHA256_Update_Y(&ctx, "Client Key", 10); + } + else { // yescrypt + HMAC_SHA256_Update_Y(&ctx, salt, saltlen); + } HMAC_SHA256_Final_Y((uint8_t *)sha256, &ctx); } /* Compute StoredKey */ diff --git a/stratum/algos/yescrypt.c b/stratum/algos/yescrypt.c index da070d6cf..2959dfa4b 100644 --- a/stratum/algos/yescrypt.c +++ b/stratum/algos/yescrypt.c @@ -327,35 +327,25 @@ static int yescrypt_bsty(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt, size_t saltlen, uint64_t N, uint32_t r, uint32_t p, uint8_t * buf, size_t buflen) { - static __thread int initialized = 0; - static __thread yescrypt_shared_t shared; - static __thread yescrypt_local_t local; + yescrypt_shared_t shared; + yescrypt_local_t local; int retval; - if (!initialized) { -/* "shared" could in fact be shared, but it's simpler to keep it private - * along with "local". It's dummy and tiny anyway. */ - if (yescrypt_init_shared(&shared, NULL, 0, + if (yescrypt_init_shared(&shared, NULL, 0, 0, 0, 0, YESCRYPT_SHARED_DEFAULTS, 0, NULL, 0)) return -1; - if (yescrypt_init_local(&local)) { + if (yescrypt_init_local(&local)) { yescrypt_free_shared(&shared); return -1; - } - initialized = 1; } + retval = yescrypt_kdf(&shared, &local, passwd, passwdlen, salt, saltlen, N, r, p, 0, YESCRYPT_FLAGS, buf, buflen); -#if 0 - if (yescrypt_free_local(&local)) { - yescrypt_free_shared(&shared); - return -1; - } - if (yescrypt_free_shared(&shared)) - return -1; - initialized = 0; -#endif + + yescrypt_free_local(&local); + yescrypt_free_shared(&shared); + return retval; } @@ -364,3 +354,13 @@ void yescrypt_hash(const char *input, char *output, uint32_t len) { yescrypt_bsty((uint8_t*)input, len, (uint8_t*)input, len, 2048, 8, 1, (uint8_t*)output, 32); } + +void yescryptR16_hash(const char *input, char *output, uint32_t len) +{ + yescrypt_bsty((uint8_t*)input, len, (uint8_t*)input, len, 4096, 16, 1, (uint8_t*)output, 32); +} + +void yescryptR32_hash(const char *input, char *output, uint32_t len) +{ + yescrypt_bsty((uint8_t*)input, len, (uint8_t*)input, len, 4096, 32, 1, (uint8_t*)output, 32); +} diff --git a/stratum/algos/yescrypt.h b/stratum/algos/yescrypt.h index db7221778..8e87c7bee 100644 --- a/stratum/algos/yescrypt.h +++ b/stratum/algos/yescrypt.h @@ -39,6 +39,8 @@ extern "C" { #include /* for size_t */ void yescrypt_hash(const char* input, char* output, uint32_t len); +void yescryptR16_hash(const char* input, char* output, uint32_t len); +void yescryptR32_hash(const char* input, char* output, uint32_t len); /** * crypto_scrypt(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen): diff --git a/stratum/base58.cpp b/stratum/base58.cpp index 3dddd95fb..631fde043 100644 --- a/stratum/base58.cpp +++ b/stratum/base58.cpp @@ -4,7 +4,6 @@ * This program is free software; you can redistribute it and/or modify it * under the terms of the standard MIT license. See COPYING for more details. */ - #include #include @@ -23,7 +22,8 @@ static const int8_t b58digits[] = { 47,48,49,50,51,52,53,54, 55,56,57,-1,-1,-1,-1,-1, }; -bool _blkmk_b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz) { +static bool _blkmk_b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz) +{ const unsigned char *b58u = (const unsigned char*)b58; unsigned char *binu = (unsigned char *)bin; size_t outisz = (binsz + 3) / 4; @@ -85,15 +85,30 @@ bool _blkmk_b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz) { bool base58_decode(const char *input, char *output) { - unsigned char output_bin[25]; + unsigned char output_bin[32] = { 0 }; + bool b = _blkmk_b58tobin(output_bin, 26, input, 0); + output[0] = '\0'; - bool b = _blkmk_b58tobin(output_bin, sizeof(output_bin), input, 0); if(!b) return false; - output[0] = 0; - for(int i=1; i < 21; i++) - sprintf(output+strlen(output), "%02x", output_bin[i]); + for(int i=2; i < 22; i++) + sprintf(output+strlen(output), "%02x", output_bin[i]); return true; } +bool is_base58(char *input) +{ + // All alphanumeric characters except "0", "O", "I" and "l" + size_t i=0, len = strlen(input); + char *c = input; + while (i < len) { + bool isdigit = (c[i] >= '1' && c[i] <= '9'); + bool isalpha = (c[i] >= 'a' && c[i] <= 'z') || (c[i] >= 'A' && c[i] <= 'Z'); + if (!isdigit && !isalpha) return false; + if (c[i] == 'I' || c[i] == 'O' || c[i] == 'l') return false; + i++; + } + return true; +} + diff --git a/stratum/client.cpp b/stratum/client.cpp index f7d7b90cd..3c2bd94ca 100644 --- a/stratum/client.cpp +++ b/stratum/client.cpp @@ -1,8 +1,6 @@ #include "stratum.h" -//#define CLIENT_DEBUGLOG_ - bool client_suggest_difficulty(YAAMP_CLIENT *client, json_value *json_params) { if(json_params->u.array.length>0) @@ -47,8 +45,8 @@ bool client_subscribe(YAAMP_CLIENT *client, json_value *json_params) if(json_params->u.array.length>0) { - strncpy(client->version, json_params->u.array.values[0]->u.string.ptr, 1023); - // if(!strcmp(client->version, "stratum-proxy/0.0.1")) return false; + if (json_params->u.array.values[0]->u.string.ptr) + strncpy(client->version, json_params->u.array.values[0]->u.string.ptr, 1023); if(strstr(client->version, "NiceHash") || strstr(client->version, "proxy") || strstr(client->version, "/3.")) client->reconnectable = false; @@ -60,8 +58,9 @@ bool client_subscribe(YAAMP_CLIENT *client, json_value *json_params) if(json_params->u.array.length>1) { - char notify_id[1024]; - strncpy(notify_id, json_params->u.array.values[1]->u.string.ptr, 1023); + char notify_id[1024] = { 0 }; + if (json_params->u.array.values[1]->u.string.ptr) + strncpy(notify_id, json_params->u.array.values[1]->u.string.ptr, 1023); YAAMP_CLIENT *client1 = client_find_notify_id(notify_id, true); if(client1) @@ -87,9 +86,9 @@ bool client_subscribe(YAAMP_CLIENT *client, json_value *json_params) memcpy(client->job_history, client1->job_history, sizeof(client->job_history)); client1->lock_count = 0; -#ifdef CLIENT_DEBUGLOG_ - debuglog("reconnecting client locked to %x\n", client->jobid_next); -#endif + if (g_debuglog_client) { + debuglog("reconnecting client locked to %x\n", client->jobid_next); + } } else @@ -105,9 +104,9 @@ bool client_subscribe(YAAMP_CLIENT *client, json_value *json_params) memcpy(client->job_history, client1->job_history, sizeof(client->job_history)); client1->lock_count = 0; -#ifdef CLIENT_DEBUGLOG_ - debuglog("reconnecting2 client\n"); -#endif + if (g_debuglog_client) { + debuglog("reconnecting2 client\n"); + } } } } @@ -115,9 +114,9 @@ bool client_subscribe(YAAMP_CLIENT *client, json_value *json_params) strcpy(client->extranonce1_last, client->extranonce1); client->extranonce2size_last = client->extranonce2size; -#ifdef CLIENT_DEBUGLOG_ - debuglog("new client with nonce %s\n", client->extranonce1); -#endif + if (g_debuglog_client) { + debuglog("new client with nonce %s\n", client->extranonce1); + } client_send_result(client, "[[[\"mining.set_difficulty\",\"%.3g\"],[\"mining.notify\",\"%s\"]],\"%s\",%d]", client->difficulty_actual, client->notify_id, client->extranonce1, client->extranonce2size); @@ -128,6 +127,24 @@ bool client_subscribe(YAAMP_CLIENT *client, json_value *json_params) /////////////////////////////////////////////////////////////////////////////////////////// bool client_validate_user_address(YAAMP_CLIENT *client) { + int client_workers = 0; + if (client->userid == 0) { + client_workers = client_workers_byaddress(client->username); + } else { + client_workers = client_workers_count(client); + } + + // if already logged in this instance, reuse data from other workers (in memory) + if (client_workers > 1) { + if (client_workers > 100 && (client_workers%100 == 0)) { + clientlog(client, "using %d workers", client_workers); + } + if (client_auth_by_workers(client)) { + // client->coinid filled + return true; + } + } + if (!client->coinid) { for(CLI li = g_list_coind.first; li; li = li->next) { YAAMP_COIND *coind = (YAAMP_COIND *)li->data; @@ -178,7 +195,14 @@ bool client_validate_user_address(YAAMP_CLIENT *client) bool client_authorize(YAAMP_CLIENT *client, json_value *json_params) { - if(json_params->u.array.length>1) + + if(g_list_client.Find(client)) { + clientlog(client, "Already logged"); + client_send_error(client, 21, "Already logged"); + return false; + } + + if(json_params->u.array.length>1 && json_params->u.array.values[1]->u.string.ptr) strncpy(client->password, json_params->u.array.values[1]->u.string.ptr, 1023); if (g_list_client.count >= g_stratum_max_cons) { @@ -186,7 +210,7 @@ bool client_authorize(YAAMP_CLIENT *client, json_value *json_params) return false; } - if(json_params->u.array.length>0) + if(json_params->u.array.length>0 && json_params->u.array.values[0]->u.string.ptr) { strncpy(client->username, json_params->u.array.values[0]->u.string.ptr, 1023); @@ -205,14 +229,19 @@ bool client_authorize(YAAMP_CLIENT *client, json_value *json_params) } } + if (!is_base58(client->username)) { + clientlog(client, "bad mining address %s", client->username); + return false; + } + bool reset = client_initialize_multialgo(client); if(reset) return false; client_initialize_difficulty(client); -#ifdef CLIENT_DEBUGLOG_ - debuglog("new client %s, %s, %s\n", client->username, client->password, client->version); -#endif + if (g_debuglog_client) { + debuglog("new client %s, %s, %s\n", client->username, client->password, client->version); + } if(!client->userid || !client->workerid) { @@ -262,7 +291,7 @@ bool client_authorize(YAAMP_CLIENT *client, json_value *json_params) bool client_update_block(YAAMP_CLIENT *client, json_value *json_params) { // password, id, block hash - if(json_params->u.array.length < 3) + if(json_params->u.array.length < 3 || !json_params->u.array.values[0]->u.string.ptr) { clientlog(client, "update block, bad params"); return false; @@ -274,14 +303,18 @@ bool client_update_block(YAAMP_CLIENT *client, json_value *json_params) return false; } - YAAMP_COIND *coind = (YAAMP_COIND *)object_find(&g_list_coind, json_params->u.array.values[1]->u.integer, true); + int coinid = json_params->u.array.values[1]->u.integer; + if(!coinid) return false; + YAAMP_COIND *coind = (YAAMP_COIND *)object_find(&g_list_coind, coinid, true); if(!coind) return false; const char* hash = json_params->u.array.values[2]->u.string.ptr; -#ifdef CLIENT_DEBUGLOG_ - debuglog("notify: new %s block %s\n", coind->symbol, hash); -#endif + if (g_debuglog_client) { + debuglog("notify: new %s block %s\n", coind->symbol, hash); + } + + snprintf(coind->lastnotifyhash, 161, "%s", hash); coind->newblock = true; coind->notreportingcounter = 0; @@ -339,6 +372,70 @@ static bool client_store_stats(YAAMP_CLIENT *client, json_value *result) /////////////////////////////////////////////////////////////////////////////////////////// +int client_workers_count(YAAMP_CLIENT *client) +{ + int count = 0; + if (!client || client->userid <= 0) + return count; + + g_list_client.Enter(); + for(CLI li = g_list_client.first; li; li = li->next) + { + YAAMP_CLIENT *cli = (YAAMP_CLIENT *)li->data; + if (cli->deleted) continue; + if (cli->userid == client->userid) count++; + } + g_list_client.Leave(); + + return count; +} + +int client_workers_byaddress(const char *username) +{ + int count = 0; + if (!username || !strlen(username)) + return count; + + g_list_client.Enter(); + for(CLI li = g_list_client.first; li; li = li->next) + { + YAAMP_CLIENT *cli = (YAAMP_CLIENT *)li->data; + if (cli->deleted) continue; + if (strcmp(cli->username, username) == 0) count++; + } + g_list_client.Leave(); + + return count; +} + +bool client_auth_by_workers(YAAMP_CLIENT *client) +{ + if (!client || client->userid < 0) + return false; + + g_list_client.Enter(); + for(CLI li = g_list_client.first; li; li = li->next) + { + YAAMP_CLIENT *cli = (YAAMP_CLIENT *)li->data; + if (cli->deleted) continue; + if (client->userid) { + if(cli->userid == client->userid) { + client->coinid = cli->coinid; + break; + } + } else if (strcmp(cli->username, client->username) == 0) { + client->coinid = cli->coinid; + client->userid = cli->userid; + break; + } + } + g_list_client.Leave(); + + return (client->coinid > 0 && client->userid > 0); +} + +/////////////////////////////////////////////////////////////////////////////////////////// + //YAAMP_SOURCE *source_init(YAAMP_CLIENT *client) //{ // YAAMP_SOURCE *source = NULL; @@ -359,7 +456,7 @@ static bool client_store_stats(YAAMP_CLIENT *client, json_value *result) // source = new YAAMP_SOURCE; // memset(source, 0, sizeof(YAAMP_SOURCE)); // -// strncpy(source->ip, client->sock->ip, 1024); +// strncpy(source->ip, client->sock->ip, 64); // source->speed = 1; // // g_list_source.AddTail(source); @@ -421,6 +518,11 @@ static bool client_store_stats(YAAMP_CLIENT *client, json_value *result) void *client_thread(void *p) { YAAMP_CLIENT *client = new YAAMP_CLIENT; + if(!client) { + stratumlog("client_thread OOM"); + pthread_exit(NULL); + return NULL; + } memset(client, 0, sizeof(YAAMP_CLIENT)); client->reconnectable = true; @@ -434,6 +536,8 @@ void *client_thread(void *p) client->shares_per_minute = YAAMP_SHAREPERSEC; client->last_submit_time = current_timestamp(); +// usleep(g_list_client.count * 5000); + while(!g_exiting) { if(client->submit_bad > 1024) @@ -451,6 +555,10 @@ void *client_thread(void *p) client->id_int = json_get_int(json, "id"); client->id_str = json_get_string(json, "id"); + if (client->id_str && strlen(client->id_str) > 32) { + clientlog(client, "bad id"); + break; + } const char *method = json_get_string(json, "method"); @@ -477,9 +585,9 @@ void *client_thread(void *p) break; } -#ifdef CLIENT_DEBUGLOG_ - debuglog("client %s %d %s\n", method, client->id_int, client->id_str? client->id_str: "null"); -#endif + if (g_debuglog_client) { + debuglog("client %s %d %s\n", method, client->id_int, client->id_str? client->id_str: "null"); + } bool b = false; if(!strcmp(method, "mining.subscribe")) @@ -503,6 +611,9 @@ void *client_thread(void *p) else if(!strcmp(method, "mining.get_transactions")) b = client_send_result(client, "[]"); + else if(!strcmp(method, "mining.multi_version")) + b = client_send_result(client, "false"); // ASICBOOST + else if(!strcmp(method, "mining.extranonce.subscribe")) { client->extranonce_subscribe = true; @@ -515,9 +626,7 @@ void *client_thread(void *p) else if(!strcmp(method, "getwork")) { clientlog(client, "using getwork"); // client using http:// url - break; } - else { b = client_send_error(client, 20, "Not supported"); @@ -532,16 +641,19 @@ void *client_thread(void *p) // source_close(client->source); -#ifdef CLIENT_DEBUGLOG_ - debuglog("client terminate\n"); -#endif - if(!client || client->deleted) { + if (g_debuglog_client) { + debuglog("client terminate\n"); + } + if(!client) { pthread_exit(NULL); } else if(client->sock->total_read == 0) clientlog(client, "no data"); + if(client->sock->sock >= 0) + shutdown(client->sock->sock, SHUT_RDWR); + if(g_list_client.Find(client)) { if(client->workerid && !client->reconnecting) @@ -550,13 +662,13 @@ void *client_thread(void *p) db_clear_worker(g_db, client); CommonUnlock(&g_db_mutex); } - object_delete(client); + } else { + // only clients sockets in g_list_client are purged (if marked deleted) + socket_close(client->sock); + delete client; } - else - client_delete(client); - pthread_exit(NULL); } diff --git a/stratum/client.h b/stratum/client.h index 713d49ade..c58260b04 100644 --- a/stratum/client.h +++ b/stratum/client.h @@ -5,12 +5,12 @@ // int count; // double speed; // -// char ip[1024]; +// char ip[64]; //}; struct YAAMP_ALGO { - char name[1024]; + char name[64]; YAAMP_HASH_FUNCTION hash_function; double diff_multiplier; @@ -105,10 +105,12 @@ class YAAMP_CLIENT: public YAAMP_OBJECT inline void client_delete(YAAMP_OBJECT *object) { YAAMP_CLIENT *client = (YAAMP_CLIENT *)object; - socket_close(client->sock); - client->sock = NULL; + if (object == NULL) return; + socket_close(client->sock); delete client; + + object = NULL; } ////////////////////////////////////////////////////////////////////////// @@ -120,6 +122,7 @@ void get_random_key(char *key); void client_sort(); void client_block_ip(YAAMP_CLIENT *client, const char *reason); +void client_block_ipset(YAAMP_CLIENT *client, const char *ipset_name); bool client_reset_multialgo(YAAMP_CLIENT *client, bool first); bool client_initialize_multialgo(YAAMP_CLIENT *client); @@ -153,6 +156,11 @@ int client_send_error(YAAMP_CLIENT *client, int error, const char *string); bool client_ask_stats(YAAMP_CLIENT *client); bool client_submit(YAAMP_CLIENT *client, json_value *json_params); + +int client_workers_count(YAAMP_CLIENT *client); +int client_workers_byaddress(const char *username); +bool client_auth_by_workers(YAAMP_CLIENT *client); + void *client_thread(void *p); void db_check_user_input(char* input); diff --git a/stratum/client_core.cpp b/stratum/client_core.cpp index fc0f463b1..08f4098ea 100644 --- a/stratum/client_core.cpp +++ b/stratum/client_core.cpp @@ -24,6 +24,9 @@ void get_random_key(char *key) YAAMP_CLIENT *client_find_notify_id(const char *notify_id, bool reconnecting) { + if (!notify_id || !strlen(notify_id)) + return NULL; + g_list_client.Enter(); for(CLI li = g_list_client.first; li; li = li->next) { @@ -122,11 +125,25 @@ int client_ask(YAAMP_CLIENT *client, const char *method, const char *format, ... void client_block_ip(YAAMP_CLIENT *client, const char *reason) { char buffer[1024]; - sprintf(buffer, "iptables -A INPUT -s %s -p tcp --dport %d -j REJECT", client->sock->ip, g_tcp_port); + if(strcmp("0.0.0.0", client->sock->ip) == 0) return; + if(strstr(client->sock->ip, "192.168.")) return; + if(strstr(client->sock->ip, "127.0.0.")) return; + int s = system(buffer); + stratumlog("%s: %s blocked (%s)\n", g_stratum_algo, client->sock->ip, reason); +} + +void client_block_ipset(YAAMP_CLIENT *client, const char *ipset_name) +{ + char buffer[1024]; + sprintf(buffer, "ipset -q -A %s %s", ipset_name, client->sock->ip); + if(strcmp("0.0.0.0", client->sock->ip) == 0) return; + if(strstr(client->sock->ip, "192.168.")) return; + if(strstr(client->sock->ip, "127.0.0.")) return; - stratumlog("%s %s blocked (%s)\n", client->sock->ip, client->username, reason); + int s = system(buffer); + stratumlog("%s: %s blocked via ipset %s %s\n", g_stratum_algo, client->sock->ip, ipset_name, client->username); } bool client_reset_multialgo(YAAMP_CLIENT *client, bool first) @@ -166,11 +183,11 @@ bool client_reset_multialgo(YAAMP_CLIENT *client, bool first) int e = time(NULL) - client->last_best; double d = best->algo->profit*best->factor - current->algo->profit*current->factor; double p = d/best->algo->profit/best->factor; - -// debuglog("current %s %f\n", current->algo->name, current->algo->profit*current->factor); -// debuglog("best %s %f\n", best->algo->name, best->algo->profit*best->factor); -// debuglog(" %d * %f = %f --- percent %f %f\n", e, d, e*d, p, e*p); - +#ifdef DEBUG_BEST_MULTI + debuglog("current %s %f\n", current->algo->name, current->algo->profit*current->factor); + debuglog("best %s %f\n", best->algo->name, best->algo->profit*best->factor); + debuglog(" %d * %f = %f --- percent %f %f\n", e, d, e*d, p, e*p); +#endif if(p < 0.02) return false; if(e*p < 100) return false; } diff --git a/stratum/client_difficulty.cpp b/stratum/client_difficulty.cpp index 59ee7510e..e3d34cb08 100644 --- a/stratum/client_difficulty.cpp +++ b/stratum/client_difficulty.cpp @@ -3,10 +3,10 @@ double client_normalize_difficulty(double difficulty) { - if(difficulty <= 0.001) difficulty = 0.001; + if(difficulty < g_stratum_min_diff) difficulty = g_stratum_min_diff; else if(difficulty < 1) difficulty = floor(difficulty*1000/2)/1000*2; else if(difficulty > 1) difficulty = floor(difficulty/2)*2; - + if(difficulty > g_stratum_max_diff) difficulty = g_stratum_max_diff; return difficulty; } @@ -48,13 +48,12 @@ void client_change_difficulty(YAAMP_CLIENT *client, double difficulty) void client_adjust_difficulty(YAAMP_CLIENT *client) { - if(client->difficulty_remote) - { + if(client->difficulty_remote) { client_change_difficulty(client, client->difficulty_remote); return; } - if(client->shares_per_minute > 600) + if(client->shares_per_minute > 100) client_change_difficulty(client, client->difficulty_actual*4); else if(client->difficulty_fixed) @@ -79,6 +78,7 @@ int client_send_difficulty(YAAMP_CLIENT *client, double difficulty) client_call(client, "mining.set_difficulty", "[%.0f]", difficulty); else client_call(client, "mining.set_difficulty", "[%.3f]", difficulty); + return 0; } void client_initialize_difficulty(YAAMP_CLIENT *client) diff --git a/stratum/client_submit.cpp b/stratum/client_submit.cpp index 02322fe0d..055c349e7 100644 --- a/stratum/client_submit.cpp +++ b/stratum/client_submit.cpp @@ -1,8 +1,9 @@ #include "stratum.h" +uint64_t lyra2z_height = 0; + //#define MERKLE_DEBUGLOG -//#define HASH_DEBUGLOG_ //#define DONTSUBMIT void build_submit_values(YAAMP_JOB_VALUES *submitvalues, YAAMP_JOB_TEMPLATE *templ, @@ -30,10 +31,14 @@ void build_submit_values(YAAMP_JOB_VALUES *submitvalues, YAAMP_JOB_TEMPLATE *tem #ifdef MERKLE_DEBUGLOG printf("merkle root %s\n", merkleroot.c_str()); #endif - if (!strcmp(g_current_algo->name, "lbry")) { + if (!strcmp(g_stratum_algo, "lbry")) { sprintf(submitvalues->header, "%s%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be, templ->claim_be, ntime, templ->nbits, nonce); - ser_string_be(submitvalues->header, submitvalues->header_be, 32 + 20); + ser_string_be(submitvalues->header, submitvalues->header_be, 112/4); + } else if (strlen(templ->extradata_be) == 128) { // LUX SC + sprintf(submitvalues->header, "%s%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be, + ntime, templ->nbits, nonce, templ->extradata_be); + ser_string_be(submitvalues->header, submitvalues->header_be, 36); // 80+64 / sizeof(u32) } else { sprintf(submitvalues->header, "%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be, ntime, templ->nbits, nonce); @@ -72,13 +77,14 @@ static void create_decred_header(YAAMP_JOB_TEMPLATE *templ, YAAMP_JOB_VALUES *ou uint32_t size; uint32_t ntime; uint32_t nonce; - unsigned char extra[36]; + unsigned char extra[32]; + uint32_t stakever; uint32_t hashtag[3]; } header; memcpy(&header, templ->header, sizeof(header)); - memset(header.extra, 0, 36); + memset(header.extra, 0, 32); sscanf(nonce, "%08x", &header.nonce); if (strcmp(vote, "")) { @@ -202,7 +208,7 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL debuglog("*** ACCEPTED %s %d (+1)\n", coind_aux->name, coind_aux->height); block_add(client->userid, client->workerid, coind_aux->id, coind_aux->height, target_to_diff(coin_target_aux), - target_to_diff(hash_int), coind_aux->aux.hash, ""); + target_to_diff(hash_int), coind_aux->aux.hash, "", 0); } else @@ -212,8 +218,19 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL if(hash_int <= coin_target) { + char count_hex[8] = { 0 }; + if (templ->txcount <= 252) + sprintf(count_hex, "%02x", templ->txcount & 0xFF); + else + sprintf(count_hex, "fd%02x%02x", templ->txcount & 0xFF, templ->txcount >> 8); + memset(block_hex, 0, block_size); - sprintf(block_hex, "%s%02x%s", submitvalues->header_be, (unsigned char)templ->txcount, submitvalues->coinbase); + sprintf(block_hex, "%s%s%s", submitvalues->header_be, count_hex, submitvalues->coinbase); + + if (g_current_algo->name && !strcmp("jha", g_current_algo->name)) { + // block header of 88 bytes + sprintf(block_hex, "%s8400000008000000%s%s", submitvalues->header_be, count_hex, submitvalues->coinbase); + } vector::const_iterator i; for(i = templ->txdata.begin(); i != templ->txdata.end(); ++i) @@ -262,28 +279,31 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL block_add(client->userid, client->workerid, coind->id, templ->height, target_to_diff(coin_target), target_to_diff(hash_int), - hash1, submitvalues->hash_be); + hash1, submitvalues->hash_be, templ->has_segwit_txs); - if(coind->noblocknotify) { - // DCR go wallet doesnt handle blocknotify= config (yet) - // required to store the user id and the user diff + if(!strcmp("DCR", coind->rpcencoding)) { + // delay between dcrd and dcrwallet sleep(1); + } + + if(!strcmp(coind->lastnotifyhash,submitvalues->hash_be)) { block_confirm(coind->id, submitvalues->hash_be); } -#ifdef HASH_DEBUGLOG_ - debuglog("--------------------------------------------------------------\n"); - debuglog("hash1 %s\n", hash1); - debuglog("hash2 %s\n", submitvalues->hash_be); -#endif + if (g_debuglog_hash) { + debuglog("--------------------------------------------------------------\n"); + debuglog("hash1 %s\n", hash1); + debuglog("hash2 %s\n", submitvalues->hash_be); + } } else { debuglog("*** REJECTED :( %s block %d %d txs\n", coind->name, templ->height, templ->txcount); -#ifdef HASH_DEBUGLOG_ - //debuglog("block %s\n", block_hex); - debuglog("--------------------------------------------------------------\n"); -#endif + rejectlog("REJECTED %s block %d\n", coind->symbol, templ->height); + if (g_debuglog_hash) { + //debuglog("block %s\n", block_hex); + debuglog("--------------------------------------------------------------\n"); + } } } @@ -309,9 +329,9 @@ void client_submit_error(YAAMP_CLIENT *client, YAAMP_JOB *job, int id, const cha share_add(client, job, false, extranonce2, ntime, nonce, 0, id); client->submit_bad++; -#ifdef HASH_DEBUGLOG_ - dump_submit_debug(message, client, job, extranonce2, ntime, nonce); -#endif + if (g_debuglog_hash) { + dump_submit_debug(message, client, job, extranonce2, ntime, nonce); + } } object_unlock(job); @@ -323,47 +343,67 @@ static bool ntime_valid_range(const char ntimehex[]) uint32_t ntime = 0; if (strlen(ntimehex) != 8) return false; sscanf(ntimehex, "%8x", &ntime); - if (ntime < 0x57000000 || ntime > 0x60000000) // 14 Jan 2021 - ntime = bswap32(ntime); // just in case... + if (ntime < 0x5b000000 || ntime > 0x60000000) // 14 Jan 2021 + return false; time(&rawtime); - return ((rawtime - ntime) < (23 * 60 * 60)); + return (abs(rawtime - ntime) < (30 * 60)); +} + +static bool valid_string_params(json_value *json_params) +{ + for(int p=0; p < json_params->u.array.length; p++) { + if (!json_is_string(json_params->u.array.values[p])) + return false; + } + return true; } bool client_submit(YAAMP_CLIENT *client, json_value *json_params) { // submit(worker_name, jobid, extranonce2, ntime, nonce): - if(json_params->u.array.length<5) - { + if(json_params->u.array.length<5 || !valid_string_params(json_params)) { debuglog("%s - %s bad message\n", client->username, client->sock->ip); client->submit_bad++; return false; } - char extranonce2[32]; - char ntime[32]; - char nonce[32]; - char vote[8]; - - memset(extranonce2, 0, 32); - memset(ntime, 0, 32); - memset(nonce, 0, 32); - memset(vote, 0, 8); + char extranonce2[32] = { 0 }; + char extra[160] = { 0 }; + char nonce[80] = { 0 }; + char ntime[32] = { 0 }; + char vote[8] = { 0 }; + if (strlen(json_params->u.array.values[1]->u.string.ptr) > 32) { + clientlog(client, "bad json, wrong jobid len"); + client->submit_bad++; + return false; + } int jobid = htoi(json_params->u.array.values[1]->u.string.ptr); + strncpy(extranonce2, json_params->u.array.values[2]->u.string.ptr, 31); strncpy(ntime, json_params->u.array.values[3]->u.string.ptr, 31); strncpy(nonce, json_params->u.array.values[4]->u.string.ptr, 31); - if (json_params->u.array.length == 6) - strncpy(vote, json_params->u.array.values[5]->u.string.ptr, 7); - -#ifdef HASH_DEBUGLOG_ - debuglog("submit %s (uid %d) %d, %s, %s, %s\n", client->sock->ip, client->userid, jobid, extranonce2, ntime, nonce); -#endif string_lower(extranonce2); string_lower(ntime); string_lower(nonce); - string_lower(vote); + + if (json_params->u.array.length == 6) { + if (strstr(g_stratum_algo, "phi")) { + // lux optional field, smart contral root hashes (not mandatory on shares submit) + strncpy(extra, json_params->u.array.values[5]->u.string.ptr, 128); + string_lower(extra); + } else { + // heavycoin vote + strncpy(vote, json_params->u.array.values[5]->u.string.ptr, 7); + string_lower(vote); + } + } + + if (g_debuglog_hash) { + debuglog("submit %s (uid %d) %d, %s, t=%s, n=%s, extra=%s\n", client->sock->ip, client->userid, + jobid, extranonce2, ntime, nonce, extra); + } YAAMP_JOB *job = (YAAMP_JOB *)object_find(&g_list_job, jobid, true); if(!job) @@ -384,16 +424,22 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params) YAAMP_JOB_TEMPLATE *templ = job->templ; - if(strlen(nonce) != YAAMP_NONCE_SIZE*2) - { + if(strlen(nonce) != YAAMP_NONCE_SIZE*2 || !ishexa(nonce, YAAMP_NONCE_SIZE*2)) { client_submit_error(client, job, 20, "Invalid nonce size", extranonce2, ntime, nonce); return true; } - if(strcmp(ntime, templ->ntime) && !ntime_valid_range(ntime)) + if(strcmp(ntime, templ->ntime)) { - client_submit_error(client, job, 23, "Invalid time rolling", extranonce2, ntime, nonce); - return true; + if (!ishexa(ntime, 8) || !ntime_valid_range(ntime)) { + client_submit_error(client, job, 23, "Invalid time rolling", extranonce2, ntime, nonce); + return true; + } + // dont allow algos permutations change over time (can lead to different speeds) + if (!g_allow_rolltime) { + client_submit_error(client, job, 23, "Invalid ntime (rolling not allowed)", extranonce2, ntime, nonce); + return true; + } } YAAMP_SHARE *share = share_find(job->id, extranonce2, ntime, nonce, client->extranonce1); @@ -422,18 +468,20 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params) if (extranull) { debuglog("extranonce %s is empty!, should be %s - %s\n", extranonce2, extra1_id, client->sock->ip); client_submit_error(client, job, 27, "Invalid extranonce2 suffix", extranonce2, ntime, nonce); - client->submit_bad++; return true; } if (extradiff) { // some ccminer pre-release doesn't fill correctly the extranonce client_submit_error(client, job, 27, "Invalid extranonce2 suffix", extranonce2, ntime, nonce); - client->submit_bad++; socket_send(client->sock, "{\"id\":null,\"method\":\"mining.set_extranonce\",\"params\":[\"%s\",%d]}\n", client->extranonce1, client->extranonce2size); return true; } } + else if(!ishexa(extranonce2, client->extranonce2size*2)) { + client_submit_error(client, job, 27, "Invalid nonce2", extranonce2, ntime, nonce); + return true; + } /////////////////////////////////////////////////////////////////////////////////////////// @@ -445,14 +493,18 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params) else build_submit_values(&submitvalues, templ, client->extranonce1, extranonce2, ntime, nonce); + if (templ->height && !strcmp(g_current_algo->name,"lyra2z")) { + lyra2z_height = templ->height; + } + // minimum hash diff begins with 0000, for all... uint8_t pfx = submitvalues.hash_bin[30] | submitvalues.hash_bin[31]; if(pfx) { -#ifdef HASH_DEBUGLOG_ - debuglog("Possible %s error, hash starts with %02x%02x%02x%02x\n", g_current_algo->name, - (int) submitvalues.hash_bin[31], (int) submitvalues.hash_bin[30], - (int) submitvalues.hash_bin[29], (int) submitvalues.hash_bin[28]); -#endif + if (g_debuglog_hash) { + debuglog("Possible %s error, hash starts with %02x%02x%02x%02x\n", g_current_algo->name, + (int) submitvalues.hash_bin[31], (int) submitvalues.hash_bin[30], + (int) submitvalues.hash_bin[29], (int) submitvalues.hash_bin[28]); + } client_submit_error(client, job, 25, "Invalid share", extranonce2, ntime, nonce); return true; } @@ -462,11 +514,11 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params) uint64_t coin_target = decode_compact(templ->nbits); if (templ->nbits && !coin_target) coin_target = 0xFFFF000000000000ULL; -#ifdef HASH_DEBUGLOG_ - debuglog("%016llx actual\n", hash_int); - debuglog("%016llx target\n", user_target); - debuglog("%016llx coin\n", coin_target); -#endif + if (g_debuglog_hash) { + debuglog("%016llx actual\n", hash_int); + debuglog("%016llx target\n", user_target); + debuglog("%016llx coin\n", coin_target); + } if(hash_int > user_target && hash_int > coin_target) { client_submit_error(client, job, 26, "Low difficulty share", extranonce2, ntime, nonce); @@ -492,12 +544,12 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params) // share_diff = share_diff / g_current_algo->diff_multiplier; // } -#ifndef HASH_DEBUGLOG_ - // only log a few... - if (share_diff > (client->difficulty_actual * 16)) - debuglog("submit %s (uid %d) %d, %s, %s, %s, %.3f/%.3f\n", client->sock->ip, client->userid, - jobid, extranonce2, ntime, nonce, share_diff, client->difficulty_actual); -#endif + if (g_debuglog_hash) { + // only log a few... + if (share_diff > (client->difficulty_actual * 16)) + debuglog("submit %s (uid %d) %d, %s, %s, %s, %.3f/%.3f\n", client->sock->ip, client->userid, + jobid, extranonce2, ntime, nonce, share_diff, client->difficulty_actual); + } share_add(client, job, true, extranonce2, ntime, nonce, share_diff, 0); object_unlock(job); diff --git a/stratum/coinbase.cpp b/stratum/coinbase.cpp index 9b507d38f..9bf0a2bd3 100644 --- a/stratum/coinbase.cpp +++ b/stratum/coinbase.cpp @@ -14,35 +14,30 @@ static void encode_tx_value(char *encoded, json_int_t value) TX_VALUE(value, 32), TX_VALUE(value, 40), TX_VALUE(value, 48), TX_VALUE(value, 56)); } -static void job_pack_devfees(YAAMP_COIND *coind, char *data, json_int_t amount, char *addr) +static void p2sh_pack_tx(YAAMP_COIND *coind, char *data, json_int_t amount, char *payee) { char evalue[32]; + char coinb2_part[256]; + char coinb2_len[4]; + sprintf(coinb2_part, "a9%02x%s87", (unsigned int)(strlen(payee) >> 1) & 0xFF, payee); + sprintf(coinb2_len, "%02x", (unsigned int)(strlen(coinb2_part) >> 1) & 0xFF); encode_tx_value(evalue, amount); - sprintf(data+strlen(data), "%s", evalue); - // "asm": "OP_HASH160 f5916158e3e2c4551c1796708db8367207ed13bb OP_EQUAL", - // "hex": "a914f5916158e3e2c4551c1796708db8367207ed13bb87", - sprintf(data+strlen(data), "a914%s87", addr); -} - -static void job_pack_vote(YAAMP_COIND *coind, char *data, char *blockhash) -{ - // OP_RETURN validSSGenReferenceOutPrefix - // 32 byte block header hash for the block + uint32 for the height of the block - char evalue[32]; - char eheight[8]; - char hash[65] = "000000000000000000000000000000000000000000000000df910622e44ef4b2"; - uint32_t height = coind->height; - sprintf(eheight, "%02x%02x%02x%02x", TX_VALUE(height, 0), TX_VALUE(height, 8), TX_VALUE(height, 16), TX_VALUE(height, 24)); - encode_tx_value(evalue, 0); - sprintf(data+strlen(data), "6a24%s%sdea1906f%s", eheight, blockhash ? blockhash : hash, evalue); + strcat(data, evalue); + strcat(data, coinb2_len); + strcat(data, coinb2_part); } static void job_pack_tx(YAAMP_COIND *coind, char *data, json_int_t amount, char *key) { int ol = strlen(data); char evalue[32]; - encode_tx_value(evalue, amount); + if(coind->p2sh_address && !key) { + p2sh_pack_tx(coind, data, amount, coind->script_pubkey); + return; + } + + encode_tx_value(evalue, amount); sprintf(data+strlen(data), "%s", evalue); if(coind->pos && !key) @@ -89,6 +84,7 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * { char eheight[32], etime[32]; char entime[32] = { 0 }; + char commitment[128] = { 0 }; ser_number(templ->height, eheight); ser_number(time(NULL), etime); @@ -101,25 +97,21 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * char script1[4*1024]; sprintf(script1, "%s%s%s08", eheight, templ->flags, etime); - if (strcmp(coind->symbol, "DCR") == 0) { - sprintf(templ->coinb1, "%s01" - "0000000000000000000000000000000000000000000000000000000000000000" - "ffffffff00ffffffff", eversion1); - strcpy(templ->coinb2, ""); - } else { + char script2[32] = "7969696d7000"; // "yiimp\0" in hex ascii - char script2[32] = "7969696d7000"; // "yiimp\0" in hex ascii + if(!coind->pos && !coind->isaux && templ->auxs_size) + coinbase_aux(templ, script2); - if(!coind->pos && !coind->isaux && templ->auxs_size) - coinbase_aux(templ, script2); + int script_len = strlen(script1)/2 + strlen(script2)/2 + 8; + sprintf(templ->coinb1, "%s%s01" + "0000000000000000000000000000000000000000000000000000000000000000" + "ffffffff%02x%s", eversion1, entime, script_len, script1); - int script_len = strlen(script1)/2 + strlen(script2)/2 + 8; - sprintf(templ->coinb1, "%s%s01" - "0000000000000000000000000000000000000000000000000000000000000000" - "ffffffff%02x%s", eversion1, entime, script_len, script1); + sprintf(templ->coinb2, "%s00000000", script2); - sprintf(templ->coinb2, "%s00000000", script2); - } + // segwit commitment, if needed + if (templ->has_segwit_txs) + sprintf(commitment, "0000000000000000%02x%s", (int) (strlen(coind->commitment)/2), coind->commitment); json_int_t available = templ->value; @@ -130,12 +122,102 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * if (strlen(coind->charity_address) == 0) sprintf(coind->charity_address, "EdFwYw4Mo2Zq6CFM2yNJgXvE2DTJxgdBRX"); } + else if(strcmp(coind->symbol, "DYN") == 0) + { + char script_dests[2048] = { 0 }; + char script_payee[128] = { 0 }; + char payees[3]; + int npayees = (templ->has_segwit_txs) ? 2 : 1; + bool dynode_enabled; + dynode_enabled = json_get_bool(json_result, "dynode_payments_enforced"); + bool superblocks_enabled = json_get_bool(json_result, "superblocks_enabled"); + json_value* superblock = json_get_array(json_result, "superblock"); + json_value* dynode; + dynode = json_get_object(json_result, "dynode"); + if(!dynode && json_get_bool(json_result, "dynode_payments")) { + coind->oldmasternodes = true; + debuglog("%s is using old dynodes rpc keys\n", coind->symbol); + return; + } + + if(superblocks_enabled && superblock) { + for(int i = 0; i < superblock->u.array.length; i++) { + const char *payee = json_get_string(superblock->u.array.values[i], "payee"); + json_int_t amount = json_get_int(superblock->u.array.values[i], "amount"); + if (payee && amount) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, script_dests, amount, script_payee); + //debuglog("%s superblock found %s %u\n", coind->symbol, payee, amount); + } + } + } + if (dynode_enabled && dynode) { + bool started; + started = json_get_bool(json_result, "dynode_payments_started"); + const char *payee = json_get_string(dynode, "payee"); + json_int_t amount = json_get_int(dynode, "amount"); + if (!payee) + debuglog("coinbase_create failed to get Dynode payee\n"); + + if (!amount) + debuglog("coinbase_create failed to get Dynode amount\n"); + + if (!started) + debuglog("coinbase_create failed to get Dynode started\n"); + + if (payee && amount && started) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, script_dests, amount, script_payee); + //debuglog("%s dynode found %s %u\n", coind->symbol, payee, amount); + } + } + sprintf(payees, "%02x", npayees); + strcat(templ->coinb2, payees); + if (templ->has_segwit_txs) strcat(templ->coinb2, commitment); + strcat(templ->coinb2, script_dests); + job_pack_tx(coind, templ->coinb2, available, NULL); + strcat(templ->coinb2, "00000000"); // locktime + coind->reward = (double)available/100000000*coind->reward_mul; + //debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests); + return; + } else if(strcmp(coind->symbol, "LTCR") == 0) { if (coind->charity_percent <= 0) coind->charity_percent = 10; if (strlen(coind->charity_address) == 0) sprintf(coind->charity_address, "BCDrF1hWdKTmrjXXVFTezPjKBmGigmaXg5"); } + else if(strcmp(coind->symbol, "XZC") == 0) { + char script_payee[1024]; + if (coind->charity_percent <= 0) + coind->charity_percent = 25; // wrong coinbase 40 instead of 40 + 10 = 50 + + json_int_t charity_amount = (available * coind->charity_percent) / 100; + + if (strlen(coind->charity_address) == 0) + sprintf(coind->charity_address, "aHu897ivzmeFuLNB6956X6gyGeVNHUBRgD"); + + strcat(templ->coinb2, "06"); + job_pack_tx(coind, templ->coinb2, available, NULL); + base58_decode("aCAgTPgtYcA4EysU4UKC86EQd5cTtHtCcr", script_payee); + job_pack_tx(coind, templ->coinb2, charity_amount/5, script_payee); + base58_decode(coind->charity_address, script_payee); // may change + job_pack_tx(coind, templ->coinb2, charity_amount/5, script_payee); + base58_decode("aQ18FBVFtnueucZKeVg4srhmzbpAeb1KoN", script_payee); + job_pack_tx(coind, templ->coinb2, charity_amount/5, script_payee); + base58_decode("a1HwTdCmQV3NspP2QqCGpehoFpi8NY4Zg3", script_payee); + job_pack_tx(coind, templ->coinb2, charity_amount/5, script_payee); + base58_decode("a1kCCGddf5pMXSipLVD9hBG2MGGVNaJ15U", script_payee); + job_pack_tx(coind, templ->coinb2, charity_amount/5, script_payee); + strcat(templ->coinb2, "00000000"); // locktime + + coind->reward = (double)available/100000000*coind->reward_mul; + return; + } else if(strcmp("DCR", coind->rpcencoding) == 0) { coind->reward_mul = 6; // coinbase value is wrong, reward_mul should be 6 coind->charity_percent = 0; @@ -144,9 +226,68 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * if (strlen(coind->charity_address) == 0 && !strcmp(coind->symbol, "DCR")) sprintf(coind->charity_address, "Dcur2mcGjmENx4DhNqDctW5wJCVyT3Qeqkx"); } + else if(strcmp(coind->symbol, "STAK") == 0) { + char script_payee[512] = { 0 }; + char payees[4]; + int npayees = (templ->has_segwit_txs) ? 2 : 1; + bool masternode_payments = json_get_bool(json_result, "masternode_payments"); + bool masternodes_enabled = json_get_bool(json_result, "enforce_masternode_payments"); + + if (masternodes_enabled && masternode_payments) { + const char *payee = json_get_string(json_result, "payee"); + json_int_t amount = json_get_int(json_result, "payee_amount"); + if (payee && amount) + ++npayees; + } + + //treasury 5% @ 10 STAK per block + json_int_t charity_amount = 50000000; + //testnet + //sprintf(coind->charity_address, "93ASJtDuVYVdKXemH9BrtSMscznvsp9stD"); + switch (templ->height % 4) { + case 0: sprintf(coind->charity_address, "3K3bPrW5h7DYEMp2RcXawTCXajcm4ZU9Zh"); + break; + case 1: sprintf(coind->charity_address, "33Ssxmn3ehVMgyxgegXhpLGSBpubPjLZQ6"); + break; + case 2: sprintf(coind->charity_address, "3HFPNAjesiBY5sSVUmuBFnMEGut69R49ca"); + break; + case 3: sprintf(coind->charity_address, "37jLjjfUXQU4bdqVzvpUXyzAqPQSmxyByi"); + break; + } + ++npayees; + available -= charity_amount; + base58_decode(coind->charity_address, script_payee); + sprintf(payees, "%02x", npayees); + strcat(templ->coinb2, payees); + if (templ->has_segwit_txs) strcat(templ->coinb2, commitment); + char echarity_amount[32]; + encode_tx_value(echarity_amount, charity_amount); + strcat(templ->coinb2, echarity_amount); + char coinb2_part[1024] = { 0 }; + char coinb2_len[3] = { 0 }; + sprintf(coinb2_part, "a9%02x%s87", (unsigned int)(strlen(script_payee) >> 1) & 0xFF, script_payee); + sprintf(coinb2_len, "%02x", (unsigned int)(strlen(coinb2_part) >> 1) & 0xFF); + strcat(templ->coinb2, coinb2_len); + strcat(templ->coinb2, coinb2_part); + if (masternodes_enabled && masternode_payments) { + //duplicated: revisit ++todo + const char *payee = json_get_string(json_result, "payee"); + json_int_t amount = json_get_int(json_result, "payee_amount"); + if (payee && amount) { + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, templ->coinb2, amount, script_payee); + } + } + job_pack_tx(coind, templ->coinb2, available, NULL); + strcat(templ->coinb2, "00000000"); // locktime + + coind->reward = (double)available / 100000000 * coind->reward_mul; + return; + } // 2 txs are required on these coins, one for foundation (dev fees) - if(coind->charity_percent) + if(coind->charity_percent && !coind->hasmasternodes) { char script_payee[1024]; char charity_payee[256] = { 0 }; @@ -158,37 +299,32 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * base58_decode(charity_payee, script_payee); - json_int_t charity_amount = (available * coind->charity_percent) / 100; + json_int_t charity_amount = json_get_int(json_result, "payee_amount"); + if (charity_amount <= 0) + charity_amount = (available * coind->charity_percent) / 100; + available -= charity_amount; coind->charity_amount = charity_amount; - strcat(templ->coinb2, "02"); + if (templ->has_segwit_txs) { + strcat(templ->coinb2, "03"); // 3 outputs (nulldata + fees + miner) + strcat(templ->coinb2, commitment); + } else { + strcat(templ->coinb2, "02"); + } job_pack_tx(coind, templ->coinb2, available, NULL); job_pack_tx(coind, templ->coinb2, charity_amount, script_payee); strcat(templ->coinb2, "00000000"); // locktime coind->reward = (double)available/100000000*coind->reward_mul; + //debuglog("INFO %s block available %f, charity %f miner %f\n", coind->symbol, + // (double) available/1e8, (double) charity_amount/1e8, coind->reward); return; } else if(coind->charity_amount && !strcmp("DCR", coind->rpcencoding)) { - char script_payee[1024]; - char charity_payee[256] = { 0 }; - const char *payee = json_get_string(json_result, "payee"); - if (payee) snprintf(charity_payee, 255, "%s", payee); - else sprintf(charity_payee, "%s", coind->charity_address); - if (strlen(charity_payee) == 0) - stratumlog("ERROR %s has no charity_address set!\n", coind->name); - - base58_decode(charity_payee, script_payee); - - strcat(templ->coinb2, "03"); - job_pack_devfees(coind, templ->coinb2, coind->charity_amount, script_payee); - job_pack_vote(coind, templ->coinb2, templ->prevhash_hex); - job_pack_tx(coind, templ->coinb2, available, NULL); - strcat(templ->coinb2, "00000000"); // locktime - + stratumlog("ERROR %s should not use coinbase (getwork only)!\n", coind->symbol); coind->reward = (double)available/100000000; return; } @@ -222,7 +358,174 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * } } - if(coind->hasmasternodes) /* DASH style */ + // most recent masternodes rpc (DASH, SIB, MUE, DSR, GBX...) + if(coind->hasmasternodes && !coind->oldmasternodes) + { + char script_dests[2048] = { 0 }; + char script_payee[128] = { 0 }; + char payees[4]; // addresses count + int npayees = (templ->has_segwit_txs) ? 2 : 1; + bool masternode_enabled = json_get_bool(json_result, "masternode_payments_enforced"); + bool superblocks_enabled = json_get_bool(json_result, "superblocks_enabled"); + json_value* superblock = json_get_array(json_result, "superblock"); + json_value* masternode = json_get_object(json_result, "masternode"); + if(!masternode && json_get_bool(json_result, "masternode_payments")) { + coind->oldmasternodes = true; + debuglog("%s is using old masternodes rpc keys\n", coind->symbol); + return; + } + if(coind->charity_percent) { + char charity_payee[256] = { 0 }; + const char *payee = json_get_string(json_result, "payee"); + if (payee) snprintf(charity_payee, 255, "%s", payee); + else sprintf(charity_payee, "%s", coind->charity_address); + if (strlen(charity_payee) == 0) + stratumlog("ERROR %s has no charity_address set!\n", coind->name); + json_int_t charity_amount = (available * coind->charity_percent) / 100; + npayees++; + available -= charity_amount; + coind->charity_amount = charity_amount; + base58_decode(charity_payee, script_payee); + job_pack_tx(coind, script_dests, charity_amount, script_payee); + } + // smart contracts balance refund, same format as DASH superblocks + json_value* screfund = json_get_array(json_result, "screfund"); + if(screfund && screfund->u.array.length) { + superblocks_enabled = true; + superblock = screfund; + } + if(superblocks_enabled && superblock) { + for(int i = 0; i < superblock->u.array.length; i++) { + const char *payee = json_get_string(superblock->u.array.values[i], "payee"); + json_int_t amount = json_get_int(superblock->u.array.values[i], "amount"); + if (payee && amount) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + bool superblock_use_p2sh = (strcmp(coind->symbol, "MAC") == 0); + if(superblock_use_p2sh) + p2sh_pack_tx(coind, script_dests, amount, script_payee); + else + job_pack_tx(coind, script_dests, amount, script_payee); + //debuglog("%s superblock %s %u\n", coind->symbol, payee, amount); + } + } + } + if (masternode_enabled && masternode) { + bool started = json_get_bool(json_result, "masternode_payments_started"); + const char *payee = json_get_string(masternode, "payee"); + json_int_t amount = json_get_int(masternode, "amount"); + if (payee && amount && started) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + bool masternode_use_p2sh = (strcmp(coind->symbol, "MAC") == 0); + if(masternode_use_p2sh) + p2sh_pack_tx(coind, script_dests, amount, script_payee); + else + job_pack_tx(coind, script_dests, amount, script_payee); + } + } + sprintf(payees, "%02x", npayees); + strcat(templ->coinb2, payees); + if (templ->has_segwit_txs) strcat(templ->coinb2, commitment); + strcat(templ->coinb2, script_dests); + job_pack_tx(coind, templ->coinb2, available, NULL); + strcat(templ->coinb2, "00000000"); // locktime + coind->reward = (double)available/100000000*coind->reward_mul; + //debuglog("%s total %u available %u\n", coind->symbol, templ->value, available); + //debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests); + return; + } + + else if(strcmp(coind->symbol, "ARC") == 0) + { + char script_dests[2048] = { 0 }; + char script_payee[128] = { 0 }; + char payees[4]; + int npayees = 1; + bool masternode_enabled = json_get_bool(json_result, "goldminenode_payments_enforced"); + bool superblocks_enabled = json_get_bool(json_result, "superblocks_enabled"); + json_value* superblock = json_get_array(json_result, "superblock"); + json_value* masternode = json_get_object(json_result, "goldminenode"); + if(superblocks_enabled && superblock) { + for(int i = 0; i < superblock->u.array.length; i++) { + const char *payee = json_get_string(superblock->u.array.values[i], "payee"); + json_int_t amount = json_get_int(superblock->u.array.values[i], "amount"); + if (payee && amount) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, script_dests, amount, script_payee); + //debuglog("%s superblock %s %u\n", coind->symbol, payee, amount); + } + } + } + if (masternode_enabled && masternode) { + const char *payee = json_get_string(masternode, "payee"); + json_int_t amount = json_get_int(masternode, "amount"); + if (payee && amount) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, script_dests, amount, script_payee); + } + } + sprintf(payees, "%02x", npayees); + strcat(templ->coinb2, payees); + strcat(templ->coinb2, script_dests); + job_pack_tx(coind, templ->coinb2, available, NULL); + strcat(templ->coinb2, "00000000"); // locktime + coind->reward = (double)available/100000000*coind->reward_mul; + //debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests); + return; + } + + else if(strcmp(coind->symbol, "ENT") == 0) + { + char script_dests[2048] = { 0 }; + char script_payee[128] = { 0 }; + char payees[4]; + int npayees = 1; + bool masternode_enabled = json_get_bool(json_result, "eternitynode_payments_enforced"); + bool superblocks_enabled = json_get_bool(json_result, "superblocks_enabled"); + json_value* superblock = json_get_array(json_result, "superblock"); + json_value* masternode = json_get_object(json_result, "eternitynode"); + if(superblocks_enabled && superblock) { + for(int i = 0; i < superblock->u.array.length; i++) { + const char *payee = json_get_string(superblock->u.array.values[i], "payee"); + json_int_t amount = json_get_int(superblock->u.array.values[i], "amount"); + if (payee && amount) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, script_dests, amount, script_payee); + //debuglog("%s superblock %s %u\n", coind->symbol, payee, amount); + } + } + } + if (masternode_enabled && masternode) { + const char *payee = json_get_string(masternode, "payee"); + json_int_t amount = json_get_int(masternode, "amount"); + if (payee && amount) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, script_dests, amount, script_payee); + } + } + sprintf(payees, "%02x", npayees); + strcat(templ->coinb2, payees); + strcat(templ->coinb2, script_dests); + job_pack_tx(coind, templ->coinb2, available, NULL); + strcat(templ->coinb2, "00000000"); // locktime + coind->reward = (double)available/100000000*coind->reward_mul; + //debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests); + return; + } + + + else if(coind->hasmasternodes && coind->oldmasternodes) /* OLD DASH style */ { char charity_payee[256] = { 0 }; const char *payee = json_get_string(json_result, "payee"); @@ -232,29 +535,81 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * bool charity_payments = json_get_bool(json_result, "masternode_payments"); bool charity_enforce = json_get_bool(json_result, "enforce_masternode_payments"); - if(charity_payments && charity_enforce) + if(strcmp(coind->symbol, "CRW") == 0) { - available -= charity_amount; + char script_dests[2048] = { 0 }; + char script_payee[128] = { 0 }; + char payees[4]; + int npayees = 1; + bool masternodes_enabled = json_get_bool(json_result, "enforce_masternode_payments"); + bool systemnodes_enabled = json_get_bool(json_result, "enforce_systemnode_payments"); + bool systemnodes = json_get_bool(json_result, "systemnodes"); + bool masternodes = json_get_bool(json_result, "masternodes"); + if(systemnodes_enabled && systemnodes) { + const char *payeeSN = json_get_string(json_result, "payeeSN"); + json_int_t payeeSN_amount = json_get_int(json_result, "payeeSN_amount"); + if (payeeSN && payeeSN_amount) { + npayees++; + available -= payeeSN_amount; + base58_decode(payeeSN, script_payee); + job_pack_tx(coind, script_dests, payeeSN_amount, script_payee); + //debuglog("%s systemnode %s %u\n", coind->symbol, payeeSN, payeeSN_amount); + } + } + if (masternodes_enabled && masternodes) { + const char *payee = json_get_string(json_result, "payee"); + json_int_t amount = json_get_int(json_result, "amount"); + if (payee && amount) { + npayees++; + available -= amount; + base58_decode(payee, script_payee); + job_pack_tx(coind, script_dests, amount, script_payee); + } + } + sprintf(payees, "%02x", npayees); + strcat(templ->coinb2, payees); + strcat(templ->coinb2, script_dests); + job_pack_tx(coind, templ->coinb2, available, NULL); + strcat(templ->coinb2, "00000000"); // locktime + coind->reward = (double)available/100000000*coind->reward_mul; + //debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests); + return; + } - char script_payee[1024]; + if(charity_payments && charity_enforce) + { + char script_payee[256] = { 0 }; base58_decode(charity_payee, script_payee); - strcat(templ->coinb2, "02"); + if (templ->has_segwit_txs) { + strcat(templ->coinb2, "03"); // 3 outputs (nulldata + node + miner) + strcat(templ->coinb2, commitment); + } else { + strcat(templ->coinb2, "02"); // 2 outputs + } + job_pack_tx(coind, templ->coinb2, charity_amount, script_payee); - } - else + available -= charity_amount; + + } else { strcat(templ->coinb2, "01"); + } } - else + else if (templ->has_segwit_txs) { + strcat(templ->coinb2, "02"); + strcat(templ->coinb2, commitment); + } else { strcat(templ->coinb2, "01"); + } job_pack_tx(coind, templ->coinb2, available, NULL); - strcat(templ->coinb2, "00000000"); // locktime //if(coind->txmessage) // strcat(templ->coinb2, "00"); + strcat(templ->coinb2, "00000000"); // locktime + coind->reward = (double)available/100000000*coind->reward_mul; // debuglog("coinbase %f\n", coind->reward); diff --git a/stratum/coind.cpp b/stratum/coind.cpp index e6c8fa4eb..1eb83a30f 100644 --- a/stratum/coind.cpp +++ b/stratum/coind.cpp @@ -98,7 +98,7 @@ bool coind_validate_user_address(YAAMP_COIND *coind, char* const address) } bool isvalid = json_get_bool(json_result, "isvalid"); - if(!isvalid) stratumlog("%s user address %s is not valid.\n", coind->name, address); + if(!isvalid) stratumlog("%s: %s user address %s is not valid.\n", g_stratum_algo, coind->symbol, address); json_value_free(json); @@ -114,7 +114,12 @@ bool coind_validate_address(YAAMP_COIND *coind) char params[YAAMP_SMALLBUFSIZE]; sprintf(params, "[\"%s\"]", coind->wallet); - json_value *json = rpc_call(&coind->rpc, "validateaddress", params); + json_value *json; + bool getaddressinfo = ((strcmp(coind->symbol,"DGB") == 0) || (strcmp(coind->symbol2, "DGB") == 0)); + if(getaddressinfo) + json = rpc_call(&coind->rpc, "getaddressinfo", params); + else + json = rpc_call(&coind->rpc, "validateaddress", params); if(!json) return false; json_value *json_result = json_get_object(json, "result"); @@ -124,11 +129,12 @@ bool coind_validate_address(YAAMP_COIND *coind) return false; } - bool isvalid = json_get_bool(json_result, "isvalid"); + bool isvalid = getaddressinfo || json_get_bool(json_result, "isvalid"); if(!isvalid) stratumlog("%s wallet %s is not valid.\n", coind->name, coind->wallet); bool ismine = json_get_bool(json_result, "ismine"); if(!ismine) stratumlog("%s wallet %s is not mine.\n", coind->name, coind->wallet); + else isvalid = ismine; const char *p = json_get_string(json_result, "pubkey"); strcpy(coind->pubkey, p ? p : ""); @@ -136,8 +142,23 @@ bool coind_validate_address(YAAMP_COIND *coind) const char *acc = json_get_string(json_result, "account"); if (acc) strcpy(coind->account, acc); + if (!base58_decode(coind->wallet, coind->script_pubkey)) + stratumlog("Warning: unable to decode %s %s script pubkey\n", coind->symbol, coind->wallet); + + coind->p2sh_address = json_get_bool(json_result, "isscript"); + + // if base58 decode fails + if (!strlen(coind->script_pubkey)) { + const char *pk = json_get_string(json_result, "scriptPubKey"); + if (pk && strlen(pk) > 10) { + strcpy(coind->script_pubkey, &pk[6]); + coind->script_pubkey[strlen(pk)-6-4] = '\0'; + stratumlog("%s %s extracted script pubkey is %s\n", coind->symbol, coind->wallet, coind->script_pubkey); + } else { + stratumlog("%s wallet addr '%s' seems incorrect!'", coind->symbol, coind->wallet); + } + } json_value_free(json); - base58_decode(coind->wallet, coind->script_pubkey); return isvalid && ismine; } @@ -152,7 +173,6 @@ void coind_init(YAAMP_COIND *coind) strcpy(account, coind->account); if(!strcmp(coind->rpcencoding, "DCR")) { coind->usegetwork = true; - //coind->noblocknotify = true; //sprintf(account, "default"); } @@ -234,8 +254,6 @@ void coind_terminate(YAAMP_COIND *coind) // CommonLock(&coind->mutex); // while(!coind->deleted) // { -// debuglog("calling coind_getinfo %s\n", coind->symbol); - // job_create_last(coind, true); // pthread_cond_wait(&coind->cond, &coind->mutex); // } diff --git a/stratum/coind.h b/stratum/coind.h index 166a0aa66..f58f091b7 100644 --- a/stratum/coind.h +++ b/stratum/coind.h @@ -35,6 +35,7 @@ class YAAMP_COIND: public YAAMP_OBJECT char pubkey[1024]; char script_pubkey[1024]; + bool p2sh_address; bool pos; bool hassubmitblock; @@ -47,6 +48,7 @@ class YAAMP_COIND: public YAAMP_OBJECT bool enable; bool auto_ready; bool newblock; + char lastnotifyhash[192]; int height; double difficulty; @@ -65,9 +67,13 @@ class YAAMP_COIND: public YAAMP_OBJECT bool usegetwork; bool usememorypool; bool hasmasternodes; - bool noblocknotify; + bool oldmasternodes; bool multialgos; // pow_hash field (or mined_hash) + bool usesegwit; + char commitment[128]; + char witness_magic[16]; + YAAMP_JOB *job; // YAAMP_JOB_TEMPLATE *templ; }; diff --git a/stratum/coind_template.cpp b/stratum/coind_template.cpp index ec2139c00..33ecc6259 100644 --- a/stratum/coind_template.cpp +++ b/stratum/coind_template.cpp @@ -68,17 +68,17 @@ YAAMP_JOB_TEMPLATE *coind_create_template_memorypool(YAAMP_COIND *coind) json_value_free(json); - json = rpc_call(&coind->rpc, "getinfo", "[]"); + json = rpc_call(&coind->rpc, "getmininginfo", "[]"); if(!json || json->type == json_null) { - coind_error(coind, "coind_getinfo"); + coind_error(coind, "coind getmininginfo"); return NULL; } json_result = json_get_object(json, "result"); if(!json_result || json_result->type == json_null) { - coind_error(coind, "coind_getinfo"); + coind_error(coind, "coind getmininginfo"); json_value_free(json); return NULL; @@ -114,7 +114,8 @@ static int decred_parse_header(YAAMP_JOB_TEMPLATE *templ, const char *header_hex uint32_t size; uint32_t ntime; uint32_t nonce; - unsigned char extra[36]; + unsigned char extra[32]; + uint32_t stakever; uint32_t hashtag[3]; } header; @@ -195,7 +196,8 @@ static YAAMP_JOB_TEMPLATE *decred_create_worktemplate(YAAMP_COIND *coind) // bypass coinbase and merkle for now... send without nonce/extradata const unsigned char *hdr = (unsigned char *) &templ->header[36]; hexlify(templ->coinb1, hdr, 192 - 80); - strcpy(templ->coinb2, ""); + const unsigned char *sfx = (unsigned char *) &templ->header[176]; + hexlify(templ->coinb2, sfx, 180 - 176); // stake version vector txhashes; txhashes.push_back(""); @@ -231,8 +233,9 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind) if(coind->usememorypool) return coind_create_template_memorypool(coind); - char params[4*1024] = "[{}]"; + char params[512] = "[{}]"; if(!strcmp(coind->symbol, "PPC")) strcpy(params, "[]"); + else if(g_stratum_segwit) strcpy(params, "[{\"rules\":[\"segwit\"]}]"); json_value *json = rpc_call(&coind->rpc, "getblocktemplate", params); if(!json || json_is_null(json)) @@ -253,6 +256,26 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind) return NULL; } + // segwit rule + json_value *json_rules = json_get_array(json_result, "rules"); + if(json_rules && !strlen(coind->witness_magic) && json_rules->u.array.length) { + for (int i=0; iu.array.length; i++) { + json_value *val = json_rules->u.array.values[i]; + if(!strcmp(val->u.string.ptr, "segwit")) { + const char *commitment = json_get_string(json_result, "default_witness_commitment"); + strcpy(coind->witness_magic, "aa21a9ed"); + if (commitment && strlen(commitment) > 12) { + strncpy(coind->witness_magic, &commitment[4], 8); + coind->witness_magic[8] = '\0'; + } + coind->usesegwit |= g_stratum_segwit; + if (coind->usesegwit) + debuglog("%s segwit enabled, magic %s\n", coind->symbol, coind->witness_magic); + break; + } + } + } + json_value *json_tx = json_get_array(json_result, "transactions"); if(!json_tx) { @@ -310,6 +333,18 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind) } } + const char *sc_root = json_get_string(json_result, "stateroot"); + const char *sc_utxo = json_get_string(json_result, "utxoroot"); + if (sc_root && sc_utxo) { + // LUX Smart Contracts, 144-bytes block headers + strcpy(&templ->extradata_hex[ 0], sc_root); // 32-bytes hash (64 in hexa) + strcpy(&templ->extradata_hex[64], sc_utxo); // 32-bytes hash too + + // same weird byte order as previousblockhash field + ser_string_be2(sc_root, &templ->extradata_be[ 0], 8); + ser_string_be2(sc_utxo, &templ->extradata_be[64], 8); + } + if (strcmp(coind->rpcencoding, "DCR") == 0) { decred_fix_template(coind, templ, json_result); } @@ -353,26 +388,96 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind) ////////////////////////////////////////////////////////////////////////////////////////// vector txhashes; + vector txids; txhashes.push_back(""); + txids.push_back(""); + + templ->has_segwit_txs = false; + + templ->has_filtered_txs = false; + templ->filtered_txs_fee = 0; for(int i = 0; i < json_tx->u.array.length; i++) { const char *p = json_get_string(json_tx->u.array.values[i], "hash"); + char hash_be[256] = { 0 }; - char hash_be[1024]; - memset(hash_be, 0, 1024); - string_be(p, hash_be); + if (templ->has_filtered_txs) { + templ->filtered_txs_fee += json_get_int(json_tx->u.array.values[i], "fee"); + continue; + } + string_be(p, hash_be); txhashes.push_back(hash_be); + const char *txid = json_get_string(json_tx->u.array.values[i], "txid"); + if(txid && strlen(txid)) { + char txid_be[256] = { 0 }; + string_be(txid, txid_be); + txids.push_back(txid_be); + if (strcmp(hash_be, txid_be)) { + templ->has_segwit_txs = true; // if not, its useless to generate a segwit block, bigger + } + } else { + templ->has_segwit_txs = false; // force disable if not supported (no txid fields) + } + const char *d = json_get_string(json_tx->u.array.values[i], "data"); templ->txdata.push_back(d); + + // if wanted, we can limit the count of txs to include + if (g_limit_txs_per_block && i >= g_limit_txs_per_block-2) { + debuglog("limiting block to %d first txs (of %d)\n", g_limit_txs_per_block, json_tx->u.array.length); + templ->has_filtered_txs = true; + } + } + + if (templ->has_filtered_txs) { + // coinbasevalue is a total with all tx fees, need to reduce it if some are skipped + templ->value -= templ->filtered_txs_fee; + } + + templ->txmerkles[0] = '\0'; + if(templ->has_segwit_txs) { + templ->txcount = txids.size(); + templ->txsteps = merkle_steps(txids); + } else { + templ->txcount = txhashes.size(); + templ->txsteps = merkle_steps(txhashes); + } + + if(templ->has_segwit_txs) { + // * We compute the witness hash (which is the hash including witnesses) of all the block's transactions, except the + // coinbase (where 0x0000....0000 is used instead). + // * The coinbase scriptWitness is a stack of a single 32-byte vector, containing a witness nonce (unconstrained). + // * We build a merkle tree with all those witness hashes as leaves (similar to the hashMerkleRoot in the block header). + // * There must be at least one output whose scriptPubKey is a single 36-byte push, the first 4 bytes (magic) of which are + // {0xaa, 0x21, 0xa9, 0xed}, and the following 32 bytes are SHA256^2(witness root, witness nonce). In case there are + /* + char bin[YAAMP_HASHLEN_BIN*2]; + char witness[128] = { 0 }; + vector mt_verify = merkle_steps(txhashes); + string witness_mt = merkle_with_first(mt_verify, "0000000000000000000000000000000000000000000000000000000000000000"); + mt_verify.clear(); + witness_mt = witness_mt + "0000000000000000000000000000000000000000000000000000000000000000"; + + binlify((unsigned char *)bin, witness_mt.c_str()); + sha256_double_hash_hex(bin, witness, YAAMP_HASHLEN_BIN*2); + + int clen = (int) (strlen(coind->witness_magic) + strlen(witness)); // 4 + 32 = 36 = 0x24 + sprintf(coind->commitment, "6a%02x%s%s", clen/2, coind->witness_magic, witness); + */ + // default commitment is already computed correctly + const char *commitment = json_get_string(json_result, "default_witness_commitment"); + if (commitment) { + sprintf(coind->commitment, "%s", commitment); + } else { + templ->has_segwit_txs = false; + } } - templ->txmerkles[0] = 0; - templ->txcount = txhashes.size(); - templ->txsteps = merkle_steps(txhashes); txhashes.clear(); + txids.clear(); vector::const_iterator i; for(i = templ->txsteps.begin(); i != templ->txsteps.end(); ++i) diff --git a/stratum/config.sample/a5a.conf b/stratum/config.sample/a5a.conf new file mode 100644 index 000000000..25bdc96d2 --- /dev/null +++ b/stratum/config.sample/a5a.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 8633 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = a5a +difficulty = 8 +max_ttf = 4000000 diff --git a/stratum/config.sample/aergo.conf b/stratum/config.sample/aergo.conf new file mode 100644 index 000000000..c7488e3a7 --- /dev/null +++ b/stratum/config.sample/aergo.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 3691 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = aergo +difficulty = 0.001 +max_ttf = 400000000 \ No newline at end of file diff --git a/stratum/config.sample/allium.conf b/stratum/config.sample/allium.conf new file mode 100644 index 000000000..1f8f1921a --- /dev/null +++ b/stratum/config.sample/allium.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 4443 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = allium +difficulty = 1 +max_ttf = 4000000 diff --git a/stratum/config.sample/argon2d-dyn.conf b/stratum/config.sample/argon2d-dyn.conf new file mode 100644 index 000000000..fc53112c0 --- /dev/null +++ b/stratum/config.sample/argon2d-dyn.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 4239 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = argon2d-dyn +difficulty = 2.0 +max_ttf = 400000000 \ No newline at end of file diff --git a/stratum/config.sample/bastion.conf b/stratum/config.sample/bastion.conf new file mode 100644 index 000000000..ed2b1dbcd --- /dev/null +++ b/stratum/config.sample/bastion.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 6433 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = bastion +difficulty = 0.02 +max_ttf = 4000000 + diff --git a/stratum/config.sample/bitcore.conf b/stratum/config.sample/bitcore.conf new file mode 100644 index 000000000..22b1fd792 --- /dev/null +++ b/stratum/config.sample/bitcore.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3556 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = bitcore +difficulty = 0.5 +max_ttf = 50000 + diff --git a/stratum/config.sample/blake2b.conf b/stratum/config.sample/blake2b.conf new file mode 100644 index 000000000..91a8e04ee --- /dev/null +++ b/stratum/config.sample/blake2b.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 5777 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = blake2b +difficulty = 0.25 +max_ttf = 4000000 + diff --git a/stratum/config.sample/decred.conf b/stratum/config.sample/decred.conf index 96c34f6fb..f397789c6 100644 --- a/stratum/config.sample/decred.conf +++ b/stratum/config.sample/decred.conf @@ -1,6 +1,6 @@ [TCP] server = yaamp.com -port = 5744 +port = 3252 password = tu8tu5 [SQL] @@ -11,6 +11,6 @@ password = patofpaq [STRATUM] algo = decred -difficulty = 0.5 +difficulty = 1 max_ttf = 1000000000 diff --git a/stratum/config.sample/deep.conf b/stratum/config.sample/deep.conf new file mode 100644 index 000000000..1cf1c8933 --- /dev/null +++ b/stratum/config.sample/deep.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3535 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = deep +difficulty = 0.0128 +max_ttf = 200000000000000 + diff --git a/stratum/config.sample/exosis.conf b/stratum/config.sample/exosis.conf new file mode 100644 index 000000000..3d54269b6 --- /dev/null +++ b/stratum/config.sample/exosis.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 3557 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = exosis +difficulty = 0.125 +max_ttf = 50000 diff --git a/stratum/config.sample/hmq1725.conf b/stratum/config.sample/hmq1725.conf new file mode 100644 index 000000000..08f348472 --- /dev/null +++ b/stratum/config.sample/hmq1725.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3747 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = hmq1725 +difficulty = 8 +max_ttf = 50000 + diff --git a/stratum/config.sample/hsr.conf b/stratum/config.sample/hsr.conf new file mode 100644 index 000000000..fbf35705a --- /dev/null +++ b/stratum/config.sample/hsr.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 7433 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = hsr +difficulty = 0.008 +max_ttf = 50000 + diff --git a/stratum/config.sample/jha.conf b/stratum/config.sample/jha.conf new file mode 100644 index 000000000..378b73ad7 --- /dev/null +++ b/stratum/config.sample/jha.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 4633 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = jha +difficulty = 128 +max_ttf = 400000 + diff --git a/stratum/config.sample/keccakc.conf b/stratum/config.sample/keccakc.conf new file mode 100644 index 000000000..0be446acc --- /dev/null +++ b/stratum/config.sample/keccakc.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 5134 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = keccakc +difficulty = 2 +max_ttf = 4000000 + diff --git a/stratum/config.sample/lbk3.conf b/stratum/config.sample/lbk3.conf new file mode 100644 index 000000000..4e82314b4 --- /dev/null +++ b/stratum/config.sample/lbk3.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 5522 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = lbk3 +difficulty = 8 +max_ttf = 40000 diff --git a/stratum/config.sample/lyra2z.conf b/stratum/config.sample/lyra2z.conf new file mode 100644 index 000000000..9faed939b --- /dev/null +++ b/stratum/config.sample/lyra2z.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 4553 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = lyra2z +difficulty = 1 +max_ttf = 40000 + diff --git a/stratum/config.sample/phi.conf b/stratum/config.sample/phi.conf new file mode 100644 index 000000000..79d0dd3de --- /dev/null +++ b/stratum/config.sample/phi.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 8333 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = phi +difficulty = 0.016 +max_ttf = 40000 + diff --git a/stratum/config.sample/phi2.conf b/stratum/config.sample/phi2.conf new file mode 100644 index 000000000..f96111283 --- /dev/null +++ b/stratum/config.sample/phi2.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 8332 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = phi2 +difficulty = 1 +max_ttf = 40000 + diff --git a/stratum/config.sample/polytimos.conf b/stratum/config.sample/polytimos.conf new file mode 100644 index 000000000..d64975c58 --- /dev/null +++ b/stratum/config.sample/polytimos.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 8463 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = polytimos +difficulty = 0.125 +max_ttf = 40000 + diff --git a/stratum/config.sample/rainforest.conf b/stratum/config.sample/rainforest.conf new file mode 100644 index 000000000..37455e7a7 --- /dev/null +++ b/stratum/config.sample/rainforest.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 7443 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = rainforest +difficulty = 1 +max_ttf = 400000000 diff --git a/stratum/config.sample/sha256t.conf b/stratum/config.sample/sha256t.conf new file mode 100644 index 000000000..f542ac0d1 --- /dev/null +++ b/stratum/config.sample/sha256t.conf @@ -0,0 +1,17 @@ +[TCP] +server = yaamp.com +port = 3339 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = sha256t +difficulty = 1 +max_ttf = 40000 +reconnect = 1 + diff --git a/stratum/config.sample/skein.conf b/stratum/config.sample/skein.conf index f4957e5e2..b6d7536e2 100644 --- a/stratum/config.sample/skein.conf +++ b/stratum/config.sample/skein.conf @@ -14,3 +14,11 @@ algo = skein difficulty = 0.1 max_ttf = 200000000000000 +[DEBUGLOG] +client = 0 +hash = 0 +socket = 0 +rpc = 0 +list = 0 +remote = 0 + diff --git a/stratum/config.sample/skunk.conf b/stratum/config.sample/skunk.conf new file mode 100644 index 000000000..0061f4f49 --- /dev/null +++ b/stratum/config.sample/skunk.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 8433 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = skunk +difficulty = 0.1 +max_ttf = 4000000 + diff --git a/stratum/config.sample/timetravel.conf b/stratum/config.sample/timetravel.conf new file mode 100644 index 000000000..3114dee95 --- /dev/null +++ b/stratum/config.sample/timetravel.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3555 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = timetravel +difficulty = 0.125 +max_ttf = 50000 + diff --git a/stratum/config.sample/tribus.conf b/stratum/config.sample/tribus.conf new file mode 100644 index 000000000..e5c3bc35c --- /dev/null +++ b/stratum/config.sample/tribus.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 8533 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = tribus +difficulty = 0.25 +max_ttf = 4000000 + diff --git a/stratum/config.sample/vitalium.conf b/stratum/config.sample/vitalium.conf new file mode 100644 index 000000000..ff522cbb1 --- /dev/null +++ b/stratum/config.sample/vitalium.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3233 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = vitalium +difficulty = 0.001 +max_ttf = 400000000 + diff --git a/stratum/config.sample/x12.conf b/stratum/config.sample/x12.conf new file mode 100644 index 000000000..6bce44ac8 --- /dev/null +++ b/stratum/config.sample/x12.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3233 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = x12 +difficulty = 0.008 +max_ttf = 50000 + diff --git a/stratum/config.sample/x16r.conf b/stratum/config.sample/x16r.conf new file mode 100644 index 000000000..a2329a823 --- /dev/null +++ b/stratum/config.sample/x16r.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3636 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = x16r +difficulty = 0.25 +max_ttf = 50000 + diff --git a/stratum/config.sample/x16s.conf b/stratum/config.sample/x16s.conf new file mode 100644 index 000000000..d71d25ec7 --- /dev/null +++ b/stratum/config.sample/x16s.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3663 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = x16s +difficulty = 0.25 +max_ttf = 50000 + diff --git a/stratum/config.sample/x22i.conf b/stratum/config.sample/x22i.conf new file mode 100644 index 000000000..156b2fbda --- /dev/null +++ b/stratum/config.sample/x22i.conf @@ -0,0 +1,16 @@ +[TCP] +server = yaamp.com +port = 3223 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = x22i +difficulty = 0.008 +max_ttf = 50000 + diff --git a/stratum/config.sample/yescryptR16.conf b/stratum/config.sample/yescryptR16.conf new file mode 100644 index 000000000..7c24aed5e --- /dev/null +++ b/stratum/config.sample/yescryptR16.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 6333 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = yescryptR16 +difficulty = 2 +max_ttf = 400000000 diff --git a/stratum/config.sample/yescryptR32.conf b/stratum/config.sample/yescryptR32.conf new file mode 100644 index 000000000..7494625ea --- /dev/null +++ b/stratum/config.sample/yescryptR32.conf @@ -0,0 +1,15 @@ +[TCP] +server = yaamp.com +port = 6343 +password = tu8tu5 + +[SQL] +host = yaampdb +database = yaamp +username = root +password = patofpaq + +[STRATUM] +algo = yescryptR32 +difficulty = 1 +max_ttf = 400000000 diff --git a/stratum/config/run.sh b/stratum/config/run.sh index be3fe2aaa..c0039f3d2 100755 --- a/stratum/config/run.sh +++ b/stratum/config/run.sh @@ -4,7 +4,7 @@ ulimit -n 10240 ulimit -u 10240 cd /var/stratum -while true; do +while [ -e config/${1}.conf ]; do gzip -f config/${1}.log ./stratum config/$1 sleep 1 diff --git a/stratum/db.cpp b/stratum/db.cpp index e3037b926..f8c513cd8 100644 --- a/stratum/db.cpp +++ b/stratum/db.cpp @@ -1,5 +1,6 @@ #include "stratum.h" +#include #include void db_reconnect(YAAMP_DB *db) @@ -12,7 +13,7 @@ void db_reconnect(YAAMP_DB *db) mysql_init(&db->mysql); for(int i=0; i<6; i++) { - MYSQL *p = mysql_real_connect(&db->mysql, g_sql_host, g_sql_username, g_sql_password, g_sql_database, 0, 0, 0); + MYSQL *p = mysql_real_connect(&db->mysql, g_sql_host, g_sql_username, g_sql_password, g_sql_database, g_sql_port, 0, 0); if(p) break; stratumlog("%d, %s\n", i, mysql_error(&db->mysql)); @@ -42,15 +43,31 @@ void db_close(YAAMP_DB *db) char *db_clean_string(YAAMP_DB *db, char *string) { - string[1000] = 0; - char tmp[1024]; - - unsigned long ret = mysql_real_escape_string(&db->mysql, tmp, string, strlen(string)); - strcpy(string, tmp); - + char *c = string; + size_t i, len = strlen(string) & 0x1FF; + for (i = 0; i < len; i++) { + bool isdigit = (c[i] >= '0' && c[i] <= '9'); + bool isalpha = (c[i] >= 'a' && c[i] <= 'z') || (c[i] >= 'A' && c[i] <= 'Z'); + bool issepch = (c[i] == '=' || c[i] == ',' || c[i] == ';' || c[i] == '.'); + bool isextra = (c[i] == '/' || c[i] == '-' || c[i] == '_'); + if (!isdigit && !isalpha && !issepch && !isextra) { c[i] = '\0'; break; } + } return string; } +// allow more chars without the most hurting ones (bench device names) +static void clean_html(char* string) +{ + char *c = string; + size_t i, len = strlen(string) & 0x1FF; + for (i = 0; i < len; i++) { + if (c[i] == '<' || c[i] == '>' || c[i] == '%' || c[i] == '\\' || c[i] == '"' || c[i] == '\'') { + c[i] = '\0'; break; + } + } + if (strstr(string, "script")) strcpy(string, ""); +} + void db_query(YAAMP_DB *db, const char *format, ...) { va_list arglist; @@ -70,6 +87,7 @@ void db_query(YAAMP_DB *db, const char *format, ...) res = mysql_errno(&db->mysql); stratumlog("SQL ERROR: %d, %s\n", res, mysql_error(&db->mysql)); + if(res == ER_DUP_ENTRY) break; // rarely seen on new user creation if(res != CR_SERVER_GONE_ERROR && res != CR_SERVER_LOST) exit(1); usleep(100*YAAMP_MS); @@ -87,12 +105,17 @@ void db_register_stratum(YAAMP_DB *db) int t = time(NULL); if(!db) return; - db_query(db, "insert into stratums (pid, time, algo) values (%d, %d, '%s') on duplicate key update time=%d", - pid, t, g_current_algo->name, t); + db_query(db, "INSERT INTO stratums (pid, time, started, algo, url, port) VALUES (%d,%d,%d,'%s','%s',%d) " + " ON DUPLICATE KEY UPDATE time=%d, algo='%s', url='%s', port=%d", + pid, t, t, g_stratum_algo, g_tcp_server, g_tcp_port, + t, g_stratum_algo, g_tcp_server, g_tcp_port + ); } void db_update_algos(YAAMP_DB *db) { + int pid = getpid(); + int fds = opened_files(); if(!db) return; if(g_current_algo->overflow) @@ -100,9 +123,21 @@ void db_update_algos(YAAMP_DB *db) debuglog("setting overflow\n"); g_current_algo->overflow = false; - db_query(db, "update algos set overflow=true where name='%s'", g_current_algo->name); + db_query(db, "UPDATE algos SET overflow=true WHERE name='%s'", g_stratum_algo); + } + + char symbol[16] = "NULL\0"; + if(g_list_coind.count == 1) { + if (g_list_coind.first) { + CLI li = g_list_coind.first; + YAAMP_COIND *coind = (YAAMP_COIND *)li->data; + sprintf(symbol,"'%s'", coind->symbol); + } } + db_query(db, "UPDATE stratums SET workers=%d, fds=%d, symbol=%s WHERE pid=%d", + g_list_client.count, fds, symbol, pid); + /////////////////////////////////////////////////////////////////////////////////////////// db_query(db, "select name, profit, rent, factor from algos"); @@ -158,7 +193,7 @@ void db_update_coinds(YAAMP_DB *db) db_query(db, "SELECT id, name, rpchost, rpcport, rpcuser, rpcpasswd, rpcencoding, master_wallet, reward, price, " "hassubmitblock, txmessage, enable, auto_ready, algo, pool_ttf, charity_address, charity_amount, charity_percent, " "reward_mul, symbol, auxpow, actual_ttf, network_ttf, usememorypool, hasmasternodes, algo, symbol2, " - "rpccurl, rpcssl, rpccert, account, multialgos " + "rpccurl, rpcssl, rpccert, account, multialgos, max_miners, max_shares, usesegwit " "FROM coins WHERE enable AND auto_ready AND algo='%s' ORDER BY index_avg", g_stratum_algo); MYSQL_RES *result = mysql_store_result(&db->mysql); @@ -184,6 +219,17 @@ void db_update_coinds(YAAMP_DB *db) coind->newcoind = false; strcpy(coind->name, row[1]); + strcpy(coind->symbol, row[20]); + // optional coin filters + if(coind->newcoind) { + bool ignore = false; + if (strlen(g_stratum_coin_include) && !strstr(g_stratum_coin_include, coind->symbol)) ignore = true; + if (strlen(g_stratum_coin_exclude) && strstr(g_stratum_coin_exclude, coind->symbol)) ignore = true; + if (ignore) { + object_delete(coind); + continue; + } + } if(row[7]) strcpy(coind->wallet, row[7]); if(row[6]) strcpy(coind->rpcencoding, row[6]); @@ -236,7 +282,6 @@ void db_update_coinds(YAAMP_DB *db) if(row[18]) coind->charity_percent = atof(row[18]); if(row[19]) coind->reward_mul = atof(row[19]); - strcpy(coind->symbol, row[20]); if(row[21]) coind->isaux = atoi(row[21]); if(row[22] && row[23]) coind->actual_ttf = min(atoi(row[22]), atoi(row[23])); @@ -256,11 +301,34 @@ void db_update_coinds(YAAMP_DB *db) if(row[31]) strcpy(coind->account, row[31]); if(row[32]) coind->multialgos = atoi(row[32]); + if(row[33] && atoi(row[33]) > 0) g_stratum_max_cons = atoi(row[33]); + if(row[34] && atol(row[34]) > 0) g_max_shares = atol(row[34]); + if(row[35]) coind->usesegwit = atoi(row[35]) > 0; + + if(coind->usesegwit) g_stratum_segwit = true; // force the right rpcencoding for DCR if(!strcmp(coind->symbol, "DCR") && strcmp(coind->rpcencoding, "DCR")) strcpy(coind->rpcencoding, "DCR"); + // old dash masternodes coins.. + if(coind->hasmasternodes) { + if (strcmp(coind->symbol, "ALQO") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "BSD") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "BWK") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "CHC") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "CRW") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "DNR") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "FLAX") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "ITZ") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "J") == 0 || strcmp(coind->symbol2, "J") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "MAG") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "PBS") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "URALS") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "VSX") == 0) coind->oldmasternodes = true; + if (strcmp(coind->symbol, "XLR") == 0) coind->oldmasternodes = true; + } + //////////////////////////////////////////////////////////////////////////////////////////////////// //coind->touch = true; @@ -477,9 +545,14 @@ static void _json_str_safe(YAAMP_DB *db, json_value *json, const char *key, size json_value *val = json_get_val(json, key); out[0] = '\0'; if (db && val && json_is_string(val)) { - strncpy(out, json_string_value(val), maxlen); + char str[128] = { 0 }; + char escaped[256] = { 0 }; + snprintf(str, sizeof(str)-1, "%s", json_string_value(val)); + str[maxlen-1] = '\0'; // truncate to dest len + clean_html(str); + mysql_real_escape_string(&db->mysql, escaped, str, strlen(str)); + snprintf(out, maxlen, "%s", escaped); out[maxlen-1] = '\0'; - db_clean_string(db, out); } } #define json_str_safe(stats, k, out) _json_str_safe(db, stats, k, sizeof(out), out) @@ -503,7 +576,7 @@ void db_store_stats(YAAMP_DB *db, YAAMP_CLIENT *client, json_value *stats) char sdev[80], stype[8], svid[12], sarch[8]; char salgo[32], sclient[48], sdriver[32], sos[8]; double khashes, intensity, throughput; - int power, mem, freq, memf; + int power, freq, memf, realfreq, realmemf, plimit; if (!db) return; @@ -522,17 +595,24 @@ void db_store_stats(YAAMP_DB *db, YAAMP_CLIENT *client, json_value *stats) json_str_safe(stats, "driver", sdriver); // or cpu compiler power = json_int_safe(stats, "power"); - mem = json_int_safe(stats, "mem"); freq = json_int_safe(stats, "freq"); memf = json_int_safe(stats, "memf"); + realfreq = json_int_safe(stats, "curr_freq"); + realmemf = json_int_safe(stats, "curr_memf"); + plimit = json_int_safe(stats, "plimit"); intensity = json_double_safe(stats, "intensity"); - throughput = json_double_safe(stats, "throughput"); khashes = json_double_safe(stats, "khashes"); + throughput = json_double_safe(stats, "throughput"); + if (throughput < 0.) throughput = 0.; + if (khashes < 0. || intensity < 0.) return; db_query(db, "INSERT INTO benchmarks(" "time, algo, type, device, arch, vendorid, os, driver," - "client, khps, freq, memf, power, mem, intensity, throughput, userid" - ") VALUES (%d,'%s','%s','%s','%s','%s','%s','%s', '%s',%f,%d,%d,%d,%d,%.2f,%.0f,%d)", + "client, khps, freq, memf, realfreq, realmemf, power, plimit, " + "intensity, throughput, userid )" + "VALUES (%d,'%s','%s','%s','%s','%s','%s','%s'," + "'%s',%f,%d,%d,%d,%d,%d,%d, %.2f,%.0f,%d)", t, g_current_algo->name, stype, sdev, sarch, svid, sos, sdriver, - sclient, khashes, freq, memf, power, mem, intensity, throughput, client->userid); + sclient, khashes, freq, memf, realfreq, realmemf, power, plimit, + intensity, throughput, client->userid); } diff --git a/stratum/job.h b/stratum/job.h index 00d97a206..aef4bdbe1 100644 --- a/stratum/job.h +++ b/stratum/job.h @@ -24,9 +24,13 @@ struct YAAMP_JOB_TEMPLATE int created; char flags[64]; - char prevhash_hex[1024]; - char prevhash_be[1024]; + char prevhash_hex[512]; + char prevhash_be[512]; + char extradata_hex[512]; + char extradata_be[512]; + + // todo: can use extra field char claim_hex[128]; char claim_be[128]; @@ -50,6 +54,11 @@ struct YAAMP_JOB_TEMPLATE char header[256]; + bool has_segwit_txs; + + bool has_filtered_txs; + int filtered_txs_fee; + int auxs_size; YAAMP_COIND_AUX *auxs[MAX_AUXS]; }; diff --git a/stratum/job_send.cpp b/stratum/job_send.cpp index 7ffd26ee0..5af3c7272 100644 --- a/stratum/job_send.cpp +++ b/stratum/job_send.cpp @@ -16,19 +16,27 @@ static void job_mining_notify_buffer(YAAMP_JOB *job, char *buffer) { YAAMP_JOB_TEMPLATE *templ = job->templ; - if (!strcmp(g_current_algo->name, "lbry")) { + if (!strcmp(g_stratum_algo, "lbry")) { sprintf(buffer, "{\"id\":null,\"method\":\"mining.notify\",\"params\":[" "\"%x\",\"%s\",\"%s\",\"%s\",\"%s\",[%s],\"%s\",\"%s\",\"%s\",true]}\n", job->id, templ->prevhash_be, templ->claim_be, templ->coinb1, templ->coinb2, templ->txmerkles, templ->version, templ->nbits, templ->ntime); return; + } else if (strlen(templ->extradata_hex) == 128) { + // LUX smart contract state hashes (like lbry extra field, here the 2 root hashes in one) + sprintf(buffer, "{\"id\":null,\"method\":\"mining.notify\",\"params\":[" + "\"%x\",\"%s\",\"%s\",\"%s\",\"%s\",[%s],\"%s\",\"%s\",\"%s\",true]}\n", + job->id, templ->prevhash_be, templ->extradata_be, templ->coinb1, templ->coinb2, + templ->txmerkles, templ->version, templ->nbits, templ->ntime); + return; } + // standard stratum sprintf(buffer, "{\"id\":null,\"method\":\"mining.notify\",\"params\":[\"%x\",\"%s\",\"%s\",\"%s\",[%s],\"%s\",\"%s\",\"%s\",true]}\n", job->id, templ->prevhash_be, templ->coinb1, templ->coinb2, templ->txmerkles, templ->version, templ->nbits, templ->ntime); } -static YAAMP_JOB *job_get_last() +static YAAMP_JOB *job_get_last(int coinid) { g_list_job.Enter(); for(CLI li = g_list_job.first; li; li = li->prev) @@ -36,6 +44,7 @@ static YAAMP_JOB *job_get_last() YAAMP_JOB *job = (YAAMP_JOB *)li->data; if(!job_can_mine(job)) continue; if(!job->coind) continue; + if(coinid > 0 && job->coind->id != coinid) continue; g_list_job.Leave(); return job; @@ -49,7 +58,13 @@ static YAAMP_JOB *job_get_last() void job_send_last(YAAMP_CLIENT *client) { - YAAMP_JOB *job = job_get_last(); +#ifdef NO_EXCHANGE + // prefer user coin first (if available) + YAAMP_JOB *job = job_get_last(client->coinid); + if(!job) job = job_get_last(0); +#else + YAAMP_JOB *job = job_get_last(0); +#endif if(!job) return; YAAMP_JOB_TEMPLATE *templ = job->templ; @@ -87,8 +102,8 @@ void job_broadcast(YAAMP_JOB *job) int s1 = current_timestamp_dms(); int count = 0; struct timeval timeout; - timeout.tv_sec = 5; - timeout.tv_usec = 0; + timeout.tv_sec = 0; + timeout.tv_usec = 100000; // max time to push to a socket (very fast) YAAMP_JOB_TEMPLATE *templ = job->templ; @@ -100,6 +115,7 @@ void job_broadcast(YAAMP_JOB *job) { YAAMP_CLIENT *client = (YAAMP_CLIENT *)li->data; if(client->deleted) continue; + if(!client->sock) continue; // if(client->reconnecting && client->locked) continue; if(client->jobid_next != job->id) continue; @@ -115,10 +131,10 @@ void job_broadcast(YAAMP_JOB *job) if (socket_send_raw(client->sock, buffer, strlen(buffer)) == -1) { int err = errno; client->broadcast_timeouts++; - clientlog(client, "unable to send job, sock err %d (%d times)", err, client->broadcast_timeouts); // too much timeouts, disconnect him if (client->broadcast_timeouts >= 3) { shutdown(client->sock->sock, SHUT_RDWR); + clientlog(client, "unable to send job, sock err %d (%d times)", err, client->broadcast_timeouts); if(client->workerid && !client->reconnecting) { // CommonLock(&g_db_mutex); db_clear_worker(g_db, client); diff --git a/stratum/json.cpp b/stratum/json.cpp index ca70ef75a..3ceba40f9 100644 --- a/stratum/json.cpp +++ b/stratum/json.cpp @@ -503,7 +503,7 @@ json_value * json_parse_ex (json_settings * settings, case ']': - if (top->type == json_array) + if (top && top->type == json_array) flags = (flags & ~ (flag_need_comma | flag_seek_value)) | flag_next; else { sprintf (error, "%d:%d: Unexpected ]", cur_line, e_off); diff --git a/stratum/list.cpp b/stratum/list.cpp index 2942f4344..ea18d7ff2 100644 --- a/stratum/list.cpp +++ b/stratum/list.cpp @@ -5,21 +5,21 @@ void CommonLock(pthread_mutex_t *mutex) { -#ifdef _LIST_DEBUG_ - int i=0; - for(; i<10; i++) - { - int res = pthread_mutex_trylock(mutex); - if(res == 0) break; + if (g_debuglog_list) { + int i=0; + for(; i<10; i++) + { + int res = pthread_mutex_trylock(mutex); + if(res == 0) break; - usleep(100*YAAMP_MS); - } + usleep(100*YAAMP_MS); + } - if(i == 10) - debuglog("failed mutex2 %x <<----------------\n", mutex); -#else - pthread_mutex_lock(mutex); -#endif + if(i == 10) + debuglog("failed mutex2 %x <<----------------\n", mutex); + } else { + pthread_mutex_lock(mutex); + } } void CommonUnlock(pthread_mutex_t *mutex) @@ -43,21 +43,21 @@ CommonList::~CommonList() void CommonList::Enter() { -#ifdef _LIST_DEBUG_ - int i=0; - for(; i<10; i++) - { - int res = pthread_mutex_trylock(&mutex); - if(res == 0) break; + if (g_debuglog_list) { + int i=0; + for(; i<10; i++) + { + int res = pthread_mutex_trylock(&mutex); + if(res == 0) break; - usleep(100*YAAMP_MS); - } + usleep(100*YAAMP_MS); + } - if(i == 10) - debuglog("failed mutex1 %x <<----------------\n", &mutex); -#else - pthread_mutex_lock(&mutex); -#endif + if(i == 10) + debuglog("failed mutex1 %x <<----------------\n", &mutex); + } else { + pthread_mutex_lock(&mutex); + } } void CommonList::Leave() diff --git a/stratum/remote.cpp b/stratum/remote.cpp index 70e879302..b3e4ef1f0 100644 --- a/stratum/remote.cpp +++ b/stratum/remote.cpp @@ -1,8 +1,6 @@ #include "stratum.h" -//#define REMOTE_DEBUGLOG_ - bool remote_can_mine(YAAMP_REMOTE *remote) { if(!remote) return false; @@ -40,9 +38,9 @@ bool remote_connected(YAAMP_REMOTE *remote) void remote_close(YAAMP_REMOTE *remote) { -#ifdef REMOTE_DEBUGLOG_ - debuglog("remote_close JOB%d\n", remote->id); -#endif + if (g_debuglog_remote) { + debuglog("remote_close JOB%d\n", remote->id); + } remote->difficulty_actual = 0; @@ -65,11 +63,11 @@ bool remote_connect(YAAMP_REMOTE *remote) if(remote_connected(remote)) remote_close(remote); -#ifdef REMOTE_DEBUGLOG_ - debuglog("connecting to %s:%d JOB%d\n", remote->host, remote->port, remote->id); -#endif + if (g_debuglog_remote) { + debuglog("connecting to %s:%d JOB%d\n", remote->host, remote->port, remote->id); + } - int sock = socket(AF_INET, SOCK_STREAM, 0); + int sock = socket(AF_INET, SOCK_STREAM, 0); if(sock <= 0) return false; struct hostent *ent = gethostbyname(remote->host); @@ -85,9 +83,9 @@ bool remote_connect(YAAMP_REMOTE *remote) int res = connect(sock, (struct sockaddr*)&serv, sizeof(serv)); if(res < 0) { -#ifdef REMOTE_DEBUGLOG_ - debuglog("cant connect to %s:%d JOB%d\n", remote->host, remote->port, remote->id); -#endif + if (g_debuglog_remote) { + debuglog("cant connect to %s:%d JOB%d\n", remote->host, remote->port, remote->id); + } return false; } diff --git a/stratum/remote_template.cpp b/stratum/remote_template.cpp index 84fadc5e7..6235b705a 100644 --- a/stratum/remote_template.cpp +++ b/stratum/remote_template.cpp @@ -62,7 +62,7 @@ void remote_create_job(YAAMP_REMOTE *remote, json_value *json_params) YAAMP_JOB_TEMPLATE *templ = new YAAMP_JOB_TEMPLATE; memset(templ, 0, sizeof(YAAMP_JOB_TEMPLATE)); - strncpy(templ->prevhash_be, json_params->u.array.values[1]->u.string.ptr, 1023); + strncpy(templ->prevhash_be, json_params->u.array.values[1]->u.string.ptr, sizeof(templ->prevhash_be)-1); strncpy(templ->coinb1, json_params->u.array.values[2]->u.string.ptr, 1023); strncpy(templ->coinb2, json_params->u.array.values[3]->u.string.ptr, 1023); diff --git a/stratum/rpc.cpp b/stratum/rpc.cpp index 66f857de1..219b619e4 100644 --- a/stratum/rpc.cpp +++ b/stratum/rpc.cpp @@ -37,9 +37,9 @@ bool rpc_connect(YAAMP_RPC *rpc) rpc->id = 0; rpc->bufpos = 0; -#ifdef RPC_DEBUGLOG_ - debuglog("connected to %s:%d\n", rpc->host, rpc->port); -#endif + if (g_debuglog_rpc) { + debuglog("connected to %s:%d\n", rpc->host, rpc->port); + } return true; } @@ -52,9 +52,9 @@ void rpc_close(YAAMP_RPC *rpc) close(rpc->sock); rpc->sock = 0; -#ifdef RPC_DEBUGLOG_ - debuglog("disconnected from %s:%d\n", rpc->host, rpc->port); -#endif + if (g_debuglog_rpc) { + debuglog("disconnected from %s:%d\n", rpc->host, rpc->port); + } } /////////////////////////////////////////////////////////////////// @@ -66,9 +66,9 @@ int rpc_send_raw(YAAMP_RPC *rpc, const char *buffer, int bytes) int res = send(rpc->sock, buffer, bytes, MSG_NOSIGNAL); if(res <= 0) return res; -#ifdef RPC_DEBUGLOG_ - debuglog("sending >%s<\n", buffer); -#endif + if (g_debuglog_rpc) { + debuglog("sending >%s<\n", buffer); + } return res; } @@ -148,9 +148,9 @@ char *rpc_do_call(YAAMP_RPC *rpc, char const *data) while(!g_exiting) { int bytes = recv(rpc->sock, buffer+bufpos, YAAMP_SMALLBUFSIZE-bufpos-1, 0); -#ifdef RPC_DEBUGLOG_ - debuglog("got %s\n", buffer+bufpos); -#endif + if (g_debuglog_rpc) { + debuglog("got %s\n", buffer+bufpos); + } if(bytes <= 0) { debuglog("ERROR: recv1, %d, %d, %s, %s\n", bytes, errno, data, buffer); diff --git a/stratum/sha3/blake2b.c b/stratum/sha3/blake2b.c new file mode 100644 index 000000000..f85c97713 --- /dev/null +++ b/stratum/sha3/blake2b.c @@ -0,0 +1,196 @@ +/* + * Copyright 2009 Colin Percival, 2014 savale + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file was originally written by Colin Percival as part of the Tarsnap + * online backup system. + */ + +#include +#include +#include + +#include "sph_types.h" +#include "blake2b.h" + +// Cyclic right rotation. + +#ifndef ROTR64 +#define ROTR64(x, y) (((x) >> (y)) ^ ((x) << (64 - (y)))) +#endif + +// Little-endian byte access. + +#define B2B_GET64(p) \ + (((uint64_t) ((uint8_t *) (p))[0]) ^ \ + (((uint64_t) ((uint8_t *) (p))[1]) << 8) ^ \ + (((uint64_t) ((uint8_t *) (p))[2]) << 16) ^ \ + (((uint64_t) ((uint8_t *) (p))[3]) << 24) ^ \ + (((uint64_t) ((uint8_t *) (p))[4]) << 32) ^ \ + (((uint64_t) ((uint8_t *) (p))[5]) << 40) ^ \ + (((uint64_t) ((uint8_t *) (p))[6]) << 48) ^ \ + (((uint64_t) ((uint8_t *) (p))[7]) << 56)) + +// G Mixing function. + +#define B2B_G(a, b, c, d, x, y) { \ + v[a] = v[a] + v[b] + x; \ + v[d] = ROTR64(v[d] ^ v[a], 32); \ + v[c] = v[c] + v[d]; \ + v[b] = ROTR64(v[b] ^ v[c], 24); \ + v[a] = v[a] + v[b] + y; \ + v[d] = ROTR64(v[d] ^ v[a], 16); \ + v[c] = v[c] + v[d]; \ + v[b] = ROTR64(v[b] ^ v[c], 63); } + +// Initialization Vector. + +static const uint64_t blake2b_iv[8] = { + 0x6A09E667F3BCC908, 0xBB67AE8584CAA73B, + 0x3C6EF372FE94F82B, 0xA54FF53A5F1D36F1, + 0x510E527FADE682D1, 0x9B05688C2B3E6C1F, + 0x1F83D9ABFB41BD6B, 0x5BE0CD19137E2179 +}; + +// Compression function. "last" flag indicates last block. + +static void blake2b_compress(blake2b_ctx *ctx, int last) +{ + const uint8_t sigma[12][16] = { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, + { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, + { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, + { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, + { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, + { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, + { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, + { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, + { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, + { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, + { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } + }; + int i; + uint64_t v[16], m[16]; + + for (i = 0; i < 8; i++) { // init work variables + v[i] = ctx->h[i]; + v[i + 8] = blake2b_iv[i]; + } + + v[12] ^= ctx->t[0]; // low 64 bits of offset + v[13] ^= ctx->t[1]; // high 64 bits + if (last) // last block flag set ? + v[14] = ~v[14]; + + for (i = 0; i < 16; i++) // get little-endian words + m[i] = B2B_GET64(&ctx->b[8 * i]); + + for (i = 0; i < 12; i++) { // twelve rounds + B2B_G( 0, 4, 8, 12, m[sigma[i][ 0]], m[sigma[i][ 1]]); + B2B_G( 1, 5, 9, 13, m[sigma[i][ 2]], m[sigma[i][ 3]]); + B2B_G( 2, 6, 10, 14, m[sigma[i][ 4]], m[sigma[i][ 5]]); + B2B_G( 3, 7, 11, 15, m[sigma[i][ 6]], m[sigma[i][ 7]]); + B2B_G( 0, 5, 10, 15, m[sigma[i][ 8]], m[sigma[i][ 9]]); + B2B_G( 1, 6, 11, 12, m[sigma[i][10]], m[sigma[i][11]]); + B2B_G( 2, 7, 8, 13, m[sigma[i][12]], m[sigma[i][13]]); + B2B_G( 3, 4, 9, 14, m[sigma[i][14]], m[sigma[i][15]]); + } + + for( i = 0; i < 8; ++i ) + ctx->h[i] ^= v[i] ^ v[i + 8]; +} + +// Initialize the hashing context "ctx" with optional key "key". +// 1 <= outlen <= 64 gives the digest size in bytes. +// Secret key (also <= 64 bytes) is optional (keylen = 0). + +int blake2b_init(blake2b_ctx *ctx, size_t outlen, + const void *key, size_t keylen) // (keylen=0: no key) +{ + size_t i; + + if (outlen == 0 || outlen > 64 || keylen > 64) + return -1; // illegal parameters + + for (i = 0; i < 8; i++) // state, "param block" + ctx->h[i] = blake2b_iv[i]; + ctx->h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen; + + ctx->t[0] = 0; // input count low word + ctx->t[1] = 0; // input count high word + ctx->c = 0; // pointer within buffer + ctx->outlen = outlen; + + for (i = keylen; i < 128; i++) // zero input block + ctx->b[i] = 0; + if (keylen > 0) { + blake2b_update(ctx, key, keylen); + ctx->c = 128; // at the end + } + + return 0; +} + +// Add "inlen" bytes from "in" into the hash. + +void blake2b_update(blake2b_ctx *ctx, + const void *in, size_t inlen) // data bytes +{ + size_t i; + + for (i = 0; i < inlen; i++) { + if (ctx->c == 128) { // buffer full ? + ctx->t[0] += ctx->c; // add counters + if (ctx->t[0] < ctx->c) // carry overflow ? + ctx->t[1]++; // high word + blake2b_compress(ctx, 0); // compress (not last) + ctx->c = 0; // counter to zero + } + ctx->b[ctx->c++] = ((const uint8_t *) in)[i]; + } +} + +// Generate the message digest (size given in init). +// Result placed in "out". + +void blake2b_final(blake2b_ctx *ctx, void *out) +{ + size_t i; + + ctx->t[0] += ctx->c; // mark last block offset + if (ctx->t[0] < ctx->c) // carry overflow + ctx->t[1]++; // high word + + while (ctx->c < 128) // fill up with zeros + ctx->b[ctx->c++] = 0; + blake2b_compress(ctx, 1); // final block flag = 1 + + // little endian convert and store + for (i = 0; i < ctx->outlen; i++) { + ((uint8_t *) out)[i] = + (ctx->h[i >> 3] >> (8 * (i & 7))) & 0xFF; + } +} + diff --git a/stratum/sha3/blake2b.h b/stratum/sha3/blake2b.h new file mode 100644 index 000000000..f8652c180 --- /dev/null +++ b/stratum/sha3/blake2b.h @@ -0,0 +1,41 @@ +#pragma once +#ifndef __BLAKE2B_H__ +#define __BLAKE2B_H__ + +#include +#include + +#if defined(_MSC_VER) +#include +#define inline __inline +#define ALIGN(x) __declspec(align(x)) +#else +#define ALIGN(x) __attribute__((aligned(x))) +#endif + +#if defined(_MSC_VER) || defined(__x86_64__) || defined(__x86__) +#define NATIVE_LITTLE_ENDIAN +#endif + +// state context +ALIGN(64) typedef struct { + uint8_t b[128]; // input buffer + uint64_t h[8]; // chained state + uint64_t t[2]; // total number of bytes + size_t c; // pointer for b[] + size_t outlen; // digest size +} blake2b_ctx; + +#if defined(__cplusplus) +extern "C" { +#endif + +int blake2b_init(blake2b_ctx *ctx, size_t outlen, const void *key, size_t keylen); +void blake2b_update(blake2b_ctx *ctx, const void *in, size_t inlen); +void blake2b_final(blake2b_ctx *ctx, void *out); + +#if defined(__cplusplus) +} +#endif + +#endif diff --git a/stratum/sha3/makefile b/stratum/sha3/makefile index 1d3f69fe4..6c917993b 100644 --- a/stratum/sha3/makefile +++ b/stratum/sha3/makefile @@ -6,8 +6,8 @@ LDFLAGS=-O2 SOURCES=sph_jh.c sph_blake.c sph_bmw.c sph_groestl.c sph_skein.c sph_keccak.c sph_luffa.c sph_cubehash.c sph_shavite.c \ sph_simd.c sph_echo.c sph_fugue.c sph_hamsi.c sph_shabal.c sph_whirlpool.c \ - sph_haval.c sph_ripemd.c sph_sha2.c sph_sha2big.c sph_tiger.c \ - blake2s.c + sph_haval.c sph_hefty1.c sph_ripemd.c sph_sha2.c sph_sha2big.c sph_tiger.c \ + blake2s.c blake2b.c OBJECTS=$(SOURCES:.c=.o) OUTPUT=libhash.a diff --git a/stratum/share.cpp b/stratum/share.cpp index 1c733845c..14c4332a7 100644 --- a/stratum/share.cpp +++ b/stratum/share.cpp @@ -78,6 +78,7 @@ static void share_add_worker(YAAMP_CLIENT *client, YAAMP_JOB *job, bool valid, c void share_add(YAAMP_CLIENT *client, YAAMP_JOB *job, bool valid, char *extranonce2, char *ntime, char *nonce, double share_diff, int error_number) { // check_job(job); + g_shares_counter++; share_add_worker(client, job, valid, ntime, share_diff, error_number); YAAMP_SHARE *share = new YAAMP_SHARE; @@ -127,6 +128,11 @@ void share_write(YAAMP_DB *db) YAAMP_WORKER *worker = (YAAMP_WORKER *)li->data; if(worker->deleted) continue; + if(!worker->workerid) { + object_delete(worker); + continue; + } + if(count) strcat(buffer, ","); sprintf(buffer+strlen(buffer), "(%d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '%s', %d)", worker->userid, worker->workerid, worker->coinid, worker->remoteid, pid, @@ -174,7 +180,7 @@ void share_prune(YAAMP_DB *db) void block_prune(YAAMP_DB *db) { int count = 0; - char buffer[128*1024] = "insert into blocks (height, blockhash, coin_id, userid, workerid, category, difficulty, difficulty_user, time, algo) values "; + char buffer[128*1024] = "insert into blocks (height, blockhash, coin_id, userid, workerid, category, difficulty, difficulty_user, time, algo, segwit) values "; g_list_block.Enter(); for(CLI li = g_list_block.first; li; li = li->next) @@ -193,9 +199,9 @@ void block_prune(YAAMP_DB *db) } if(count) strcat(buffer, ","); - sprintf(buffer+strlen(buffer), "(%d, '%s', %d, %d, %d, 'new', %f, %f, %d, '%s')", + sprintf(buffer+strlen(buffer), "(%d, '%s', %d, %d, %d, 'new', %f, %f, %d, '%s', %d)", block->height, block->hash, block->coinid, block->userid, block->workerid, - block->difficulty, block->difficulty_user, (int)block->created, g_stratum_algo); + block->difficulty, block->difficulty_user, (int)block->created, g_stratum_algo, block->segwit?1:0); object_delete(block); count++; @@ -205,7 +211,7 @@ void block_prune(YAAMP_DB *db) if(count) db_query(db, buffer); } -void block_add(int userid, int workerid, int coinid, int height, double difficulty, double difficulty_user, const char *hash1, const char *hash2) +void block_add(int userid, int workerid, int coinid, int height, double diff, double diff_user, const char *h1, const char *h2, int segwit) { YAAMP_BLOCK *block = new YAAMP_BLOCK; memset(block, 0, sizeof(YAAMP_BLOCK)); @@ -215,20 +221,21 @@ void block_add(int userid, int workerid, int coinid, int height, double difficul block->workerid = workerid; block->coinid = coinid; block->height = height; - block->difficulty = difficulty; - block->difficulty_user = difficulty_user; + block->difficulty = diff; + block->difficulty_user = diff_user; + block->segwit = segwit; - strcpy(block->hash1, hash1); - strcpy(block->hash2, hash2); + strcpy(block->hash1, h1); + strcpy(block->hash2, h2); g_list_block.AddTail(block); } // called from blocknotify tool -void block_confirm(int coinid, const char *blockhash) +bool block_confirm(int coinid, const char *blockhash) { char hash[192]; - if(strlen(blockhash) < 64) return; + if(strlen(blockhash) < 64) return false; snprintf(hash, 161, "%s", blockhash); @@ -254,10 +261,29 @@ void block_confirm(int coinid, const char *blockhash) } const char *h1 = json_get_string(json_res, "pow_hash"); // DGB, MYR, J const char *h2 = json_get_string(json_res, "mined_hash"); // XVG + const char *h3 = json_get_string(json_res, "phash"); // XSH if (h1) snprintf(hash, 161, "%s", h1); else if (h2) snprintf(hash, 161, "%s", h2); + else if (h3) snprintf(hash, 161, "%s", h3); //debuglog("%s: getblock %s -> pow %s\n", __func__, blockhash, hash); - json_value_free(json_res); + json_value_free(json); + break; + } else if (strcmp(coind->symbol,"ORB") == 0) { + char params[192]; + sprintf(params, "[\"%s\"]", blockhash); + json_value *json = rpc_call(&coind->rpc, "getblock", params); + if(!json) { + debuglog("%s: error getblock, no answer\n", __func__); + break; + } + json_value *json_res = json_get_object(json, "result"); + if(!json_res) { + debuglog("%s: error getblock, no result\n", __func__); + break; + } + const char *h = json_get_string(json_res, "proofhash"); + if (h) snprintf(hash, 161, "%s", h); + json_value_free(json); break; } } @@ -266,17 +292,18 @@ void block_confirm(int coinid, const char *blockhash) for(CLI li = g_list_block.first; li; li = li->next) { YAAMP_BLOCK *block = (YAAMP_BLOCK *)li->data; - if(block->coinid == coinid && !block->confirmed && !block->deleted) + if(block->coinid == coinid && !block->deleted) { if(strcmp(block->hash1, hash) && strcmp(block->hash2, hash)) continue; - debuglog("*** CONFIRMED %d : %s\n", block->height, block->hash2); - - strncpy(block->hash, blockhash, 65); - block->confirmed = true; - - return; + if (!block->confirmed) { + debuglog("*** CONFIRMED %d : %s\n", block->height, block->hash2); + strncpy(block->hash, blockhash, 65); + block->confirmed = true; + } + return true; } } + return false; } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/stratum/share.h b/stratum/share.h index 5305d2de2..dd90eca47 100644 --- a/stratum/share.h +++ b/stratum/share.h @@ -9,7 +9,7 @@ class YAAMP_WORKER: public YAAMP_OBJECT bool valid; bool extranonce1; - int error_number; + int32_t error_number; uint32_t ntime; double difficulty; @@ -28,10 +28,10 @@ class YAAMP_SHARE: public YAAMP_OBJECT { public: int jobid; - char extranonce2[32]; + char extranonce2[64]; char ntime[32]; - char nonce[32]; - char nonce1[32]; + char nonce[64]; + char nonce1[64]; }; inline void share_delete(YAAMP_OBJECT *object) @@ -56,8 +56,9 @@ void share_prune(YAAMP_DB *db); class YAAMP_BLOCK: public YAAMP_OBJECT { public: - int created; + time_t created; bool confirmed; + bool segwit; int userid; int workerid; @@ -83,7 +84,7 @@ inline void block_delete(YAAMP_OBJECT *object) class YAAMP_SUBMIT: public YAAMP_OBJECT { public: - int created; + time_t created; bool valid; int remoteid; @@ -98,8 +99,8 @@ inline void submit_delete(YAAMP_OBJECT *object) void block_prune(YAAMP_DB *db); -void block_add(int userid, int workerid, int coinid, int height, double difficulty, double difficulty_user, const char *hash1, const char *hash2); -void block_confirm(int coinid, const char *hash); +void block_add(int userid, int workerid, int coinid, int height, double diff, double diff_user, const char *hash1, const char *h2, int segwit); +bool block_confirm(int coinid, const char *hash); YAAMP_SUBMIT *submit_add(int remoteid, double difficulty); void submit_prune(YAAMP_DB *db); diff --git a/stratum/socket.cpp b/stratum/socket.cpp index 107b0ac08..a9796fc22 100644 --- a/stratum/socket.cpp +++ b/stratum/socket.cpp @@ -1,42 +1,91 @@ #include "stratum.h" -//#define SOCKET_DEBUGLOG_ - bool socket_connected(YAAMP_SOCKET *s) { return s->sock > 0; } +void socket_real_ip(YAAMP_SOCKET *s) +{ + // get real ip if we are using haproxy or similar that use PROXY protocol + // https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt + int size, ret; + const char v2sig[] = "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A"; + + do { + ret = recv(s->sock, &hdr, sizeof(hdr), MSG_PEEK); + } while (ret == -1 && errno == EINTR); + + if (ret >= (16 + ntohs(hdr.v2.len)) && + memcmp(&hdr.v2, v2sig, 12) == 0 && + ((hdr.v2.ver_cmd & 0xF0) == 0x20) && + hdr.v2.fam == 0x11) { + // we received a proxy v2 header + inet_ntop(AF_INET, &hdr.v2.addr.ip4.src_addr, s->ip, 64); + s->port = ntohs(hdr.v2.addr.ip4.src_port); + + // we need to consume the appropriate amount of data from the socket + // read the buffer without PEEK'ing so that we begin at the real data later in socket_nextjson + size = 16 + ntohs(hdr.v2.len); + do { + ret = recv(s->sock, &hdr, size, 0); + } while (ret == -1 && errno == EINTR); + return; + } + else { + // not received any proxy header + struct sockaddr_in name; + socklen_t len = sizeof(name); + memset(&name, 0, len); + + int res = getpeername(s->sock, (struct sockaddr *)&name, &len); + inet_ntop(AF_INET, &name.sin_addr, s->ip, 64); + + res = getsockname(s->sock, (struct sockaddr *)&name, &len); + s->port = ntohs(name.sin_port); + return; + } +} + YAAMP_SOCKET *socket_initialize(int sock) { + struct timeval timeout; + timeout.tv_sec = g_socket_recv_timeout; + timeout.tv_usec = 0; YAAMP_SOCKET *s = new YAAMP_SOCKET; memset(s, 0, sizeof(YAAMP_SOCKET)); s->buflen = 0; s->sock = sock; + setsockopt(s->sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); + // yaamp_create_mutex(&s->mutex); // pthread_mutex_lock(&s->mutex); - - struct sockaddr_in name; - socklen_t len = sizeof(name); - memset(&name, 0, len); - - int res = getpeername(s->sock, (struct sockaddr *)&name, &len); - inet_ntop(AF_INET, &name.sin_addr, s->ip, 1024); - - res = getsockname(s->sock, (struct sockaddr *)&name, &len); - s->port = ntohs(name.sin_port); + if (!g_handle_haproxy_ips) { + int res = 0; + struct sockaddr_in name; + socklen_t len = sizeof(name); + memset(&name, 0, len); + + res = getpeername(s->sock, (struct sockaddr *)&name, &len); + inet_ntop(AF_INET, &name.sin_addr, s->ip, 64); + + res = getsockname(s->sock, (struct sockaddr *)&name, &len); + s->port = ntohs(name.sin_port); + } else { + socket_real_ip(s); + } return s; } void socket_close(YAAMP_SOCKET *s) { -#ifdef SOCKET_DEBUGLOG_ - debuglog("socket_close\n"); -#endif + if (g_debuglog_socket) { + debuglog("socket_close\n"); + } if(!s) return; if(s->sock) close(s->sock); @@ -140,9 +189,9 @@ json_value *socket_nextjson(YAAMP_SOCKET *s, YAAMP_CLIENT *client) int socket_send_raw(YAAMP_SOCKET *s, const char *buffer, int size) { -#ifdef SOCKET_DEBUGLOG_ - debuglog("socket send: %s", buffer); -#endif + if (g_debuglog_socket) { + debuglog("socket send: %s", buffer); + } int res = send(s->sock, buffer, size, MSG_NOSIGNAL); return res; @@ -170,7 +219,6 @@ int socket_send(YAAMP_SOCKET *s, const char *format, ...) // pthread_mutex_lock(&s->mutex); int res = socket_send_raw(s, buffer, strlen(buffer)); - // pthread_mutex_unlock(&s->mutex); return res; } diff --git a/stratum/socket.h b/stratum/socket.h index 75a04219d..f992fa5db 100644 --- a/stratum/socket.h +++ b/stratum/socket.h @@ -3,7 +3,7 @@ struct YAAMP_SOCKET { - char ip[1024]; + char ip[64]; int port; // pthread_mutex_t mutex; @@ -18,6 +18,8 @@ struct YAAMP_SOCKET bool socket_connected(YAAMP_SOCKET *s); +void socket_real_ip(YAAMP_SOCKET *s); + YAAMP_SOCKET *socket_initialize(int sock); void socket_close(YAAMP_SOCKET *s); @@ -26,3 +28,32 @@ int socket_send(YAAMP_SOCKET *s, const char *format, ...); int socket_send_raw(YAAMP_SOCKET *s, const char *buffer, int size); +static union { + struct { + char line[108]; + } v1; + struct { + uint8_t sig[12]; + uint8_t ver_cmd; + uint8_t fam; + uint16_t len; + union { + struct { /* for TCP/UDP over IPv4, len = 12 */ + uint32_t src_addr; + uint32_t dst_addr; + uint16_t src_port; + uint16_t dst_port; + } ip4; + struct { /* for TCP/UDP over IPv6, len = 36 */ + uint8_t src_addr[16]; + uint8_t dst_addr[16]; + uint16_t src_port; + uint16_t dst_port; + } ip6; + struct { /* for AF_UNIX sockets, len = 216 */ + uint8_t src_addr[108]; + uint8_t dst_addr[108]; + } unx; + } addr; + } v2; +} hdr; diff --git a/stratum/stratum.cpp b/stratum/stratum.cpp index 886e60b09..b8e38c23f 100644 --- a/stratum/stratum.cpp +++ b/stratum/stratum.cpp @@ -23,16 +23,41 @@ char g_sql_host[1024]; char g_sql_database[1024]; char g_sql_username[1024]; char g_sql_password[1024]; +int g_sql_port = 3306; -char g_stratum_algo[1024]; +char g_stratum_coin_include[256]; +char g_stratum_coin_exclude[256]; + +char g_stratum_algo[256]; double g_stratum_difficulty; +double g_stratum_min_diff; +double g_stratum_max_diff; int g_stratum_max_ttf; int g_stratum_max_cons = 5000; bool g_stratum_reconnect; bool g_stratum_renting; +bool g_stratum_segwit = false; + +int g_limit_txs_per_block = 0; + +bool g_handle_haproxy_ips = false; +int g_socket_recv_timeout = 600; + +bool g_debuglog_client; +bool g_debuglog_hash; +bool g_debuglog_socket; +bool g_debuglog_rpc; +bool g_debuglog_list; +bool g_debuglog_remote; + bool g_autoexchange = true; +uint64_t g_max_shares = 0; +uint64_t g_shares_counter = 0; +uint64_t g_shares_log = 0; + +bool g_allow_rolltime = true; time_t g_last_broadcasted = 0; YAAMP_DB *g_db = NULL; @@ -92,23 +117,40 @@ YAAMP_ALGO g_algos[] = {"c11", c11_hash, 1, 0, 0}, {"x11", x11_hash, 1, 0, 0}, + {"x12", x12_hash, 1, 0, 0}, {"x13", x13_hash, 1, 0, 0}, {"x14", x14_hash, 1, 0, 0}, {"x15", x15_hash, 1, 0, 0}, {"x17", x17_hash, 1, 0, 0}, + {"x22i", x22i_hash, 1, 0, 0}, {"x11evo", x11evo_hash, 1, 0, 0}, {"xevan", xevan_hash, 0x100, 0, 0}, + {"x16r", x16r_hash, 0x100, 0, 0}, + {"x16s", x16s_hash, 0x100, 0, 0}, + {"timetravel", timetravel_hash, 0x100, 0, 0}, + {"bitcore", timetravel10_hash, 0x100, 0, 0}, + {"exosis", exosis_hash, 0x100, 0, 0}, + {"hsr", hsr_hash, 1, 0, 0}, + {"hmq1725", hmq17_hash, 0x10000, 0, 0}, + + {"jha", jha_hash, 0x10000, 0}, + + {"allium", allium_hash, 0x100, 0, 0}, {"lyra2", lyra2re_hash, 0x80, 0, 0}, {"lyra2v2", lyra2v2_hash, 0x100, 0, 0}, + {"lyra2z", lyra2z_hash, 0x100, 0, 0}, + {"bastion", bastion_hash, 1, 0 }, {"blake", blake_hash, 1, 0 }, {"blakecoin", blakecoin_hash, 1 /*0x100*/, 0, sha256_hash_hex }, + {"blake2b", blake2b_hash, 1, 0 }, {"blake2s", blake2s_hash, 1, 0 }, {"vanilla", blakecoin_hash, 1, 0 }, {"decred", decred_hash, 1, 0 }, + {"deep", deep_hash, 1, 0, 0}, {"fresh", fresh_hash, 0x100, 0, 0}, {"quark", quark_hash, 1, 0, 0}, {"nist5", nist5_hash, 1, 0, 0}, @@ -117,21 +159,41 @@ YAAMP_ALGO g_algos[] = {"dmd-gr", groestl_hash, 0x100, 0, 0}, /* diamond (double groestl) */ {"myr-gr", groestlmyriad_hash, 1, 0, 0}, /* groestl + sha 64 */ {"skein", skein_hash, 1, 0, 0}, + {"sonoa", sonoa_hash, 1, 0, 0}, + {"tribus", tribus_hash, 1, 0, 0}, {"keccak", keccak256_hash, 0x80, 0, sha256_hash_hex }, + {"keccakc", keccak256_hash, 0x100, 0, 0}, + {"hex", hex_hash, 0x100, 0, sha256_hash_hex }, + + {"phi", phi_hash, 1, 0, 0}, + {"phi2", phi2_hash, 0x100, 0, 0}, + + {"polytimos", polytimos_hash, 1, 0, 0}, + {"skunk", skunk_hash, 1, 0, 0}, {"bmw", bmw_hash, 1, 0, 0}, + {"lbk3", lbk3_hash, 0x100, 0, 0}, {"lbry", lbry_hash, 0x100, 0, 0}, {"luffa", luffa_hash, 1, 0, 0}, {"penta", penta_hash, 1, 0, 0}, + {"rainforest", rainforest_hash, 0x100, 0, 0}, {"skein2", skein2_hash, 1, 0, 0}, {"yescrypt", yescrypt_hash, 0x10000, 0, 0}, + {"yescryptR16", yescryptR16_hash, 0x10000, 0, 0 }, + {"yescryptR32", yescryptR32_hash, 0x10000, 0, 0 }, {"zr5", zr5_hash, 1, 0, 0}, + {"a5a", a5a_hash, 0x10000, 0, 0}, {"hive", hive_hash, 0x10000, 0, 0}, {"m7m", m7m_hash, 0x10000, 0, 0}, {"veltor", veltor_hash, 1, 0, 0}, {"velvet", velvet_hash, 0x10000, 0, 0}, - {"argon2", argon2_hash, 0x10000, 0, sha256_hash_hex }, + {"argon2", argon2a_hash, 0x10000, 0, sha256_hash_hex }, + {"argon2d-dyn", argon2d_dyn_hash, 0x10000, 0, 0 }, // Dynamic Argon2d Implementation + {"vitalium", vitalium_hash, 1, 0, 0}, + {"aergo", aergo_hash, 1, 0, 0}, + + {"sha256t", sha256t_hash, 1, 0, 0}, // sha256 3x {"sib", sib_hash, 1, 0, 0}, @@ -155,8 +217,6 @@ YAAMP_ALGO *stratum_find_algo(const char *name) //////////////////////////////////////////////////////////////////////////////////////// -#include - int main(int argc, char **argv) { if(argc < 2) @@ -193,13 +253,35 @@ int main(int argc, char **argv) strcpy(g_sql_database, iniparser_getstring(ini, "SQL:database", NULL)); strcpy(g_sql_username, iniparser_getstring(ini, "SQL:username", NULL)); strcpy(g_sql_password, iniparser_getstring(ini, "SQL:password", NULL)); + g_sql_port = iniparser_getint(ini, "SQL:port", 3306); + + // optional coin filters (to mine only one on a special port or a test instance) + char *coin_filter = iniparser_getstring(ini, "WALLETS:include", NULL); + strcpy(g_stratum_coin_include, coin_filter ? coin_filter : ""); + coin_filter = iniparser_getstring(ini, "WALLETS:exclude", NULL); + strcpy(g_stratum_coin_exclude, coin_filter ? coin_filter : ""); strcpy(g_stratum_algo, iniparser_getstring(ini, "STRATUM:algo", NULL)); g_stratum_difficulty = iniparser_getdouble(ini, "STRATUM:difficulty", 16); + g_stratum_min_diff = iniparser_getdouble(ini, "STRATUM:diff_min", g_stratum_difficulty/2); + g_stratum_max_diff = iniparser_getdouble(ini, "STRATUM:diff_max", g_stratum_difficulty*8192); + g_stratum_max_cons = iniparser_getint(ini, "STRATUM:max_cons", 5000); g_stratum_max_ttf = iniparser_getint(ini, "STRATUM:max_ttf", 0x70000000); g_stratum_reconnect = iniparser_getint(ini, "STRATUM:reconnect", true); g_stratum_renting = iniparser_getint(ini, "STRATUM:renting", true); + g_handle_haproxy_ips = iniparser_getint(ini, "STRATUM:haproxy_ips", g_handle_haproxy_ips); + g_socket_recv_timeout = iniparser_getint(ini, "STRATUM:recv_timeout", 600); + + g_max_shares = iniparser_getint(ini, "STRATUM:max_shares", g_max_shares); + g_limit_txs_per_block = iniparser_getint(ini, "STRATUM:max_txs_per_block", 0); + + g_debuglog_client = iniparser_getint(ini, "DEBUGLOG:client", false); + g_debuglog_hash = iniparser_getint(ini, "DEBUGLOG:hash", false); + g_debuglog_socket = iniparser_getint(ini, "DEBUGLOG:socket", false); + g_debuglog_rpc = iniparser_getint(ini, "DEBUGLOG:rpc", false); + g_debuglog_list = iniparser_getint(ini, "DEBUGLOG:list", false); + g_debuglog_remote = iniparser_getint(ini, "DEBUGLOG:remote", false); iniparser_freedict(ini); @@ -214,7 +296,16 @@ int main(int argc, char **argv) struct rlimit rlim_threads = {0x8000, 0x8000}; setrlimit(RLIMIT_NPROC, &rlim_threads); - stratumlog("* starting stratumd for %s on %s:%d\n", g_current_algo->name, g_tcp_server, g_tcp_port); + stratumlogdate("starting stratum for %s on %s:%d\n", + g_current_algo->name, g_tcp_server, g_tcp_port); + + // ntime should not be changed by miners for these algos + g_allow_rolltime = strcmp(g_stratum_algo,"x11evo"); + g_allow_rolltime = g_allow_rolltime && strcmp(g_stratum_algo,"timetravel"); + g_allow_rolltime = g_allow_rolltime && strcmp(g_stratum_algo,"bitcore"); + g_allow_rolltime = g_allow_rolltime && strcmp(g_stratum_algo,"exosis"); + if (!g_allow_rolltime) + stratumlog("note: time roll disallowed for %s algo\n", g_current_algo->name); g_db = db_connect(); if(!g_db) yaamp_error("Cant connect database"); @@ -291,6 +382,8 @@ int main(int argc, char **argv) pthread_join(thread2, NULL); db_close(g_db); // client threads (called by stratum one) + closelogs(); + return 0; } @@ -305,9 +398,23 @@ void *monitor_thread(void *p) if(g_last_broadcasted + YAAMP_MAXJOBDELAY < time(NULL)) { g_exiting = true; - stratumlog("%s dead lock, exiting...\n", g_current_algo->name); + stratumlogdate("%s dead lock, exiting...\n", g_stratum_algo); exit(1); } + + if(g_max_shares && g_shares_counter) { + + if((g_shares_counter - g_shares_log) > 10000) { + stratumlogdate("%s %luK shares...\n", g_stratum_algo, (g_shares_counter/1000u)); + g_shares_log = g_shares_counter; + } + + if(g_shares_counter > g_max_shares) { + g_exiting = true; + stratumlogdate("%s need a restart (%lu shares), exiting...\n", g_stratum_algo, (unsigned long) g_max_shares); + exit(1); + } + } } } @@ -335,22 +442,33 @@ void *stratum_thread(void *p) ///////////////////////////////////////////////////////////////////////// + int failcount = 0; while(!g_exiting) { int sock = accept(listen_sock, NULL, NULL); if(sock <= 0) { - stratumlog("%s accept error %d %d\n", g_current_algo->name, res, errno); + int error = errno; + stratumlog("%s socket accept() error %d\n", g_stratum_algo, error); + failcount++; + usleep(50000); + if (error == 24 && failcount > 5) { + g_exiting = true; // happen when max open files is reached (see ulimit) + stratumlogdate("%s too much socket failure, exiting...\n", g_stratum_algo); + exit(error); + } continue; } + failcount = 0; pthread_t thread; - int res = pthread_create(&thread, NULL, client_thread, (void *)(long)sock); if(res != 0) { + int error = errno; close(sock); - stratumlog("%s pthread_create error %d %d\n", g_current_algo->name, res, errno); + g_exiting = true; + stratumlog("%s pthread_create error %d %d\n", g_stratum_algo, res, error); } pthread_detach(thread); diff --git a/stratum/stratum.h b/stratum/stratum.h index 6c5eabd99..636141af5 100644 --- a/stratum/stratum.h +++ b/stratum/stratum.h @@ -1,4 +1,3 @@ - #include #include #include @@ -19,6 +18,7 @@ #include #include #include +#include #include #include @@ -74,15 +74,37 @@ extern char g_sql_host[1024]; extern char g_sql_database[1024]; extern char g_sql_username[1024]; extern char g_sql_password[1024]; +extern int g_sql_port; + +extern char g_stratum_coin_include[256]; +extern char g_stratum_coin_exclude[256]; -extern char g_stratum_algo[1024]; +extern char g_stratum_algo[256]; extern double g_stratum_difficulty; +extern double g_stratum_min_diff; +extern double g_stratum_max_diff; extern int g_stratum_max_cons; extern int g_stratum_max_ttf; extern bool g_stratum_reconnect; extern bool g_stratum_renting; +extern bool g_stratum_segwit; +extern int g_limit_txs_per_block; + +extern bool g_handle_haproxy_ips; +extern int g_socket_recv_timeout; +extern bool g_debuglog_client; +extern bool g_debuglog_hash; +extern bool g_debuglog_socket; +extern bool g_debuglog_rpc; +extern bool g_debuglog_list; +extern bool g_debuglog_remote; + +extern uint64_t g_max_shares; +extern uint64_t g_shares_counter; + +extern bool g_allow_rolltime; extern time_t g_last_broadcasted; extern struct ifaddrs *g_ifaddr; @@ -125,32 +147,51 @@ void scrypt_N_R_1_256(const char* input, char* output, uint32_t N, uint32_t R, u void sha256_hash_hex(const char *input, char *output, unsigned int len); void sha256_double_hash_hex(const char *input, char *output, unsigned int len); +#include "algos/a5a.h" #include "algos/c11.h" #include "algos/x11.h" #include "algos/x11evo.h" +#include "algos/x12.h" #include "algos/x13.h" #include "algos/x14.h" #include "algos/x15.h" +#include "algos/x16r.h" +#include "algos/x16s.h" #include "algos/x17.h" +#include "algos/x22i.h" #include "algos/xevan.h" +#include "algos/hmq17.h" #include "algos/nist5.h" #include "algos/fresh.h" +#include "algos/hsr14.h" #include "algos/quark.h" #include "algos/neoscrypt.h" +#include "algos/allium.h" #include "algos/lyra2re.h" #include "algos/lyra2v2.h" +#include "algos/lyra2z.h" #include "algos/blake.h" #include "algos/blakecoin.h" -#include "algos/blake2.h" +#include "algos/blake2b.h" +#include "algos/blake2s.h" #include "algos/qubit.h" #include "algos/groestl.h" +#include "algos/jha.h" #include "algos/skein.h" #include "algos/keccak.h" +#include "algos/sha256t.h" +#include "algos/skunk.h" +#include "algos/timetravel.h" +#include "algos/bitcore.h" +#include "algos/bastion.h" #include "algos/bmw.h" +#include "algos/deep.h" +#include "algos/lbk3.h" #include "algos/lbry.h" #include "algos/luffa.h" #include "algos/pentablake.h" +#include "algos/rainforest.h" #include "algos/whirlpool.h" #include "algos/whirlpoolx.h" #include "algos/skein2.h" @@ -159,7 +200,16 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len); #include "algos/hive.h" #include "algos/sib.h" #include "algos/m7m.h" +#include "algos/phi.h" +#include "algos/phi2.h" +#include "algos/polytimos.h" +#include "algos/sonoa.h" +#include "algos/tribus.h" #include "algos/veltor.h" #include "algos/velvet.h" #include "algos/argon2a.h" - +#include "algos/vitalium.h" +#include "algos/aergo.h" +#include "algos/hex.h" +#include "algos/argon2d-dyn.h" +#include "algos/exosis.h" diff --git a/stratum/user.cpp b/stratum/user.cpp index 7f0d4e894..1e2ec6ce0 100644 --- a/stratum/user.cpp +++ b/stratum/user.cpp @@ -11,6 +11,29 @@ void db_check_user_input(char* input) } } +void db_check_coin_symbol(YAAMP_DB *db, char* symbol) +{ + if (!symbol) return; + size_t len = strlen(symbol); + if (len >= 2 && len <= 12) { +#ifdef NO_EXCHANGE + db_query(db, "SELECT symbol FROM coins WHERE installed AND algo='%s' AND symbol='%s'", g_stratum_algo, symbol); +#else + db_query(db, "SELECT symbol FROM coins WHERE installed AND (symbol='%s' OR symbol2='%s')", symbol, symbol); +#endif + MYSQL_RES *result = mysql_store_result(&db->mysql); + *symbol = '\0'; + if (!result) return; + MYSQL_ROW row = mysql_fetch_row(result); + if (row) { + strcpy(symbol, row[0]); + } + mysql_free_result(result); + } else { + *symbol = '\0'; + } +} + void db_add_user(YAAMP_DB *db, YAAMP_CLIENT *client) { db_clean_string(db, client->username); @@ -75,6 +98,7 @@ void db_add_user(YAAMP_DB *db, YAAMP_CLIENT *client) mysql_free_result(result); db_check_user_input(symbol); + db_check_coin_symbol(db, symbol); if (gift < 0) gift = 0; client->donation = gift; @@ -84,13 +108,21 @@ void db_add_user(YAAMP_DB *db, YAAMP_CLIENT *client) else if(client->userid == 0 && strlen(client->username) >= MIN_ADDRESS_LEN) { - db_query(db, "INSERT INTO accounts (username, coinsymbol, balance, donation) values ('%s', '%s', 0, %d)", - client->username, symbol, gift); + db_query(db, "INSERT INTO accounts (username, coinsymbol, balance, donation, hostaddr) values ('%s', '%s', 0, %d, '%s')", + client->username, symbol, gift, client->sock->ip); client->userid = (int)mysql_insert_id(&db->mysql); } - else - db_query(db, "UPDATE accounts SET coinsymbol='%s', donation=%d WHERE id=%d", symbol, gift, client->userid); + else { + db_query(db, "UPDATE accounts SET coinsymbol='%s', swap_time=%u, donation=%d, hostaddr='%s' WHERE id=%d AND balance = 0" + " AND (SELECT COUNT(id) FROM payouts WHERE account_id=%d AND tx IS NULL) = 0" // failed balance + " AND (SELECT pending FROM balanceuser WHERE userid=%d ORDER by time DESC LIMIT 1) = 0" // pending balance + , symbol, (uint) time(NULL), gift, client->sock->ip, client->userid, client->userid, client->userid); + if (mysql_affected_rows(&db->mysql) > 0 && strlen(symbol)) { + debuglog("%s: %s coinsymbol set to %s ip %s uid (%d)\n", + g_current_algo->name, client->username, symbol, client->sock->ip, client->userid); + } + } } ////////////////////////////////////////////////////////////////////////////////////// @@ -106,19 +138,34 @@ void db_clear_worker(YAAMP_DB *db, YAAMP_CLIENT *client) void db_add_worker(YAAMP_DB *db, YAAMP_CLIENT *client) { - db_clear_worker(db, client); + char password[128] = { 0 }; + char version[128] = { 0 }; + char worker[128] = { 0 }; int now = time(NULL); - /* maybe not required here (already made), but... */ + db_clear_worker(db, client); + db_check_user_input(client->username); db_check_user_input(client->version); db_check_user_input(client->password); db_check_user_input(client->worker); + // strip for recent mysql defaults (error if fields are too long) + if (strlen(client->password) > 64) + clientlog(client, "password too long truncated: %s", client->password); + if (strlen(client->version) > 64) + clientlog(client, "version too long truncated: %s", client->version); + if (strlen(client->worker) > 64) + clientlog(client, "worker too long truncated: %s", client->worker); + + strncpy(password, client->password, 64); + strncpy(version, client->version, 64); + strncpy(worker, client->worker, 64); + db_query(db, "INSERT INTO workers (userid, ip, name, difficulty, version, password, worker, algo, time, pid) "\ "VALUES (%d, '%s', '%s', %f, '%s', '%s', '%s', '%s', %d, %d)", client->userid, client->sock->ip, client->username, client->difficulty_actual, - client->version, client->password, client->worker, g_stratum_algo, now, getpid()); + version, password, worker, g_stratum_algo, now, getpid()); client->workerid = (int)mysql_insert_id(&db->mysql); } @@ -136,7 +183,8 @@ void db_update_workers(YAAMP_DB *db) { clientlog(client, "speed %f", client->speed); shutdown(client->sock->sock, SHUT_RDWR); - + db_clear_worker(db, client); + object_delete(client); continue; } @@ -148,7 +196,7 @@ void db_update_workers(YAAMP_DB *db) client->difficulty_written = client->difficulty_actual; } - client_sort(); + //client_sort(); g_list_client.Leave(); } diff --git a/stratum/util.cpp b/stratum/util.cpp index bcfec08e4..92f284a80 100644 --- a/stratum/util.cpp +++ b/stratum/util.cpp @@ -88,6 +88,7 @@ json_value *json_get_object(json_value *json, const char *name) FILE *g_debuglog = NULL; FILE *g_stratumlog = NULL; FILE *g_clientlog = NULL; +FILE *g_rejectlog = NULL; void initlog(const char *algo) { @@ -98,6 +99,23 @@ void initlog(const char *algo) g_stratumlog = fopen("stratum.log", "a"); g_clientlog = fopen("client.log", "a"); + g_rejectlog = fopen("reject.log", "a"); +} + +void closelogs() +{ + if (g_debuglog) { + fflush(g_debuglog); fclose(g_debuglog); + } + if (g_stratumlog) { + fflush(g_stratumlog); fclose(g_stratumlog); + } + if (g_clientlog) { + fflush(g_clientlog); fclose(g_clientlog); + } + if (g_rejectlog) { + fflush(g_rejectlog); fclose(g_rejectlog); + } } void clientlog(YAAMP_CLIENT *client, const char *format, ...) @@ -131,7 +149,11 @@ void clientlog(YAAMP_CLIENT *client, const char *format, ...) if(g_clientlog) { fprintf(g_clientlog, "%s", buffer3); - fflush(g_clientlog); + if (fflush(g_clientlog) == EOF) { + // reopen if wiped + fclose(g_clientlog); + g_clientlog = fopen("client.log", "a"); + } } } @@ -161,6 +183,18 @@ void debuglog(const char *format, ...) } } +void debuglog_hex(void *data, int len) +{ + uint8_t* const bin = (uint8_t*) data; + char *hex = (char*) calloc(1, len*2 + 2); + if (!hex) return; + for(int i=0; i < len; i++) + sprintf(hex+strlen(hex), "%02x", bin[i]); + strcpy(hex+strlen(hex), "\n"); + debuglog(hex); + free(hex); +} + void stratumlog(const char *format, ...) { char buffer[YAAMP_SMALLBUFSIZE]; @@ -189,13 +223,66 @@ void stratumlog(const char *format, ...) if(g_stratumlog) { fprintf(g_stratumlog, "%s: %s", buffer2, buffer); - fflush(g_stratumlog); + if (fflush(g_stratumlog) == EOF) { + fclose(g_stratumlog); + g_stratumlog = fopen("stratum.log", "a"); + } + } +} + +void stratumlogdate(const char *format, ...) +{ + char buffer[YAAMP_SMALLBUFSIZE]; + char date[16]; + va_list args; + time_t rawtime; + struct tm * timeinfo; + + time(&rawtime); + timeinfo = localtime(&rawtime); + strftime(date, 16, "%Y-%m-%d", timeinfo); + + va_start(args, format); + vsprintf(buffer, format, args); + va_end(args); + + stratumlog("%s %s", date, buffer); +} + +void rejectlog(const char *format, ...) +{ + char buffer[YAAMP_SMALLBUFSIZE]; + va_list args; + + va_start(args, format); + vsnprintf(buffer, YAAMP_SMALLBUFSIZE-1, format, args); + va_end(args); + + time_t rawtime; + struct tm * timeinfo; + char buffer2[80]; + + time(&rawtime); + timeinfo = localtime(&rawtime); + + strftime(buffer2, 80, "%Y-%m-%d %H:%M:%S", timeinfo); + printf("%s: %s", buffer2, buffer); + + if(g_rejectlog) + { + fprintf(g_rejectlog, "%s: %s", buffer2, buffer); + if (fflush(g_rejectlog) == EOF) { + fclose(g_rejectlog); + g_rejectlog = fopen("reject.log", "a"); + } } } + bool yaamp_error(char const *message) { debuglog("ERROR: %d %s\n", errno, message); + closelogs(); exit(1); } @@ -321,49 +408,6 @@ void base64_decode(char *normal, const char *base64) *normal = 0; } -//////////////////////////////////////////////////////////////////////////////////////////// - -//const unsigned char g_base58_tab[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; -// -//void base58_decode(const char *input, char *output) -//{ -// int i; -// -// unsigned char decoding_tab[256]; -// memset(decoding_tab, 255, 256); -// -// for(i = 0; i < 58; i++) -// decoding_tab[g_base58_tab[i]] = i; -// -// unsigned long current = 0; -// int bit_filled = 0; -// -// for(i = 0; base58[i]; i++) -// { -// if(base58[i] == 0x0A || base58[i] == 0x0D || base58[i] == 0x20 || base58[i] == 0x09) -// continue; -// -// if(base58[i] == '=') -// break; -// -// unsigned char digit = decoding_tab[base58[i]]; -// -// current <<= 6; -// current |= digit; -// bit_filled += 6; -// -// if(bit_filled >= 8) -// { -// unsigned long b = (current >> (bit_filled - 8)); -// -// *normal++ = (unsigned char)(b & 0xFF); -// bit_filled -= 8; -// } -// } -// -// *normal = 0; -//} - /////////////////////////////////////////////////////////////////////////////////////////////// void hexlify(char *hex, const unsigned char *bin, int len) @@ -373,6 +417,14 @@ void hexlify(char *hex, const unsigned char *bin, int len) sprintf(hex+strlen(hex), "%02x", bin[i]); } +bool ishexa(char *hex, int len) +{ + for(int i=0; i= '0' && v <= '9') @@ -630,6 +682,29 @@ long long current_timestamp_dms() // allow 0.1 ms time return dms; } +int opened_files() +{ + int fds = 0; + DIR *d = opendir("/proc/self/fd"); + if (d) { + while (readdir(d)) fds++; + closedir(d); + } + return fds; +} + +int resident_size() +{ + int sz, res = 0; + FILE *fp = fopen("/proc/self/statm", "r"); + if (fp) { + int p = fscanf(fp, "%d", &sz); + if (p) p += fscanf(fp, "%d", &res); + fclose(fp); + } + return res; +} + void string_lower(char *s) { for(int i = 0; s[i]; i++) diff --git a/stratum/util.h b/stratum/util.h index 60e22629b..bf57bfd27 100644 --- a/stratum/util.h +++ b/stratum/util.h @@ -58,10 +58,13 @@ bool yaamp_error(char const *message); const char *header_value(const char *data, const char *search, char *value); void initlog(const char *algo); +void closelogs(); void debuglog(const char *format, ...); void stratumlog(const char *format, ...); +void stratumlogdate(const char *format, ...); void clientlog(YAAMP_CLIENT *client, const char *format, ...); +void rejectlog(const char *format, ...); ////////////////////////////////////////////////////////////////////////// @@ -71,6 +74,7 @@ string merkle_with_first(vector steps, string f); ////////////////////////////////////////////////////////////////////////// bool base58_decode(const char *input, char *output); +bool is_base58(char *input); void base64_encode(char *base64, const char *normal); void base64_decode(char *normal, const char *base64); @@ -83,6 +87,8 @@ void ser_string_be2(const char *input, char *output, int len); void string_be(const char *input, char *output); void string_be1(char *s); +bool ishexa(char *hex, int len); + void hexlify(char *hex, const unsigned char *bin, int len); void binlify(unsigned char *bin, const char *hex); @@ -99,6 +105,9 @@ uint64_t get_hash_difficulty(unsigned char *input); long long current_timestamp(); long long current_timestamp_dms(); +int opened_files(); +int resident_size(); + void string_lower(char *s); void string_upper(char *s); diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/tests/.gitkeep @@ -0,0 +1 @@ + diff --git a/web/blocks.sh b/web/blocks.sh index 42b40be5a..a6e5e3227 100755 --- a/web/blocks.sh +++ b/web/blocks.sh @@ -1,10 +1,15 @@ #!/bin/bash -alias php5='php -d max_execution_time=60' +PHP_CLI='php -d max_execution_time=60' + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +cd ${DIR} + +date +echo started in ${DIR} -cd /var/web while true; do - php5 run.php cronjob/runBlocks + ${PHP_CLI} runconsole.php cronjob/runBlocks sleep 20 done exec bash diff --git a/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/schema.ser b/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/schema.ser deleted file mode 100644 index 22ea32185..000000000 Binary files a/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/schema.ser and /dev/null differ diff --git a/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/Filter/YouTube.php b/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/Filter/YouTube.php deleted file mode 100644 index 23df221ea..000000000 --- a/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/Filter/YouTube.php +++ /dev/null @@ -1,39 +0,0 @@ -]+>.+?'. - 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s'; - $pre_replace = '\1'; - return preg_replace($pre_regex, $pre_replace, $html); - } - - public function postFilter($html, $config, $context) { - $post_regex = '#((?:v|cp)/[A-Za-z0-9\-_=]+)#'; - return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html); - } - - protected function armorUrl($url) { - return str_replace('--', '--', $url); - } - - protected function postFilterCallback($matches) { - $url = $this->armorUrl($matches[1]); - return ''. - ''. - ''. - ''; - - } -} - -// vim: et sw=4 sts=4 diff --git a/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/Lexer/PH5P.php b/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/Lexer/PH5P.php deleted file mode 100644 index faf00b829..000000000 --- a/web/framework-1.1.17/vendors/htmlpurifier/standalone/HTMLPurifier/Lexer/PH5P.php +++ /dev/null @@ -1,3904 +0,0 @@ -normalize($html, $config, $context); - $new_html = $this->wrapHTML($new_html, $config, $context); - try { - $parser = new HTML5($new_html); - $doc = $parser->save(); - } catch (DOMException $e) { - // Uh oh, it failed. Punt to DirectLex. - $lexer = new HTMLPurifier_Lexer_DirectLex(); - $context->register('PH5PError', $e); // save the error, so we can detect it - return $lexer->tokenizeHTML($html, $config, $context); // use original HTML - } - $tokens = array(); - $this->tokenizeDOM( - $doc->getElementsByTagName('html')->item(0)-> // - getElementsByTagName('body')->item(0)-> // - getElementsByTagName('div')->item(0) //
- , $tokens); - return $tokens; - } - -} - -/* - -Copyright 2007 Jeroen van der Meer - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -*/ - -class HTML5 { - private $data; - private $char; - private $EOF; - private $state; - private $tree; - private $token; - private $content_model; - private $escape = false; - private $entities = array('AElig;','AElig','AMP;','AMP','Aacute;','Aacute', - 'Acirc;','Acirc','Agrave;','Agrave','Alpha;','Aring;','Aring','Atilde;', - 'Atilde','Auml;','Auml','Beta;','COPY;','COPY','Ccedil;','Ccedil','Chi;', - 'Dagger;','Delta;','ETH;','ETH','Eacute;','Eacute','Ecirc;','Ecirc','Egrave;', - 'Egrave','Epsilon;','Eta;','Euml;','Euml','GT;','GT','Gamma;','Iacute;', - 'Iacute','Icirc;','Icirc','Igrave;','Igrave','Iota;','Iuml;','Iuml','Kappa;', - 'LT;','LT','Lambda;','Mu;','Ntilde;','Ntilde','Nu;','OElig;','Oacute;', - 'Oacute','Ocirc;','Ocirc','Ograve;','Ograve','Omega;','Omicron;','Oslash;', - 'Oslash','Otilde;','Otilde','Ouml;','Ouml','Phi;','Pi;','Prime;','Psi;', - 'QUOT;','QUOT','REG;','REG','Rho;','Scaron;','Sigma;','THORN;','THORN', - 'TRADE;','Tau;','Theta;','Uacute;','Uacute','Ucirc;','Ucirc','Ugrave;', - 'Ugrave','Upsilon;','Uuml;','Uuml','Xi;','Yacute;','Yacute','Yuml;','Zeta;', - 'aacute;','aacute','acirc;','acirc','acute;','acute','aelig;','aelig', - 'agrave;','agrave','alefsym;','alpha;','amp;','amp','and;','ang;','apos;', - 'aring;','aring','asymp;','atilde;','atilde','auml;','auml','bdquo;','beta;', - 'brvbar;','brvbar','bull;','cap;','ccedil;','ccedil','cedil;','cedil', - 'cent;','cent','chi;','circ;','clubs;','cong;','copy;','copy','crarr;', - 'cup;','curren;','curren','dArr;','dagger;','darr;','deg;','deg','delta;', - 'diams;','divide;','divide','eacute;','eacute','ecirc;','ecirc','egrave;', - 'egrave','empty;','emsp;','ensp;','epsilon;','equiv;','eta;','eth;','eth', - 'euml;','euml','euro;','exist;','fnof;','forall;','frac12;','frac12', - 'frac14;','frac14','frac34;','frac34','frasl;','gamma;','ge;','gt;','gt', - 'hArr;','harr;','hearts;','hellip;','iacute;','iacute','icirc;','icirc', - 'iexcl;','iexcl','igrave;','igrave','image;','infin;','int;','iota;', - 'iquest;','iquest','isin;','iuml;','iuml','kappa;','lArr;','lambda;','lang;', - 'laquo;','laquo','larr;','lceil;','ldquo;','le;','lfloor;','lowast;','loz;', - 'lrm;','lsaquo;','lsquo;','lt;','lt','macr;','macr','mdash;','micro;','micro', - 'middot;','middot','minus;','mu;','nabla;','nbsp;','nbsp','ndash;','ne;', - 'ni;','not;','not','notin;','nsub;','ntilde;','ntilde','nu;','oacute;', - 'oacute','ocirc;','ocirc','oelig;','ograve;','ograve','oline;','omega;', - 'omicron;','oplus;','or;','ordf;','ordf','ordm;','ordm','oslash;','oslash', - 'otilde;','otilde','otimes;','ouml;','ouml','para;','para','part;','permil;', - 'perp;','phi;','pi;','piv;','plusmn;','plusmn','pound;','pound','prime;', - 'prod;','prop;','psi;','quot;','quot','rArr;','radic;','rang;','raquo;', - 'raquo','rarr;','rceil;','rdquo;','real;','reg;','reg','rfloor;','rho;', - 'rlm;','rsaquo;','rsquo;','sbquo;','scaron;','sdot;','sect;','sect','shy;', - 'shy','sigma;','sigmaf;','sim;','spades;','sub;','sube;','sum;','sup1;', - 'sup1','sup2;','sup2','sup3;','sup3','sup;','supe;','szlig;','szlig','tau;', - 'there4;','theta;','thetasym;','thinsp;','thorn;','thorn','tilde;','times;', - 'times','trade;','uArr;','uacute;','uacute','uarr;','ucirc;','ucirc', - 'ugrave;','ugrave','uml;','uml','upsih;','upsilon;','uuml;','uuml','weierp;', - 'xi;','yacute;','yacute','yen;','yen','yuml;','yuml','zeta;','zwj;','zwnj;'); - - const PCDATA = 0; - const RCDATA = 1; - const CDATA = 2; - const PLAINTEXT = 3; - - const DOCTYPE = 0; - const STARTTAG = 1; - const ENDTAG = 2; - const COMMENT = 3; - const CHARACTR = 4; - const EOF = 5; - - public function __construct($data) { - - $this->data = $data; - $this->char = -1; - $this->EOF = strlen($data); - $this->tree = new HTML5TreeConstructer; - $this->content_model = self::PCDATA; - - $this->state = 'data'; - - while($this->state !== null) { - $this->{$this->state.'State'}(); - } - } - - public function save() { - return $this->tree->save(); - } - - private function char() { - return ($this->char < $this->EOF) - ? $this->data[$this->char] - : false; - } - - private function character($s, $l = 0) { - if($s + $l < $this->EOF) { - if($l === 0) { - return $this->data[$s]; - } else { - return substr($this->data, $s, $l); - } - } - } - - private function characters($char_class, $start) { - return preg_replace('#^(['.$char_class.']+).*#s', '\\1', substr($this->data, $start)); - } - - private function dataState() { - // Consume the next input character - $this->char++; - $char = $this->char(); - - if($char === '&' && ($this->content_model === self::PCDATA || $this->content_model === self::RCDATA)) { - /* U+0026 AMPERSAND (&) - When the content model flag is set to one of the PCDATA or RCDATA - states: switch to the entity data state. Otherwise: treat it as per - the "anything else" entry below. */ - $this->state = 'entityData'; - - } elseif($char === '-') { - /* If the content model flag is set to either the RCDATA state or - the CDATA state, and the escape flag is false, and there are at - least three characters before this one in the input stream, and the - last four characters in the input stream, including this one, are - U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, - and U+002D HYPHEN-MINUS (""), - set the escape flag to false. */ - if(($this->content_model === self::RCDATA || - $this->content_model === self::CDATA) && $this->escape === true && - $this->character($this->char, 3) === '-->') { - $this->escape = false; - } - - /* In any case, emit the input character as a character token. - Stay in the data state. */ - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => $char - )); - - } elseif($this->char === $this->EOF) { - /* EOF - Emit an end-of-file token. */ - $this->EOF(); - - } elseif($this->content_model === self::PLAINTEXT) { - /* When the content model flag is set to the PLAINTEXT state - THIS DIFFERS GREATLY FROM THE SPEC: Get the remaining characters of - the text and emit it as a character token. */ - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => substr($this->data, $this->char) - )); - - $this->EOF(); - - } else { - /* Anything else - THIS DIFFERS GREATLY FROM THE SPEC: Get as many character that - otherwise would also be treated as a character token and emit it - as a single character token. Stay in the data state. */ - $len = strcspn($this->data, '<&', $this->char); - $char = substr($this->data, $this->char, $len); - $this->char += $len - 1; - - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => $char - )); - - $this->state = 'data'; - } - } - - private function entityDataState() { - // Attempt to consume an entity. - $entity = $this->entity(); - - // If nothing is returned, emit a U+0026 AMPERSAND character token. - // Otherwise, emit the character token that was returned. - $char = (!$entity) ? '&' : $entity; - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => $char - )); - - // Finally, switch to the data state. - $this->state = 'data'; - } - - private function tagOpenState() { - switch($this->content_model) { - case self::RCDATA: - case self::CDATA: - /* If the next input character is a U+002F SOLIDUS (/) character, - consume it and switch to the close tag open state. If the next - input character is not a U+002F SOLIDUS (/) character, emit a - U+003C LESS-THAN SIGN character token and switch to the data - state to process the next input character. */ - if($this->character($this->char + 1) === '/') { - $this->char++; - $this->state = 'closeTagOpen'; - - } else { - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => '<' - )); - - $this->state = 'data'; - } - break; - - case self::PCDATA: - // If the content model flag is set to the PCDATA state - // Consume the next input character: - $this->char++; - $char = $this->char(); - - if($char === '!') { - /* U+0021 EXCLAMATION MARK (!) - Switch to the markup declaration open state. */ - $this->state = 'markupDeclarationOpen'; - - } elseif($char === '/') { - /* U+002F SOLIDUS (/) - Switch to the close tag open state. */ - $this->state = 'closeTagOpen'; - - } elseif(preg_match('/^[A-Za-z]$/', $char)) { - /* U+0041 LATIN LETTER A through to U+005A LATIN LETTER Z - Create a new start tag token, set its tag name to the lowercase - version of the input character (add 0x0020 to the character's code - point), then switch to the tag name state. (Don't emit the token - yet; further details will be filled in before it is emitted.) */ - $this->token = array( - 'name' => strtolower($char), - 'type' => self::STARTTAG, - 'attr' => array() - ); - - $this->state = 'tagName'; - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Parse error. Emit a U+003C LESS-THAN SIGN character token and a - U+003E GREATER-THAN SIGN character token. Switch to the data state. */ - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => '<>' - )); - - $this->state = 'data'; - - } elseif($char === '?') { - /* U+003F QUESTION MARK (?) - Parse error. Switch to the bogus comment state. */ - $this->state = 'bogusComment'; - - } else { - /* Anything else - Parse error. Emit a U+003C LESS-THAN SIGN character token and - reconsume the current input character in the data state. */ - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => '<' - )); - - $this->char--; - $this->state = 'data'; - } - break; - } - } - - private function closeTagOpenState() { - $next_node = strtolower($this->characters('A-Za-z', $this->char + 1)); - $the_same = count($this->tree->stack) > 0 && $next_node === end($this->tree->stack)->nodeName; - - if(($this->content_model === self::RCDATA || $this->content_model === self::CDATA) && - (!$the_same || ($the_same && (!preg_match('/[\t\n\x0b\x0c >\/]/', - $this->character($this->char + 1 + strlen($next_node))) || $this->EOF === $this->char)))) { - /* If the content model flag is set to the RCDATA or CDATA states then - examine the next few characters. If they do not match the tag name of - the last start tag token emitted (case insensitively), or if they do but - they are not immediately followed by one of the following characters: - * U+0009 CHARACTER TABULATION - * U+000A LINE FEED (LF) - * U+000B LINE TABULATION - * U+000C FORM FEED (FF) - * U+0020 SPACE - * U+003E GREATER-THAN SIGN (>) - * U+002F SOLIDUS (/) - * EOF - ...then there is a parse error. Emit a U+003C LESS-THAN SIGN character - token, a U+002F SOLIDUS character token, and switch to the data state - to process the next input character. */ - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => 'state = 'data'; - - } else { - /* Otherwise, if the content model flag is set to the PCDATA state, - or if the next few characters do match that tag name, consume the - next input character: */ - $this->char++; - $char = $this->char(); - - if(preg_match('/^[A-Za-z]$/', $char)) { - /* U+0041 LATIN LETTER A through to U+005A LATIN LETTER Z - Create a new end tag token, set its tag name to the lowercase version - of the input character (add 0x0020 to the character's code point), then - switch to the tag name state. (Don't emit the token yet; further details - will be filled in before it is emitted.) */ - $this->token = array( - 'name' => strtolower($char), - 'type' => self::ENDTAG - ); - - $this->state = 'tagName'; - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Parse error. Switch to the data state. */ - $this->state = 'data'; - - } elseif($this->char === $this->EOF) { - /* EOF - Parse error. Emit a U+003C LESS-THAN SIGN character token and a U+002F - SOLIDUS character token. Reconsume the EOF character in the data state. */ - $this->emitToken(array( - 'type' => self::CHARACTR, - 'data' => 'char--; - $this->state = 'data'; - - } else { - /* Parse error. Switch to the bogus comment state. */ - $this->state = 'bogusComment'; - } - } - } - - private function tagNameState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - /* U+0009 CHARACTER TABULATION - U+000A LINE FEED (LF) - U+000B LINE TABULATION - U+000C FORM FEED (FF) - U+0020 SPACE - Switch to the before attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Emit the current tag token. Switch to the data state. */ - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif($this->char === $this->EOF) { - /* EOF - Parse error. Emit the current tag token. Reconsume the EOF - character in the data state. */ - $this->emitToken($this->token); - - $this->char--; - $this->state = 'data'; - - } elseif($char === '/') { - /* U+002F SOLIDUS (/) - Parse error unless this is a permitted slash. Switch to the before - attribute name state. */ - $this->state = 'beforeAttributeName'; - - } else { - /* Anything else - Append the current input character to the current tag token's tag name. - Stay in the tag name state. */ - $this->token['name'] .= strtolower($char); - $this->state = 'tagName'; - } - } - - private function beforeAttributeNameState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - /* U+0009 CHARACTER TABULATION - U+000A LINE FEED (LF) - U+000B LINE TABULATION - U+000C FORM FEED (FF) - U+0020 SPACE - Stay in the before attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Emit the current tag token. Switch to the data state. */ - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif($char === '/') { - /* U+002F SOLIDUS (/) - Parse error unless this is a permitted slash. Stay in the before - attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($this->char === $this->EOF) { - /* EOF - Parse error. Emit the current tag token. Reconsume the EOF - character in the data state. */ - $this->emitToken($this->token); - - $this->char--; - $this->state = 'data'; - - } else { - /* Anything else - Start a new attribute in the current tag token. Set that attribute's - name to the current input character, and its value to the empty string. - Switch to the attribute name state. */ - $this->token['attr'][] = array( - 'name' => strtolower($char), - 'value' => null - ); - - $this->state = 'attributeName'; - } - } - - private function attributeNameState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - /* U+0009 CHARACTER TABULATION - U+000A LINE FEED (LF) - U+000B LINE TABULATION - U+000C FORM FEED (FF) - U+0020 SPACE - Stay in the before attribute name state. */ - $this->state = 'afterAttributeName'; - - } elseif($char === '=') { - /* U+003D EQUALS SIGN (=) - Switch to the before attribute value state. */ - $this->state = 'beforeAttributeValue'; - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Emit the current tag token. Switch to the data state. */ - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif($char === '/' && $this->character($this->char + 1) !== '>') { - /* U+002F SOLIDUS (/) - Parse error unless this is a permitted slash. Switch to the before - attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($this->char === $this->EOF) { - /* EOF - Parse error. Emit the current tag token. Reconsume the EOF - character in the data state. */ - $this->emitToken($this->token); - - $this->char--; - $this->state = 'data'; - - } else { - /* Anything else - Append the current input character to the current attribute's name. - Stay in the attribute name state. */ - $last = count($this->token['attr']) - 1; - $this->token['attr'][$last]['name'] .= strtolower($char); - - $this->state = 'attributeName'; - } - } - - private function afterAttributeNameState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - /* U+0009 CHARACTER TABULATION - U+000A LINE FEED (LF) - U+000B LINE TABULATION - U+000C FORM FEED (FF) - U+0020 SPACE - Stay in the after attribute name state. */ - $this->state = 'afterAttributeName'; - - } elseif($char === '=') { - /* U+003D EQUALS SIGN (=) - Switch to the before attribute value state. */ - $this->state = 'beforeAttributeValue'; - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Emit the current tag token. Switch to the data state. */ - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif($char === '/' && $this->character($this->char + 1) !== '>') { - /* U+002F SOLIDUS (/) - Parse error unless this is a permitted slash. Switch to the - before attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($this->char === $this->EOF) { - /* EOF - Parse error. Emit the current tag token. Reconsume the EOF - character in the data state. */ - $this->emitToken($this->token); - - $this->char--; - $this->state = 'data'; - - } else { - /* Anything else - Start a new attribute in the current tag token. Set that attribute's - name to the current input character, and its value to the empty string. - Switch to the attribute name state. */ - $this->token['attr'][] = array( - 'name' => strtolower($char), - 'value' => null - ); - - $this->state = 'attributeName'; - } - } - - private function beforeAttributeValueState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - /* U+0009 CHARACTER TABULATION - U+000A LINE FEED (LF) - U+000B LINE TABULATION - U+000C FORM FEED (FF) - U+0020 SPACE - Stay in the before attribute value state. */ - $this->state = 'beforeAttributeValue'; - - } elseif($char === '"') { - /* U+0022 QUOTATION MARK (") - Switch to the attribute value (double-quoted) state. */ - $this->state = 'attributeValueDoubleQuoted'; - - } elseif($char === '&') { - /* U+0026 AMPERSAND (&) - Switch to the attribute value (unquoted) state and reconsume - this input character. */ - $this->char--; - $this->state = 'attributeValueUnquoted'; - - } elseif($char === '\'') { - /* U+0027 APOSTROPHE (') - Switch to the attribute value (single-quoted) state. */ - $this->state = 'attributeValueSingleQuoted'; - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Emit the current tag token. Switch to the data state. */ - $this->emitToken($this->token); - $this->state = 'data'; - - } else { - /* Anything else - Append the current input character to the current attribute's value. - Switch to the attribute value (unquoted) state. */ - $last = count($this->token['attr']) - 1; - $this->token['attr'][$last]['value'] .= $char; - - $this->state = 'attributeValueUnquoted'; - } - } - - private function attributeValueDoubleQuotedState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if($char === '"') { - /* U+0022 QUOTATION MARK (") - Switch to the before attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($char === '&') { - /* U+0026 AMPERSAND (&) - Switch to the entity in attribute value state. */ - $this->entityInAttributeValueState('double'); - - } elseif($this->char === $this->EOF) { - /* EOF - Parse error. Emit the current tag token. Reconsume the character - in the data state. */ - $this->emitToken($this->token); - - $this->char--; - $this->state = 'data'; - - } else { - /* Anything else - Append the current input character to the current attribute's value. - Stay in the attribute value (double-quoted) state. */ - $last = count($this->token['attr']) - 1; - $this->token['attr'][$last]['value'] .= $char; - - $this->state = 'attributeValueDoubleQuoted'; - } - } - - private function attributeValueSingleQuotedState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if($char === '\'') { - /* U+0022 QUOTATION MARK (') - Switch to the before attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($char === '&') { - /* U+0026 AMPERSAND (&) - Switch to the entity in attribute value state. */ - $this->entityInAttributeValueState('single'); - - } elseif($this->char === $this->EOF) { - /* EOF - Parse error. Emit the current tag token. Reconsume the character - in the data state. */ - $this->emitToken($this->token); - - $this->char--; - $this->state = 'data'; - - } else { - /* Anything else - Append the current input character to the current attribute's value. - Stay in the attribute value (single-quoted) state. */ - $last = count($this->token['attr']) - 1; - $this->token['attr'][$last]['value'] .= $char; - - $this->state = 'attributeValueSingleQuoted'; - } - } - - private function attributeValueUnquotedState() { - // Consume the next input character: - $this->char++; - $char = $this->character($this->char); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - /* U+0009 CHARACTER TABULATION - U+000A LINE FEED (LF) - U+000B LINE TABULATION - U+000C FORM FEED (FF) - U+0020 SPACE - Switch to the before attribute name state. */ - $this->state = 'beforeAttributeName'; - - } elseif($char === '&') { - /* U+0026 AMPERSAND (&) - Switch to the entity in attribute value state. */ - $this->entityInAttributeValueState(); - - } elseif($char === '>') { - /* U+003E GREATER-THAN SIGN (>) - Emit the current tag token. Switch to the data state. */ - $this->emitToken($this->token); - $this->state = 'data'; - - } else { - /* Anything else - Append the current input character to the current attribute's value. - Stay in the attribute value (unquoted) state. */ - $last = count($this->token['attr']) - 1; - $this->token['attr'][$last]['value'] .= $char; - - $this->state = 'attributeValueUnquoted'; - } - } - - private function entityInAttributeValueState() { - // Attempt to consume an entity. - $entity = $this->entity(); - - // If nothing is returned, append a U+0026 AMPERSAND character to the - // current attribute's value. Otherwise, emit the character token that - // was returned. - $char = (!$entity) - ? '&' - : $entity; - - $last = count($this->token['attr']) - 1; - $this->token['attr'][$last]['value'] .= $char; - } - - private function bogusCommentState() { - /* Consume every character up to the first U+003E GREATER-THAN SIGN - character (>) or the end of the file (EOF), whichever comes first. Emit - a comment token whose data is the concatenation of all the characters - starting from and including the character that caused the state machine - to switch into the bogus comment state, up to and including the last - consumed character before the U+003E character, if any, or up to the - end of the file otherwise. (If the comment was started by the end of - the file (EOF), the token is empty.) */ - $data = $this->characters('^>', $this->char); - $this->emitToken(array( - 'data' => $data, - 'type' => self::COMMENT - )); - - $this->char += strlen($data); - - /* Switch to the data state. */ - $this->state = 'data'; - - /* If the end of the file was reached, reconsume the EOF character. */ - if($this->char === $this->EOF) { - $this->char = $this->EOF - 1; - } - } - - private function markupDeclarationOpenState() { - /* If the next two characters are both U+002D HYPHEN-MINUS (-) - characters, consume those two characters, create a comment token whose - data is the empty string, and switch to the comment state. */ - if($this->character($this->char + 1, 2) === '--') { - $this->char += 2; - $this->state = 'comment'; - $this->token = array( - 'data' => null, - 'type' => self::COMMENT - ); - - /* Otherwise if the next seven chacacters are a case-insensitive match - for the word "DOCTYPE", then consume those characters and switch to the - DOCTYPE state. */ - } elseif(strtolower($this->character($this->char + 1, 7)) === 'doctype') { - $this->char += 7; - $this->state = 'doctype'; - - /* Otherwise, is is a parse error. Switch to the bogus comment state. - The next character that is consumed, if any, is the first character - that will be in the comment. */ - } else { - $this->char++; - $this->state = 'bogusComment'; - } - } - - private function commentState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - /* U+002D HYPHEN-MINUS (-) */ - if($char === '-') { - /* Switch to the comment dash state */ - $this->state = 'commentDash'; - - /* EOF */ - } elseif($this->char === $this->EOF) { - /* Parse error. Emit the comment token. Reconsume the EOF character - in the data state. */ - $this->emitToken($this->token); - $this->char--; - $this->state = 'data'; - - /* Anything else */ - } else { - /* Append the input character to the comment token's data. Stay in - the comment state. */ - $this->token['data'] .= $char; - } - } - - private function commentDashState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - /* U+002D HYPHEN-MINUS (-) */ - if($char === '-') { - /* Switch to the comment end state */ - $this->state = 'commentEnd'; - - /* EOF */ - } elseif($this->char === $this->EOF) { - /* Parse error. Emit the comment token. Reconsume the EOF character - in the data state. */ - $this->emitToken($this->token); - $this->char--; - $this->state = 'data'; - - /* Anything else */ - } else { - /* Append a U+002D HYPHEN-MINUS (-) character and the input - character to the comment token's data. Switch to the comment state. */ - $this->token['data'] .= '-'.$char; - $this->state = 'comment'; - } - } - - private function commentEndState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - if($char === '>') { - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif($char === '-') { - $this->token['data'] .= '-'; - - } elseif($this->char === $this->EOF) { - $this->emitToken($this->token); - $this->char--; - $this->state = 'data'; - - } else { - $this->token['data'] .= '--'.$char; - $this->state = 'comment'; - } - } - - private function doctypeState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - $this->state = 'beforeDoctypeName'; - - } else { - $this->char--; - $this->state = 'beforeDoctypeName'; - } - } - - private function beforeDoctypeNameState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - // Stay in the before DOCTYPE name state. - - } elseif(preg_match('/^[a-z]$/', $char)) { - $this->token = array( - 'name' => strtoupper($char), - 'type' => self::DOCTYPE, - 'error' => true - ); - - $this->state = 'doctypeName'; - - } elseif($char === '>') { - $this->emitToken(array( - 'name' => null, - 'type' => self::DOCTYPE, - 'error' => true - )); - - $this->state = 'data'; - - } elseif($this->char === $this->EOF) { - $this->emitToken(array( - 'name' => null, - 'type' => self::DOCTYPE, - 'error' => true - )); - - $this->char--; - $this->state = 'data'; - - } else { - $this->token = array( - 'name' => $char, - 'type' => self::DOCTYPE, - 'error' => true - ); - - $this->state = 'doctypeName'; - } - } - - private function doctypeNameState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - $this->state = 'AfterDoctypeName'; - - } elseif($char === '>') { - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif(preg_match('/^[a-z]$/', $char)) { - $this->token['name'] .= strtoupper($char); - - } elseif($this->char === $this->EOF) { - $this->emitToken($this->token); - $this->char--; - $this->state = 'data'; - - } else { - $this->token['name'] .= $char; - } - - $this->token['error'] = ($this->token['name'] === 'HTML') - ? false - : true; - } - - private function afterDoctypeNameState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - if(preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { - // Stay in the DOCTYPE name state. - - } elseif($char === '>') { - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif($this->char === $this->EOF) { - $this->emitToken($this->token); - $this->char--; - $this->state = 'data'; - - } else { - $this->token['error'] = true; - $this->state = 'bogusDoctype'; - } - } - - private function bogusDoctypeState() { - /* Consume the next input character: */ - $this->char++; - $char = $this->char(); - - if($char === '>') { - $this->emitToken($this->token); - $this->state = 'data'; - - } elseif($this->char === $this->EOF) { - $this->emitToken($this->token); - $this->char--; - $this->state = 'data'; - - } else { - // Stay in the bogus DOCTYPE state. - } - } - - private function entity() { - $start = $this->char; - - // This section defines how to consume an entity. This definition is - // used when parsing entities in text and in attributes. - - // The behaviour depends on the identity of the next character (the - // one immediately after the U+0026 AMPERSAND character): - - switch($this->character($this->char + 1)) { - // U+0023 NUMBER SIGN (#) - case '#': - - // The behaviour further depends on the character after the - // U+0023 NUMBER SIGN: - switch($this->character($this->char + 1)) { - // U+0078 LATIN SMALL LETTER X - // U+0058 LATIN CAPITAL LETTER X - case 'x': - case 'X': - // Follow the steps below, but using the range of - // characters U+0030 DIGIT ZERO through to U+0039 DIGIT - // NINE, U+0061 LATIN SMALL LETTER A through to U+0066 - // LATIN SMALL LETTER F, and U+0041 LATIN CAPITAL LETTER - // A, through to U+0046 LATIN CAPITAL LETTER F (in other - // words, 0-9, A-F, a-f). - $char = 1; - $char_class = '0-9A-Fa-f'; - break; - - // Anything else - default: - // Follow the steps below, but using the range of - // characters U+0030 DIGIT ZERO through to U+0039 DIGIT - // NINE (i.e. just 0-9). - $char = 0; - $char_class = '0-9'; - break; - } - - // Consume as many characters as match the range of characters - // given above. - $this->char++; - $e_name = $this->characters($char_class, $this->char + $char + 1); - $entity = $this->character($start, $this->char); - $cond = strlen($e_name) > 0; - - // The rest of the parsing happens bellow. - break; - - // Anything else - default: - // Consume the maximum number of characters possible, with the - // consumed characters case-sensitively matching one of the - // identifiers in the first column of the entities table. - $e_name = $this->characters('0-9A-Za-z;', $this->char + 1); - $len = strlen($e_name); - - for($c = 1; $c <= $len; $c++) { - $id = substr($e_name, 0, $c); - $this->char++; - - if(in_array($id, $this->entities)) { - if ($e_name[$c-1] !== ';') { - if ($c < $len && $e_name[$c] == ';') { - $this->char++; // consume extra semicolon - } - } - $entity = $id; - break; - } - } - - $cond = isset($entity); - // The rest of the parsing happens bellow. - break; - } - - if(!$cond) { - // If no match can be made, then this is a parse error. No - // characters are consumed, and nothing is returned. - $this->char = $start; - return false; - } - - // Return a character token for the character corresponding to the - // entity name (as given by the second column of the entities table). - return html_entity_decode('&'.$entity.';', ENT_QUOTES, 'UTF-8'); - } - - private function emitToken($token) { - $emit = $this->tree->emitToken($token); - - if(is_int($emit)) { - $this->content_model = $emit; - - } elseif($token['type'] === self::ENDTAG) { - $this->content_model = self::PCDATA; - } - } - - private function EOF() { - $this->state = null; - $this->tree->emitToken(array( - 'type' => self::EOF - )); - } -} - -class HTML5TreeConstructer { - public $stack = array(); - - private $phase; - private $mode; - private $dom; - private $foster_parent = null; - private $a_formatting = array(); - - private $head_pointer = null; - private $form_pointer = null; - - private $scoping = array('button','caption','html','marquee','object','table','td','th'); - private $formatting = array('a','b','big','em','font','i','nobr','s','small','strike','strong','tt','u'); - private $special = array('address','area','base','basefont','bgsound', - 'blockquote','body','br','center','col','colgroup','dd','dir','div','dl', - 'dt','embed','fieldset','form','frame','frameset','h1','h2','h3','h4','h5', - 'h6','head','hr','iframe','image','img','input','isindex','li','link', - 'listing','menu','meta','noembed','noframes','noscript','ol','optgroup', - 'option','p','param','plaintext','pre','script','select','spacer','style', - 'tbody','textarea','tfoot','thead','title','tr','ul','wbr'); - - // The different phases. - const INIT_PHASE = 0; - const ROOT_PHASE = 1; - const MAIN_PHASE = 2; - const END_PHASE = 3; - - // The different insertion modes for the main phase. - const BEFOR_HEAD = 0; - const IN_HEAD = 1; - const AFTER_HEAD = 2; - const IN_BODY = 3; - const IN_TABLE = 4; - const IN_CAPTION = 5; - const IN_CGROUP = 6; - const IN_TBODY = 7; - const IN_ROW = 8; - const IN_CELL = 9; - const IN_SELECT = 10; - const AFTER_BODY = 11; - const IN_FRAME = 12; - const AFTR_FRAME = 13; - - // The different types of elements. - const SPECIAL = 0; - const SCOPING = 1; - const FORMATTING = 2; - const PHRASING = 3; - - const MARKER = 0; - - public function __construct() { - $this->phase = self::INIT_PHASE; - $this->mode = self::BEFOR_HEAD; - $this->dom = new DOMDocument; - - $this->dom->encoding = 'UTF-8'; - $this->dom->preserveWhiteSpace = true; - $this->dom->substituteEntities = true; - $this->dom->strictErrorChecking = false; - } - - // Process tag tokens - public function emitToken($token) { - switch($this->phase) { - case self::INIT_PHASE: return $this->initPhase($token); break; - case self::ROOT_PHASE: return $this->rootElementPhase($token); break; - case self::MAIN_PHASE: return $this->mainPhase($token); break; - case self::END_PHASE : return $this->trailingEndPhase($token); break; - } - } - - private function initPhase($token) { - /* Initially, the tree construction stage must handle each token - emitted from the tokenisation stage as follows: */ - - /* A DOCTYPE token that is marked as being in error - A comment token - A start tag token - An end tag token - A character token that is not one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE - An end-of-file token */ - if((isset($token['error']) && $token['error']) || - $token['type'] === HTML5::COMMENT || - $token['type'] === HTML5::STARTTAG || - $token['type'] === HTML5::ENDTAG || - $token['type'] === HTML5::EOF || - ($token['type'] === HTML5::CHARACTR && isset($token['data']) && - !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']))) { - /* This specification does not define how to handle this case. In - particular, user agents may ignore the entirety of this specification - altogether for such documents, and instead invoke special parse modes - with a greater emphasis on backwards compatibility. */ - - $this->phase = self::ROOT_PHASE; - return $this->rootElementPhase($token); - - /* A DOCTYPE token marked as being correct */ - } elseif(isset($token['error']) && !$token['error']) { - /* Append a DocumentType node to the Document node, with the name - attribute set to the name given in the DOCTYPE token (which will be - "HTML"), and the other attributes specific to DocumentType objects - set to null, empty lists, or the empty string as appropriate. */ - $doctype = new DOMDocumentType(null, null, 'HTML'); - - /* Then, switch to the root element phase of the tree construction - stage. */ - $this->phase = self::ROOT_PHASE; - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - } elseif(isset($token['data']) && preg_match('/^[\t\n\x0b\x0c ]+$/', - $token['data'])) { - /* Append that character to the Document node. */ - $text = $this->dom->createTextNode($token['data']); - $this->dom->appendChild($text); - } - } - - private function rootElementPhase($token) { - /* After the initial phase, as each token is emitted from the tokenisation - stage, it must be processed as described in this section. */ - - /* A DOCTYPE token */ - if($token['type'] === HTML5::DOCTYPE) { - // Parse error. Ignore the token. - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the Document object with the data - attribute set to the data given in the comment token. */ - $comment = $this->dom->createComment($token['data']); - $this->dom->appendChild($comment); - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - } elseif($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Append that character to the Document node. */ - $text = $this->dom->createTextNode($token['data']); - $this->dom->appendChild($text); - - /* A character token that is not one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED - (FF), or U+0020 SPACE - A start tag token - An end tag token - An end-of-file token */ - } elseif(($token['type'] === HTML5::CHARACTR && - !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || - $token['type'] === HTML5::STARTTAG || - $token['type'] === HTML5::ENDTAG || - $token['type'] === HTML5::EOF) { - /* Create an HTMLElement node with the tag name html, in the HTML - namespace. Append it to the Document object. Switch to the main - phase and reprocess the current token. */ - $html = $this->dom->createElement('html'); - $this->dom->appendChild($html); - $this->stack[] = $html; - - $this->phase = self::MAIN_PHASE; - return $this->mainPhase($token); - } - } - - private function mainPhase($token) { - /* Tokens in the main phase must be handled as follows: */ - - /* A DOCTYPE token */ - if($token['type'] === HTML5::DOCTYPE) { - // Parse error. Ignore the token. - - /* A start tag token with the tag name "html" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'html') { - /* If this start tag token was not the first start tag token, then - it is a parse error. */ - - /* For each attribute on the token, check to see if the attribute - is already present on the top element of the stack of open elements. - If it is not, add the attribute and its corresponding value to that - element. */ - foreach($token['attr'] as $attr) { - if(!$this->stack[0]->hasAttribute($attr['name'])) { - $this->stack[0]->setAttribute($attr['name'], $attr['value']); - } - } - - /* An end-of-file token */ - } elseif($token['type'] === HTML5::EOF) { - /* Generate implied end tags. */ - $this->generateImpliedEndTags(); - - /* Anything else. */ - } else { - /* Depends on the insertion mode: */ - switch($this->mode) { - case self::BEFOR_HEAD: return $this->beforeHead($token); break; - case self::IN_HEAD: return $this->inHead($token); break; - case self::AFTER_HEAD: return $this->afterHead($token); break; - case self::IN_BODY: return $this->inBody($token); break; - case self::IN_TABLE: return $this->inTable($token); break; - case self::IN_CAPTION: return $this->inCaption($token); break; - case self::IN_CGROUP: return $this->inColumnGroup($token); break; - case self::IN_TBODY: return $this->inTableBody($token); break; - case self::IN_ROW: return $this->inRow($token); break; - case self::IN_CELL: return $this->inCell($token); break; - case self::IN_SELECT: return $this->inSelect($token); break; - case self::AFTER_BODY: return $this->afterBody($token); break; - case self::IN_FRAME: return $this->inFrameset($token); break; - case self::AFTR_FRAME: return $this->afterFrameset($token); break; - case self::END_PHASE: return $this->trailingEndPhase($token); break; - } - } - } - - private function beforeHead($token) { - /* Handle the token as follows: */ - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - if($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Append the character to the current node. */ - $this->insertText($token['data']); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data attribute - set to the data given in the comment token. */ - $this->insertComment($token['data']); - - /* A start tag token with the tag name "head" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') { - /* Create an element for the token, append the new element to the - current node and push it onto the stack of open elements. */ - $element = $this->insertElement($token); - - /* Set the head element pointer to this new element node. */ - $this->head_pointer = $element; - - /* Change the insertion mode to "in head". */ - $this->mode = self::IN_HEAD; - - /* A start tag token whose tag name is one of: "base", "link", "meta", - "script", "style", "title". Or an end tag with the tag name "html". - Or a character token that is not one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE. Or any other start tag token */ - } elseif($token['type'] === HTML5::STARTTAG || - ($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') || - ($token['type'] === HTML5::CHARACTR && !preg_match('/^[\t\n\x0b\x0c ]$/', - $token['data']))) { - /* Act as if a start tag token with the tag name "head" and no - attributes had been seen, then reprocess the current token. */ - $this->beforeHead(array( - 'name' => 'head', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - return $this->inHead($token); - - /* Any other end tag */ - } elseif($token['type'] === HTML5::ENDTAG) { - /* Parse error. Ignore the token. */ - } - } - - private function inHead($token) { - /* Handle the token as follows: */ - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE. - - THIS DIFFERS FROM THE SPEC: If the current node is either a title, style - or script element, append the character to the current node regardless - of its content. */ - if(($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || ( - $token['type'] === HTML5::CHARACTR && in_array(end($this->stack)->nodeName, - array('title', 'style', 'script')))) { - /* Append the character to the current node. */ - $this->insertText($token['data']); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data attribute - set to the data given in the comment token. */ - $this->insertComment($token['data']); - - } elseif($token['type'] === HTML5::ENDTAG && - in_array($token['name'], array('title', 'style', 'script'))) { - array_pop($this->stack); - return HTML5::PCDATA; - - /* A start tag with the tag name "title" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'title') { - /* Create an element for the token and append the new element to the - node pointed to by the head element pointer, or, if that is null - (innerHTML case), to the current node. */ - if($this->head_pointer !== null) { - $element = $this->insertElement($token, false); - $this->head_pointer->appendChild($element); - - } else { - $element = $this->insertElement($token); - } - - /* Switch the tokeniser's content model flag to the RCDATA state. */ - return HTML5::RCDATA; - - /* A start tag with the tag name "style" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'style') { - /* Create an element for the token and append the new element to the - node pointed to by the head element pointer, or, if that is null - (innerHTML case), to the current node. */ - if($this->head_pointer !== null) { - $element = $this->insertElement($token, false); - $this->head_pointer->appendChild($element); - - } else { - $this->insertElement($token); - } - - /* Switch the tokeniser's content model flag to the CDATA state. */ - return HTML5::CDATA; - - /* A start tag with the tag name "script" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'script') { - /* Create an element for the token. */ - $element = $this->insertElement($token, false); - $this->head_pointer->appendChild($element); - - /* Switch the tokeniser's content model flag to the CDATA state. */ - return HTML5::CDATA; - - /* A start tag with the tag name "base", "link", or "meta" */ - } elseif($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('base', 'link', 'meta'))) { - /* Create an element for the token and append the new element to the - node pointed to by the head element pointer, or, if that is null - (innerHTML case), to the current node. */ - if($this->head_pointer !== null) { - $element = $this->insertElement($token, false); - $this->head_pointer->appendChild($element); - array_pop($this->stack); - - } else { - $this->insertElement($token); - } - - /* An end tag with the tag name "head" */ - } elseif($token['type'] === HTML5::ENDTAG && $token['name'] === 'head') { - /* If the current node is a head element, pop the current node off - the stack of open elements. */ - if($this->head_pointer->isSameNode(end($this->stack))) { - array_pop($this->stack); - - /* Otherwise, this is a parse error. */ - } else { - // k - } - - /* Change the insertion mode to "after head". */ - $this->mode = self::AFTER_HEAD; - - /* A start tag with the tag name "head" or an end tag except "html". */ - } elseif(($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') || - ($token['type'] === HTML5::ENDTAG && $token['name'] !== 'html')) { - // Parse error. Ignore the token. - - /* Anything else */ - } else { - /* If the current node is a head element, act as if an end tag - token with the tag name "head" had been seen. */ - if($this->head_pointer->isSameNode(end($this->stack))) { - $this->inHead(array( - 'name' => 'head', - 'type' => HTML5::ENDTAG - )); - - /* Otherwise, change the insertion mode to "after head". */ - } else { - $this->mode = self::AFTER_HEAD; - } - - /* Then, reprocess the current token. */ - return $this->afterHead($token); - } - } - - private function afterHead($token) { - /* Handle the token as follows: */ - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - if($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Append the character to the current node. */ - $this->insertText($token['data']); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data attribute - set to the data given in the comment token. */ - $this->insertComment($token['data']); - - /* A start tag token with the tag name "body" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'body') { - /* Insert a body element for the token. */ - $this->insertElement($token); - - /* Change the insertion mode to "in body". */ - $this->mode = self::IN_BODY; - - /* A start tag token with the tag name "frameset" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'frameset') { - /* Insert a frameset element for the token. */ - $this->insertElement($token); - - /* Change the insertion mode to "in frameset". */ - $this->mode = self::IN_FRAME; - - /* A start tag token whose tag name is one of: "base", "link", "meta", - "script", "style", "title" */ - } elseif($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('base', 'link', 'meta', 'script', 'style', 'title'))) { - /* Parse error. Switch the insertion mode back to "in head" and - reprocess the token. */ - $this->mode = self::IN_HEAD; - return $this->inHead($token); - - /* Anything else */ - } else { - /* Act as if a start tag token with the tag name "body" and no - attributes had been seen, and then reprocess the current token. */ - $this->afterHead(array( - 'name' => 'body', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - return $this->inBody($token); - } - } - - private function inBody($token) { - /* Handle the token as follows: */ - - switch($token['type']) { - /* A character token */ - case HTML5::CHARACTR: - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Append the token's character to the current node. */ - $this->insertText($token['data']); - break; - - /* A comment token */ - case HTML5::COMMENT: - /* Append a Comment node to the current node with the data - attribute set to the data given in the comment token. */ - $this->insertComment($token['data']); - break; - - case HTML5::STARTTAG: - switch($token['name']) { - /* A start tag token whose tag name is one of: "script", - "style" */ - case 'script': case 'style': - /* Process the token as if the insertion mode had been "in - head". */ - return $this->inHead($token); - break; - - /* A start tag token whose tag name is one of: "base", "link", - "meta", "title" */ - case 'base': case 'link': case 'meta': case 'title': - /* Parse error. Process the token as if the insertion mode - had been "in head". */ - return $this->inHead($token); - break; - - /* A start tag token with the tag name "body" */ - case 'body': - /* Parse error. If the second element on the stack of open - elements is not a body element, or, if the stack of open - elements has only one node on it, then ignore the token. - (innerHTML case) */ - if(count($this->stack) === 1 || $this->stack[1]->nodeName !== 'body') { - // Ignore - - /* Otherwise, for each attribute on the token, check to see - if the attribute is already present on the body element (the - second element) on the stack of open elements. If it is not, - add the attribute and its corresponding value to that - element. */ - } else { - foreach($token['attr'] as $attr) { - if(!$this->stack[1]->hasAttribute($attr['name'])) { - $this->stack[1]->setAttribute($attr['name'], $attr['value']); - } - } - } - break; - - /* A start tag whose tag name is one of: "address", - "blockquote", "center", "dir", "div", "dl", "fieldset", - "listing", "menu", "ol", "p", "ul" */ - case 'address': case 'blockquote': case 'center': case 'dir': - case 'div': case 'dl': case 'fieldset': case 'listing': - case 'menu': case 'ol': case 'p': case 'ul': - /* If the stack of open elements has a p element in scope, - then act as if an end tag with the tag name p had been - seen. */ - if($this->elementInScope('p')) { - $this->emitToken(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - } - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - break; - - /* A start tag whose tag name is "form" */ - case 'form': - /* If the form element pointer is not null, ignore the - token with a parse error. */ - if($this->form_pointer !== null) { - // Ignore. - - /* Otherwise: */ - } else { - /* If the stack of open elements has a p element in - scope, then act as if an end tag with the tag name p - had been seen. */ - if($this->elementInScope('p')) { - $this->emitToken(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - } - - /* Insert an HTML element for the token, and set the - form element pointer to point to the element created. */ - $element = $this->insertElement($token); - $this->form_pointer = $element; - } - break; - - /* A start tag whose tag name is "li", "dd" or "dt" */ - case 'li': case 'dd': case 'dt': - /* If the stack of open elements has a p element in scope, - then act as if an end tag with the tag name p had been - seen. */ - if($this->elementInScope('p')) { - $this->emitToken(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - } - - $stack_length = count($this->stack) - 1; - - for($n = $stack_length; 0 <= $n; $n--) { - /* 1. Initialise node to be the current node (the - bottommost node of the stack). */ - $stop = false; - $node = $this->stack[$n]; - $cat = $this->getElementCategory($node->tagName); - - /* 2. If node is an li, dd or dt element, then pop all - the nodes from the current node up to node, including - node, then stop this algorithm. */ - if($token['name'] === $node->tagName || ($token['name'] !== 'li' - && ($node->tagName === 'dd' || $node->tagName === 'dt'))) { - for($x = $stack_length; $x >= $n ; $x--) { - array_pop($this->stack); - } - - break; - } - - /* 3. If node is not in the formatting category, and is - not in the phrasing category, and is not an address or - div element, then stop this algorithm. */ - if($cat !== self::FORMATTING && $cat !== self::PHRASING && - $node->tagName !== 'address' && $node->tagName !== 'div') { - break; - } - } - - /* Finally, insert an HTML element with the same tag - name as the token's. */ - $this->insertElement($token); - break; - - /* A start tag token whose tag name is "plaintext" */ - case 'plaintext': - /* If the stack of open elements has a p element in scope, - then act as if an end tag with the tag name p had been - seen. */ - if($this->elementInScope('p')) { - $this->emitToken(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - } - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - return HTML5::PLAINTEXT; - break; - - /* A start tag whose tag name is one of: "h1", "h2", "h3", "h4", - "h5", "h6" */ - case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': - /* If the stack of open elements has a p element in scope, - then act as if an end tag with the tag name p had been seen. */ - if($this->elementInScope('p')) { - $this->emitToken(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - } - - /* If the stack of open elements has in scope an element whose - tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then - this is a parse error; pop elements from the stack until an - element with one of those tag names has been popped from the - stack. */ - while($this->elementInScope(array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) { - array_pop($this->stack); - } - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - break; - - /* A start tag whose tag name is "a" */ - case 'a': - /* If the list of active formatting elements contains - an element whose tag name is "a" between the end of the - list and the last marker on the list (or the start of - the list if there is no marker on the list), then this - is a parse error; act as if an end tag with the tag name - "a" had been seen, then remove that element from the list - of active formatting elements and the stack of open - elements if the end tag didn't already remove it (it - might not have if the element is not in table scope). */ - $leng = count($this->a_formatting); - - for($n = $leng - 1; $n >= 0; $n--) { - if($this->a_formatting[$n] === self::MARKER) { - break; - - } elseif($this->a_formatting[$n]->nodeName === 'a') { - $this->emitToken(array( - 'name' => 'a', - 'type' => HTML5::ENDTAG - )); - break; - } - } - - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an HTML element for the token. */ - $el = $this->insertElement($token); - - /* Add that element to the list of active formatting - elements. */ - $this->a_formatting[] = $el; - break; - - /* A start tag whose tag name is one of: "b", "big", "em", "font", - "i", "nobr", "s", "small", "strike", "strong", "tt", "u" */ - case 'b': case 'big': case 'em': case 'font': case 'i': - case 'nobr': case 's': case 'small': case 'strike': - case 'strong': case 'tt': case 'u': - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an HTML element for the token. */ - $el = $this->insertElement($token); - - /* Add that element to the list of active formatting - elements. */ - $this->a_formatting[] = $el; - break; - - /* A start tag token whose tag name is "button" */ - case 'button': - /* If the stack of open elements has a button element in scope, - then this is a parse error; act as if an end tag with the tag - name "button" had been seen, then reprocess the token. (We don't - do that. Unnecessary.) */ - if($this->elementInScope('button')) { - $this->inBody(array( - 'name' => 'button', - 'type' => HTML5::ENDTAG - )); - } - - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Insert a marker at the end of the list of active - formatting elements. */ - $this->a_formatting[] = self::MARKER; - break; - - /* A start tag token whose tag name is one of: "marquee", "object" */ - case 'marquee': case 'object': - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Insert a marker at the end of the list of active - formatting elements. */ - $this->a_formatting[] = self::MARKER; - break; - - /* A start tag token whose tag name is "xmp" */ - case 'xmp': - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Switch the content model flag to the CDATA state. */ - return HTML5::CDATA; - break; - - /* A start tag whose tag name is "table" */ - case 'table': - /* If the stack of open elements has a p element in scope, - then act as if an end tag with the tag name p had been seen. */ - if($this->elementInScope('p')) { - $this->emitToken(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - } - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Change the insertion mode to "in table". */ - $this->mode = self::IN_TABLE; - break; - - /* A start tag whose tag name is one of: "area", "basefont", - "bgsound", "br", "embed", "img", "param", "spacer", "wbr" */ - case 'area': case 'basefont': case 'bgsound': case 'br': - case 'embed': case 'img': case 'param': case 'spacer': - case 'wbr': - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Immediately pop the current node off the stack of open elements. */ - array_pop($this->stack); - break; - - /* A start tag whose tag name is "hr" */ - case 'hr': - /* If the stack of open elements has a p element in scope, - then act as if an end tag with the tag name p had been seen. */ - if($this->elementInScope('p')) { - $this->emitToken(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - } - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Immediately pop the current node off the stack of open elements. */ - array_pop($this->stack); - break; - - /* A start tag whose tag name is "image" */ - case 'image': - /* Parse error. Change the token's tag name to "img" and - reprocess it. (Don't ask.) */ - $token['name'] = 'img'; - return $this->inBody($token); - break; - - /* A start tag whose tag name is "input" */ - case 'input': - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an input element for the token. */ - $element = $this->insertElement($token, false); - - /* If the form element pointer is not null, then associate the - input element with the form element pointed to by the form - element pointer. */ - $this->form_pointer !== null - ? $this->form_pointer->appendChild($element) - : end($this->stack)->appendChild($element); - - /* Pop that input element off the stack of open elements. */ - array_pop($this->stack); - break; - - /* A start tag whose tag name is "isindex" */ - case 'isindex': - /* Parse error. */ - // w/e - - /* If the form element pointer is not null, - then ignore the token. */ - if($this->form_pointer === null) { - /* Act as if a start tag token with the tag name "form" had - been seen. */ - $this->inBody(array( - 'name' => 'body', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - /* Act as if a start tag token with the tag name "hr" had - been seen. */ - $this->inBody(array( - 'name' => 'hr', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - /* Act as if a start tag token with the tag name "p" had - been seen. */ - $this->inBody(array( - 'name' => 'p', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - /* Act as if a start tag token with the tag name "label" - had been seen. */ - $this->inBody(array( - 'name' => 'label', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - /* Act as if a stream of character tokens had been seen. */ - $this->insertText('This is a searchable index. '. - 'Insert your search keywords here: '); - - /* Act as if a start tag token with the tag name "input" - had been seen, with all the attributes from the "isindex" - token, except with the "name" attribute set to the value - "isindex" (ignoring any explicit "name" attribute). */ - $attr = $token['attr']; - $attr[] = array('name' => 'name', 'value' => 'isindex'); - - $this->inBody(array( - 'name' => 'input', - 'type' => HTML5::STARTTAG, - 'attr' => $attr - )); - - /* Act as if a stream of character tokens had been seen - (see below for what they should say). */ - $this->insertText('This is a searchable index. '. - 'Insert your search keywords here: '); - - /* Act as if an end tag token with the tag name "label" - had been seen. */ - $this->inBody(array( - 'name' => 'label', - 'type' => HTML5::ENDTAG - )); - - /* Act as if an end tag token with the tag name "p" had - been seen. */ - $this->inBody(array( - 'name' => 'p', - 'type' => HTML5::ENDTAG - )); - - /* Act as if a start tag token with the tag name "hr" had - been seen. */ - $this->inBody(array( - 'name' => 'hr', - 'type' => HTML5::ENDTAG - )); - - /* Act as if an end tag token with the tag name "form" had - been seen. */ - $this->inBody(array( - 'name' => 'form', - 'type' => HTML5::ENDTAG - )); - } - break; - - /* A start tag whose tag name is "textarea" */ - case 'textarea': - $this->insertElement($token); - - /* Switch the tokeniser's content model flag to the - RCDATA state. */ - return HTML5::RCDATA; - break; - - /* A start tag whose tag name is one of: "iframe", "noembed", - "noframes" */ - case 'iframe': case 'noembed': case 'noframes': - $this->insertElement($token); - - /* Switch the tokeniser's content model flag to the CDATA state. */ - return HTML5::CDATA; - break; - - /* A start tag whose tag name is "select" */ - case 'select': - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Change the insertion mode to "in select". */ - $this->mode = self::IN_SELECT; - break; - - /* A start or end tag whose tag name is one of: "caption", "col", - "colgroup", "frame", "frameset", "head", "option", "optgroup", - "tbody", "td", "tfoot", "th", "thead", "tr". */ - case 'caption': case 'col': case 'colgroup': case 'frame': - case 'frameset': case 'head': case 'option': case 'optgroup': - case 'tbody': case 'td': case 'tfoot': case 'th': case 'thead': - case 'tr': - // Parse error. Ignore the token. - break; - - /* A start or end tag whose tag name is one of: "event-source", - "section", "nav", "article", "aside", "header", "footer", - "datagrid", "command" */ - case 'event-source': case 'section': case 'nav': case 'article': - case 'aside': case 'header': case 'footer': case 'datagrid': - case 'command': - // Work in progress! - break; - - /* A start tag token not covered by the previous entries */ - default: - /* Reconstruct the active formatting elements, if any. */ - $this->reconstructActiveFormattingElements(); - - $this->insertElement($token, true, true); - break; - } - break; - - case HTML5::ENDTAG: - switch($token['name']) { - /* An end tag with the tag name "body" */ - case 'body': - /* If the second element in the stack of open elements is - not a body element, this is a parse error. Ignore the token. - (innerHTML case) */ - if(count($this->stack) < 2 || $this->stack[1]->nodeName !== 'body') { - // Ignore. - - /* If the current node is not the body element, then this - is a parse error. */ - } elseif(end($this->stack)->nodeName !== 'body') { - // Parse error. - } - - /* Change the insertion mode to "after body". */ - $this->mode = self::AFTER_BODY; - break; - - /* An end tag with the tag name "html" */ - case 'html': - /* Act as if an end tag with tag name "body" had been seen, - then, if that token wasn't ignored, reprocess the current - token. */ - $this->inBody(array( - 'name' => 'body', - 'type' => HTML5::ENDTAG - )); - - return $this->afterBody($token); - break; - - /* An end tag whose tag name is one of: "address", "blockquote", - "center", "dir", "div", "dl", "fieldset", "listing", "menu", - "ol", "pre", "ul" */ - case 'address': case 'blockquote': case 'center': case 'dir': - case 'div': case 'dl': case 'fieldset': case 'listing': - case 'menu': case 'ol': case 'pre': case 'ul': - /* If the stack of open elements has an element in scope - with the same tag name as that of the token, then generate - implied end tags. */ - if($this->elementInScope($token['name'])) { - $this->generateImpliedEndTags(); - - /* Now, if the current node is not an element with - the same tag name as that of the token, then this - is a parse error. */ - // w/e - - /* If the stack of open elements has an element in - scope with the same tag name as that of the token, - then pop elements from this stack until an element - with that tag name has been popped from the stack. */ - for($n = count($this->stack) - 1; $n >= 0; $n--) { - if($this->stack[$n]->nodeName === $token['name']) { - $n = -1; - } - - array_pop($this->stack); - } - } - break; - - /* An end tag whose tag name is "form" */ - case 'form': - /* If the stack of open elements has an element in scope - with the same tag name as that of the token, then generate - implied end tags. */ - if($this->elementInScope($token['name'])) { - $this->generateImpliedEndTags(); - - } - - if(end($this->stack)->nodeName !== $token['name']) { - /* Now, if the current node is not an element with the - same tag name as that of the token, then this is a parse - error. */ - // w/e - - } else { - /* Otherwise, if the current node is an element with - the same tag name as that of the token pop that element - from the stack. */ - array_pop($this->stack); - } - - /* In any case, set the form element pointer to null. */ - $this->form_pointer = null; - break; - - /* An end tag whose tag name is "p" */ - case 'p': - /* If the stack of open elements has a p element in scope, - then generate implied end tags, except for p elements. */ - if($this->elementInScope('p')) { - $this->generateImpliedEndTags(array('p')); - - /* If the current node is not a p element, then this is - a parse error. */ - // k - - /* If the stack of open elements has a p element in - scope, then pop elements from this stack until the stack - no longer has a p element in scope. */ - for($n = count($this->stack) - 1; $n >= 0; $n--) { - if($this->elementInScope('p')) { - array_pop($this->stack); - - } else { - break; - } - } - } - break; - - /* An end tag whose tag name is "dd", "dt", or "li" */ - case 'dd': case 'dt': case 'li': - /* If the stack of open elements has an element in scope - whose tag name matches the tag name of the token, then - generate implied end tags, except for elements with the - same tag name as the token. */ - if($this->elementInScope($token['name'])) { - $this->generateImpliedEndTags(array($token['name'])); - - /* If the current node is not an element with the same - tag name as the token, then this is a parse error. */ - // w/e - - /* If the stack of open elements has an element in scope - whose tag name matches the tag name of the token, then - pop elements from this stack until an element with that - tag name has been popped from the stack. */ - for($n = count($this->stack) - 1; $n >= 0; $n--) { - if($this->stack[$n]->nodeName === $token['name']) { - $n = -1; - } - - array_pop($this->stack); - } - } - break; - - /* An end tag whose tag name is one of: "h1", "h2", "h3", "h4", - "h5", "h6" */ - case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': - $elements = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'); - - /* If the stack of open elements has in scope an element whose - tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then - generate implied end tags. */ - if($this->elementInScope($elements)) { - $this->generateImpliedEndTags(); - - /* Now, if the current node is not an element with the same - tag name as that of the token, then this is a parse error. */ - // w/e - - /* If the stack of open elements has in scope an element - whose tag name is one of "h1", "h2", "h3", "h4", "h5", or - "h6", then pop elements from the stack until an element - with one of those tag names has been popped from the stack. */ - while($this->elementInScope($elements)) { - array_pop($this->stack); - } - } - break; - - /* An end tag whose tag name is one of: "a", "b", "big", "em", - "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u" */ - case 'a': case 'b': case 'big': case 'em': case 'font': - case 'i': case 'nobr': case 's': case 'small': case 'strike': - case 'strong': case 'tt': case 'u': - /* 1. Let the formatting element be the last element in - the list of active formatting elements that: - * is between the end of the list and the last scope - marker in the list, if any, or the start of the list - otherwise, and - * has the same tag name as the token. - */ - while(true) { - for($a = count($this->a_formatting) - 1; $a >= 0; $a--) { - if($this->a_formatting[$a] === self::MARKER) { - break; - - } elseif($this->a_formatting[$a]->tagName === $token['name']) { - $formatting_element = $this->a_formatting[$a]; - $in_stack = in_array($formatting_element, $this->stack, true); - $fe_af_pos = $a; - break; - } - } - - /* If there is no such node, or, if that node is - also in the stack of open elements but the element - is not in scope, then this is a parse error. Abort - these steps. The token is ignored. */ - if(!isset($formatting_element) || ($in_stack && - !$this->elementInScope($token['name']))) { - break; - - /* Otherwise, if there is such a node, but that node - is not in the stack of open elements, then this is a - parse error; remove the element from the list, and - abort these steps. */ - } elseif(isset($formatting_element) && !$in_stack) { - unset($this->a_formatting[$fe_af_pos]); - $this->a_formatting = array_merge($this->a_formatting); - break; - } - - /* 2. Let the furthest block be the topmost node in the - stack of open elements that is lower in the stack - than the formatting element, and is not an element in - the phrasing or formatting categories. There might - not be one. */ - $fe_s_pos = array_search($formatting_element, $this->stack, true); - $length = count($this->stack); - - for($s = $fe_s_pos + 1; $s < $length; $s++) { - $category = $this->getElementCategory($this->stack[$s]->nodeName); - - if($category !== self::PHRASING && $category !== self::FORMATTING) { - $furthest_block = $this->stack[$s]; - } - } - - /* 3. If there is no furthest block, then the UA must - skip the subsequent steps and instead just pop all - the nodes from the bottom of the stack of open - elements, from the current node up to the formatting - element, and remove the formatting element from the - list of active formatting elements. */ - if(!isset($furthest_block)) { - for($n = $length - 1; $n >= $fe_s_pos; $n--) { - array_pop($this->stack); - } - - unset($this->a_formatting[$fe_af_pos]); - $this->a_formatting = array_merge($this->a_formatting); - break; - } - - /* 4. Let the common ancestor be the element - immediately above the formatting element in the stack - of open elements. */ - $common_ancestor = $this->stack[$fe_s_pos - 1]; - - /* 5. If the furthest block has a parent node, then - remove the furthest block from its parent node. */ - if($furthest_block->parentNode !== null) { - $furthest_block->parentNode->removeChild($furthest_block); - } - - /* 6. Let a bookmark note the position of the - formatting element in the list of active formatting - elements relative to the elements on either side - of it in the list. */ - $bookmark = $fe_af_pos; - - /* 7. Let node and last node be the furthest block. - Follow these steps: */ - $node = $furthest_block; - $last_node = $furthest_block; - - while(true) { - for($n = array_search($node, $this->stack, true) - 1; $n >= 0; $n--) { - /* 7.1 Let node be the element immediately - prior to node in the stack of open elements. */ - $node = $this->stack[$n]; - - /* 7.2 If node is not in the list of active - formatting elements, then remove node from - the stack of open elements and then go back - to step 1. */ - if(!in_array($node, $this->a_formatting, true)) { - unset($this->stack[$n]); - $this->stack = array_merge($this->stack); - - } else { - break; - } - } - - /* 7.3 Otherwise, if node is the formatting - element, then go to the next step in the overall - algorithm. */ - if($node === $formatting_element) { - break; - - /* 7.4 Otherwise, if last node is the furthest - block, then move the aforementioned bookmark to - be immediately after the node in the list of - active formatting elements. */ - } elseif($last_node === $furthest_block) { - $bookmark = array_search($node, $this->a_formatting, true) + 1; - } - - /* 7.5 If node has any children, perform a - shallow clone of node, replace the entry for - node in the list of active formatting elements - with an entry for the clone, replace the entry - for node in the stack of open elements with an - entry for the clone, and let node be the clone. */ - if($node->hasChildNodes()) { - $clone = $node->cloneNode(); - $s_pos = array_search($node, $this->stack, true); - $a_pos = array_search($node, $this->a_formatting, true); - - $this->stack[$s_pos] = $clone; - $this->a_formatting[$a_pos] = $clone; - $node = $clone; - } - - /* 7.6 Insert last node into node, first removing - it from its previous parent node if any. */ - if($last_node->parentNode !== null) { - $last_node->parentNode->removeChild($last_node); - } - - $node->appendChild($last_node); - - /* 7.7 Let last node be node. */ - $last_node = $node; - } - - /* 8. Insert whatever last node ended up being in - the previous step into the common ancestor node, - first removing it from its previous parent node if - any. */ - if($last_node->parentNode !== null) { - $last_node->parentNode->removeChild($last_node); - } - - $common_ancestor->appendChild($last_node); - - /* 9. Perform a shallow clone of the formatting - element. */ - $clone = $formatting_element->cloneNode(); - - /* 10. Take all of the child nodes of the furthest - block and append them to the clone created in the - last step. */ - while($furthest_block->hasChildNodes()) { - $child = $furthest_block->firstChild; - $furthest_block->removeChild($child); - $clone->appendChild($child); - } - - /* 11. Append that clone to the furthest block. */ - $furthest_block->appendChild($clone); - - /* 12. Remove the formatting element from the list - of active formatting elements, and insert the clone - into the list of active formatting elements at the - position of the aforementioned bookmark. */ - $fe_af_pos = array_search($formatting_element, $this->a_formatting, true); - unset($this->a_formatting[$fe_af_pos]); - $this->a_formatting = array_merge($this->a_formatting); - - $af_part1 = array_slice($this->a_formatting, 0, $bookmark - 1); - $af_part2 = array_slice($this->a_formatting, $bookmark, count($this->a_formatting)); - $this->a_formatting = array_merge($af_part1, array($clone), $af_part2); - - /* 13. Remove the formatting element from the stack - of open elements, and insert the clone into the stack - of open elements immediately after (i.e. in a more - deeply nested position than) the position of the - furthest block in that stack. */ - $fe_s_pos = array_search($formatting_element, $this->stack, true); - $fb_s_pos = array_search($furthest_block, $this->stack, true); - unset($this->stack[$fe_s_pos]); - - $s_part1 = array_slice($this->stack, 0, $fb_s_pos); - $s_part2 = array_slice($this->stack, $fb_s_pos + 1, count($this->stack)); - $this->stack = array_merge($s_part1, array($clone), $s_part2); - - /* 14. Jump back to step 1 in this series of steps. */ - unset($formatting_element, $fe_af_pos, $fe_s_pos, $furthest_block); - } - break; - - /* An end tag token whose tag name is one of: "button", - "marquee", "object" */ - case 'button': case 'marquee': case 'object': - /* If the stack of open elements has an element in scope whose - tag name matches the tag name of the token, then generate implied - tags. */ - if($this->elementInScope($token['name'])) { - $this->generateImpliedEndTags(); - - /* Now, if the current node is not an element with the same - tag name as the token, then this is a parse error. */ - // k - - /* Now, if the stack of open elements has an element in scope - whose tag name matches the tag name of the token, then pop - elements from the stack until that element has been popped from - the stack, and clear the list of active formatting elements up - to the last marker. */ - for($n = count($this->stack) - 1; $n >= 0; $n--) { - if($this->stack[$n]->nodeName === $token['name']) { - $n = -1; - } - - array_pop($this->stack); - } - - $marker = end(array_keys($this->a_formatting, self::MARKER, true)); - - for($n = count($this->a_formatting) - 1; $n > $marker; $n--) { - array_pop($this->a_formatting); - } - } - break; - - /* Or an end tag whose tag name is one of: "area", "basefont", - "bgsound", "br", "embed", "hr", "iframe", "image", "img", - "input", "isindex", "noembed", "noframes", "param", "select", - "spacer", "table", "textarea", "wbr" */ - case 'area': case 'basefont': case 'bgsound': case 'br': - case 'embed': case 'hr': case 'iframe': case 'image': - case 'img': case 'input': case 'isindex': case 'noembed': - case 'noframes': case 'param': case 'select': case 'spacer': - case 'table': case 'textarea': case 'wbr': - // Parse error. Ignore the token. - break; - - /* An end tag token not covered by the previous entries */ - default: - for($n = count($this->stack) - 1; $n >= 0; $n--) { - /* Initialise node to be the current node (the bottommost - node of the stack). */ - $node = end($this->stack); - - /* If node has the same tag name as the end tag token, - then: */ - if($token['name'] === $node->nodeName) { - /* Generate implied end tags. */ - $this->generateImpliedEndTags(); - - /* If the tag name of the end tag token does not - match the tag name of the current node, this is a - parse error. */ - // k - - /* Pop all the nodes from the current node up to - node, including node, then stop this algorithm. */ - for($x = count($this->stack) - $n; $x >= $n; $x--) { - array_pop($this->stack); - } - - } else { - $category = $this->getElementCategory($node); - - if($category !== self::SPECIAL && $category !== self::SCOPING) { - /* Otherwise, if node is in neither the formatting - category nor the phrasing category, then this is a - parse error. Stop this algorithm. The end tag token - is ignored. */ - return false; - } - } - } - break; - } - break; - } - } - - private function inTable($token) { - $clear = array('html', 'table'); - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - if($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Append the character to the current node. */ - $text = $this->dom->createTextNode($token['data']); - end($this->stack)->appendChild($text); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data - attribute set to the data given in the comment token. */ - $comment = $this->dom->createComment($token['data']); - end($this->stack)->appendChild($comment); - - /* A start tag whose tag name is "caption" */ - } elseif($token['type'] === HTML5::STARTTAG && - $token['name'] === 'caption') { - /* Clear the stack back to a table context. */ - $this->clearStackToTableContext($clear); - - /* Insert a marker at the end of the list of active - formatting elements. */ - $this->a_formatting[] = self::MARKER; - - /* Insert an HTML element for the token, then switch the - insertion mode to "in caption". */ - $this->insertElement($token); - $this->mode = self::IN_CAPTION; - - /* A start tag whose tag name is "colgroup" */ - } elseif($token['type'] === HTML5::STARTTAG && - $token['name'] === 'colgroup') { - /* Clear the stack back to a table context. */ - $this->clearStackToTableContext($clear); - - /* Insert an HTML element for the token, then switch the - insertion mode to "in column group". */ - $this->insertElement($token); - $this->mode = self::IN_CGROUP; - - /* A start tag whose tag name is "col" */ - } elseif($token['type'] === HTML5::STARTTAG && - $token['name'] === 'col') { - $this->inTable(array( - 'name' => 'colgroup', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - $this->inColumnGroup($token); - - /* A start tag whose tag name is one of: "tbody", "tfoot", "thead" */ - } elseif($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('tbody', 'tfoot', 'thead'))) { - /* Clear the stack back to a table context. */ - $this->clearStackToTableContext($clear); - - /* Insert an HTML element for the token, then switch the insertion - mode to "in table body". */ - $this->insertElement($token); - $this->mode = self::IN_TBODY; - - /* A start tag whose tag name is one of: "td", "th", "tr" */ - } elseif($token['type'] === HTML5::STARTTAG && - in_array($token['name'], array('td', 'th', 'tr'))) { - /* Act as if a start tag token with the tag name "tbody" had been - seen, then reprocess the current token. */ - $this->inTable(array( - 'name' => 'tbody', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - return $this->inTableBody($token); - - /* A start tag whose tag name is "table" */ - } elseif($token['type'] === HTML5::STARTTAG && - $token['name'] === 'table') { - /* Parse error. Act as if an end tag token with the tag name "table" - had been seen, then, if that token wasn't ignored, reprocess the - current token. */ - $this->inTable(array( - 'name' => 'table', - 'type' => HTML5::ENDTAG - )); - - return $this->mainPhase($token); - - /* An end tag whose tag name is "table" */ - } elseif($token['type'] === HTML5::ENDTAG && - $token['name'] === 'table') { - /* If the stack of open elements does not have an element in table - scope with the same tag name as the token, this is a parse error. - Ignore the token. (innerHTML case) */ - if(!$this->elementInScope($token['name'], true)) { - return false; - - /* Otherwise: */ - } else { - /* Generate implied end tags. */ - $this->generateImpliedEndTags(); - - /* Now, if the current node is not a table element, then this - is a parse error. */ - // w/e - - /* Pop elements from this stack until a table element has been - popped from the stack. */ - while(true) { - $current = end($this->stack)->nodeName; - array_pop($this->stack); - - if($current === 'table') { - break; - } - } - - /* Reset the insertion mode appropriately. */ - $this->resetInsertionMode(); - } - - /* An end tag whose tag name is one of: "body", "caption", "col", - "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ - } elseif($token['type'] === HTML5::ENDTAG && in_array($token['name'], - array('body', 'caption', 'col', 'colgroup', 'html', 'tbody', 'td', - 'tfoot', 'th', 'thead', 'tr'))) { - // Parse error. Ignore the token. - - /* Anything else */ - } else { - /* Parse error. Process the token as if the insertion mode was "in - body", with the following exception: */ - - /* If the current node is a table, tbody, tfoot, thead, or tr - element, then, whenever a node would be inserted into the current - node, it must instead be inserted into the foster parent element. */ - if(in_array(end($this->stack)->nodeName, - array('table', 'tbody', 'tfoot', 'thead', 'tr'))) { - /* The foster parent element is the parent element of the last - table element in the stack of open elements, if there is a - table element and it has such a parent element. If there is no - table element in the stack of open elements (innerHTML case), - then the foster parent element is the first element in the - stack of open elements (the html element). Otherwise, if there - is a table element in the stack of open elements, but the last - table element in the stack of open elements has no parent, or - its parent node is not an element, then the foster parent - element is the element before the last table element in the - stack of open elements. */ - for($n = count($this->stack) - 1; $n >= 0; $n--) { - if($this->stack[$n]->nodeName === 'table') { - $table = $this->stack[$n]; - break; - } - } - - if(isset($table) && $table->parentNode !== null) { - $this->foster_parent = $table->parentNode; - - } elseif(!isset($table)) { - $this->foster_parent = $this->stack[0]; - - } elseif(isset($table) && ($table->parentNode === null || - $table->parentNode->nodeType !== XML_ELEMENT_NODE)) { - $this->foster_parent = $this->stack[$n - 1]; - } - } - - $this->inBody($token); - } - } - - private function inCaption($token) { - /* An end tag whose tag name is "caption" */ - if($token['type'] === HTML5::ENDTAG && $token['name'] === 'caption') { - /* If the stack of open elements does not have an element in table - scope with the same tag name as the token, this is a parse error. - Ignore the token. (innerHTML case) */ - if(!$this->elementInScope($token['name'], true)) { - // Ignore - - /* Otherwise: */ - } else { - /* Generate implied end tags. */ - $this->generateImpliedEndTags(); - - /* Now, if the current node is not a caption element, then this - is a parse error. */ - // w/e - - /* Pop elements from this stack until a caption element has - been popped from the stack. */ - while(true) { - $node = end($this->stack)->nodeName; - array_pop($this->stack); - - if($node === 'caption') { - break; - } - } - - /* Clear the list of active formatting elements up to the last - marker. */ - $this->clearTheActiveFormattingElementsUpToTheLastMarker(); - - /* Switch the insertion mode to "in table". */ - $this->mode = self::IN_TABLE; - } - - /* A start tag whose tag name is one of: "caption", "col", "colgroup", - "tbody", "td", "tfoot", "th", "thead", "tr", or an end tag whose tag - name is "table" */ - } elseif(($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', - 'thead', 'tr'))) || ($token['type'] === HTML5::ENDTAG && - $token['name'] === 'table')) { - /* Parse error. Act as if an end tag with the tag name "caption" - had been seen, then, if that token wasn't ignored, reprocess the - current token. */ - $this->inCaption(array( - 'name' => 'caption', - 'type' => HTML5::ENDTAG - )); - - return $this->inTable($token); - - /* An end tag whose tag name is one of: "body", "col", "colgroup", - "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ - } elseif($token['type'] === HTML5::ENDTAG && in_array($token['name'], - array('body', 'col', 'colgroup', 'html', 'tbody', 'tfoot', 'th', - 'thead', 'tr'))) { - // Parse error. Ignore the token. - - /* Anything else */ - } else { - /* Process the token as if the insertion mode was "in body". */ - $this->inBody($token); - } - } - - private function inColumnGroup($token) { - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - if($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Append the character to the current node. */ - $text = $this->dom->createTextNode($token['data']); - end($this->stack)->appendChild($text); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data - attribute set to the data given in the comment token. */ - $comment = $this->dom->createComment($token['data']); - end($this->stack)->appendChild($comment); - - /* A start tag whose tag name is "col" */ - } elseif($token['type'] === HTML5::STARTTAG && $token['name'] === 'col') { - /* Insert a col element for the token. Immediately pop the current - node off the stack of open elements. */ - $this->insertElement($token); - array_pop($this->stack); - - /* An end tag whose tag name is "colgroup" */ - } elseif($token['type'] === HTML5::ENDTAG && - $token['name'] === 'colgroup') { - /* If the current node is the root html element, then this is a - parse error, ignore the token. (innerHTML case) */ - if(end($this->stack)->nodeName === 'html') { - // Ignore - - /* Otherwise, pop the current node (which will be a colgroup - element) from the stack of open elements. Switch the insertion - mode to "in table". */ - } else { - array_pop($this->stack); - $this->mode = self::IN_TABLE; - } - - /* An end tag whose tag name is "col" */ - } elseif($token['type'] === HTML5::ENDTAG && $token['name'] === 'col') { - /* Parse error. Ignore the token. */ - - /* Anything else */ - } else { - /* Act as if an end tag with the tag name "colgroup" had been seen, - and then, if that token wasn't ignored, reprocess the current token. */ - $this->inColumnGroup(array( - 'name' => 'colgroup', - 'type' => HTML5::ENDTAG - )); - - return $this->inTable($token); - } - } - - private function inTableBody($token) { - $clear = array('tbody', 'tfoot', 'thead', 'html'); - - /* A start tag whose tag name is "tr" */ - if($token['type'] === HTML5::STARTTAG && $token['name'] === 'tr') { - /* Clear the stack back to a table body context. */ - $this->clearStackToTableContext($clear); - - /* Insert a tr element for the token, then switch the insertion - mode to "in row". */ - $this->insertElement($token); - $this->mode = self::IN_ROW; - - /* A start tag whose tag name is one of: "th", "td" */ - } elseif($token['type'] === HTML5::STARTTAG && - ($token['name'] === 'th' || $token['name'] === 'td')) { - /* Parse error. Act as if a start tag with the tag name "tr" had - been seen, then reprocess the current token. */ - $this->inTableBody(array( - 'name' => 'tr', - 'type' => HTML5::STARTTAG, - 'attr' => array() - )); - - return $this->inRow($token); - - /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ - } elseif($token['type'] === HTML5::ENDTAG && - in_array($token['name'], array('tbody', 'tfoot', 'thead'))) { - /* If the stack of open elements does not have an element in table - scope with the same tag name as the token, this is a parse error. - Ignore the token. */ - if(!$this->elementInScope($token['name'], true)) { - // Ignore - - /* Otherwise: */ - } else { - /* Clear the stack back to a table body context. */ - $this->clearStackToTableContext($clear); - - /* Pop the current node from the stack of open elements. Switch - the insertion mode to "in table". */ - array_pop($this->stack); - $this->mode = self::IN_TABLE; - } - - /* A start tag whose tag name is one of: "caption", "col", "colgroup", - "tbody", "tfoot", "thead", or an end tag whose tag name is "table" */ - } elseif(($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('caption', 'col', 'colgroup', 'tbody', 'tfoor', 'thead'))) || - ($token['type'] === HTML5::STARTTAG && $token['name'] === 'table')) { - /* If the stack of open elements does not have a tbody, thead, or - tfoot element in table scope, this is a parse error. Ignore the - token. (innerHTML case) */ - if(!$this->elementInScope(array('tbody', 'thead', 'tfoot'), true)) { - // Ignore. - - /* Otherwise: */ - } else { - /* Clear the stack back to a table body context. */ - $this->clearStackToTableContext($clear); - - /* Act as if an end tag with the same tag name as the current - node ("tbody", "tfoot", or "thead") had been seen, then - reprocess the current token. */ - $this->inTableBody(array( - 'name' => end($this->stack)->nodeName, - 'type' => HTML5::ENDTAG - )); - - return $this->mainPhase($token); - } - - /* An end tag whose tag name is one of: "body", "caption", "col", - "colgroup", "html", "td", "th", "tr" */ - } elseif($token['type'] === HTML5::ENDTAG && in_array($token['name'], - array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th', 'tr'))) { - /* Parse error. Ignore the token. */ - - /* Anything else */ - } else { - /* Process the token as if the insertion mode was "in table". */ - $this->inTable($token); - } - } - - private function inRow($token) { - $clear = array('tr', 'html'); - - /* A start tag whose tag name is one of: "th", "td" */ - if($token['type'] === HTML5::STARTTAG && - ($token['name'] === 'th' || $token['name'] === 'td')) { - /* Clear the stack back to a table row context. */ - $this->clearStackToTableContext($clear); - - /* Insert an HTML element for the token, then switch the insertion - mode to "in cell". */ - $this->insertElement($token); - $this->mode = self::IN_CELL; - - /* Insert a marker at the end of the list of active formatting - elements. */ - $this->a_formatting[] = self::MARKER; - - /* An end tag whose tag name is "tr" */ - } elseif($token['type'] === HTML5::ENDTAG && $token['name'] === 'tr') { - /* If the stack of open elements does not have an element in table - scope with the same tag name as the token, this is a parse error. - Ignore the token. (innerHTML case) */ - if(!$this->elementInScope($token['name'], true)) { - // Ignore. - - /* Otherwise: */ - } else { - /* Clear the stack back to a table row context. */ - $this->clearStackToTableContext($clear); - - /* Pop the current node (which will be a tr element) from the - stack of open elements. Switch the insertion mode to "in table - body". */ - array_pop($this->stack); - $this->mode = self::IN_TBODY; - } - - /* A start tag whose tag name is one of: "caption", "col", "colgroup", - "tbody", "tfoot", "thead", "tr" or an end tag whose tag name is "table" */ - } elseif($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('caption', 'col', 'colgroup', 'tbody', 'tfoot', 'thead', 'tr'))) { - /* Act as if an end tag with the tag name "tr" had been seen, then, - if that token wasn't ignored, reprocess the current token. */ - $this->inRow(array( - 'name' => 'tr', - 'type' => HTML5::ENDTAG - )); - - return $this->inCell($token); - - /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ - } elseif($token['type'] === HTML5::ENDTAG && - in_array($token['name'], array('tbody', 'tfoot', 'thead'))) { - /* If the stack of open elements does not have an element in table - scope with the same tag name as the token, this is a parse error. - Ignore the token. */ - if(!$this->elementInScope($token['name'], true)) { - // Ignore. - - /* Otherwise: */ - } else { - /* Otherwise, act as if an end tag with the tag name "tr" had - been seen, then reprocess the current token. */ - $this->inRow(array( - 'name' => 'tr', - 'type' => HTML5::ENDTAG - )); - - return $this->inCell($token); - } - - /* An end tag whose tag name is one of: "body", "caption", "col", - "colgroup", "html", "td", "th" */ - } elseif($token['type'] === HTML5::ENDTAG && in_array($token['name'], - array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th', 'tr'))) { - /* Parse error. Ignore the token. */ - - /* Anything else */ - } else { - /* Process the token as if the insertion mode was "in table". */ - $this->inTable($token); - } - } - - private function inCell($token) { - /* An end tag whose tag name is one of: "td", "th" */ - if($token['type'] === HTML5::ENDTAG && - ($token['name'] === 'td' || $token['name'] === 'th')) { - /* If the stack of open elements does not have an element in table - scope with the same tag name as that of the token, then this is a - parse error and the token must be ignored. */ - if(!$this->elementInScope($token['name'], true)) { - // Ignore. - - /* Otherwise: */ - } else { - /* Generate implied end tags, except for elements with the same - tag name as the token. */ - $this->generateImpliedEndTags(array($token['name'])); - - /* Now, if the current node is not an element with the same tag - name as the token, then this is a parse error. */ - // k - - /* Pop elements from this stack until an element with the same - tag name as the token has been popped from the stack. */ - while(true) { - $node = end($this->stack)->nodeName; - array_pop($this->stack); - - if($node === $token['name']) { - break; - } - } - - /* Clear the list of active formatting elements up to the last - marker. */ - $this->clearTheActiveFormattingElementsUpToTheLastMarker(); - - /* Switch the insertion mode to "in row". (The current node - will be a tr element at this point.) */ - $this->mode = self::IN_ROW; - } - - /* A start tag whose tag name is one of: "caption", "col", "colgroup", - "tbody", "td", "tfoot", "th", "thead", "tr" */ - } elseif($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', - 'thead', 'tr'))) { - /* If the stack of open elements does not have a td or th element - in table scope, then this is a parse error; ignore the token. - (innerHTML case) */ - if(!$this->elementInScope(array('td', 'th'), true)) { - // Ignore. - - /* Otherwise, close the cell (see below) and reprocess the current - token. */ - } else { - $this->closeCell(); - return $this->inRow($token); - } - - /* A start tag whose tag name is one of: "caption", "col", "colgroup", - "tbody", "td", "tfoot", "th", "thead", "tr" */ - } elseif($token['type'] === HTML5::STARTTAG && in_array($token['name'], - array('caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th', - 'thead', 'tr'))) { - /* If the stack of open elements does not have a td or th element - in table scope, then this is a parse error; ignore the token. - (innerHTML case) */ - if(!$this->elementInScope(array('td', 'th'), true)) { - // Ignore. - - /* Otherwise, close the cell (see below) and reprocess the current - token. */ - } else { - $this->closeCell(); - return $this->inRow($token); - } - - /* An end tag whose tag name is one of: "body", "caption", "col", - "colgroup", "html" */ - } elseif($token['type'] === HTML5::ENDTAG && in_array($token['name'], - array('body', 'caption', 'col', 'colgroup', 'html'))) { - /* Parse error. Ignore the token. */ - - /* An end tag whose tag name is one of: "table", "tbody", "tfoot", - "thead", "tr" */ - } elseif($token['type'] === HTML5::ENDTAG && in_array($token['name'], - array('table', 'tbody', 'tfoot', 'thead', 'tr'))) { - /* If the stack of open elements does not have an element in table - scope with the same tag name as that of the token (which can only - happen for "tbody", "tfoot" and "thead", or, in the innerHTML case), - then this is a parse error and the token must be ignored. */ - if(!$this->elementInScope($token['name'], true)) { - // Ignore. - - /* Otherwise, close the cell (see below) and reprocess the current - token. */ - } else { - $this->closeCell(); - return $this->inRow($token); - } - - /* Anything else */ - } else { - /* Process the token as if the insertion mode was "in body". */ - $this->inBody($token); - } - } - - private function inSelect($token) { - /* Handle the token as follows: */ - - /* A character token */ - if($token['type'] === HTML5::CHARACTR) { - /* Append the token's character to the current node. */ - $this->insertText($token['data']); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data - attribute set to the data given in the comment token. */ - $this->insertComment($token['data']); - - /* A start tag token whose tag name is "option" */ - } elseif($token['type'] === HTML5::STARTTAG && - $token['name'] === 'option') { - /* If the current node is an option element, act as if an end tag - with the tag name "option" had been seen. */ - if(end($this->stack)->nodeName === 'option') { - $this->inSelect(array( - 'name' => 'option', - 'type' => HTML5::ENDTAG - )); - } - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* A start tag token whose tag name is "optgroup" */ - } elseif($token['type'] === HTML5::STARTTAG && - $token['name'] === 'optgroup') { - /* If the current node is an option element, act as if an end tag - with the tag name "option" had been seen. */ - if(end($this->stack)->nodeName === 'option') { - $this->inSelect(array( - 'name' => 'option', - 'type' => HTML5::ENDTAG - )); - } - - /* If the current node is an optgroup element, act as if an end tag - with the tag name "optgroup" had been seen. */ - if(end($this->stack)->nodeName === 'optgroup') { - $this->inSelect(array( - 'name' => 'optgroup', - 'type' => HTML5::ENDTAG - )); - } - - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* An end tag token whose tag name is "optgroup" */ - } elseif($token['type'] === HTML5::ENDTAG && - $token['name'] === 'optgroup') { - /* First, if the current node is an option element, and the node - immediately before it in the stack of open elements is an optgroup - element, then act as if an end tag with the tag name "option" had - been seen. */ - $elements_in_stack = count($this->stack); - - if($this->stack[$elements_in_stack - 1]->nodeName === 'option' && - $this->stack[$elements_in_stack - 2]->nodeName === 'optgroup') { - $this->inSelect(array( - 'name' => 'option', - 'type' => HTML5::ENDTAG - )); - } - - /* If the current node is an optgroup element, then pop that node - from the stack of open elements. Otherwise, this is a parse error, - ignore the token. */ - if($this->stack[$elements_in_stack - 1] === 'optgroup') { - array_pop($this->stack); - } - - /* An end tag token whose tag name is "option" */ - } elseif($token['type'] === HTML5::ENDTAG && - $token['name'] === 'option') { - /* If the current node is an option element, then pop that node - from the stack of open elements. Otherwise, this is a parse error, - ignore the token. */ - if(end($this->stack)->nodeName === 'option') { - array_pop($this->stack); - } - - /* An end tag whose tag name is "select" */ - } elseif($token['type'] === HTML5::ENDTAG && - $token['name'] === 'select') { - /* If the stack of open elements does not have an element in table - scope with the same tag name as the token, this is a parse error. - Ignore the token. (innerHTML case) */ - if(!$this->elementInScope($token['name'], true)) { - // w/e - - /* Otherwise: */ - } else { - /* Pop elements from the stack of open elements until a select - element has been popped from the stack. */ - while(true) { - $current = end($this->stack)->nodeName; - array_pop($this->stack); - - if($current === 'select') { - break; - } - } - - /* Reset the insertion mode appropriately. */ - $this->resetInsertionMode(); - } - - /* A start tag whose tag name is "select" */ - } elseif($token['name'] === 'select' && - $token['type'] === HTML5::STARTTAG) { - /* Parse error. Act as if the token had been an end tag with the - tag name "select" instead. */ - $this->inSelect(array( - 'name' => 'select', - 'type' => HTML5::ENDTAG - )); - - /* An end tag whose tag name is one of: "caption", "table", "tbody", - "tfoot", "thead", "tr", "td", "th" */ - } elseif(in_array($token['name'], array('caption', 'table', 'tbody', - 'tfoot', 'thead', 'tr', 'td', 'th')) && $token['type'] === HTML5::ENDTAG) { - /* Parse error. */ - // w/e - - /* If the stack of open elements has an element in table scope with - the same tag name as that of the token, then act as if an end tag - with the tag name "select" had been seen, and reprocess the token. - Otherwise, ignore the token. */ - if($this->elementInScope($token['name'], true)) { - $this->inSelect(array( - 'name' => 'select', - 'type' => HTML5::ENDTAG - )); - - $this->mainPhase($token); - } - - /* Anything else */ - } else { - /* Parse error. Ignore the token. */ - } - } - - private function afterBody($token) { - /* Handle the token as follows: */ - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - if($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Process the token as it would be processed if the insertion mode - was "in body". */ - $this->inBody($token); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the first element in the stack of open - elements (the html element), with the data attribute set to the - data given in the comment token. */ - $comment = $this->dom->createComment($token['data']); - $this->stack[0]->appendChild($comment); - - /* An end tag with the tag name "html" */ - } elseif($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') { - /* If the parser was originally created in order to handle the - setting of an element's innerHTML attribute, this is a parse error; - ignore the token. (The element will be an html element in this - case.) (innerHTML case) */ - - /* Otherwise, switch to the trailing end phase. */ - $this->phase = self::END_PHASE; - - /* Anything else */ - } else { - /* Parse error. Set the insertion mode to "in body" and reprocess - the token. */ - $this->mode = self::IN_BODY; - return $this->inBody($token); - } - } - - private function inFrameset($token) { - /* Handle the token as follows: */ - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ - if($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Append the character to the current node. */ - $this->insertText($token['data']); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data - attribute set to the data given in the comment token. */ - $this->insertComment($token['data']); - - /* A start tag with the tag name "frameset" */ - } elseif($token['name'] === 'frameset' && - $token['type'] === HTML5::STARTTAG) { - $this->insertElement($token); - - /* An end tag with the tag name "frameset" */ - } elseif($token['name'] === 'frameset' && - $token['type'] === HTML5::ENDTAG) { - /* If the current node is the root html element, then this is a - parse error; ignore the token. (innerHTML case) */ - if(end($this->stack)->nodeName === 'html') { - // Ignore - - } else { - /* Otherwise, pop the current node from the stack of open - elements. */ - array_pop($this->stack); - - /* If the parser was not originally created in order to handle - the setting of an element's innerHTML attribute (innerHTML case), - and the current node is no longer a frameset element, then change - the insertion mode to "after frameset". */ - $this->mode = self::AFTR_FRAME; - } - - /* A start tag with the tag name "frame" */ - } elseif($token['name'] === 'frame' && - $token['type'] === HTML5::STARTTAG) { - /* Insert an HTML element for the token. */ - $this->insertElement($token); - - /* Immediately pop the current node off the stack of open elements. */ - array_pop($this->stack); - - /* A start tag with the tag name "noframes" */ - } elseif($token['name'] === 'noframes' && - $token['type'] === HTML5::STARTTAG) { - /* Process the token as if the insertion mode had been "in body". */ - $this->inBody($token); - - /* Anything else */ - } else { - /* Parse error. Ignore the token. */ - } - } - - private function afterFrameset($token) { - /* Handle the token as follows: */ - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ - if($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Append the character to the current node. */ - $this->insertText($token['data']); - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the current node with the data - attribute set to the data given in the comment token. */ - $this->insertComment($token['data']); - - /* An end tag with the tag name "html" */ - } elseif($token['name'] === 'html' && - $token['type'] === HTML5::ENDTAG) { - /* Switch to the trailing end phase. */ - $this->phase = self::END_PHASE; - - /* A start tag with the tag name "noframes" */ - } elseif($token['name'] === 'noframes' && - $token['type'] === HTML5::STARTTAG) { - /* Process the token as if the insertion mode had been "in body". */ - $this->inBody($token); - - /* Anything else */ - } else { - /* Parse error. Ignore the token. */ - } - } - - private function trailingEndPhase($token) { - /* After the main phase, as each token is emitted from the tokenisation - stage, it must be processed as described in this section. */ - - /* A DOCTYPE token */ - if($token['type'] === HTML5::DOCTYPE) { - // Parse error. Ignore the token. - - /* A comment token */ - } elseif($token['type'] === HTML5::COMMENT) { - /* Append a Comment node to the Document object with the data - attribute set to the data given in the comment token. */ - $comment = $this->dom->createComment($token['data']); - $this->dom->appendChild($comment); - - /* A character token that is one of one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE */ - } elseif($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) { - /* Process the token as it would be processed in the main phase. */ - $this->mainPhase($token); - - /* A character token that is not one of U+0009 CHARACTER TABULATION, - U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), - or U+0020 SPACE. Or a start tag token. Or an end tag token. */ - } elseif(($token['type'] === HTML5::CHARACTR && - preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || - $token['type'] === HTML5::STARTTAG || $token['type'] === HTML5::ENDTAG) { - /* Parse error. Switch back to the main phase and reprocess the - token. */ - $this->phase = self::MAIN_PHASE; - return $this->mainPhase($token); - - /* An end-of-file token */ - } elseif($token['type'] === HTML5::EOF) { - /* OMG DONE!! */ - } - } - - private function insertElement($token, $append = true, $check = false) { - // Proprietary workaround for libxml2's limitations with tag names - if ($check) { - // Slightly modified HTML5 tag-name modification, - // removing anything that's not an ASCII letter, digit, or hyphen - $token['name'] = preg_replace('/[^a-z0-9-]/i', '', $token['name']); - // Remove leading hyphens and numbers - $token['name'] = ltrim($token['name'], '-0..9'); - // In theory, this should ever be needed, but just in case - if ($token['name'] === '') $token['name'] = 'span'; // arbitrary generic choice - } - - $el = $this->dom->createElement($token['name']); - - foreach($token['attr'] as $attr) { - if(!$el->hasAttribute($attr['name'])) { - $el->setAttribute($attr['name'], $attr['value']); - } - } - - $this->appendToRealParent($el); - $this->stack[] = $el; - - return $el; - } - - private function insertText($data) { - $text = $this->dom->createTextNode($data); - $this->appendToRealParent($text); - } - - private function insertComment($data) { - $comment = $this->dom->createComment($data); - $this->appendToRealParent($comment); - } - - private function appendToRealParent($node) { - if($this->foster_parent === null) { - end($this->stack)->appendChild($node); - - } elseif($this->foster_parent !== null) { - /* If the foster parent element is the parent element of the - last table element in the stack of open elements, then the new - node must be inserted immediately before the last table element - in the stack of open elements in the foster parent element; - otherwise, the new node must be appended to the foster parent - element. */ - for($n = count($this->stack) - 1; $n >= 0; $n--) { - if($this->stack[$n]->nodeName === 'table' && - $this->stack[$n]->parentNode !== null) { - $table = $this->stack[$n]; - break; - } - } - - if(isset($table) && $this->foster_parent->isSameNode($table->parentNode)) - $this->foster_parent->insertBefore($node, $table); - else - $this->foster_parent->appendChild($node); - - $this->foster_parent = null; - } - } - - private function elementInScope($el, $table = false) { - if(is_array($el)) { - foreach($el as $element) { - if($this->elementInScope($element, $table)) { - return true; - } - } - - return false; - } - - $leng = count($this->stack); - - for($n = 0; $n < $leng; $n++) { - /* 1. Initialise node to be the current node (the bottommost node of - the stack). */ - $node = $this->stack[$leng - 1 - $n]; - - if($node->tagName === $el) { - /* 2. If node is the target node, terminate in a match state. */ - return true; - - } elseif($node->tagName === 'table') { - /* 3. Otherwise, if node is a table element, terminate in a failure - state. */ - return false; - - } elseif($table === true && in_array($node->tagName, array('caption', 'td', - 'th', 'button', 'marquee', 'object'))) { - /* 4. Otherwise, if the algorithm is the "has an element in scope" - variant (rather than the "has an element in table scope" variant), - and node is one of the following, terminate in a failure state. */ - return false; - - } elseif($node === $node->ownerDocument->documentElement) { - /* 5. Otherwise, if node is an html element (root element), terminate - in a failure state. (This can only happen if the node is the topmost - node of the stack of open elements, and prevents the next step from - being invoked if there are no more elements in the stack.) */ - return false; - } - - /* Otherwise, set node to the previous entry in the stack of open - elements and return to step 2. (This will never fail, since the loop - will always terminate in the previous step if the top of the stack - is reached.) */ - } - } - - private function reconstructActiveFormattingElements() { - /* 1. If there are no entries in the list of active formatting elements, - then there is nothing to reconstruct; stop this algorithm. */ - $formatting_elements = count($this->a_formatting); - - if($formatting_elements === 0) { - return false; - } - - /* 3. Let entry be the last (most recently added) element in the list - of active formatting elements. */ - $entry = end($this->a_formatting); - - /* 2. If the last (most recently added) entry in the list of active - formatting elements is a marker, or if it is an element that is in the - stack of open elements, then there is nothing to reconstruct; stop this - algorithm. */ - if($entry === self::MARKER || in_array($entry, $this->stack, true)) { - return false; - } - - for($a = $formatting_elements - 1; $a >= 0; true) { - /* 4. If there are no entries before entry in the list of active - formatting elements, then jump to step 8. */ - if($a === 0) { - $step_seven = false; - break; - } - - /* 5. Let entry be the entry one earlier than entry in the list of - active formatting elements. */ - $a--; - $entry = $this->a_formatting[$a]; - - /* 6. If entry is neither a marker nor an element that is also in - thetack of open elements, go to step 4. */ - if($entry === self::MARKER || in_array($entry, $this->stack, true)) { - break; - } - } - - while(true) { - /* 7. Let entry be the element one later than entry in the list of - active formatting elements. */ - if(isset($step_seven) && $step_seven === true) { - $a++; - $entry = $this->a_formatting[$a]; - } - - /* 8. Perform a shallow clone of the element entry to obtain clone. */ - $clone = $entry->cloneNode(); - - /* 9. Append clone to the current node and push it onto the stack - of open elements so that it is the new current node. */ - end($this->stack)->appendChild($clone); - $this->stack[] = $clone; - - /* 10. Replace the entry for entry in the list with an entry for - clone. */ - $this->a_formatting[$a] = $clone; - - /* 11. If the entry for clone in the list of active formatting - elements is not the last entry in the list, return to step 7. */ - if(end($this->a_formatting) !== $clone) { - $step_seven = true; - } else { - break; - } - } - } - - private function clearTheActiveFormattingElementsUpToTheLastMarker() { - /* When the steps below require the UA to clear the list of active - formatting elements up to the last marker, the UA must perform the - following steps: */ - - while(true) { - /* 1. Let entry be the last (most recently added) entry in the list - of active formatting elements. */ - $entry = end($this->a_formatting); - - /* 2. Remove entry from the list of active formatting elements. */ - array_pop($this->a_formatting); - - /* 3. If entry was a marker, then stop the algorithm at this point. - The list has been cleared up to the last marker. */ - if($entry === self::MARKER) { - break; - } - } - } - - private function generateImpliedEndTags($exclude = array()) { - /* When the steps below require the UA to generate implied end tags, - then, if the current node is a dd element, a dt element, an li element, - a p element, a td element, a th element, or a tr element, the UA must - act as if an end tag with the respective tag name had been seen and - then generate implied end tags again. */ - $node = end($this->stack); - $elements = array_diff(array('dd', 'dt', 'li', 'p', 'td', 'th', 'tr'), $exclude); - - while(in_array(end($this->stack)->nodeName, $elements)) { - array_pop($this->stack); - } - } - - private function getElementCategory($node) { - $name = $node->tagName; - if(in_array($name, $this->special)) - return self::SPECIAL; - - elseif(in_array($name, $this->scoping)) - return self::SCOPING; - - elseif(in_array($name, $this->formatting)) - return self::FORMATTING; - - else - return self::PHRASING; - } - - private function clearStackToTableContext($elements) { - /* When the steps above require the UA to clear the stack back to a - table context, it means that the UA must, while the current node is not - a table element or an html element, pop elements from the stack of open - elements. If this causes any elements to be popped from the stack, then - this is a parse error. */ - while(true) { - $node = end($this->stack)->nodeName; - - if(in_array($node, $elements)) { - break; - } else { - array_pop($this->stack); - } - } - } - - private function resetInsertionMode() { - /* 1. Let last be false. */ - $last = false; - $leng = count($this->stack); - - for($n = $leng - 1; $n >= 0; $n--) { - /* 2. Let node be the last node in the stack of open elements. */ - $node = $this->stack[$n]; - - /* 3. If node is the first node in the stack of open elements, then - set last to true. If the element whose innerHTML attribute is being - set is neither a td element nor a th element, then set node to the - element whose innerHTML attribute is being set. (innerHTML case) */ - if($this->stack[0]->isSameNode($node)) { - $last = true; - } - - /* 4. If node is a select element, then switch the insertion mode to - "in select" and abort these steps. (innerHTML case) */ - if($node->nodeName === 'select') { - $this->mode = self::IN_SELECT; - break; - - /* 5. If node is a td or th element, then switch the insertion mode - to "in cell" and abort these steps. */ - } elseif($node->nodeName === 'td' || $node->nodeName === 'th') { - $this->mode = self::IN_CELL; - break; - - /* 6. If node is a tr element, then switch the insertion mode to - "in row" and abort these steps. */ - } elseif($node->nodeName === 'tr') { - $this->mode = self::IN_ROW; - break; - - /* 7. If node is a tbody, thead, or tfoot element, then switch the - insertion mode to "in table body" and abort these steps. */ - } elseif(in_array($node->nodeName, array('tbody', 'thead', 'tfoot'))) { - $this->mode = self::IN_TBODY; - break; - - /* 8. If node is a caption element, then switch the insertion mode - to "in caption" and abort these steps. */ - } elseif($node->nodeName === 'caption') { - $this->mode = self::IN_CAPTION; - break; - - /* 9. If node is a colgroup element, then switch the insertion mode - to "in column group" and abort these steps. (innerHTML case) */ - } elseif($node->nodeName === 'colgroup') { - $this->mode = self::IN_CGROUP; - break; - - /* 10. If node is a table element, then switch the insertion mode - to "in table" and abort these steps. */ - } elseif($node->nodeName === 'table') { - $this->mode = self::IN_TABLE; - break; - - /* 11. If node is a head element, then switch the insertion mode - to "in body" ("in body"! not "in head"!) and abort these steps. - (innerHTML case) */ - } elseif($node->nodeName === 'head') { - $this->mode = self::IN_BODY; - break; - - /* 12. If node is a body element, then switch the insertion mode to - "in body" and abort these steps. */ - } elseif($node->nodeName === 'body') { - $this->mode = self::IN_BODY; - break; - - /* 13. If node is a frameset element, then switch the insertion - mode to "in frameset" and abort these steps. (innerHTML case) */ - } elseif($node->nodeName === 'frameset') { - $this->mode = self::IN_FRAME; - break; - - /* 14. If node is an html element, then: if the head element - pointer is null, switch the insertion mode to "before head", - otherwise, switch the insertion mode to "after head". In either - case, abort these steps. (innerHTML case) */ - } elseif($node->nodeName === 'html') { - $this->mode = ($this->head_pointer === null) - ? self::BEFOR_HEAD - : self::AFTER_HEAD; - - break; - - /* 15. If last is true, then set the insertion mode to "in body" - and abort these steps. (innerHTML case) */ - } elseif($last) { - $this->mode = self::IN_BODY; - break; - } - } - } - - private function closeCell() { - /* If the stack of open elements has a td or th element in table scope, - then act as if an end tag token with that tag name had been seen. */ - foreach(array('td', 'th') as $cell) { - if($this->elementInScope($cell, true)) { - $this->inCell(array( - 'name' => $cell, - 'type' => HTML5::ENDTAG - )); - - break; - } - } - } - - public function save() { - return $this->dom; - } -} -?> diff --git a/web/framework-1.1.17/.htaccess b/web/framework/.htaccess similarity index 100% rename from web/framework-1.1.17/.htaccess rename to web/framework/.htaccess diff --git a/web/framework-1.1.17/YiiBase.php b/web/framework/YiiBase.php similarity index 99% rename from web/framework-1.1.17/YiiBase.php rename to web/framework/YiiBase.php index 289b7f962..f406cff00 100644 --- a/web/framework-1.1.17/YiiBase.php +++ b/web/framework/YiiBase.php @@ -80,7 +80,7 @@ class YiiBase */ public static function getVersion() { - return '1.1.17'; + return '1.1.18'; } /** @@ -179,6 +179,7 @@ public static function getFrameworkPath() */ public static function createComponent($config) { + $args = func_get_args(); if(is_string($config)) { $type=$config; @@ -197,7 +198,6 @@ public static function createComponent($config) if(($n=func_num_args())>1) { - $args=func_get_args(); if($n===2) $object=new $type($args[1]); elseif($n===3) diff --git a/web/framework-1.1.17/base/CApplication.php b/web/framework/base/CApplication.php similarity index 99% rename from web/framework-1.1.17/base/CApplication.php rename to web/framework/base/CApplication.php index 8c44e27fb..5d891bd5d 100644 --- a/web/framework-1.1.17/base/CApplication.php +++ b/web/framework/base/CApplication.php @@ -133,7 +133,7 @@ public function __construct($config=null) { Yii::setApplication($this); - // set basePath at early as possible to avoid trouble + // set basePath as early as possible to avoid trouble if(is_string($config)) $config=require($config); if(isset($config['basePath'])) @@ -400,7 +400,7 @@ public function findLocalizedFile($srcFile,$srcLanguage=null,$language=null) /** * Returns the locale instance. * @param string $localeID the locale ID (e.g. en_US). If null, the {@link getLanguage application language ID} will be used. - * @return an instance of CLocale + * @return CLocale an instance of CLocale */ public function getLocale($localeID=null) { @@ -572,7 +572,7 @@ public function createUrl($route,$params=array(),$ampersand='&') public function createAbsoluteUrl($route,$params=array(),$schema='',$ampersand='&') { $url=$this->createUrl($route,$params,$ampersand); - if(strpos($url,'http')===0) + if(strpos($url,'http')===0 || strpos($url,'//')===0) return $url; else return $this->getRequest()->getHostInfo($schema).$url; diff --git a/web/framework-1.1.17/base/CApplicationComponent.php b/web/framework/base/CApplicationComponent.php similarity index 100% rename from web/framework-1.1.17/base/CApplicationComponent.php rename to web/framework/base/CApplicationComponent.php diff --git a/web/framework-1.1.17/base/CBehavior.php b/web/framework/base/CBehavior.php similarity index 100% rename from web/framework-1.1.17/base/CBehavior.php rename to web/framework/base/CBehavior.php diff --git a/web/framework-1.1.17/base/CComponent.php b/web/framework/base/CComponent.php similarity index 99% rename from web/framework-1.1.17/base/CComponent.php rename to web/framework/base/CComponent.php index 13d81f5a3..ed6901fbd 100644 --- a/web/framework-1.1.17/base/CComponent.php +++ b/web/framework/base/CComponent.php @@ -609,7 +609,14 @@ public function evaluateExpression($_expression_,$_data_=array()) if(is_string($_expression_)) { extract($_data_); - return eval('return '.$_expression_.';'); + try + { + return eval('return ' . $_expression_ . ';'); + } + catch (ParseError $e) + { + return false; + } } else { diff --git a/web/framework-1.1.17/base/CDbStatePersister.php b/web/framework/base/CDbStatePersister.php similarity index 100% rename from web/framework-1.1.17/base/CDbStatePersister.php rename to web/framework/base/CDbStatePersister.php diff --git a/web/framework-1.1.17/base/CErrorEvent.php b/web/framework/base/CErrorEvent.php similarity index 100% rename from web/framework-1.1.17/base/CErrorEvent.php rename to web/framework/base/CErrorEvent.php diff --git a/web/framework-1.1.17/base/CErrorHandler.php b/web/framework/base/CErrorHandler.php similarity index 100% rename from web/framework-1.1.17/base/CErrorHandler.php rename to web/framework/base/CErrorHandler.php diff --git a/web/framework-1.1.17/base/CException.php b/web/framework/base/CException.php similarity index 100% rename from web/framework-1.1.17/base/CException.php rename to web/framework/base/CException.php diff --git a/web/framework-1.1.17/base/CExceptionEvent.php b/web/framework/base/CExceptionEvent.php similarity index 100% rename from web/framework-1.1.17/base/CExceptionEvent.php rename to web/framework/base/CExceptionEvent.php diff --git a/web/framework-1.1.17/base/CHttpException.php b/web/framework/base/CHttpException.php similarity index 100% rename from web/framework-1.1.17/base/CHttpException.php rename to web/framework/base/CHttpException.php diff --git a/web/framework-1.1.17/base/CModel.php b/web/framework/base/CModel.php similarity index 100% rename from web/framework-1.1.17/base/CModel.php rename to web/framework/base/CModel.php diff --git a/web/framework-1.1.17/base/CModelBehavior.php b/web/framework/base/CModelBehavior.php similarity index 100% rename from web/framework-1.1.17/base/CModelBehavior.php rename to web/framework/base/CModelBehavior.php diff --git a/web/framework-1.1.17/base/CModelEvent.php b/web/framework/base/CModelEvent.php similarity index 100% rename from web/framework-1.1.17/base/CModelEvent.php rename to web/framework/base/CModelEvent.php diff --git a/web/framework-1.1.17/base/CModule.php b/web/framework/base/CModule.php similarity index 99% rename from web/framework-1.1.17/base/CModule.php rename to web/framework/base/CModule.php index b81b2bd41..57f27252a 100644 --- a/web/framework-1.1.17/base/CModule.php +++ b/web/framework/base/CModule.php @@ -71,7 +71,7 @@ public function __construct($id,$parent,$config=null) $this->_id=$id; $this->_parentModule=$parent; - // set basePath at early as possible to avoid trouble + // set basePath as early as possible to avoid trouble if(is_string($config)) $config=require($config); if(isset($config['basePath'])) diff --git a/web/framework-1.1.17/base/CSecurityManager.php b/web/framework/base/CSecurityManager.php similarity index 95% rename from web/framework-1.1.17/base/CSecurityManager.php rename to web/framework/base/CSecurityManager.php index 6f339c6da..9832498a1 100644 --- a/web/framework-1.1.17/base/CSecurityManager.php +++ b/web/framework/base/CSecurityManager.php @@ -614,4 +614,35 @@ public function compareString($expected,$actual) $diff|=(ord($actual[$i])^ord($expected[$i%$expectedLength])); return $diff===0; } + + /** + * Masks a token to make it uncompressible. + * Applies a random mask to the token and prepends the mask used to the result making the string always unique. + * Used to mitigate BREACH attack by randomizing how token is outputted on each request. + * @param string $token An unmasked token. + * @return string A masked token. + * @since 1.1.18 + */ + public function maskToken($token) + { + // The number of bytes in a mask is always equal to the number of bytes in a token. + $mask=$this->generateRandomString($this->strlen($token)); + return strtr(base64_encode($mask.($mask^$token)),'+/','-_'); + } + + /** + * Unmasks a token previously masked by `maskToken`. + * @param string $maskedToken A masked token. + * @return string An unmasked token, or an empty string in case of token format is invalid. + * @since 1.1.18 + */ + public function unmaskToken($maskedToken) + { + $decoded=base64_decode(strtr($maskedToken,'-_','+/')); + $length=$this->strlen($decoded)/2; + // Check if the masked token has an even length. + if(!is_int($length)) + return ''; + return $this->substr($decoded,$length,$length)^$this->substr($decoded,0,$length); + } } diff --git a/web/framework-1.1.17/base/CStatePersister.php b/web/framework/base/CStatePersister.php similarity index 98% rename from web/framework-1.1.17/base/CStatePersister.php rename to web/framework/base/CStatePersister.php index 86e3d9d2e..75b56f003 100644 --- a/web/framework-1.1.17/base/CStatePersister.php +++ b/web/framework/base/CStatePersister.php @@ -105,7 +105,8 @@ public function load() * Loads content from file using a shared lock to avoid data corruption when reading * the file while it is being written by save() * - * @return string file contents + * @param string $filename file name + * @return bool|string file contents * @since 1.1.17 */ protected function getContent($filename) diff --git a/web/framework-1.1.17/base/interfaces.php b/web/framework/base/interfaces.php similarity index 100% rename from web/framework-1.1.17/base/interfaces.php rename to web/framework/base/interfaces.php diff --git a/web/framework-1.1.17/caching/CApcCache.php b/web/framework/caching/CApcCache.php similarity index 100% rename from web/framework-1.1.17/caching/CApcCache.php rename to web/framework/caching/CApcCache.php diff --git a/web/framework-1.1.17/caching/CCache.php b/web/framework/caching/CCache.php similarity index 100% rename from web/framework-1.1.17/caching/CCache.php rename to web/framework/caching/CCache.php diff --git a/web/framework-1.1.17/caching/CDbCache.php b/web/framework/caching/CDbCache.php similarity index 100% rename from web/framework-1.1.17/caching/CDbCache.php rename to web/framework/caching/CDbCache.php diff --git a/web/framework-1.1.17/caching/CDummyCache.php b/web/framework/caching/CDummyCache.php similarity index 100% rename from web/framework-1.1.17/caching/CDummyCache.php rename to web/framework/caching/CDummyCache.php diff --git a/web/framework-1.1.17/caching/CEAcceleratorCache.php b/web/framework/caching/CEAcceleratorCache.php similarity index 100% rename from web/framework-1.1.17/caching/CEAcceleratorCache.php rename to web/framework/caching/CEAcceleratorCache.php diff --git a/web/framework-1.1.17/caching/CFileCache.php b/web/framework/caching/CFileCache.php similarity index 99% rename from web/framework-1.1.17/caching/CFileCache.php rename to web/framework/caching/CFileCache.php index 330e74d4d..6ecff4864 100644 --- a/web/framework-1.1.17/caching/CFileCache.php +++ b/web/framework/caching/CFileCache.php @@ -130,7 +130,7 @@ protected function getValue($key) { $cacheFile=$this->getCacheFile($key); if(($time=$this->filemtime($cacheFile))>time()) - return @file_get_contents($cacheFile,false,null,$this->embedExpiry ? 10 : -1); + return @file_get_contents($cacheFile,false,null,$this->embedExpiry ? 10 : null); elseif($time>0) @unlink($cacheFile); return false; diff --git a/web/framework-1.1.17/caching/CMemCache.php b/web/framework/caching/CMemCache.php similarity index 100% rename from web/framework-1.1.17/caching/CMemCache.php rename to web/framework/caching/CMemCache.php diff --git a/web/framework-1.1.17/caching/CRedisCache.php b/web/framework/caching/CRedisCache.php similarity index 99% rename from web/framework-1.1.17/caching/CRedisCache.php rename to web/framework/caching/CRedisCache.php index 3d19b8407..c122bff3d 100644 --- a/web/framework-1.1.17/caching/CRedisCache.php +++ b/web/framework/caching/CRedisCache.php @@ -95,7 +95,10 @@ protected function connect() $this->executeCommand('SELECT',array($this->database)); } else + { + $this->_socket = null; throw new CException('Failed to connect to redis: '.$errorDescription,(int)$errorNumber); + } } /** diff --git a/web/framework-1.1.17/caching/CWinCache.php b/web/framework/caching/CWinCache.php similarity index 100% rename from web/framework-1.1.17/caching/CWinCache.php rename to web/framework/caching/CWinCache.php diff --git a/web/framework-1.1.17/caching/CXCache.php b/web/framework/caching/CXCache.php similarity index 100% rename from web/framework-1.1.17/caching/CXCache.php rename to web/framework/caching/CXCache.php diff --git a/web/framework-1.1.17/caching/CZendDataCache.php b/web/framework/caching/CZendDataCache.php similarity index 100% rename from web/framework-1.1.17/caching/CZendDataCache.php rename to web/framework/caching/CZendDataCache.php diff --git a/web/framework-1.1.17/caching/dependencies/CCacheDependency.php b/web/framework/caching/dependencies/CCacheDependency.php similarity index 100% rename from web/framework-1.1.17/caching/dependencies/CCacheDependency.php rename to web/framework/caching/dependencies/CCacheDependency.php diff --git a/web/framework-1.1.17/caching/dependencies/CChainedCacheDependency.php b/web/framework/caching/dependencies/CChainedCacheDependency.php similarity index 100% rename from web/framework-1.1.17/caching/dependencies/CChainedCacheDependency.php rename to web/framework/caching/dependencies/CChainedCacheDependency.php diff --git a/web/framework-1.1.17/caching/dependencies/CDbCacheDependency.php b/web/framework/caching/dependencies/CDbCacheDependency.php similarity index 100% rename from web/framework-1.1.17/caching/dependencies/CDbCacheDependency.php rename to web/framework/caching/dependencies/CDbCacheDependency.php diff --git a/web/framework-1.1.17/caching/dependencies/CDirectoryCacheDependency.php b/web/framework/caching/dependencies/CDirectoryCacheDependency.php similarity index 100% rename from web/framework-1.1.17/caching/dependencies/CDirectoryCacheDependency.php rename to web/framework/caching/dependencies/CDirectoryCacheDependency.php diff --git a/web/framework-1.1.17/caching/dependencies/CExpressionDependency.php b/web/framework/caching/dependencies/CExpressionDependency.php similarity index 100% rename from web/framework-1.1.17/caching/dependencies/CExpressionDependency.php rename to web/framework/caching/dependencies/CExpressionDependency.php diff --git a/web/framework-1.1.17/caching/dependencies/CFileCacheDependency.php b/web/framework/caching/dependencies/CFileCacheDependency.php similarity index 100% rename from web/framework-1.1.17/caching/dependencies/CFileCacheDependency.php rename to web/framework/caching/dependencies/CFileCacheDependency.php diff --git a/web/framework-1.1.17/caching/dependencies/CGlobalStateCacheDependency.php b/web/framework/caching/dependencies/CGlobalStateCacheDependency.php similarity index 100% rename from web/framework-1.1.17/caching/dependencies/CGlobalStateCacheDependency.php rename to web/framework/caching/dependencies/CGlobalStateCacheDependency.php diff --git a/web/framework-1.1.17/cli/commands/MessageCommand.php b/web/framework/cli/commands/MessageCommand.php similarity index 97% rename from web/framework-1.1.17/cli/commands/MessageCommand.php rename to web/framework/cli/commands/MessageCommand.php index d1e0e2cfb..00d3b749e 100644 --- a/web/framework-1.1.17/cli/commands/MessageCommand.php +++ b/web/framework/cli/commands/MessageCommand.php @@ -147,7 +147,15 @@ protected function extractMessages($fileName,$translator) else $category=substr($matches[$i][1],1,-1); $message=$matches[$i][2]; - $messages[$category][]=eval("return $message;"); // use eval to eliminate quote escape + try + { + $evalResult = eval("return $message;"); // use eval to eliminate quote escape + } + catch (ParseError $e) + { + $evalResult = false; + } + $messages[$category][] = $evalResult; } } return $messages; diff --git a/web/framework-1.1.17/cli/commands/MigrateCommand.php b/web/framework/cli/commands/MigrateCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/MigrateCommand.php rename to web/framework/cli/commands/MigrateCommand.php diff --git a/web/framework-1.1.17/cli/commands/ShellCommand.php b/web/framework/cli/commands/ShellCommand.php similarity index 96% rename from web/framework-1.1.17/cli/commands/ShellCommand.php rename to web/framework/cli/commands/ShellCommand.php index 5855f261a..06aa82b57 100644 --- a/web/framework-1.1.17/cli/commands/ShellCommand.php +++ b/web/framework/cli/commands/ShellCommand.php @@ -125,7 +125,18 @@ protected function runShell() $_command_->run($_args_); } else - echo eval($_line_.';'); + { + try + { + $evalResult = eval($_line_ . ';'); + } + catch (ParseError $e) + { + $evalResult = false; + } + + echo $evalResult; + } } catch(Exception $e) { diff --git a/web/framework-1.1.17/cli/commands/WebAppCommand.php b/web/framework/cli/commands/WebAppCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/WebAppCommand.php rename to web/framework/cli/commands/WebAppCommand.php diff --git a/web/framework-1.1.17/cli/commands/shell/ControllerCommand.php b/web/framework/cli/commands/shell/ControllerCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/shell/ControllerCommand.php rename to web/framework/cli/commands/shell/ControllerCommand.php diff --git a/web/framework-1.1.17/cli/commands/shell/CrudCommand.php b/web/framework/cli/commands/shell/CrudCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/shell/CrudCommand.php rename to web/framework/cli/commands/shell/CrudCommand.php diff --git a/web/framework-1.1.17/cli/commands/shell/FormCommand.php b/web/framework/cli/commands/shell/FormCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/shell/FormCommand.php rename to web/framework/cli/commands/shell/FormCommand.php diff --git a/web/framework-1.1.17/cli/commands/shell/HelpCommand.php b/web/framework/cli/commands/shell/HelpCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/shell/HelpCommand.php rename to web/framework/cli/commands/shell/HelpCommand.php diff --git a/web/framework-1.1.17/cli/commands/shell/ModelCommand.php b/web/framework/cli/commands/shell/ModelCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/shell/ModelCommand.php rename to web/framework/cli/commands/shell/ModelCommand.php diff --git a/web/framework-1.1.17/cli/commands/shell/ModuleCommand.php b/web/framework/cli/commands/shell/ModuleCommand.php similarity index 100% rename from web/framework-1.1.17/cli/commands/shell/ModuleCommand.php rename to web/framework/cli/commands/shell/ModuleCommand.php diff --git a/web/framework-1.1.17/cli/views/shell/controller/controller.php b/web/framework/cli/views/shell/controller/controller.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/controller/controller.php rename to web/framework/cli/views/shell/controller/controller.php diff --git a/web/framework-1.1.17/cli/views/shell/controller/view.php b/web/framework/cli/views/shell/controller/view.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/controller/view.php rename to web/framework/cli/views/shell/controller/view.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/_form.php b/web/framework/cli/views/shell/crud/_form.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/_form.php rename to web/framework/cli/views/shell/crud/_form.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/_search.php b/web/framework/cli/views/shell/crud/_search.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/_search.php rename to web/framework/cli/views/shell/crud/_search.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/_view.php b/web/framework/cli/views/shell/crud/_view.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/_view.php rename to web/framework/cli/views/shell/crud/_view.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/admin.php b/web/framework/cli/views/shell/crud/admin.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/admin.php rename to web/framework/cli/views/shell/crud/admin.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/controller.php b/web/framework/cli/views/shell/crud/controller.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/controller.php rename to web/framework/cli/views/shell/crud/controller.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/create.php b/web/framework/cli/views/shell/crud/create.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/create.php rename to web/framework/cli/views/shell/crud/create.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/index.php b/web/framework/cli/views/shell/crud/index.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/index.php rename to web/framework/cli/views/shell/crud/index.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/test.php b/web/framework/cli/views/shell/crud/test.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/test.php rename to web/framework/cli/views/shell/crud/test.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/update.php b/web/framework/cli/views/shell/crud/update.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/update.php rename to web/framework/cli/views/shell/crud/update.php diff --git a/web/framework-1.1.17/cli/views/shell/crud/view.php b/web/framework/cli/views/shell/crud/view.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/crud/view.php rename to web/framework/cli/views/shell/crud/view.php diff --git a/web/framework-1.1.17/cli/views/shell/form/action.php b/web/framework/cli/views/shell/form/action.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/form/action.php rename to web/framework/cli/views/shell/form/action.php diff --git a/web/framework-1.1.17/cli/views/shell/form/form.php b/web/framework/cli/views/shell/form/form.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/form/form.php rename to web/framework/cli/views/shell/form/form.php diff --git a/web/framework-1.1.17/cli/views/shell/model/fixture.php b/web/framework/cli/views/shell/model/fixture.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/model/fixture.php rename to web/framework/cli/views/shell/model/fixture.php diff --git a/web/framework-1.1.17/cli/views/shell/model/model.php b/web/framework/cli/views/shell/model/model.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/model/model.php rename to web/framework/cli/views/shell/model/model.php diff --git a/web/framework-1.1.17/cli/views/shell/model/test.php b/web/framework/cli/views/shell/model/test.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/model/test.php rename to web/framework/cli/views/shell/model/test.php diff --git a/web/framework-1.1.17/cli/views/shell/module/controllers/DefaultController.php b/web/framework/cli/views/shell/module/controllers/DefaultController.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/module/controllers/DefaultController.php rename to web/framework/cli/views/shell/module/controllers/DefaultController.php diff --git a/web/framework-1.1.17/cli/views/shell/module/module.php b/web/framework/cli/views/shell/module/module.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/module/module.php rename to web/framework/cli/views/shell/module/module.php diff --git a/web/framework-1.1.17/cli/views/shell/module/views/default/index.php b/web/framework/cli/views/shell/module/views/default/index.php similarity index 100% rename from web/framework-1.1.17/cli/views/shell/module/views/default/index.php rename to web/framework/cli/views/shell/module/views/default/index.php diff --git a/web/framework-1.1.17/cli/views/webapp/assets/git-gitignore b/web/framework/cli/views/webapp/assets/git-gitignore similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/assets/git-gitignore rename to web/framework/cli/views/webapp/assets/git-gitignore diff --git a/web/framework-1.1.17/cli/views/webapp/assets/hg-hgkeep b/web/framework/cli/views/webapp/assets/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/assets/hg-hgkeep rename to web/framework/cli/views/webapp/assets/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/css/bg.gif b/web/framework/cli/views/webapp/css/bg.gif similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/css/bg.gif rename to web/framework/cli/views/webapp/css/bg.gif diff --git a/web/framework-1.1.17/cli/views/webapp/css/form.css b/web/framework/cli/views/webapp/css/form.css similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/css/form.css rename to web/framework/cli/views/webapp/css/form.css diff --git a/web/framework-1.1.17/cli/views/webapp/css/ie.css b/web/framework/cli/views/webapp/css/ie.css similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/css/ie.css rename to web/framework/cli/views/webapp/css/ie.css diff --git a/web/framework-1.1.17/cli/views/webapp/css/main.css b/web/framework/cli/views/webapp/css/main.css similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/css/main.css rename to web/framework/cli/views/webapp/css/main.css diff --git a/web/framework-1.1.17/cli/views/webapp/css/print.css b/web/framework/cli/views/webapp/css/print.css similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/css/print.css rename to web/framework/cli/views/webapp/css/print.css diff --git a/web/framework-1.1.17/cli/views/webapp/css/screen.css b/web/framework/cli/views/webapp/css/screen.css similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/css/screen.css rename to web/framework/cli/views/webapp/css/screen.css diff --git a/web/framework-1.1.17/cli/views/webapp/hg-hgignore b/web/framework/cli/views/webapp/hg-hgignore similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/hg-hgignore rename to web/framework/cli/views/webapp/hg-hgignore diff --git a/web/framework-1.1.17/cli/views/webapp/images/git-gitkeep b/web/framework/cli/views/webapp/images/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/images/git-gitkeep rename to web/framework/cli/views/webapp/images/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/images/hg-hgkeep b/web/framework/cli/views/webapp/images/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/images/hg-hgkeep rename to web/framework/cli/views/webapp/images/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/index-test.php b/web/framework/cli/views/webapp/index-test.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/index-test.php rename to web/framework/cli/views/webapp/index-test.php diff --git a/web/framework-1.1.17/cli/views/webapp/index.php b/web/framework/cli/views/webapp/index.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/index.php rename to web/framework/cli/views/webapp/index.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/.htaccess b/web/framework/cli/views/webapp/protected/.htaccess similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/.htaccess rename to web/framework/cli/views/webapp/protected/.htaccess diff --git a/web/framework-1.1.17/cli/views/webapp/protected/commands/shell/git-gitkeep b/web/framework/cli/views/webapp/protected/commands/shell/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/commands/shell/git-gitkeep rename to web/framework/cli/views/webapp/protected/commands/shell/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/commands/shell/hg-hgkeep b/web/framework/cli/views/webapp/protected/commands/shell/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/commands/shell/hg-hgkeep rename to web/framework/cli/views/webapp/protected/commands/shell/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/components/Controller.php b/web/framework/cli/views/webapp/protected/components/Controller.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/components/Controller.php rename to web/framework/cli/views/webapp/protected/components/Controller.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/components/UserIdentity.php b/web/framework/cli/views/webapp/protected/components/UserIdentity.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/components/UserIdentity.php rename to web/framework/cli/views/webapp/protected/components/UserIdentity.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/config/console.php b/web/framework/cli/views/webapp/protected/config/console.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/config/console.php rename to web/framework/cli/views/webapp/protected/config/console.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/config/database.php b/web/framework/cli/views/webapp/protected/config/database.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/config/database.php rename to web/framework/cli/views/webapp/protected/config/database.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/config/main.php b/web/framework/cli/views/webapp/protected/config/main.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/config/main.php rename to web/framework/cli/views/webapp/protected/config/main.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/config/test.php b/web/framework/cli/views/webapp/protected/config/test.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/config/test.php rename to web/framework/cli/views/webapp/protected/config/test.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/controllers/SiteController.php b/web/framework/cli/views/webapp/protected/controllers/SiteController.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/controllers/SiteController.php rename to web/framework/cli/views/webapp/protected/controllers/SiteController.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/data/schema.mysql.sql b/web/framework/cli/views/webapp/protected/data/schema.mysql.sql similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/data/schema.mysql.sql rename to web/framework/cli/views/webapp/protected/data/schema.mysql.sql diff --git a/web/framework-1.1.17/cli/views/webapp/protected/data/schema.sqlite.sql b/web/framework/cli/views/webapp/protected/data/schema.sqlite.sql similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/data/schema.sqlite.sql rename to web/framework/cli/views/webapp/protected/data/schema.sqlite.sql diff --git a/web/framework-1.1.17/cli/views/webapp/protected/data/testdrive.db b/web/framework/cli/views/webapp/protected/data/testdrive.db similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/data/testdrive.db rename to web/framework/cli/views/webapp/protected/data/testdrive.db diff --git a/web/framework-1.1.17/cli/views/webapp/protected/extensions/git-gitkeep b/web/framework/cli/views/webapp/protected/extensions/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/extensions/git-gitkeep rename to web/framework/cli/views/webapp/protected/extensions/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/extensions/hg-hgkeep b/web/framework/cli/views/webapp/protected/extensions/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/extensions/hg-hgkeep rename to web/framework/cli/views/webapp/protected/extensions/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/messages/git-gitkeep b/web/framework/cli/views/webapp/protected/messages/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/messages/git-gitkeep rename to web/framework/cli/views/webapp/protected/messages/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/messages/hg-hgkeep b/web/framework/cli/views/webapp/protected/messages/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/messages/hg-hgkeep rename to web/framework/cli/views/webapp/protected/messages/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/migrations/git-gitkeep b/web/framework/cli/views/webapp/protected/migrations/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/migrations/git-gitkeep rename to web/framework/cli/views/webapp/protected/migrations/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/migrations/hg-hgkeep b/web/framework/cli/views/webapp/protected/migrations/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/migrations/hg-hgkeep rename to web/framework/cli/views/webapp/protected/migrations/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/models/ContactForm.php b/web/framework/cli/views/webapp/protected/models/ContactForm.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/models/ContactForm.php rename to web/framework/cli/views/webapp/protected/models/ContactForm.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/models/LoginForm.php b/web/framework/cli/views/webapp/protected/models/LoginForm.php similarity index 91% rename from web/framework-1.1.17/cli/views/webapp/protected/models/LoginForm.php rename to web/framework/cli/views/webapp/protected/models/LoginForm.php index eb36e4a99..632c47578 100644 --- a/web/framework-1.1.17/cli/views/webapp/protected/models/LoginForm.php +++ b/web/framework/cli/views/webapp/protected/models/LoginForm.php @@ -43,6 +43,8 @@ public function attributeLabels() /** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). + * @param string $attribute the name of the attribute to be validated. + * @param array $params additional parameters passed with rule when being executed. */ public function authenticate($attribute,$params) { diff --git a/web/framework-1.1.17/cli/views/webapp/protected/runtime/git-gitignore b/web/framework/cli/views/webapp/protected/runtime/git-gitignore similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/runtime/git-gitignore rename to web/framework/cli/views/webapp/protected/runtime/git-gitignore diff --git a/web/framework-1.1.17/cli/views/webapp/protected/runtime/hg-hgkeep b/web/framework/cli/views/webapp/protected/runtime/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/runtime/hg-hgkeep rename to web/framework/cli/views/webapp/protected/runtime/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/WebTestCase.php b/web/framework/cli/views/webapp/protected/tests/WebTestCase.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/WebTestCase.php rename to web/framework/cli/views/webapp/protected/tests/WebTestCase.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/bootstrap.php b/web/framework/cli/views/webapp/protected/tests/bootstrap.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/bootstrap.php rename to web/framework/cli/views/webapp/protected/tests/bootstrap.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/fixtures/git-gitkeep b/web/framework/cli/views/webapp/protected/tests/fixtures/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/fixtures/git-gitkeep rename to web/framework/cli/views/webapp/protected/tests/fixtures/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/fixtures/hg-hgkeep b/web/framework/cli/views/webapp/protected/tests/fixtures/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/fixtures/hg-hgkeep rename to web/framework/cli/views/webapp/protected/tests/fixtures/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/functional/SiteTest.php b/web/framework/cli/views/webapp/protected/tests/functional/SiteTest.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/functional/SiteTest.php rename to web/framework/cli/views/webapp/protected/tests/functional/SiteTest.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/phpunit.xml b/web/framework/cli/views/webapp/protected/tests/phpunit.xml similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/phpunit.xml rename to web/framework/cli/views/webapp/protected/tests/phpunit.xml diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/report/git-gitignore b/web/framework/cli/views/webapp/protected/tests/report/git-gitignore similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/report/git-gitignore rename to web/framework/cli/views/webapp/protected/tests/report/git-gitignore diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/report/hg-hgkeep b/web/framework/cli/views/webapp/protected/tests/report/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/report/hg-hgkeep rename to web/framework/cli/views/webapp/protected/tests/report/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/unit/git-gitkeep b/web/framework/cli/views/webapp/protected/tests/unit/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/unit/git-gitkeep rename to web/framework/cli/views/webapp/protected/tests/unit/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/tests/unit/hg-hgkeep b/web/framework/cli/views/webapp/protected/tests/unit/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/tests/unit/hg-hgkeep rename to web/framework/cli/views/webapp/protected/tests/unit/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/vendor/git-gitkeep b/web/framework/cli/views/webapp/protected/vendor/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/vendor/git-gitkeep rename to web/framework/cli/views/webapp/protected/vendor/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/vendor/hg-hgkeep b/web/framework/cli/views/webapp/protected/vendor/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/vendor/hg-hgkeep rename to web/framework/cli/views/webapp/protected/vendor/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/layouts/column1.php b/web/framework/cli/views/webapp/protected/views/layouts/column1.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/layouts/column1.php rename to web/framework/cli/views/webapp/protected/views/layouts/column1.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/layouts/column2.php b/web/framework/cli/views/webapp/protected/views/layouts/column2.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/layouts/column2.php rename to web/framework/cli/views/webapp/protected/views/layouts/column2.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/layouts/main.php b/web/framework/cli/views/webapp/protected/views/layouts/main.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/layouts/main.php rename to web/framework/cli/views/webapp/protected/views/layouts/main.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/site/contact.php b/web/framework/cli/views/webapp/protected/views/site/contact.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/site/contact.php rename to web/framework/cli/views/webapp/protected/views/site/contact.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/site/error.php b/web/framework/cli/views/webapp/protected/views/site/error.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/site/error.php rename to web/framework/cli/views/webapp/protected/views/site/error.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/site/index.php b/web/framework/cli/views/webapp/protected/views/site/index.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/site/index.php rename to web/framework/cli/views/webapp/protected/views/site/index.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/site/login.php b/web/framework/cli/views/webapp/protected/views/site/login.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/site/login.php rename to web/framework/cli/views/webapp/protected/views/site/login.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/views/site/pages/about.php b/web/framework/cli/views/webapp/protected/views/site/pages/about.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/views/site/pages/about.php rename to web/framework/cli/views/webapp/protected/views/site/pages/about.php diff --git a/web/framework-1.1.17/cli/views/webapp/protected/yiic b/web/framework/cli/views/webapp/protected/yiic similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/yiic rename to web/framework/cli/views/webapp/protected/yiic diff --git a/web/framework-1.1.17/cli/views/webapp/protected/yiic.bat b/web/framework/cli/views/webapp/protected/yiic.bat similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/yiic.bat rename to web/framework/cli/views/webapp/protected/yiic.bat diff --git a/web/framework-1.1.17/cli/views/webapp/protected/yiic.php b/web/framework/cli/views/webapp/protected/yiic.php similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/protected/yiic.php rename to web/framework/cli/views/webapp/protected/yiic.php diff --git a/web/framework-1.1.17/cli/views/webapp/themes/classic/views/.htaccess b/web/framework/cli/views/webapp/themes/classic/views/.htaccess similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/themes/classic/views/.htaccess rename to web/framework/cli/views/webapp/themes/classic/views/.htaccess diff --git a/web/framework-1.1.17/cli/views/webapp/themes/classic/views/layouts/git-gitkeep b/web/framework/cli/views/webapp/themes/classic/views/layouts/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/themes/classic/views/layouts/git-gitkeep rename to web/framework/cli/views/webapp/themes/classic/views/layouts/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/themes/classic/views/layouts/hg-hgkeep b/web/framework/cli/views/webapp/themes/classic/views/layouts/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/themes/classic/views/layouts/hg-hgkeep rename to web/framework/cli/views/webapp/themes/classic/views/layouts/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/themes/classic/views/site/git-gitkeep b/web/framework/cli/views/webapp/themes/classic/views/site/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/themes/classic/views/site/git-gitkeep rename to web/framework/cli/views/webapp/themes/classic/views/site/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/themes/classic/views/site/hg-hgkeep b/web/framework/cli/views/webapp/themes/classic/views/site/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/themes/classic/views/site/hg-hgkeep rename to web/framework/cli/views/webapp/themes/classic/views/site/hg-hgkeep diff --git a/web/framework-1.1.17/cli/views/webapp/themes/classic/views/system/git-gitkeep b/web/framework/cli/views/webapp/themes/classic/views/system/git-gitkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/themes/classic/views/system/git-gitkeep rename to web/framework/cli/views/webapp/themes/classic/views/system/git-gitkeep diff --git a/web/framework-1.1.17/cli/views/webapp/themes/classic/views/system/hg-hgkeep b/web/framework/cli/views/webapp/themes/classic/views/system/hg-hgkeep similarity index 100% rename from web/framework-1.1.17/cli/views/webapp/themes/classic/views/system/hg-hgkeep rename to web/framework/cli/views/webapp/themes/classic/views/system/hg-hgkeep diff --git a/web/framework-1.1.17/collections/CAttributeCollection.php b/web/framework/collections/CAttributeCollection.php similarity index 100% rename from web/framework-1.1.17/collections/CAttributeCollection.php rename to web/framework/collections/CAttributeCollection.php diff --git a/web/framework-1.1.17/collections/CConfiguration.php b/web/framework/collections/CConfiguration.php similarity index 100% rename from web/framework-1.1.17/collections/CConfiguration.php rename to web/framework/collections/CConfiguration.php diff --git a/web/framework-1.1.17/collections/CList.php b/web/framework/collections/CList.php similarity index 100% rename from web/framework-1.1.17/collections/CList.php rename to web/framework/collections/CList.php diff --git a/web/framework-1.1.17/collections/CListIterator.php b/web/framework/collections/CListIterator.php similarity index 100% rename from web/framework-1.1.17/collections/CListIterator.php rename to web/framework/collections/CListIterator.php diff --git a/web/framework-1.1.17/collections/CMap.php b/web/framework/collections/CMap.php similarity index 100% rename from web/framework-1.1.17/collections/CMap.php rename to web/framework/collections/CMap.php diff --git a/web/framework-1.1.17/collections/CMapIterator.php b/web/framework/collections/CMapIterator.php similarity index 100% rename from web/framework-1.1.17/collections/CMapIterator.php rename to web/framework/collections/CMapIterator.php diff --git a/web/framework-1.1.17/collections/CQueue.php b/web/framework/collections/CQueue.php similarity index 100% rename from web/framework-1.1.17/collections/CQueue.php rename to web/framework/collections/CQueue.php diff --git a/web/framework-1.1.17/collections/CQueueIterator.php b/web/framework/collections/CQueueIterator.php similarity index 100% rename from web/framework-1.1.17/collections/CQueueIterator.php rename to web/framework/collections/CQueueIterator.php diff --git a/web/framework-1.1.17/collections/CStack.php b/web/framework/collections/CStack.php similarity index 100% rename from web/framework-1.1.17/collections/CStack.php rename to web/framework/collections/CStack.php diff --git a/web/framework-1.1.17/collections/CStackIterator.php b/web/framework/collections/CStackIterator.php similarity index 100% rename from web/framework-1.1.17/collections/CStackIterator.php rename to web/framework/collections/CStackIterator.php diff --git a/web/framework-1.1.17/collections/CTypedList.php b/web/framework/collections/CTypedList.php similarity index 100% rename from web/framework-1.1.17/collections/CTypedList.php rename to web/framework/collections/CTypedList.php diff --git a/web/framework-1.1.17/collections/CTypedMap.php b/web/framework/collections/CTypedMap.php similarity index 100% rename from web/framework-1.1.17/collections/CTypedMap.php rename to web/framework/collections/CTypedMap.php diff --git a/web/framework-1.1.17/console/CConsoleApplication.php b/web/framework/console/CConsoleApplication.php similarity index 100% rename from web/framework-1.1.17/console/CConsoleApplication.php rename to web/framework/console/CConsoleApplication.php diff --git a/web/framework-1.1.17/console/CConsoleCommand.php b/web/framework/console/CConsoleCommand.php similarity index 100% rename from web/framework-1.1.17/console/CConsoleCommand.php rename to web/framework/console/CConsoleCommand.php diff --git a/web/framework-1.1.17/console/CConsoleCommandBehavior.php b/web/framework/console/CConsoleCommandBehavior.php similarity index 100% rename from web/framework-1.1.17/console/CConsoleCommandBehavior.php rename to web/framework/console/CConsoleCommandBehavior.php diff --git a/web/framework-1.1.17/console/CConsoleCommandEvent.php b/web/framework/console/CConsoleCommandEvent.php similarity index 100% rename from web/framework-1.1.17/console/CConsoleCommandEvent.php rename to web/framework/console/CConsoleCommandEvent.php diff --git a/web/framework-1.1.17/console/CConsoleCommandRunner.php b/web/framework/console/CConsoleCommandRunner.php similarity index 100% rename from web/framework-1.1.17/console/CConsoleCommandRunner.php rename to web/framework/console/CConsoleCommandRunner.php diff --git a/web/framework-1.1.17/console/CHelpCommand.php b/web/framework/console/CHelpCommand.php similarity index 100% rename from web/framework-1.1.17/console/CHelpCommand.php rename to web/framework/console/CHelpCommand.php diff --git a/web/framework-1.1.17/db/CDbCommand.php b/web/framework/db/CDbCommand.php similarity index 100% rename from web/framework-1.1.17/db/CDbCommand.php rename to web/framework/db/CDbCommand.php diff --git a/web/framework-1.1.17/db/CDbConnection.php b/web/framework/db/CDbConnection.php similarity index 97% rename from web/framework-1.1.17/db/CDbConnection.php rename to web/framework/db/CDbConnection.php index 3fd88d833..0de608045 100644 --- a/web/framework-1.1.17/db/CDbConnection.php +++ b/web/framework/db/CDbConnection.php @@ -582,6 +582,26 @@ public function quoteValue($str) return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'"; } + /** + * Quotes a value for use in a query using a given type. + * @param mixed $value the value to be quoted. + * @param integer $type The type to be used for quoting. + * This should be one of the `PDO::PARAM_*` constants described in + * {@link http://www.php.net/manual/en/pdo.constants.php PDO documentation}. + * This parameter will be passed to the `PDO::quote()` function. + * @return string the properly quoted string. + * @see http://www.php.net/manual/en/function.PDO-quote.php + * @since 1.1.18 + */ + public function quoteValueWithType($value, $type) + { + $this->setActive(true); + if(($quoted=$this->_pdo->quote($value, $type))!==false) + return $quoted; + else // the driver doesn't support quote (e.g. oci) + return "'" . addcslashes(str_replace("'", "''", $value), "\000\n\r\\\032") . "'"; + } + /** * Quotes a table name for use in a query. * If the table name contains schema prefix, the prefix will also be properly quoted. diff --git a/web/framework-1.1.17/db/CDbDataReader.php b/web/framework/db/CDbDataReader.php similarity index 100% rename from web/framework-1.1.17/db/CDbDataReader.php rename to web/framework/db/CDbDataReader.php diff --git a/web/framework-1.1.17/db/CDbException.php b/web/framework/db/CDbException.php similarity index 100% rename from web/framework-1.1.17/db/CDbException.php rename to web/framework/db/CDbException.php diff --git a/web/framework-1.1.17/db/CDbMigration.php b/web/framework/db/CDbMigration.php similarity index 100% rename from web/framework-1.1.17/db/CDbMigration.php rename to web/framework/db/CDbMigration.php diff --git a/web/framework-1.1.17/db/CDbTransaction.php b/web/framework/db/CDbTransaction.php similarity index 100% rename from web/framework-1.1.17/db/CDbTransaction.php rename to web/framework/db/CDbTransaction.php diff --git a/web/framework-1.1.17/db/ar/CActiveFinder.php b/web/framework/db/ar/CActiveFinder.php similarity index 99% rename from web/framework-1.1.17/db/ar/CActiveFinder.php rename to web/framework/db/ar/CActiveFinder.php index 36eb86c85..4af164cdb 100644 --- a/web/framework-1.1.17/db/ar/CActiveFinder.php +++ b/web/framework/db/ar/CActiveFinder.php @@ -194,6 +194,7 @@ private function destroyJoinTree() * @param CJoinElement $parent the parent tree node * @param mixed $with the names of the related objects relative to the parent tree node * @param array $options additional query options to be merged with the relation + * @return CJoinElement|mixed * @throws CDbException if given parent tree node is an instance of {@link CStatElement} * or relation is not defined in the given parent's tree node model class */ diff --git a/web/framework-1.1.17/db/ar/CActiveRecord.php b/web/framework/db/ar/CActiveRecord.php similarity index 99% rename from web/framework-1.1.17/db/ar/CActiveRecord.php rename to web/framework/db/ar/CActiveRecord.php index 0619ee23c..5f1d1d619 100644 --- a/web/framework-1.1.17/db/ar/CActiveRecord.php +++ b/web/framework/db/ar/CActiveRecord.php @@ -150,6 +150,7 @@ public function __get($name) * This method is overridden so that AR attributes can be accessed like properties. * @param string $name property name * @param mixed $value property value + * @throws CException */ public function __set($name,$value) { @@ -188,6 +189,7 @@ public function __isset($name) * This method overrides the parent implementation by clearing * the specified attribute value. * @param string $name the property name or the event name + * @throws CException */ public function __unset($name) { @@ -812,9 +814,10 @@ public function save($runValidation=true,$attributes=null) } /** - * Returns if the current record is new. + * Returns if the current record is new (was never saved to database) * @return boolean whether the record is new and should be inserted when calling {@link save}. - * This property is automatically set in constructor and {@link populateRecord}. + * This property is automatically set in constructor and {@link populateRecord} and is set + * to false right after inserting record to database. * Defaults to false, but it will be set to true if the instance is created using * the new operator. */ diff --git a/web/framework-1.1.17/db/ar/CActiveRecordBehavior.php b/web/framework/db/ar/CActiveRecordBehavior.php similarity index 100% rename from web/framework-1.1.17/db/ar/CActiveRecordBehavior.php rename to web/framework/db/ar/CActiveRecordBehavior.php diff --git a/web/framework-1.1.17/db/schema/CDbColumnSchema.php b/web/framework/db/schema/CDbColumnSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/CDbColumnSchema.php rename to web/framework/db/schema/CDbColumnSchema.php diff --git a/web/framework-1.1.17/db/schema/CDbCommandBuilder.php b/web/framework/db/schema/CDbCommandBuilder.php similarity index 100% rename from web/framework-1.1.17/db/schema/CDbCommandBuilder.php rename to web/framework/db/schema/CDbCommandBuilder.php diff --git a/web/framework-1.1.17/db/schema/CDbCriteria.php b/web/framework/db/schema/CDbCriteria.php similarity index 100% rename from web/framework-1.1.17/db/schema/CDbCriteria.php rename to web/framework/db/schema/CDbCriteria.php diff --git a/web/framework-1.1.17/db/schema/CDbExpression.php b/web/framework/db/schema/CDbExpression.php similarity index 100% rename from web/framework-1.1.17/db/schema/CDbExpression.php rename to web/framework/db/schema/CDbExpression.php diff --git a/web/framework-1.1.17/db/schema/CDbSchema.php b/web/framework/db/schema/CDbSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/CDbSchema.php rename to web/framework/db/schema/CDbSchema.php diff --git a/web/framework-1.1.17/db/schema/CDbTableSchema.php b/web/framework/db/schema/CDbTableSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/CDbTableSchema.php rename to web/framework/db/schema/CDbTableSchema.php diff --git a/web/framework-1.1.17/db/schema/cubrid/CCubridColumnSchema.php b/web/framework/db/schema/cubrid/CCubridColumnSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/cubrid/CCubridColumnSchema.php rename to web/framework/db/schema/cubrid/CCubridColumnSchema.php diff --git a/web/framework-1.1.17/db/schema/cubrid/CCubridSchema.php b/web/framework/db/schema/cubrid/CCubridSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/cubrid/CCubridSchema.php rename to web/framework/db/schema/cubrid/CCubridSchema.php diff --git a/web/framework-1.1.17/db/schema/cubrid/CCubridTableSchema.php b/web/framework/db/schema/cubrid/CCubridTableSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/cubrid/CCubridTableSchema.php rename to web/framework/db/schema/cubrid/CCubridTableSchema.php diff --git a/web/framework-1.1.17/db/schema/mssql/CMssqlColumnSchema.php b/web/framework/db/schema/mssql/CMssqlColumnSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/mssql/CMssqlColumnSchema.php rename to web/framework/db/schema/mssql/CMssqlColumnSchema.php diff --git a/web/framework-1.1.17/db/schema/mssql/CMssqlCommandBuilder.php b/web/framework/db/schema/mssql/CMssqlCommandBuilder.php similarity index 100% rename from web/framework-1.1.17/db/schema/mssql/CMssqlCommandBuilder.php rename to web/framework/db/schema/mssql/CMssqlCommandBuilder.php diff --git a/web/framework-1.1.17/db/schema/mssql/CMssqlPdoAdapter.php b/web/framework/db/schema/mssql/CMssqlPdoAdapter.php similarity index 100% rename from web/framework-1.1.17/db/schema/mssql/CMssqlPdoAdapter.php rename to web/framework/db/schema/mssql/CMssqlPdoAdapter.php diff --git a/web/framework-1.1.17/db/schema/mssql/CMssqlSchema.php b/web/framework/db/schema/mssql/CMssqlSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/mssql/CMssqlSchema.php rename to web/framework/db/schema/mssql/CMssqlSchema.php diff --git a/web/framework-1.1.17/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php b/web/framework/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php similarity index 100% rename from web/framework-1.1.17/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php rename to web/framework/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php diff --git a/web/framework-1.1.17/db/schema/mssql/CMssqlTableSchema.php b/web/framework/db/schema/mssql/CMssqlTableSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/mssql/CMssqlTableSchema.php rename to web/framework/db/schema/mssql/CMssqlTableSchema.php diff --git a/web/framework-1.1.17/db/schema/mysql/CMysqlColumnSchema.php b/web/framework/db/schema/mysql/CMysqlColumnSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/mysql/CMysqlColumnSchema.php rename to web/framework/db/schema/mysql/CMysqlColumnSchema.php diff --git a/web/framework-1.1.17/db/schema/mysql/CMysqlCommandBuilder.php b/web/framework/db/schema/mysql/CMysqlCommandBuilder.php similarity index 100% rename from web/framework-1.1.17/db/schema/mysql/CMysqlCommandBuilder.php rename to web/framework/db/schema/mysql/CMysqlCommandBuilder.php diff --git a/web/framework-1.1.17/db/schema/mysql/CMysqlSchema.php b/web/framework/db/schema/mysql/CMysqlSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/mysql/CMysqlSchema.php rename to web/framework/db/schema/mysql/CMysqlSchema.php diff --git a/web/framework-1.1.17/db/schema/mysql/CMysqlTableSchema.php b/web/framework/db/schema/mysql/CMysqlTableSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/mysql/CMysqlTableSchema.php rename to web/framework/db/schema/mysql/CMysqlTableSchema.php diff --git a/web/framework-1.1.17/db/schema/oci/COciColumnSchema.php b/web/framework/db/schema/oci/COciColumnSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/oci/COciColumnSchema.php rename to web/framework/db/schema/oci/COciColumnSchema.php diff --git a/web/framework-1.1.17/db/schema/oci/COciCommandBuilder.php b/web/framework/db/schema/oci/COciCommandBuilder.php similarity index 100% rename from web/framework-1.1.17/db/schema/oci/COciCommandBuilder.php rename to web/framework/db/schema/oci/COciCommandBuilder.php diff --git a/web/framework-1.1.17/db/schema/oci/COciSchema.php b/web/framework/db/schema/oci/COciSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/oci/COciSchema.php rename to web/framework/db/schema/oci/COciSchema.php diff --git a/web/framework-1.1.17/db/schema/oci/COciTableSchema.php b/web/framework/db/schema/oci/COciTableSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/oci/COciTableSchema.php rename to web/framework/db/schema/oci/COciTableSchema.php diff --git a/web/framework-1.1.17/db/schema/pgsql/CPgsqlColumnSchema.php b/web/framework/db/schema/pgsql/CPgsqlColumnSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/pgsql/CPgsqlColumnSchema.php rename to web/framework/db/schema/pgsql/CPgsqlColumnSchema.php diff --git a/web/framework-1.1.17/db/schema/pgsql/CPgsqlCommandBuilder.php b/web/framework/db/schema/pgsql/CPgsqlCommandBuilder.php similarity index 100% rename from web/framework-1.1.17/db/schema/pgsql/CPgsqlCommandBuilder.php rename to web/framework/db/schema/pgsql/CPgsqlCommandBuilder.php diff --git a/web/framework-1.1.17/db/schema/pgsql/CPgsqlSchema.php b/web/framework/db/schema/pgsql/CPgsqlSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/pgsql/CPgsqlSchema.php rename to web/framework/db/schema/pgsql/CPgsqlSchema.php diff --git a/web/framework-1.1.17/db/schema/pgsql/CPgsqlTableSchema.php b/web/framework/db/schema/pgsql/CPgsqlTableSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/pgsql/CPgsqlTableSchema.php rename to web/framework/db/schema/pgsql/CPgsqlTableSchema.php diff --git a/web/framework-1.1.17/db/schema/sqlite/CSqliteColumnSchema.php b/web/framework/db/schema/sqlite/CSqliteColumnSchema.php similarity index 100% rename from web/framework-1.1.17/db/schema/sqlite/CSqliteColumnSchema.php rename to web/framework/db/schema/sqlite/CSqliteColumnSchema.php diff --git a/web/framework-1.1.17/db/schema/sqlite/CSqliteCommandBuilder.php b/web/framework/db/schema/sqlite/CSqliteCommandBuilder.php similarity index 100% rename from web/framework-1.1.17/db/schema/sqlite/CSqliteCommandBuilder.php rename to web/framework/db/schema/sqlite/CSqliteCommandBuilder.php diff --git a/web/framework-1.1.17/db/schema/sqlite/CSqliteSchema.php b/web/framework/db/schema/sqlite/CSqliteSchema.php similarity index 98% rename from web/framework-1.1.17/db/schema/sqlite/CSqliteSchema.php rename to web/framework/db/schema/sqlite/CSqliteSchema.php index bdf31be61..b6294b1e6 100644 --- a/web/framework-1.1.17/db/schema/sqlite/CSqliteSchema.php +++ b/web/framework/db/schema/sqlite/CSqliteSchema.php @@ -225,6 +225,7 @@ public function truncateTable($table) * @param string $column the name of the column to be dropped. The name will be properly quoted by the method. * @return string the SQL statement for dropping a DB column. * @since 1.1.6 + * @throws CDbException */ public function dropColumn($table, $column) { @@ -239,6 +240,7 @@ public function dropColumn($table, $column) * @param string $newName the new name of the column. The name will be properly quoted by the method. * @return string the SQL statement for renaming a DB column. * @since 1.1.6 + * @throws CDbException */ public function renameColumn($table, $name, $newName) { @@ -257,6 +259,7 @@ public function renameColumn($table, $name, $newName) * @param string $update the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL * @return string the SQL statement for adding a foreign key constraint to an existing table. * @since 1.1.6 + * @throws CDbException */ public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete=null, $update=null) { @@ -270,6 +273,7 @@ public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $ * @param string $table the table whose foreign is to be dropped. The name will be properly quoted by the method. * @return string the SQL statement for dropping a foreign key constraint. * @since 1.1.6 + * @throws CDbException */ public function dropForeignKey($name, $table) { @@ -286,6 +290,7 @@ public function dropForeignKey($name, $table) * For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'. * @return string the SQL statement for changing the definition of a column. * @since 1.1.6 + * @throws CDbException */ public function alterColumn($table, $column, $type) { @@ -312,6 +317,7 @@ public function dropIndex($name, $table) * @param string|array $columns comma separated string or array of columns that the primary key will consist of. * @return string the SQL statement for adding a primary key constraint to an existing table. * @since 1.1.13 + * @throws CDbException */ public function addPrimaryKey($name,$table,$columns) { @@ -326,6 +332,7 @@ public function addPrimaryKey($name,$table,$columns) * @param string $table the table that the primary key constraint will be removed from. * @return string the SQL statement for removing a primary key constraint from an existing table. * @since 1.1.13 + * @throws CDbException */ public function dropPrimaryKey($name,$table) { diff --git a/web/framework-1.1.17/gii/CCodeFile.php b/web/framework/gii/CCodeFile.php similarity index 100% rename from web/framework-1.1.17/gii/CCodeFile.php rename to web/framework/gii/CCodeFile.php diff --git a/web/framework-1.1.17/gii/CCodeForm.php b/web/framework/gii/CCodeForm.php similarity index 100% rename from web/framework-1.1.17/gii/CCodeForm.php rename to web/framework/gii/CCodeForm.php diff --git a/web/framework-1.1.17/gii/CCodeGenerator.php b/web/framework/gii/CCodeGenerator.php similarity index 100% rename from web/framework-1.1.17/gii/CCodeGenerator.php rename to web/framework/gii/CCodeGenerator.php diff --git a/web/framework-1.1.17/gii/CCodeModel.php b/web/framework/gii/CCodeModel.php similarity index 100% rename from web/framework-1.1.17/gii/CCodeModel.php rename to web/framework/gii/CCodeModel.php diff --git a/web/framework-1.1.17/gii/GiiModule.php b/web/framework/gii/GiiModule.php similarity index 100% rename from web/framework-1.1.17/gii/GiiModule.php rename to web/framework/gii/GiiModule.php diff --git a/web/framework-1.1.17/gii/assets/css/ie.css b/web/framework/gii/assets/css/ie.css similarity index 100% rename from web/framework-1.1.17/gii/assets/css/ie.css rename to web/framework/gii/assets/css/ie.css diff --git a/web/framework-1.1.17/gii/assets/css/main.css b/web/framework/gii/assets/css/main.css similarity index 100% rename from web/framework-1.1.17/gii/assets/css/main.css rename to web/framework/gii/assets/css/main.css diff --git a/web/framework-1.1.17/gii/assets/css/print.css b/web/framework/gii/assets/css/print.css similarity index 100% rename from web/framework-1.1.17/gii/assets/css/print.css rename to web/framework/gii/assets/css/print.css diff --git a/web/framework-1.1.17/gii/assets/css/screen.css b/web/framework/gii/assets/css/screen.css similarity index 100% rename from web/framework-1.1.17/gii/assets/css/screen.css rename to web/framework/gii/assets/css/screen.css diff --git a/web/framework-1.1.17/gii/assets/images/logo.png b/web/framework/gii/assets/images/logo.png similarity index 100% rename from web/framework-1.1.17/gii/assets/images/logo.png rename to web/framework/gii/assets/images/logo.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/blank.gif b/web/framework/gii/assets/js/fancybox/blank.gif similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/blank.gif rename to web/framework/gii/assets/js/fancybox/blank.gif diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_close.png b/web/framework/gii/assets/js/fancybox/fancy_close.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_close.png rename to web/framework/gii/assets/js/fancybox/fancy_close.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_loading.png b/web/framework/gii/assets/js/fancybox/fancy_loading.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_loading.png rename to web/framework/gii/assets/js/fancybox/fancy_loading.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_nav_left.png b/web/framework/gii/assets/js/fancybox/fancy_nav_left.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_nav_left.png rename to web/framework/gii/assets/js/fancybox/fancy_nav_left.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_nav_right.png b/web/framework/gii/assets/js/fancybox/fancy_nav_right.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_nav_right.png rename to web/framework/gii/assets/js/fancybox/fancy_nav_right.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_e.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_e.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_e.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_e.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_n.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_n.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_n.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_n.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_ne.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_ne.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_ne.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_ne.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_nw.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_nw.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_nw.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_nw.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_s.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_s.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_s.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_s.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_se.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_se.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_se.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_se.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_sw.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_sw.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_sw.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_sw.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_w.png b/web/framework/gii/assets/js/fancybox/fancy_shadow_w.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_shadow_w.png rename to web/framework/gii/assets/js/fancybox/fancy_shadow_w.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_left.png b/web/framework/gii/assets/js/fancybox/fancy_title_left.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_left.png rename to web/framework/gii/assets/js/fancybox/fancy_title_left.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_main.png b/web/framework/gii/assets/js/fancybox/fancy_title_main.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_main.png rename to web/framework/gii/assets/js/fancybox/fancy_title_main.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_over.png b/web/framework/gii/assets/js/fancybox/fancy_title_over.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_over.png rename to web/framework/gii/assets/js/fancybox/fancy_title_over.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_right.png b/web/framework/gii/assets/js/fancybox/fancy_title_right.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancy_title_right.png rename to web/framework/gii/assets/js/fancybox/fancy_title_right.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancybox-x.png b/web/framework/gii/assets/js/fancybox/fancybox-x.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancybox-x.png rename to web/framework/gii/assets/js/fancybox/fancybox-x.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancybox-y.png b/web/framework/gii/assets/js/fancybox/fancybox-y.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancybox-y.png rename to web/framework/gii/assets/js/fancybox/fancybox-y.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/fancybox.png b/web/framework/gii/assets/js/fancybox/fancybox.png similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/fancybox.png rename to web/framework/gii/assets/js/fancybox/fancybox.png diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/jquery.fancybox-1.3.1.css b/web/framework/gii/assets/js/fancybox/jquery.fancybox-1.3.1.css similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/jquery.fancybox-1.3.1.css rename to web/framework/gii/assets/js/fancybox/jquery.fancybox-1.3.1.css diff --git a/web/framework-1.1.17/gii/assets/js/fancybox/jquery.fancybox-1.3.1.pack.js b/web/framework/gii/assets/js/fancybox/jquery.fancybox-1.3.1.pack.js similarity index 100% rename from web/framework-1.1.17/gii/assets/js/fancybox/jquery.fancybox-1.3.1.pack.js rename to web/framework/gii/assets/js/fancybox/jquery.fancybox-1.3.1.pack.js diff --git a/web/framework-1.1.17/gii/assets/js/main.js b/web/framework/gii/assets/js/main.js similarity index 100% rename from web/framework-1.1.17/gii/assets/js/main.js rename to web/framework/gii/assets/js/main.js diff --git a/web/framework-1.1.17/gii/assets/js/tooltip.js b/web/framework/gii/assets/js/tooltip.js similarity index 100% rename from web/framework-1.1.17/gii/assets/js/tooltip.js rename to web/framework/gii/assets/js/tooltip.js diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff.php b/web/framework/gii/components/Pear/Text/Diff.php similarity index 95% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff.php rename to web/framework/gii/components/Pear/Text/Diff.php index 4b30968f9..eb0079a73 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff.php +++ b/web/framework/gii/components/Pear/Text/Diff.php @@ -6,10 +6,10 @@ * The original PHP version of this code was written by Geoffrey T. Dairiki * , and is used/adapted with his permission. * - * $Horde: framework/Text_Diff/Diff.php,v 1.11.2.11 2008/02/24 10:57:46 jan Exp $ + * $Horde: framework/Text_Diff/Diff.php,v 1.11.2.12 2009/01/06 15:23:41 jan Exp $ * * Copyright 2004 Geoffrey T. Dairiki - * Copyright 2004-2008 The Horde Project (http://www.horde.org/) + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. @@ -35,7 +35,7 @@ class Text_Diff { * Normally an array of two arrays, each * containing the lines from a file. */ - function Text_Diff($engine, $params) + function __construct($engine, $params) { // Backward compatibility workaround. if (!is_string($engine)) { @@ -307,13 +307,13 @@ class Text_MappedDiff extends Text_Diff { * @param array $mapped_to_lines This array should have the same number * of elements as $to_lines. */ - function Text_MappedDiff($from_lines, $to_lines, + function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { assert(count($from_lines) == count($mapped_from_lines)); assert(count($to_lines) == count($mapped_to_lines)); - parent::Text_Diff($mapped_from_lines, $mapped_to_lines); + parent::__construct($mapped_from_lines, $mapped_to_lines); $xi = $yi = 0; for ($i = 0; $i < count($this->_edits); $i++) { @@ -369,7 +369,7 @@ function nfinal() */ class Text_Diff_Op_copy extends Text_Diff_Op { - function Text_Diff_Op_copy($orig, $final = false) + function __construct($orig, $final = false) { if (!is_array($final)) { $final = $orig; @@ -394,7 +394,7 @@ function &reverse() */ class Text_Diff_Op_delete extends Text_Diff_Op { - function Text_Diff_Op_delete($lines) + function __construct($lines) { $this->orig = $lines; $this->final = false; @@ -416,7 +416,7 @@ function &reverse() */ class Text_Diff_Op_add extends Text_Diff_Op { - function Text_Diff_Op_add($lines) + function __construct($lines) { $this->final = $lines; $this->orig = false; @@ -438,7 +438,7 @@ function &reverse() */ class Text_Diff_Op_change extends Text_Diff_Op { - function Text_Diff_Op_change($orig, $final) + function __construct($orig, $final) { $this->orig = $orig; $this->final = $final; diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/native.php b/web/framework/gii/components/Pear/Text/Diff/Engine/native.php similarity index 99% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/native.php rename to web/framework/gii/components/Pear/Text/Diff/Engine/native.php index 410f84995..86240e598 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/native.php +++ b/web/framework/gii/components/Pear/Text/Diff/Engine/native.php @@ -18,9 +18,9 @@ * Geoffrey T. Dairiki . The original PHP version of this * code was written by him, and is used/adapted with his permission. * - * $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.7.2.4 2008/01/04 10:38:10 jan Exp $ + * $Horde: framework/Text_Diff/Diff/Engine/native.php,v 1.7.2.5 2009/01/06 15:23:41 jan Exp $ * - * Copyright 2004-2008 The Horde Project (http://www.horde.org/) + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/shell.php b/web/framework/gii/components/Pear/Text/Diff/Engine/shell.php similarity index 93% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/shell.php rename to web/framework/gii/components/Pear/Text/Diff/Engine/shell.php index f1aaa98f0..7f858cbff 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/shell.php +++ b/web/framework/gii/components/Pear/Text/Diff/Engine/shell.php @@ -5,9 +5,9 @@ * This class uses the Unix `diff` program via shell_exec to compute the * differences between the two input arrays. * - * $Horde: framework/Text_Diff/Diff/Engine/shell.php,v 1.6.2.3 2008/01/04 10:37:27 jan Exp $ + * $Horde: framework/Text_Diff/Diff/Engine/shell.php,v 1.6.2.4 2009/01/06 15:23:41 jan Exp $ * - * Copyright 2007-2008 The Horde Project (http://www.horde.org/) + * Copyright 2007-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. @@ -138,8 +138,10 @@ function diff($from_lines, $to_lines) * @access private * * @param array &$text_lines Either $from_lines or $to_lines - * @param integer &$line_no Current line number - * @param integer $end Optional end line, when we want to chop more than one line. + * @param int &$line_no Current line number + * @param int $end Optional end line, when we want to chop more + * than one line. + * * @return array The chopped lines */ function _getLines(&$text_lines, &$line_no, $end = false) diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/string.php b/web/framework/gii/components/Pear/Text/Diff/Engine/string.php similarity index 93% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/string.php rename to web/framework/gii/components/Pear/Text/Diff/Engine/string.php index 4b29daafe..9352e60d6 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/string.php +++ b/web/framework/gii/components/Pear/Text/Diff/Engine/string.php @@ -10,10 +10,10 @@ * echo $renderer->render($diff); * * - * $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.5.2.5 2008/09/10 08:31:58 jan Exp $ + * $Horde: framework/Text_Diff/Diff/Engine/string.php,v 1.5.2.7 2009/07/24 13:04:43 jan Exp $ * * Copyright 2005 Örjan Persson - * Copyright 2005-2008 The Horde Project (http://www.horde.org/) + * Copyright 2005-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. @@ -39,6 +39,19 @@ class Text_Diff_Engine_string { */ function diff($diff, $mode = 'autodetect') { + // Detect line breaks. + $lnbr = "\n"; + if (strpos($diff, "\r\n") !== false) { + $lnbr = "\r\n"; + } elseif (strpos($diff, "\r") !== false) { + $lnbr = "\r"; + } + + // Make sure we have a line break at the EOF. + if (substr($diff, -strlen($lnbr)) != $lnbr) { + $diff .= $lnbr; + } + if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') { return PEAR::raiseError('Type of diff is unsupported'); } @@ -56,7 +69,7 @@ function diff($diff, $mode = 'autodetect') } // Split by new line and remove the diff header, if there is one. - $diff = explode("\n", $diff); + $diff = explode($lnbr, $diff); if (($mode == 'context' && strpos($diff[0], '***') === 0) || ($mode == 'unified' && strpos($diff[0], '---') === 0)) { array_shift($diff); diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/xdiff.php b/web/framework/gii/components/Pear/Text/Diff/Engine/xdiff.php similarity index 89% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/xdiff.php rename to web/framework/gii/components/Pear/Text/Diff/Engine/xdiff.php index 681ea4cf8..da8f174fb 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Engine/xdiff.php +++ b/web/framework/gii/components/Pear/Text/Diff/Engine/xdiff.php @@ -5,9 +5,9 @@ * This class uses the xdiff PECL package (http://pecl.php.net/package/xdiff) * to compute the differences between the two input arrays. * - * $Horde: framework/Text_Diff/Diff/Engine/xdiff.php,v 1.4.2.3 2008/01/04 10:37:27 jan Exp $ + * $Horde: framework/Text_Diff/Diff/Engine/xdiff.php,v 1.4.2.5 2009/07/24 13:06:24 jan Exp $ * - * Copyright 2004-2008 The Horde Project (http://www.horde.org/) + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. @@ -42,6 +42,9 @@ function diff($from_lines, $to_lines) * valid, albeit a little less descriptive and efficient. */ $edits = array(); foreach ($diff as $line) { + if (!strlen($line)) { + continue; + } switch ($line[0]) { case ' ': $edits[] = new Text_Diff_Op_copy(array(substr($line, 1))); diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Mapped.php b/web/framework/gii/components/Pear/Text/Diff/Mapped.php similarity index 86% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Mapped.php rename to web/framework/gii/components/Pear/Text/Diff/Mapped.php index 7f671844e..e4a3e013b 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Mapped.php +++ b/web/framework/gii/components/Pear/Text/Diff/Mapped.php @@ -1,8 +1,8 @@ $value) { $v = '_' . $param; diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/context.php b/web/framework/gii/components/Pear/Text/Diff/Renderer/context.php similarity index 94% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/context.php rename to web/framework/gii/components/Pear/Text/Diff/Renderer/context.php index 79775006a..af538015f 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/context.php +++ b/web/framework/gii/components/Pear/Text/Diff/Renderer/context.php @@ -4,9 +4,9 @@ * * This class renders the diff in classic "context diff" format. * - * $Horde: framework/Text_Diff/Diff/Renderer/context.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $ + * $Horde: framework/Text_Diff/Diff/Renderer/context.php,v 1.3.2.4 2009/01/06 15:23:42 jan Exp $ * - * Copyright 2004-2008 The Horde Project (http://www.horde.org/) + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/inline.php b/web/framework/gii/components/Pear/Text/Diff/Renderer/inline.php similarity index 90% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/inline.php rename to web/framework/gii/components/Pear/Text/Diff/Renderer/inline.php index 7f4e5ef2c..5dd20d2f3 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/inline.php +++ b/web/framework/gii/components/Pear/Text/Diff/Renderer/inline.php @@ -2,9 +2,9 @@ /** * "Inline" diff renderer. * - * $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.4.10.14 2008/01/04 10:37:27 jan Exp $ + * $Horde: framework/Text_Diff/Diff/Renderer/inline.php,v 1.4.10.16 2009/07/24 13:25:29 jan Exp $ * - * Copyright 2004-2008 The Horde Project (http://www.horde.org/) + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. @@ -131,12 +131,14 @@ function _changed($orig, $final) /* We want to split on word boundaries, but we need to * preserve whitespace as well. Therefore we split on words, * but include all blocks of whitespace in the wordlist. */ - $diff = new Text_Diff($this->_splitOnWords($text1, $nl), - $this->_splitOnWords($text2, $nl)); + $diff = new Text_Diff('native', + array($this->_splitOnWords($text1, $nl), + $this->_splitOnWords($text2, $nl))); /* Get the diff in inline format. */ - $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(), - array('split_level' => 'words'))); + $renderer = new Text_Diff_Renderer_inline + (array_merge($this->getParams(), + array('split_level' => 'words'))); /* Run the diff and get the output. */ return str_replace($nl, "\n", $renderer->render($diff)) . "\n"; diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/unified.php b/web/framework/gii/components/Pear/Text/Diff/Renderer/unified.php similarity index 93% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/unified.php rename to web/framework/gii/components/Pear/Text/Diff/Renderer/unified.php index 943d519ac..f990f7295 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/Renderer/unified.php +++ b/web/framework/gii/components/Pear/Text/Diff/Renderer/unified.php @@ -4,9 +4,9 @@ * * This class renders the diff in classic "unified diff" format. * - * $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.3.10.6 2008/01/04 10:37:27 jan Exp $ + * $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.3.10.7 2009/01/06 15:23:42 jan Exp $ * - * Copyright 2004-2008 The Horde Project (http://www.horde.org/) + * Copyright 2004-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff/ThreeWay.php b/web/framework/gii/components/Pear/Text/Diff/ThreeWay.php similarity index 94% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff/ThreeWay.php rename to web/framework/gii/components/Pear/Text/Diff/ThreeWay.php index 4e4b939d0..a24757417 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff/ThreeWay.php +++ b/web/framework/gii/components/Pear/Text/Diff/ThreeWay.php @@ -2,9 +2,9 @@ /** * A class for computing three way diffs. * - * $Horde: framework/Text_Diff/Diff/ThreeWay.php,v 1.3.2.3 2008/01/04 10:37:27 jan Exp $ + * $Horde: framework/Text_Diff/Diff/ThreeWay.php,v 1.3.2.4 2009/01/06 15:23:41 jan Exp $ * - * Copyright 2007-2008 The Horde Project (http://www.horde.org/) + * Copyright 2007-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. @@ -38,7 +38,7 @@ class Text_Diff_ThreeWay extends Text_Diff { * @param array $final1 The first version to compare to. * @param array $final2 The second version to compare to. */ - function Text_Diff_ThreeWay($orig, $final1, $final2) + function __construct($orig, $final1, $final2) { if (extension_loaded('xdiff')) { $engine = new Text_Diff_Engine_xdiff(); @@ -155,7 +155,7 @@ function _diff3($edits1, $edits2) */ class Text_Diff_ThreeWay_Op { - function Text_Diff_ThreeWay_Op($orig = false, $final1 = false, $final2 = false) + function __construct($orig = false, $final1 = false, $final2 = false) { $this->orig = $orig ? $orig : array(); $this->final1 = $final1 ? $final1 : array(); @@ -194,7 +194,7 @@ function isConflict() */ class Text_Diff_ThreeWay_Op_copy extends Text_Diff_ThreeWay_Op { - function Text_Diff_ThreeWay_Op_Copy($lines = false) + function __construct($lines = false) { $this->orig = $lines ? $lines : array(); $this->final1 = &$this->orig; @@ -221,7 +221,7 @@ function isConflict() */ class Text_Diff_ThreeWay_BlockBuilder { - function Text_Diff_ThreeWay_BlockBuilder() + function __construct() { $this->_init(); } diff --git a/web/framework-1.1.17/gii/components/Pear/Text/Diff3.php b/web/framework/gii/components/Pear/Text/Diff3.php similarity index 95% rename from web/framework-1.1.17/gii/components/Pear/Text/Diff3.php rename to web/framework/gii/components/Pear/Text/Diff3.php index 2c2837070..fa6eb0be8 100644 --- a/web/framework-1.1.17/gii/components/Pear/Text/Diff3.php +++ b/web/framework/gii/components/Pear/Text/Diff3.php @@ -2,9 +2,9 @@ /** * A class for computing three way diffs. * - * $Horde: framework/Text_Diff/Diff3.php,v 1.2.10.6 2008/01/04 10:37:26 jan Exp $ + * $Horde: framework/Text_Diff/Diff3.php,v 1.2.10.7 2009/01/06 15:23:41 jan Exp $ * - * Copyright 2007-2008 The Horde Project (http://www.horde.org/) + * Copyright 2007-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did * not receive this file, see http://opensource.org/licenses/lgpl-license.php. @@ -38,7 +38,7 @@ class Text_Diff3 extends Text_Diff { * @param array $final1 The first version to compare to. * @param array $final2 The second version to compare to. */ - function Text_Diff3($orig, $final1, $final2) + function __construct($orig, $final1, $final2) { if (extension_loaded('xdiff')) { $engine = new Text_Diff_Engine_xdiff(); @@ -155,7 +155,7 @@ function _diff3($edits1, $edits2) */ class Text_Diff3_Op { - function Text_Diff3_Op($orig = false, $final1 = false, $final2 = false) + function __construct($orig = false, $final1 = false, $final2 = false) { $this->orig = $orig ? $orig : array(); $this->final1 = $final1 ? $final1 : array(); @@ -221,7 +221,7 @@ function isConflict() */ class Text_Diff3_BlockBuilder { - function Text_Diff3_BlockBuilder() + function __construct() { $this->_init(); } diff --git a/web/framework-1.1.17/gii/components/TextDiff.php b/web/framework/gii/components/TextDiff.php similarity index 100% rename from web/framework-1.1.17/gii/components/TextDiff.php rename to web/framework/gii/components/TextDiff.php diff --git a/web/framework-1.1.17/gii/components/UserIdentity.php b/web/framework/gii/components/UserIdentity.php similarity index 96% rename from web/framework-1.1.17/gii/components/UserIdentity.php rename to web/framework/gii/components/UserIdentity.php index 81d6aa129..94798af0e 100644 --- a/web/framework-1.1.17/gii/components/UserIdentity.php +++ b/web/framework/gii/components/UserIdentity.php @@ -5,6 +5,7 @@ class UserIdentity extends CUserIdentity /** * Authenticates a user. * @return boolean whether authentication succeeds. + * @throws CException */ public function authenticate() { diff --git a/web/framework-1.1.17/gii/controllers/DefaultController.php b/web/framework/gii/controllers/DefaultController.php similarity index 100% rename from web/framework-1.1.17/gii/controllers/DefaultController.php rename to web/framework/gii/controllers/DefaultController.php diff --git a/web/framework-1.1.17/gii/generators/controller/ControllerCode.php b/web/framework/gii/generators/controller/ControllerCode.php similarity index 100% rename from web/framework-1.1.17/gii/generators/controller/ControllerCode.php rename to web/framework/gii/generators/controller/ControllerCode.php diff --git a/web/framework-1.1.17/gii/generators/controller/ControllerGenerator.php b/web/framework/gii/generators/controller/ControllerGenerator.php similarity index 100% rename from web/framework-1.1.17/gii/generators/controller/ControllerGenerator.php rename to web/framework/gii/generators/controller/ControllerGenerator.php diff --git a/web/framework-1.1.17/gii/generators/controller/templates/default/controller.php b/web/framework/gii/generators/controller/templates/default/controller.php similarity index 100% rename from web/framework-1.1.17/gii/generators/controller/templates/default/controller.php rename to web/framework/gii/generators/controller/templates/default/controller.php diff --git a/web/framework-1.1.17/gii/generators/controller/templates/default/view.php b/web/framework/gii/generators/controller/templates/default/view.php similarity index 100% rename from web/framework-1.1.17/gii/generators/controller/templates/default/view.php rename to web/framework/gii/generators/controller/templates/default/view.php diff --git a/web/framework-1.1.17/gii/generators/controller/views/index.php b/web/framework/gii/generators/controller/views/index.php similarity index 100% rename from web/framework-1.1.17/gii/generators/controller/views/index.php rename to web/framework/gii/generators/controller/views/index.php diff --git a/web/framework-1.1.17/gii/generators/crud/CrudCode.php b/web/framework/gii/generators/crud/CrudCode.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/CrudCode.php rename to web/framework/gii/generators/crud/CrudCode.php diff --git a/web/framework-1.1.17/gii/generators/crud/CrudGenerator.php b/web/framework/gii/generators/crud/CrudGenerator.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/CrudGenerator.php rename to web/framework/gii/generators/crud/CrudGenerator.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/_form.php b/web/framework/gii/generators/crud/templates/default/_form.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/_form.php rename to web/framework/gii/generators/crud/templates/default/_form.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/_search.php b/web/framework/gii/generators/crud/templates/default/_search.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/_search.php rename to web/framework/gii/generators/crud/templates/default/_search.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/_view.php b/web/framework/gii/generators/crud/templates/default/_view.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/_view.php rename to web/framework/gii/generators/crud/templates/default/_view.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/admin.php b/web/framework/gii/generators/crud/templates/default/admin.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/admin.php rename to web/framework/gii/generators/crud/templates/default/admin.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/controller.php b/web/framework/gii/generators/crud/templates/default/controller.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/controller.php rename to web/framework/gii/generators/crud/templates/default/controller.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/create.php b/web/framework/gii/generators/crud/templates/default/create.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/create.php rename to web/framework/gii/generators/crud/templates/default/create.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/index.php b/web/framework/gii/generators/crud/templates/default/index.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/index.php rename to web/framework/gii/generators/crud/templates/default/index.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/update.php b/web/framework/gii/generators/crud/templates/default/update.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/update.php rename to web/framework/gii/generators/crud/templates/default/update.php diff --git a/web/framework-1.1.17/gii/generators/crud/templates/default/view.php b/web/framework/gii/generators/crud/templates/default/view.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/templates/default/view.php rename to web/framework/gii/generators/crud/templates/default/view.php diff --git a/web/framework-1.1.17/gii/generators/crud/views/index.php b/web/framework/gii/generators/crud/views/index.php similarity index 100% rename from web/framework-1.1.17/gii/generators/crud/views/index.php rename to web/framework/gii/generators/crud/views/index.php diff --git a/web/framework-1.1.17/gii/generators/form/FormCode.php b/web/framework/gii/generators/form/FormCode.php similarity index 100% rename from web/framework-1.1.17/gii/generators/form/FormCode.php rename to web/framework/gii/generators/form/FormCode.php diff --git a/web/framework-1.1.17/gii/generators/form/FormGenerator.php b/web/framework/gii/generators/form/FormGenerator.php similarity index 100% rename from web/framework-1.1.17/gii/generators/form/FormGenerator.php rename to web/framework/gii/generators/form/FormGenerator.php diff --git a/web/framework-1.1.17/gii/generators/form/templates/default/action.php b/web/framework/gii/generators/form/templates/default/action.php similarity index 100% rename from web/framework-1.1.17/gii/generators/form/templates/default/action.php rename to web/framework/gii/generators/form/templates/default/action.php diff --git a/web/framework-1.1.17/gii/generators/form/templates/default/form.php b/web/framework/gii/generators/form/templates/default/form.php similarity index 100% rename from web/framework-1.1.17/gii/generators/form/templates/default/form.php rename to web/framework/gii/generators/form/templates/default/form.php diff --git a/web/framework-1.1.17/gii/generators/form/views/index.php b/web/framework/gii/generators/form/views/index.php similarity index 100% rename from web/framework-1.1.17/gii/generators/form/views/index.php rename to web/framework/gii/generators/form/views/index.php diff --git a/web/framework-1.1.17/gii/generators/model/ModelCode.php b/web/framework/gii/generators/model/ModelCode.php similarity index 100% rename from web/framework-1.1.17/gii/generators/model/ModelCode.php rename to web/framework/gii/generators/model/ModelCode.php diff --git a/web/framework-1.1.17/gii/generators/model/ModelGenerator.php b/web/framework/gii/generators/model/ModelGenerator.php similarity index 100% rename from web/framework-1.1.17/gii/generators/model/ModelGenerator.php rename to web/framework/gii/generators/model/ModelGenerator.php diff --git a/web/framework-1.1.17/gii/generators/model/templates/default/model.php b/web/framework/gii/generators/model/templates/default/model.php similarity index 100% rename from web/framework-1.1.17/gii/generators/model/templates/default/model.php rename to web/framework/gii/generators/model/templates/default/model.php diff --git a/web/framework-1.1.17/gii/generators/model/views/index.php b/web/framework/gii/generators/model/views/index.php similarity index 100% rename from web/framework-1.1.17/gii/generators/model/views/index.php rename to web/framework/gii/generators/model/views/index.php diff --git a/web/framework-1.1.17/gii/generators/module/ModuleCode.php b/web/framework/gii/generators/module/ModuleCode.php similarity index 100% rename from web/framework-1.1.17/gii/generators/module/ModuleCode.php rename to web/framework/gii/generators/module/ModuleCode.php diff --git a/web/framework-1.1.17/gii/generators/module/ModuleGenerator.php b/web/framework/gii/generators/module/ModuleGenerator.php similarity index 100% rename from web/framework-1.1.17/gii/generators/module/ModuleGenerator.php rename to web/framework/gii/generators/module/ModuleGenerator.php diff --git a/web/framework-1.1.17/gii/generators/module/templates/default/components/.gitkeep b/web/framework/gii/generators/module/templates/default/components/.gitkeep similarity index 100% rename from web/framework-1.1.17/gii/generators/module/templates/default/components/.gitkeep rename to web/framework/gii/generators/module/templates/default/components/.gitkeep diff --git a/web/framework-1.1.17/gii/generators/module/templates/default/controllers/DefaultController.php b/web/framework/gii/generators/module/templates/default/controllers/DefaultController.php similarity index 100% rename from web/framework-1.1.17/gii/generators/module/templates/default/controllers/DefaultController.php rename to web/framework/gii/generators/module/templates/default/controllers/DefaultController.php diff --git a/web/framework-1.1.17/gii/generators/module/templates/default/messages/.gitkeep b/web/framework/gii/generators/module/templates/default/messages/.gitkeep similarity index 100% rename from web/framework-1.1.17/gii/generators/module/templates/default/messages/.gitkeep rename to web/framework/gii/generators/module/templates/default/messages/.gitkeep diff --git a/web/framework-1.1.17/gii/generators/module/templates/default/models/.gitkeep b/web/framework/gii/generators/module/templates/default/models/.gitkeep similarity index 100% rename from web/framework-1.1.17/gii/generators/module/templates/default/models/.gitkeep rename to web/framework/gii/generators/module/templates/default/models/.gitkeep diff --git a/web/framework-1.1.17/gii/generators/module/templates/default/module.php b/web/framework/gii/generators/module/templates/default/module.php similarity index 100% rename from web/framework-1.1.17/gii/generators/module/templates/default/module.php rename to web/framework/gii/generators/module/templates/default/module.php diff --git a/web/framework-1.1.17/gii/generators/module/templates/default/views/default/index.php b/web/framework/gii/generators/module/templates/default/views/default/index.php similarity index 100% rename from web/framework-1.1.17/gii/generators/module/templates/default/views/default/index.php rename to web/framework/gii/generators/module/templates/default/views/default/index.php diff --git a/web/framework-1.1.17/gii/generators/module/templates/default/views/layouts/.gitkeep b/web/framework/gii/generators/module/templates/default/views/layouts/.gitkeep similarity index 100% rename from web/framework-1.1.17/gii/generators/module/templates/default/views/layouts/.gitkeep rename to web/framework/gii/generators/module/templates/default/views/layouts/.gitkeep diff --git a/web/framework-1.1.17/gii/generators/module/views/index.php b/web/framework/gii/generators/module/views/index.php similarity index 100% rename from web/framework-1.1.17/gii/generators/module/views/index.php rename to web/framework/gii/generators/module/views/index.php diff --git a/web/framework-1.1.17/gii/models/LoginForm.php b/web/framework/gii/models/LoginForm.php similarity index 86% rename from web/framework-1.1.17/gii/models/LoginForm.php rename to web/framework/gii/models/LoginForm.php index f4b838c5e..31118abce 100644 --- a/web/framework-1.1.17/gii/models/LoginForm.php +++ b/web/framework/gii/models/LoginForm.php @@ -19,6 +19,8 @@ public function rules() /** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). + * @param string $attribute the name of the attribute to be validated. + * @param array $params additional parameters passed with rule when being executed. */ public function authenticate($attribute,$params) { diff --git a/web/framework-1.1.17/gii/views/common/code.php b/web/framework/gii/views/common/code.php similarity index 100% rename from web/framework-1.1.17/gii/views/common/code.php rename to web/framework/gii/views/common/code.php diff --git a/web/framework-1.1.17/gii/views/common/diff.php b/web/framework/gii/views/common/diff.php similarity index 100% rename from web/framework-1.1.17/gii/views/common/diff.php rename to web/framework/gii/views/common/diff.php diff --git a/web/framework-1.1.17/gii/views/common/generator.php b/web/framework/gii/views/common/generator.php similarity index 100% rename from web/framework-1.1.17/gii/views/common/generator.php rename to web/framework/gii/views/common/generator.php diff --git a/web/framework-1.1.17/gii/views/default/error.php b/web/framework/gii/views/default/error.php similarity index 100% rename from web/framework-1.1.17/gii/views/default/error.php rename to web/framework/gii/views/default/error.php diff --git a/web/framework-1.1.17/gii/views/default/index.php b/web/framework/gii/views/default/index.php similarity index 100% rename from web/framework-1.1.17/gii/views/default/index.php rename to web/framework/gii/views/default/index.php diff --git a/web/framework-1.1.17/gii/views/default/login.php b/web/framework/gii/views/default/login.php similarity index 100% rename from web/framework-1.1.17/gii/views/default/login.php rename to web/framework/gii/views/default/login.php diff --git a/web/framework-1.1.17/gii/views/layouts/column1.php b/web/framework/gii/views/layouts/column1.php similarity index 100% rename from web/framework-1.1.17/gii/views/layouts/column1.php rename to web/framework/gii/views/layouts/column1.php diff --git a/web/framework-1.1.17/gii/views/layouts/generator.php b/web/framework/gii/views/layouts/generator.php similarity index 100% rename from web/framework-1.1.17/gii/views/layouts/generator.php rename to web/framework/gii/views/layouts/generator.php diff --git a/web/framework-1.1.17/gii/views/layouts/main.php b/web/framework/gii/views/layouts/main.php similarity index 100% rename from web/framework-1.1.17/gii/views/layouts/main.php rename to web/framework/gii/views/layouts/main.php diff --git a/web/framework-1.1.17/i18n/CChoiceFormat.php b/web/framework/i18n/CChoiceFormat.php similarity index 100% rename from web/framework-1.1.17/i18n/CChoiceFormat.php rename to web/framework/i18n/CChoiceFormat.php diff --git a/web/framework-1.1.17/i18n/CDateFormatter.php b/web/framework/i18n/CDateFormatter.php similarity index 100% rename from web/framework-1.1.17/i18n/CDateFormatter.php rename to web/framework/i18n/CDateFormatter.php diff --git a/web/framework-1.1.17/i18n/CDbMessageSource.php b/web/framework/i18n/CDbMessageSource.php similarity index 100% rename from web/framework-1.1.17/i18n/CDbMessageSource.php rename to web/framework/i18n/CDbMessageSource.php diff --git a/web/framework-1.1.17/i18n/CGettextMessageSource.php b/web/framework/i18n/CGettextMessageSource.php similarity index 98% rename from web/framework-1.1.17/i18n/CGettextMessageSource.php rename to web/framework/i18n/CGettextMessageSource.php index 881d0981f..bf1ed878e 100644 --- a/web/framework-1.1.17/i18n/CGettextMessageSource.php +++ b/web/framework/i18n/CGettextMessageSource.php @@ -53,7 +53,7 @@ class CGettextMessageSource extends CMessageSource */ public $useMoFile=true; /** - * @var boolean whether to use Big Endian to read and write MO files. + * @var boolean whether to use Big Endian to read MO files. * Defaults to false. This property is only used when {@link useMoFile} is true. */ public $useBigEndian=false; diff --git a/web/framework-1.1.17/i18n/CLocale.php b/web/framework/i18n/CLocale.php similarity index 100% rename from web/framework-1.1.17/i18n/CLocale.php rename to web/framework/i18n/CLocale.php diff --git a/web/framework-1.1.17/i18n/CMessageSource.php b/web/framework/i18n/CMessageSource.php similarity index 100% rename from web/framework-1.1.17/i18n/CMessageSource.php rename to web/framework/i18n/CMessageSource.php diff --git a/web/framework-1.1.17/i18n/CNumberFormatter.php b/web/framework/i18n/CNumberFormatter.php similarity index 100% rename from web/framework-1.1.17/i18n/CNumberFormatter.php rename to web/framework/i18n/CNumberFormatter.php diff --git a/web/framework-1.1.17/i18n/CPhpMessageSource.php b/web/framework/i18n/CPhpMessageSource.php similarity index 100% rename from web/framework-1.1.17/i18n/CPhpMessageSource.php rename to web/framework/i18n/CPhpMessageSource.php diff --git a/web/framework-1.1.17/i18n/data/README.txt b/web/framework/i18n/data/README.txt similarity index 100% rename from web/framework-1.1.17/i18n/data/README.txt rename to web/framework/i18n/data/README.txt diff --git a/web/framework-1.1.17/i18n/data/aa.php b/web/framework/i18n/data/aa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/aa.php rename to web/framework/i18n/data/aa.php diff --git a/web/framework-1.1.17/i18n/data/aa_dj.php b/web/framework/i18n/data/aa_dj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/aa_dj.php rename to web/framework/i18n/data/aa_dj.php diff --git a/web/framework-1.1.17/i18n/data/aa_er.php b/web/framework/i18n/data/aa_er.php similarity index 100% rename from web/framework-1.1.17/i18n/data/aa_er.php rename to web/framework/i18n/data/aa_er.php diff --git a/web/framework-1.1.17/i18n/data/aa_et.php b/web/framework/i18n/data/aa_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/aa_et.php rename to web/framework/i18n/data/aa_et.php diff --git a/web/framework-1.1.17/i18n/data/af.php b/web/framework/i18n/data/af.php similarity index 100% rename from web/framework-1.1.17/i18n/data/af.php rename to web/framework/i18n/data/af.php diff --git a/web/framework-1.1.17/i18n/data/af_na.php b/web/framework/i18n/data/af_na.php similarity index 100% rename from web/framework-1.1.17/i18n/data/af_na.php rename to web/framework/i18n/data/af_na.php diff --git a/web/framework-1.1.17/i18n/data/af_za.php b/web/framework/i18n/data/af_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/af_za.php rename to web/framework/i18n/data/af_za.php diff --git a/web/framework-1.1.17/i18n/data/agq.php b/web/framework/i18n/data/agq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/agq.php rename to web/framework/i18n/data/agq.php diff --git a/web/framework-1.1.17/i18n/data/agq_cm.php b/web/framework/i18n/data/agq_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/agq_cm.php rename to web/framework/i18n/data/agq_cm.php diff --git a/web/framework-1.1.17/i18n/data/ak.php b/web/framework/i18n/data/ak.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ak.php rename to web/framework/i18n/data/ak.php diff --git a/web/framework-1.1.17/i18n/data/ak_gh.php b/web/framework/i18n/data/ak_gh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ak_gh.php rename to web/framework/i18n/data/ak_gh.php diff --git a/web/framework-1.1.17/i18n/data/am.php b/web/framework/i18n/data/am.php similarity index 100% rename from web/framework-1.1.17/i18n/data/am.php rename to web/framework/i18n/data/am.php diff --git a/web/framework-1.1.17/i18n/data/am_et.php b/web/framework/i18n/data/am_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/am_et.php rename to web/framework/i18n/data/am_et.php diff --git a/web/framework-1.1.17/i18n/data/ar.php b/web/framework/i18n/data/ar.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar.php rename to web/framework/i18n/data/ar.php diff --git a/web/framework-1.1.17/i18n/data/ar_001.php b/web/framework/i18n/data/ar_001.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_001.php rename to web/framework/i18n/data/ar_001.php diff --git a/web/framework-1.1.17/i18n/data/ar_ae.php b/web/framework/i18n/data/ar_ae.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_ae.php rename to web/framework/i18n/data/ar_ae.php diff --git a/web/framework-1.1.17/i18n/data/ar_bh.php b/web/framework/i18n/data/ar_bh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_bh.php rename to web/framework/i18n/data/ar_bh.php diff --git a/web/framework-1.1.17/i18n/data/ar_dj.php b/web/framework/i18n/data/ar_dj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_dj.php rename to web/framework/i18n/data/ar_dj.php diff --git a/web/framework-1.1.17/i18n/data/ar_dz.php b/web/framework/i18n/data/ar_dz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_dz.php rename to web/framework/i18n/data/ar_dz.php diff --git a/web/framework-1.1.17/i18n/data/ar_eg.php b/web/framework/i18n/data/ar_eg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_eg.php rename to web/framework/i18n/data/ar_eg.php diff --git a/web/framework-1.1.17/i18n/data/ar_eh.php b/web/framework/i18n/data/ar_eh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_eh.php rename to web/framework/i18n/data/ar_eh.php diff --git a/web/framework-1.1.17/i18n/data/ar_er.php b/web/framework/i18n/data/ar_er.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_er.php rename to web/framework/i18n/data/ar_er.php diff --git a/web/framework-1.1.17/i18n/data/ar_il.php b/web/framework/i18n/data/ar_il.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_il.php rename to web/framework/i18n/data/ar_il.php diff --git a/web/framework-1.1.17/i18n/data/ar_iq.php b/web/framework/i18n/data/ar_iq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_iq.php rename to web/framework/i18n/data/ar_iq.php diff --git a/web/framework-1.1.17/i18n/data/ar_jo.php b/web/framework/i18n/data/ar_jo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_jo.php rename to web/framework/i18n/data/ar_jo.php diff --git a/web/framework-1.1.17/i18n/data/ar_km.php b/web/framework/i18n/data/ar_km.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_km.php rename to web/framework/i18n/data/ar_km.php diff --git a/web/framework-1.1.17/i18n/data/ar_kw.php b/web/framework/i18n/data/ar_kw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_kw.php rename to web/framework/i18n/data/ar_kw.php diff --git a/web/framework-1.1.17/i18n/data/ar_lb.php b/web/framework/i18n/data/ar_lb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_lb.php rename to web/framework/i18n/data/ar_lb.php diff --git a/web/framework-1.1.17/i18n/data/ar_ly.php b/web/framework/i18n/data/ar_ly.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_ly.php rename to web/framework/i18n/data/ar_ly.php diff --git a/web/framework-1.1.17/i18n/data/ar_ma.php b/web/framework/i18n/data/ar_ma.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_ma.php rename to web/framework/i18n/data/ar_ma.php diff --git a/web/framework-1.1.17/i18n/data/ar_mr.php b/web/framework/i18n/data/ar_mr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_mr.php rename to web/framework/i18n/data/ar_mr.php diff --git a/web/framework-1.1.17/i18n/data/ar_om.php b/web/framework/i18n/data/ar_om.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_om.php rename to web/framework/i18n/data/ar_om.php diff --git a/web/framework-1.1.17/i18n/data/ar_ps.php b/web/framework/i18n/data/ar_ps.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_ps.php rename to web/framework/i18n/data/ar_ps.php diff --git a/web/framework-1.1.17/i18n/data/ar_qa.php b/web/framework/i18n/data/ar_qa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_qa.php rename to web/framework/i18n/data/ar_qa.php diff --git a/web/framework-1.1.17/i18n/data/ar_sa.php b/web/framework/i18n/data/ar_sa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_sa.php rename to web/framework/i18n/data/ar_sa.php diff --git a/web/framework-1.1.17/i18n/data/ar_sd.php b/web/framework/i18n/data/ar_sd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_sd.php rename to web/framework/i18n/data/ar_sd.php diff --git a/web/framework-1.1.17/i18n/data/ar_so.php b/web/framework/i18n/data/ar_so.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_so.php rename to web/framework/i18n/data/ar_so.php diff --git a/web/framework-1.1.17/i18n/data/ar_sy.php b/web/framework/i18n/data/ar_sy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_sy.php rename to web/framework/i18n/data/ar_sy.php diff --git a/web/framework-1.1.17/i18n/data/ar_td.php b/web/framework/i18n/data/ar_td.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_td.php rename to web/framework/i18n/data/ar_td.php diff --git a/web/framework-1.1.17/i18n/data/ar_tn.php b/web/framework/i18n/data/ar_tn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_tn.php rename to web/framework/i18n/data/ar_tn.php diff --git a/web/framework-1.1.17/i18n/data/ar_ye.php b/web/framework/i18n/data/ar_ye.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ar_ye.php rename to web/framework/i18n/data/ar_ye.php diff --git a/web/framework-1.1.17/i18n/data/as.php b/web/framework/i18n/data/as.php similarity index 100% rename from web/framework-1.1.17/i18n/data/as.php rename to web/framework/i18n/data/as.php diff --git a/web/framework-1.1.17/i18n/data/as_in.php b/web/framework/i18n/data/as_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/as_in.php rename to web/framework/i18n/data/as_in.php diff --git a/web/framework-1.1.17/i18n/data/asa.php b/web/framework/i18n/data/asa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/asa.php rename to web/framework/i18n/data/asa.php diff --git a/web/framework-1.1.17/i18n/data/asa_tz.php b/web/framework/i18n/data/asa_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/asa_tz.php rename to web/framework/i18n/data/asa_tz.php diff --git a/web/framework-1.1.17/i18n/data/ast.php b/web/framework/i18n/data/ast.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ast.php rename to web/framework/i18n/data/ast.php diff --git a/web/framework-1.1.17/i18n/data/ast_es.php b/web/framework/i18n/data/ast_es.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ast_es.php rename to web/framework/i18n/data/ast_es.php diff --git a/web/framework-1.1.17/i18n/data/az.php b/web/framework/i18n/data/az.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az.php rename to web/framework/i18n/data/az.php diff --git a/web/framework-1.1.17/i18n/data/az_arab.php b/web/framework/i18n/data/az_arab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_arab.php rename to web/framework/i18n/data/az_arab.php diff --git a/web/framework-1.1.17/i18n/data/az_arab_ir.php b/web/framework/i18n/data/az_arab_ir.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_arab_ir.php rename to web/framework/i18n/data/az_arab_ir.php diff --git a/web/framework-1.1.17/i18n/data/az_az.php b/web/framework/i18n/data/az_az.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_az.php rename to web/framework/i18n/data/az_az.php diff --git a/web/framework-1.1.17/i18n/data/az_cyrl.php b/web/framework/i18n/data/az_cyrl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_cyrl.php rename to web/framework/i18n/data/az_cyrl.php diff --git a/web/framework-1.1.17/i18n/data/az_cyrl_az.php b/web/framework/i18n/data/az_cyrl_az.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_cyrl_az.php rename to web/framework/i18n/data/az_cyrl_az.php diff --git a/web/framework-1.1.17/i18n/data/az_ir.php b/web/framework/i18n/data/az_ir.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_ir.php rename to web/framework/i18n/data/az_ir.php diff --git a/web/framework-1.1.17/i18n/data/az_latn.php b/web/framework/i18n/data/az_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_latn.php rename to web/framework/i18n/data/az_latn.php diff --git a/web/framework-1.1.17/i18n/data/az_latn_az.php b/web/framework/i18n/data/az_latn_az.php similarity index 100% rename from web/framework-1.1.17/i18n/data/az_latn_az.php rename to web/framework/i18n/data/az_latn_az.php diff --git a/web/framework-1.1.17/i18n/data/bas.php b/web/framework/i18n/data/bas.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bas.php rename to web/framework/i18n/data/bas.php diff --git a/web/framework-1.1.17/i18n/data/bas_cm.php b/web/framework/i18n/data/bas_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bas_cm.php rename to web/framework/i18n/data/bas_cm.php diff --git a/web/framework-1.1.17/i18n/data/be.php b/web/framework/i18n/data/be.php similarity index 100% rename from web/framework-1.1.17/i18n/data/be.php rename to web/framework/i18n/data/be.php diff --git a/web/framework-1.1.17/i18n/data/be_by.php b/web/framework/i18n/data/be_by.php similarity index 100% rename from web/framework-1.1.17/i18n/data/be_by.php rename to web/framework/i18n/data/be_by.php diff --git a/web/framework-1.1.17/i18n/data/bem.php b/web/framework/i18n/data/bem.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bem.php rename to web/framework/i18n/data/bem.php diff --git a/web/framework-1.1.17/i18n/data/bem_zm.php b/web/framework/i18n/data/bem_zm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bem_zm.php rename to web/framework/i18n/data/bem_zm.php diff --git a/web/framework-1.1.17/i18n/data/bez.php b/web/framework/i18n/data/bez.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bez.php rename to web/framework/i18n/data/bez.php diff --git a/web/framework-1.1.17/i18n/data/bez_tz.php b/web/framework/i18n/data/bez_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bez_tz.php rename to web/framework/i18n/data/bez_tz.php diff --git a/web/framework-1.1.17/i18n/data/bg.php b/web/framework/i18n/data/bg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bg.php rename to web/framework/i18n/data/bg.php diff --git a/web/framework-1.1.17/i18n/data/bg_bg.php b/web/framework/i18n/data/bg_bg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bg_bg.php rename to web/framework/i18n/data/bg_bg.php diff --git a/web/framework-1.1.17/i18n/data/bm.php b/web/framework/i18n/data/bm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bm.php rename to web/framework/i18n/data/bm.php diff --git a/web/framework-1.1.17/i18n/data/bm_ml.php b/web/framework/i18n/data/bm_ml.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bm_ml.php rename to web/framework/i18n/data/bm_ml.php diff --git a/web/framework-1.1.17/i18n/data/bn.php b/web/framework/i18n/data/bn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bn.php rename to web/framework/i18n/data/bn.php diff --git a/web/framework-1.1.17/i18n/data/bn_bd.php b/web/framework/i18n/data/bn_bd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bn_bd.php rename to web/framework/i18n/data/bn_bd.php diff --git a/web/framework-1.1.17/i18n/data/bn_in.php b/web/framework/i18n/data/bn_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bn_in.php rename to web/framework/i18n/data/bn_in.php diff --git a/web/framework-1.1.17/i18n/data/bo.php b/web/framework/i18n/data/bo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bo.php rename to web/framework/i18n/data/bo.php diff --git a/web/framework-1.1.17/i18n/data/bo_cn.php b/web/framework/i18n/data/bo_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bo_cn.php rename to web/framework/i18n/data/bo_cn.php diff --git a/web/framework-1.1.17/i18n/data/bo_in.php b/web/framework/i18n/data/bo_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bo_in.php rename to web/framework/i18n/data/bo_in.php diff --git a/web/framework-1.1.17/i18n/data/br.php b/web/framework/i18n/data/br.php similarity index 100% rename from web/framework-1.1.17/i18n/data/br.php rename to web/framework/i18n/data/br.php diff --git a/web/framework-1.1.17/i18n/data/br_fr.php b/web/framework/i18n/data/br_fr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/br_fr.php rename to web/framework/i18n/data/br_fr.php diff --git a/web/framework-1.1.17/i18n/data/brx.php b/web/framework/i18n/data/brx.php similarity index 100% rename from web/framework-1.1.17/i18n/data/brx.php rename to web/framework/i18n/data/brx.php diff --git a/web/framework-1.1.17/i18n/data/brx_in.php b/web/framework/i18n/data/brx_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/brx_in.php rename to web/framework/i18n/data/brx_in.php diff --git a/web/framework-1.1.17/i18n/data/bs.php b/web/framework/i18n/data/bs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bs.php rename to web/framework/i18n/data/bs.php diff --git a/web/framework-1.1.17/i18n/data/bs_ba.php b/web/framework/i18n/data/bs_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bs_ba.php rename to web/framework/i18n/data/bs_ba.php diff --git a/web/framework-1.1.17/i18n/data/bs_cyrl.php b/web/framework/i18n/data/bs_cyrl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bs_cyrl.php rename to web/framework/i18n/data/bs_cyrl.php diff --git a/web/framework-1.1.17/i18n/data/bs_cyrl_ba.php b/web/framework/i18n/data/bs_cyrl_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bs_cyrl_ba.php rename to web/framework/i18n/data/bs_cyrl_ba.php diff --git a/web/framework-1.1.17/i18n/data/bs_latn.php b/web/framework/i18n/data/bs_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bs_latn.php rename to web/framework/i18n/data/bs_latn.php diff --git a/web/framework-1.1.17/i18n/data/bs_latn_ba.php b/web/framework/i18n/data/bs_latn_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/bs_latn_ba.php rename to web/framework/i18n/data/bs_latn_ba.php diff --git a/web/framework-1.1.17/i18n/data/byn.php b/web/framework/i18n/data/byn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/byn.php rename to web/framework/i18n/data/byn.php diff --git a/web/framework-1.1.17/i18n/data/byn_er.php b/web/framework/i18n/data/byn_er.php similarity index 100% rename from web/framework-1.1.17/i18n/data/byn_er.php rename to web/framework/i18n/data/byn_er.php diff --git a/web/framework-1.1.17/i18n/data/ca.php b/web/framework/i18n/data/ca.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ca.php rename to web/framework/i18n/data/ca.php diff --git a/web/framework-1.1.17/i18n/data/ca_ad.php b/web/framework/i18n/data/ca_ad.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ca_ad.php rename to web/framework/i18n/data/ca_ad.php diff --git a/web/framework-1.1.17/i18n/data/ca_es.php b/web/framework/i18n/data/ca_es.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ca_es.php rename to web/framework/i18n/data/ca_es.php diff --git a/web/framework-1.1.17/i18n/data/cch.php b/web/framework/i18n/data/cch.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cch.php rename to web/framework/i18n/data/cch.php diff --git a/web/framework-1.1.17/i18n/data/cch_ng.php b/web/framework/i18n/data/cch_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cch_ng.php rename to web/framework/i18n/data/cch_ng.php diff --git a/web/framework-1.1.17/i18n/data/cgg.php b/web/framework/i18n/data/cgg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cgg.php rename to web/framework/i18n/data/cgg.php diff --git a/web/framework-1.1.17/i18n/data/cgg_ug.php b/web/framework/i18n/data/cgg_ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cgg_ug.php rename to web/framework/i18n/data/cgg_ug.php diff --git a/web/framework-1.1.17/i18n/data/chr.php b/web/framework/i18n/data/chr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/chr.php rename to web/framework/i18n/data/chr.php diff --git a/web/framework-1.1.17/i18n/data/chr_us.php b/web/framework/i18n/data/chr_us.php similarity index 100% rename from web/framework-1.1.17/i18n/data/chr_us.php rename to web/framework/i18n/data/chr_us.php diff --git a/web/framework-1.1.17/i18n/data/cs.php b/web/framework/i18n/data/cs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cs.php rename to web/framework/i18n/data/cs.php diff --git a/web/framework-1.1.17/i18n/data/cs_cz.php b/web/framework/i18n/data/cs_cz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cs_cz.php rename to web/framework/i18n/data/cs_cz.php diff --git a/web/framework-1.1.17/i18n/data/cy.php b/web/framework/i18n/data/cy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cy.php rename to web/framework/i18n/data/cy.php diff --git a/web/framework-1.1.17/i18n/data/cy_gb.php b/web/framework/i18n/data/cy_gb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/cy_gb.php rename to web/framework/i18n/data/cy_gb.php diff --git a/web/framework-1.1.17/i18n/data/da.php b/web/framework/i18n/data/da.php similarity index 100% rename from web/framework-1.1.17/i18n/data/da.php rename to web/framework/i18n/data/da.php diff --git a/web/framework-1.1.17/i18n/data/da_dk.php b/web/framework/i18n/data/da_dk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/da_dk.php rename to web/framework/i18n/data/da_dk.php diff --git a/web/framework-1.1.17/i18n/data/dav.php b/web/framework/i18n/data/dav.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dav.php rename to web/framework/i18n/data/dav.php diff --git a/web/framework-1.1.17/i18n/data/dav_ke.php b/web/framework/i18n/data/dav_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dav_ke.php rename to web/framework/i18n/data/dav_ke.php diff --git a/web/framework-1.1.17/i18n/data/de.php b/web/framework/i18n/data/de.php similarity index 100% rename from web/framework-1.1.17/i18n/data/de.php rename to web/framework/i18n/data/de.php diff --git a/web/framework-1.1.17/i18n/data/de_at.php b/web/framework/i18n/data/de_at.php similarity index 100% rename from web/framework-1.1.17/i18n/data/de_at.php rename to web/framework/i18n/data/de_at.php diff --git a/web/framework-1.1.17/i18n/data/de_be.php b/web/framework/i18n/data/de_be.php similarity index 100% rename from web/framework-1.1.17/i18n/data/de_be.php rename to web/framework/i18n/data/de_be.php diff --git a/web/framework-1.1.17/i18n/data/de_ch.php b/web/framework/i18n/data/de_ch.php similarity index 100% rename from web/framework-1.1.17/i18n/data/de_ch.php rename to web/framework/i18n/data/de_ch.php diff --git a/web/framework-1.1.17/i18n/data/de_de.php b/web/framework/i18n/data/de_de.php similarity index 100% rename from web/framework-1.1.17/i18n/data/de_de.php rename to web/framework/i18n/data/de_de.php diff --git a/web/framework-1.1.17/i18n/data/de_li.php b/web/framework/i18n/data/de_li.php similarity index 100% rename from web/framework-1.1.17/i18n/data/de_li.php rename to web/framework/i18n/data/de_li.php diff --git a/web/framework-1.1.17/i18n/data/de_lu.php b/web/framework/i18n/data/de_lu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/de_lu.php rename to web/framework/i18n/data/de_lu.php diff --git a/web/framework-1.1.17/i18n/data/dje.php b/web/framework/i18n/data/dje.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dje.php rename to web/framework/i18n/data/dje.php diff --git a/web/framework-1.1.17/i18n/data/dje_ne.php b/web/framework/i18n/data/dje_ne.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dje_ne.php rename to web/framework/i18n/data/dje_ne.php diff --git a/web/framework-1.1.17/i18n/data/dua.php b/web/framework/i18n/data/dua.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dua.php rename to web/framework/i18n/data/dua.php diff --git a/web/framework-1.1.17/i18n/data/dua_cm.php b/web/framework/i18n/data/dua_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dua_cm.php rename to web/framework/i18n/data/dua_cm.php diff --git a/web/framework-1.1.17/i18n/data/dv.php b/web/framework/i18n/data/dv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dv.php rename to web/framework/i18n/data/dv.php diff --git a/web/framework-1.1.17/i18n/data/dv_mv.php b/web/framework/i18n/data/dv_mv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dv_mv.php rename to web/framework/i18n/data/dv_mv.php diff --git a/web/framework-1.1.17/i18n/data/dyo.php b/web/framework/i18n/data/dyo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dyo.php rename to web/framework/i18n/data/dyo.php diff --git a/web/framework-1.1.17/i18n/data/dyo_sn.php b/web/framework/i18n/data/dyo_sn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dyo_sn.php rename to web/framework/i18n/data/dyo_sn.php diff --git a/web/framework-1.1.17/i18n/data/dz.php b/web/framework/i18n/data/dz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dz.php rename to web/framework/i18n/data/dz.php diff --git a/web/framework-1.1.17/i18n/data/dz_bt.php b/web/framework/i18n/data/dz_bt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/dz_bt.php rename to web/framework/i18n/data/dz_bt.php diff --git a/web/framework-1.1.17/i18n/data/ebu.php b/web/framework/i18n/data/ebu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ebu.php rename to web/framework/i18n/data/ebu.php diff --git a/web/framework-1.1.17/i18n/data/ebu_ke.php b/web/framework/i18n/data/ebu_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ebu_ke.php rename to web/framework/i18n/data/ebu_ke.php diff --git a/web/framework-1.1.17/i18n/data/ee.php b/web/framework/i18n/data/ee.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ee.php rename to web/framework/i18n/data/ee.php diff --git a/web/framework-1.1.17/i18n/data/ee_gh.php b/web/framework/i18n/data/ee_gh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ee_gh.php rename to web/framework/i18n/data/ee_gh.php diff --git a/web/framework-1.1.17/i18n/data/ee_tg.php b/web/framework/i18n/data/ee_tg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ee_tg.php rename to web/framework/i18n/data/ee_tg.php diff --git a/web/framework-1.1.17/i18n/data/el.php b/web/framework/i18n/data/el.php similarity index 100% rename from web/framework-1.1.17/i18n/data/el.php rename to web/framework/i18n/data/el.php diff --git a/web/framework-1.1.17/i18n/data/el_cy.php b/web/framework/i18n/data/el_cy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/el_cy.php rename to web/framework/i18n/data/el_cy.php diff --git a/web/framework-1.1.17/i18n/data/el_gr.php b/web/framework/i18n/data/el_gr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/el_gr.php rename to web/framework/i18n/data/el_gr.php diff --git a/web/framework-1.1.17/i18n/data/el_polyton.php b/web/framework/i18n/data/el_polyton.php similarity index 100% rename from web/framework-1.1.17/i18n/data/el_polyton.php rename to web/framework/i18n/data/el_polyton.php diff --git a/web/framework-1.1.17/i18n/data/en.php b/web/framework/i18n/data/en.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en.php rename to web/framework/i18n/data/en.php diff --git a/web/framework-1.1.17/i18n/data/en_150.php b/web/framework/i18n/data/en_150.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_150.php rename to web/framework/i18n/data/en_150.php diff --git a/web/framework-1.1.17/i18n/data/en_ag.php b/web/framework/i18n/data/en_ag.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ag.php rename to web/framework/i18n/data/en_ag.php diff --git a/web/framework-1.1.17/i18n/data/en_as.php b/web/framework/i18n/data/en_as.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_as.php rename to web/framework/i18n/data/en_as.php diff --git a/web/framework-1.1.17/i18n/data/en_au.php b/web/framework/i18n/data/en_au.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_au.php rename to web/framework/i18n/data/en_au.php diff --git a/web/framework-1.1.17/i18n/data/en_bb.php b/web/framework/i18n/data/en_bb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_bb.php rename to web/framework/i18n/data/en_bb.php diff --git a/web/framework-1.1.17/i18n/data/en_be.php b/web/framework/i18n/data/en_be.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_be.php rename to web/framework/i18n/data/en_be.php diff --git a/web/framework-1.1.17/i18n/data/en_bm.php b/web/framework/i18n/data/en_bm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_bm.php rename to web/framework/i18n/data/en_bm.php diff --git a/web/framework-1.1.17/i18n/data/en_bs.php b/web/framework/i18n/data/en_bs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_bs.php rename to web/framework/i18n/data/en_bs.php diff --git a/web/framework-1.1.17/i18n/data/en_bw.php b/web/framework/i18n/data/en_bw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_bw.php rename to web/framework/i18n/data/en_bw.php diff --git a/web/framework-1.1.17/i18n/data/en_bz.php b/web/framework/i18n/data/en_bz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_bz.php rename to web/framework/i18n/data/en_bz.php diff --git a/web/framework-1.1.17/i18n/data/en_ca.php b/web/framework/i18n/data/en_ca.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ca.php rename to web/framework/i18n/data/en_ca.php diff --git a/web/framework-1.1.17/i18n/data/en_cm.php b/web/framework/i18n/data/en_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_cm.php rename to web/framework/i18n/data/en_cm.php diff --git a/web/framework-1.1.17/i18n/data/en_dm.php b/web/framework/i18n/data/en_dm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_dm.php rename to web/framework/i18n/data/en_dm.php diff --git a/web/framework-1.1.17/i18n/data/en_dsrt.php b/web/framework/i18n/data/en_dsrt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_dsrt.php rename to web/framework/i18n/data/en_dsrt.php diff --git a/web/framework-1.1.17/i18n/data/en_dsrt_us.php b/web/framework/i18n/data/en_dsrt_us.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_dsrt_us.php rename to web/framework/i18n/data/en_dsrt_us.php diff --git a/web/framework-1.1.17/i18n/data/en_fj.php b/web/framework/i18n/data/en_fj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_fj.php rename to web/framework/i18n/data/en_fj.php diff --git a/web/framework-1.1.17/i18n/data/en_fm.php b/web/framework/i18n/data/en_fm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_fm.php rename to web/framework/i18n/data/en_fm.php diff --git a/web/framework-1.1.17/i18n/data/en_gb.php b/web/framework/i18n/data/en_gb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gb.php rename to web/framework/i18n/data/en_gb.php diff --git a/web/framework-1.1.17/i18n/data/en_gd.php b/web/framework/i18n/data/en_gd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gd.php rename to web/framework/i18n/data/en_gd.php diff --git a/web/framework-1.1.17/i18n/data/en_gg.php b/web/framework/i18n/data/en_gg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gg.php rename to web/framework/i18n/data/en_gg.php diff --git a/web/framework-1.1.17/i18n/data/en_gh.php b/web/framework/i18n/data/en_gh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gh.php rename to web/framework/i18n/data/en_gh.php diff --git a/web/framework-1.1.17/i18n/data/en_gi.php b/web/framework/i18n/data/en_gi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gi.php rename to web/framework/i18n/data/en_gi.php diff --git a/web/framework-1.1.17/i18n/data/en_gm.php b/web/framework/i18n/data/en_gm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gm.php rename to web/framework/i18n/data/en_gm.php diff --git a/web/framework-1.1.17/i18n/data/en_gu.php b/web/framework/i18n/data/en_gu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gu.php rename to web/framework/i18n/data/en_gu.php diff --git a/web/framework-1.1.17/i18n/data/en_gy.php b/web/framework/i18n/data/en_gy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_gy.php rename to web/framework/i18n/data/en_gy.php diff --git a/web/framework-1.1.17/i18n/data/en_hk.php b/web/framework/i18n/data/en_hk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_hk.php rename to web/framework/i18n/data/en_hk.php diff --git a/web/framework-1.1.17/i18n/data/en_ie.php b/web/framework/i18n/data/en_ie.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ie.php rename to web/framework/i18n/data/en_ie.php diff --git a/web/framework-1.1.17/i18n/data/en_im.php b/web/framework/i18n/data/en_im.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_im.php rename to web/framework/i18n/data/en_im.php diff --git a/web/framework-1.1.17/i18n/data/en_in.php b/web/framework/i18n/data/en_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_in.php rename to web/framework/i18n/data/en_in.php diff --git a/web/framework-1.1.17/i18n/data/en_je.php b/web/framework/i18n/data/en_je.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_je.php rename to web/framework/i18n/data/en_je.php diff --git a/web/framework-1.1.17/i18n/data/en_jm.php b/web/framework/i18n/data/en_jm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_jm.php rename to web/framework/i18n/data/en_jm.php diff --git a/web/framework-1.1.17/i18n/data/en_ke.php b/web/framework/i18n/data/en_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ke.php rename to web/framework/i18n/data/en_ke.php diff --git a/web/framework-1.1.17/i18n/data/en_ki.php b/web/framework/i18n/data/en_ki.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ki.php rename to web/framework/i18n/data/en_ki.php diff --git a/web/framework-1.1.17/i18n/data/en_kn.php b/web/framework/i18n/data/en_kn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_kn.php rename to web/framework/i18n/data/en_kn.php diff --git a/web/framework-1.1.17/i18n/data/en_ky.php b/web/framework/i18n/data/en_ky.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ky.php rename to web/framework/i18n/data/en_ky.php diff --git a/web/framework-1.1.17/i18n/data/en_lc.php b/web/framework/i18n/data/en_lc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_lc.php rename to web/framework/i18n/data/en_lc.php diff --git a/web/framework-1.1.17/i18n/data/en_lr.php b/web/framework/i18n/data/en_lr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_lr.php rename to web/framework/i18n/data/en_lr.php diff --git a/web/framework-1.1.17/i18n/data/en_ls.php b/web/framework/i18n/data/en_ls.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ls.php rename to web/framework/i18n/data/en_ls.php diff --git a/web/framework-1.1.17/i18n/data/en_mg.php b/web/framework/i18n/data/en_mg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_mg.php rename to web/framework/i18n/data/en_mg.php diff --git a/web/framework-1.1.17/i18n/data/en_mh.php b/web/framework/i18n/data/en_mh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_mh.php rename to web/framework/i18n/data/en_mh.php diff --git a/web/framework-1.1.17/i18n/data/en_mp.php b/web/framework/i18n/data/en_mp.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_mp.php rename to web/framework/i18n/data/en_mp.php diff --git a/web/framework-1.1.17/i18n/data/en_mt.php b/web/framework/i18n/data/en_mt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_mt.php rename to web/framework/i18n/data/en_mt.php diff --git a/web/framework-1.1.17/i18n/data/en_mu.php b/web/framework/i18n/data/en_mu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_mu.php rename to web/framework/i18n/data/en_mu.php diff --git a/web/framework-1.1.17/i18n/data/en_mw.php b/web/framework/i18n/data/en_mw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_mw.php rename to web/framework/i18n/data/en_mw.php diff --git a/web/framework-1.1.17/i18n/data/en_na.php b/web/framework/i18n/data/en_na.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_na.php rename to web/framework/i18n/data/en_na.php diff --git a/web/framework-1.1.17/i18n/data/en_ng.php b/web/framework/i18n/data/en_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ng.php rename to web/framework/i18n/data/en_ng.php diff --git a/web/framework-1.1.17/i18n/data/en_nz.php b/web/framework/i18n/data/en_nz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_nz.php rename to web/framework/i18n/data/en_nz.php diff --git a/web/framework-1.1.17/i18n/data/en_pg.php b/web/framework/i18n/data/en_pg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_pg.php rename to web/framework/i18n/data/en_pg.php diff --git a/web/framework-1.1.17/i18n/data/en_ph.php b/web/framework/i18n/data/en_ph.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ph.php rename to web/framework/i18n/data/en_ph.php diff --git a/web/framework-1.1.17/i18n/data/en_pk.php b/web/framework/i18n/data/en_pk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_pk.php rename to web/framework/i18n/data/en_pk.php diff --git a/web/framework-1.1.17/i18n/data/en_pr.php b/web/framework/i18n/data/en_pr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_pr.php rename to web/framework/i18n/data/en_pr.php diff --git a/web/framework-1.1.17/i18n/data/en_pw.php b/web/framework/i18n/data/en_pw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_pw.php rename to web/framework/i18n/data/en_pw.php diff --git a/web/framework-1.1.17/i18n/data/en_sb.php b/web/framework/i18n/data/en_sb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_sb.php rename to web/framework/i18n/data/en_sb.php diff --git a/web/framework-1.1.17/i18n/data/en_sc.php b/web/framework/i18n/data/en_sc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_sc.php rename to web/framework/i18n/data/en_sc.php diff --git a/web/framework-1.1.17/i18n/data/en_sg.php b/web/framework/i18n/data/en_sg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_sg.php rename to web/framework/i18n/data/en_sg.php diff --git a/web/framework-1.1.17/i18n/data/en_shaw.php b/web/framework/i18n/data/en_shaw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_shaw.php rename to web/framework/i18n/data/en_shaw.php diff --git a/web/framework-1.1.17/i18n/data/en_sl.php b/web/framework/i18n/data/en_sl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_sl.php rename to web/framework/i18n/data/en_sl.php diff --git a/web/framework-1.1.17/i18n/data/en_ss.php b/web/framework/i18n/data/en_ss.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ss.php rename to web/framework/i18n/data/en_ss.php diff --git a/web/framework-1.1.17/i18n/data/en_sz.php b/web/framework/i18n/data/en_sz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_sz.php rename to web/framework/i18n/data/en_sz.php diff --git a/web/framework-1.1.17/i18n/data/en_tc.php b/web/framework/i18n/data/en_tc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_tc.php rename to web/framework/i18n/data/en_tc.php diff --git a/web/framework-1.1.17/i18n/data/en_to.php b/web/framework/i18n/data/en_to.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_to.php rename to web/framework/i18n/data/en_to.php diff --git a/web/framework-1.1.17/i18n/data/en_tt.php b/web/framework/i18n/data/en_tt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_tt.php rename to web/framework/i18n/data/en_tt.php diff --git a/web/framework-1.1.17/i18n/data/en_tz.php b/web/framework/i18n/data/en_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_tz.php rename to web/framework/i18n/data/en_tz.php diff --git a/web/framework-1.1.17/i18n/data/en_ug.php b/web/framework/i18n/data/en_ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ug.php rename to web/framework/i18n/data/en_ug.php diff --git a/web/framework-1.1.17/i18n/data/en_um.php b/web/framework/i18n/data/en_um.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_um.php rename to web/framework/i18n/data/en_um.php diff --git a/web/framework-1.1.17/i18n/data/en_us.php b/web/framework/i18n/data/en_us.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_us.php rename to web/framework/i18n/data/en_us.php diff --git a/web/framework-1.1.17/i18n/data/en_us_posix.php b/web/framework/i18n/data/en_us_posix.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_us_posix.php rename to web/framework/i18n/data/en_us_posix.php diff --git a/web/framework-1.1.17/i18n/data/en_vc.php b/web/framework/i18n/data/en_vc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_vc.php rename to web/framework/i18n/data/en_vc.php diff --git a/web/framework-1.1.17/i18n/data/en_vg.php b/web/framework/i18n/data/en_vg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_vg.php rename to web/framework/i18n/data/en_vg.php diff --git a/web/framework-1.1.17/i18n/data/en_vi.php b/web/framework/i18n/data/en_vi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_vi.php rename to web/framework/i18n/data/en_vi.php diff --git a/web/framework-1.1.17/i18n/data/en_vu.php b/web/framework/i18n/data/en_vu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_vu.php rename to web/framework/i18n/data/en_vu.php diff --git a/web/framework-1.1.17/i18n/data/en_ws.php b/web/framework/i18n/data/en_ws.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_ws.php rename to web/framework/i18n/data/en_ws.php diff --git a/web/framework-1.1.17/i18n/data/en_za.php b/web/framework/i18n/data/en_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_za.php rename to web/framework/i18n/data/en_za.php diff --git a/web/framework-1.1.17/i18n/data/en_zm.php b/web/framework/i18n/data/en_zm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_zm.php rename to web/framework/i18n/data/en_zm.php diff --git a/web/framework-1.1.17/i18n/data/en_zw.php b/web/framework/i18n/data/en_zw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_zw.php rename to web/framework/i18n/data/en_zw.php diff --git a/web/framework-1.1.17/i18n/data/en_zz.php b/web/framework/i18n/data/en_zz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/en_zz.php rename to web/framework/i18n/data/en_zz.php diff --git a/web/framework-1.1.17/i18n/data/eo.php b/web/framework/i18n/data/eo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/eo.php rename to web/framework/i18n/data/eo.php diff --git a/web/framework-1.1.17/i18n/data/es.php b/web/framework/i18n/data/es.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es.php rename to web/framework/i18n/data/es.php diff --git a/web/framework-1.1.17/i18n/data/es_419.php b/web/framework/i18n/data/es_419.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_419.php rename to web/framework/i18n/data/es_419.php diff --git a/web/framework-1.1.17/i18n/data/es_ar.php b/web/framework/i18n/data/es_ar.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_ar.php rename to web/framework/i18n/data/es_ar.php diff --git a/web/framework-1.1.17/i18n/data/es_bo.php b/web/framework/i18n/data/es_bo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_bo.php rename to web/framework/i18n/data/es_bo.php diff --git a/web/framework-1.1.17/i18n/data/es_cl.php b/web/framework/i18n/data/es_cl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_cl.php rename to web/framework/i18n/data/es_cl.php diff --git a/web/framework-1.1.17/i18n/data/es_co.php b/web/framework/i18n/data/es_co.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_co.php rename to web/framework/i18n/data/es_co.php diff --git a/web/framework-1.1.17/i18n/data/es_cr.php b/web/framework/i18n/data/es_cr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_cr.php rename to web/framework/i18n/data/es_cr.php diff --git a/web/framework-1.1.17/i18n/data/es_cu.php b/web/framework/i18n/data/es_cu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_cu.php rename to web/framework/i18n/data/es_cu.php diff --git a/web/framework-1.1.17/i18n/data/es_do.php b/web/framework/i18n/data/es_do.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_do.php rename to web/framework/i18n/data/es_do.php diff --git a/web/framework-1.1.17/i18n/data/es_ea.php b/web/framework/i18n/data/es_ea.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_ea.php rename to web/framework/i18n/data/es_ea.php diff --git a/web/framework-1.1.17/i18n/data/es_ec.php b/web/framework/i18n/data/es_ec.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_ec.php rename to web/framework/i18n/data/es_ec.php diff --git a/web/framework-1.1.17/i18n/data/es_es.php b/web/framework/i18n/data/es_es.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_es.php rename to web/framework/i18n/data/es_es.php diff --git a/web/framework-1.1.17/i18n/data/es_gq.php b/web/framework/i18n/data/es_gq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_gq.php rename to web/framework/i18n/data/es_gq.php diff --git a/web/framework-1.1.17/i18n/data/es_gt.php b/web/framework/i18n/data/es_gt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_gt.php rename to web/framework/i18n/data/es_gt.php diff --git a/web/framework-1.1.17/i18n/data/es_hn.php b/web/framework/i18n/data/es_hn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_hn.php rename to web/framework/i18n/data/es_hn.php diff --git a/web/framework-1.1.17/i18n/data/es_ic.php b/web/framework/i18n/data/es_ic.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_ic.php rename to web/framework/i18n/data/es_ic.php diff --git a/web/framework-1.1.17/i18n/data/es_mx.php b/web/framework/i18n/data/es_mx.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_mx.php rename to web/framework/i18n/data/es_mx.php diff --git a/web/framework-1.1.17/i18n/data/es_ni.php b/web/framework/i18n/data/es_ni.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_ni.php rename to web/framework/i18n/data/es_ni.php diff --git a/web/framework-1.1.17/i18n/data/es_pa.php b/web/framework/i18n/data/es_pa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_pa.php rename to web/framework/i18n/data/es_pa.php diff --git a/web/framework-1.1.17/i18n/data/es_pe.php b/web/framework/i18n/data/es_pe.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_pe.php rename to web/framework/i18n/data/es_pe.php diff --git a/web/framework-1.1.17/i18n/data/es_ph.php b/web/framework/i18n/data/es_ph.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_ph.php rename to web/framework/i18n/data/es_ph.php diff --git a/web/framework-1.1.17/i18n/data/es_pr.php b/web/framework/i18n/data/es_pr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_pr.php rename to web/framework/i18n/data/es_pr.php diff --git a/web/framework-1.1.17/i18n/data/es_py.php b/web/framework/i18n/data/es_py.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_py.php rename to web/framework/i18n/data/es_py.php diff --git a/web/framework-1.1.17/i18n/data/es_sv.php b/web/framework/i18n/data/es_sv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_sv.php rename to web/framework/i18n/data/es_sv.php diff --git a/web/framework-1.1.17/i18n/data/es_us.php b/web/framework/i18n/data/es_us.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_us.php rename to web/framework/i18n/data/es_us.php diff --git a/web/framework-1.1.17/i18n/data/es_uy.php b/web/framework/i18n/data/es_uy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_uy.php rename to web/framework/i18n/data/es_uy.php diff --git a/web/framework-1.1.17/i18n/data/es_ve.php b/web/framework/i18n/data/es_ve.php similarity index 100% rename from web/framework-1.1.17/i18n/data/es_ve.php rename to web/framework/i18n/data/es_ve.php diff --git a/web/framework-1.1.17/i18n/data/et.php b/web/framework/i18n/data/et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/et.php rename to web/framework/i18n/data/et.php diff --git a/web/framework-1.1.17/i18n/data/et_ee.php b/web/framework/i18n/data/et_ee.php similarity index 100% rename from web/framework-1.1.17/i18n/data/et_ee.php rename to web/framework/i18n/data/et_ee.php diff --git a/web/framework-1.1.17/i18n/data/eu.php b/web/framework/i18n/data/eu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/eu.php rename to web/framework/i18n/data/eu.php diff --git a/web/framework-1.1.17/i18n/data/eu_es.php b/web/framework/i18n/data/eu_es.php similarity index 100% rename from web/framework-1.1.17/i18n/data/eu_es.php rename to web/framework/i18n/data/eu_es.php diff --git a/web/framework-1.1.17/i18n/data/ewo.php b/web/framework/i18n/data/ewo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ewo.php rename to web/framework/i18n/data/ewo.php diff --git a/web/framework-1.1.17/i18n/data/ewo_cm.php b/web/framework/i18n/data/ewo_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ewo_cm.php rename to web/framework/i18n/data/ewo_cm.php diff --git a/web/framework-1.1.17/i18n/data/fa.php b/web/framework/i18n/data/fa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fa.php rename to web/framework/i18n/data/fa.php diff --git a/web/framework-1.1.17/i18n/data/fa_af.php b/web/framework/i18n/data/fa_af.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fa_af.php rename to web/framework/i18n/data/fa_af.php diff --git a/web/framework-1.1.17/i18n/data/fa_ir.php b/web/framework/i18n/data/fa_ir.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fa_ir.php rename to web/framework/i18n/data/fa_ir.php diff --git a/web/framework-1.1.17/i18n/data/ff.php b/web/framework/i18n/data/ff.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ff.php rename to web/framework/i18n/data/ff.php diff --git a/web/framework-1.1.17/i18n/data/ff_sn.php b/web/framework/i18n/data/ff_sn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ff_sn.php rename to web/framework/i18n/data/ff_sn.php diff --git a/web/framework-1.1.17/i18n/data/fi.php b/web/framework/i18n/data/fi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fi.php rename to web/framework/i18n/data/fi.php diff --git a/web/framework-1.1.17/i18n/data/fi_fi.php b/web/framework/i18n/data/fi_fi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fi_fi.php rename to web/framework/i18n/data/fi_fi.php diff --git a/web/framework-1.1.17/i18n/data/fil.php b/web/framework/i18n/data/fil.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fil.php rename to web/framework/i18n/data/fil.php diff --git a/web/framework-1.1.17/i18n/data/fil_ph.php b/web/framework/i18n/data/fil_ph.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fil_ph.php rename to web/framework/i18n/data/fil_ph.php diff --git a/web/framework-1.1.17/i18n/data/fo.php b/web/framework/i18n/data/fo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fo.php rename to web/framework/i18n/data/fo.php diff --git a/web/framework-1.1.17/i18n/data/fo_fo.php b/web/framework/i18n/data/fo_fo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fo_fo.php rename to web/framework/i18n/data/fo_fo.php diff --git a/web/framework-1.1.17/i18n/data/fr.php b/web/framework/i18n/data/fr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr.php rename to web/framework/i18n/data/fr.php diff --git a/web/framework-1.1.17/i18n/data/fr_be.php b/web/framework/i18n/data/fr_be.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_be.php rename to web/framework/i18n/data/fr_be.php diff --git a/web/framework-1.1.17/i18n/data/fr_bf.php b/web/framework/i18n/data/fr_bf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_bf.php rename to web/framework/i18n/data/fr_bf.php diff --git a/web/framework-1.1.17/i18n/data/fr_bi.php b/web/framework/i18n/data/fr_bi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_bi.php rename to web/framework/i18n/data/fr_bi.php diff --git a/web/framework-1.1.17/i18n/data/fr_bj.php b/web/framework/i18n/data/fr_bj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_bj.php rename to web/framework/i18n/data/fr_bj.php diff --git a/web/framework-1.1.17/i18n/data/fr_bl.php b/web/framework/i18n/data/fr_bl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_bl.php rename to web/framework/i18n/data/fr_bl.php diff --git a/web/framework-1.1.17/i18n/data/fr_ca.php b/web/framework/i18n/data/fr_ca.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ca.php rename to web/framework/i18n/data/fr_ca.php diff --git a/web/framework-1.1.17/i18n/data/fr_cd.php b/web/framework/i18n/data/fr_cd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_cd.php rename to web/framework/i18n/data/fr_cd.php diff --git a/web/framework-1.1.17/i18n/data/fr_cf.php b/web/framework/i18n/data/fr_cf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_cf.php rename to web/framework/i18n/data/fr_cf.php diff --git a/web/framework-1.1.17/i18n/data/fr_cg.php b/web/framework/i18n/data/fr_cg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_cg.php rename to web/framework/i18n/data/fr_cg.php diff --git a/web/framework-1.1.17/i18n/data/fr_ch.php b/web/framework/i18n/data/fr_ch.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ch.php rename to web/framework/i18n/data/fr_ch.php diff --git a/web/framework-1.1.17/i18n/data/fr_ci.php b/web/framework/i18n/data/fr_ci.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ci.php rename to web/framework/i18n/data/fr_ci.php diff --git a/web/framework-1.1.17/i18n/data/fr_cm.php b/web/framework/i18n/data/fr_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_cm.php rename to web/framework/i18n/data/fr_cm.php diff --git a/web/framework-1.1.17/i18n/data/fr_dj.php b/web/framework/i18n/data/fr_dj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_dj.php rename to web/framework/i18n/data/fr_dj.php diff --git a/web/framework-1.1.17/i18n/data/fr_dz.php b/web/framework/i18n/data/fr_dz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_dz.php rename to web/framework/i18n/data/fr_dz.php diff --git a/web/framework-1.1.17/i18n/data/fr_fr.php b/web/framework/i18n/data/fr_fr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_fr.php rename to web/framework/i18n/data/fr_fr.php diff --git a/web/framework-1.1.17/i18n/data/fr_ga.php b/web/framework/i18n/data/fr_ga.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ga.php rename to web/framework/i18n/data/fr_ga.php diff --git a/web/framework-1.1.17/i18n/data/fr_gf.php b/web/framework/i18n/data/fr_gf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_gf.php rename to web/framework/i18n/data/fr_gf.php diff --git a/web/framework-1.1.17/i18n/data/fr_gn.php b/web/framework/i18n/data/fr_gn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_gn.php rename to web/framework/i18n/data/fr_gn.php diff --git a/web/framework-1.1.17/i18n/data/fr_gp.php b/web/framework/i18n/data/fr_gp.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_gp.php rename to web/framework/i18n/data/fr_gp.php diff --git a/web/framework-1.1.17/i18n/data/fr_gq.php b/web/framework/i18n/data/fr_gq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_gq.php rename to web/framework/i18n/data/fr_gq.php diff --git a/web/framework-1.1.17/i18n/data/fr_ht.php b/web/framework/i18n/data/fr_ht.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ht.php rename to web/framework/i18n/data/fr_ht.php diff --git a/web/framework-1.1.17/i18n/data/fr_km.php b/web/framework/i18n/data/fr_km.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_km.php rename to web/framework/i18n/data/fr_km.php diff --git a/web/framework-1.1.17/i18n/data/fr_lu.php b/web/framework/i18n/data/fr_lu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_lu.php rename to web/framework/i18n/data/fr_lu.php diff --git a/web/framework-1.1.17/i18n/data/fr_ma.php b/web/framework/i18n/data/fr_ma.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ma.php rename to web/framework/i18n/data/fr_ma.php diff --git a/web/framework-1.1.17/i18n/data/fr_mc.php b/web/framework/i18n/data/fr_mc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_mc.php rename to web/framework/i18n/data/fr_mc.php diff --git a/web/framework-1.1.17/i18n/data/fr_mf.php b/web/framework/i18n/data/fr_mf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_mf.php rename to web/framework/i18n/data/fr_mf.php diff --git a/web/framework-1.1.17/i18n/data/fr_mg.php b/web/framework/i18n/data/fr_mg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_mg.php rename to web/framework/i18n/data/fr_mg.php diff --git a/web/framework-1.1.17/i18n/data/fr_ml.php b/web/framework/i18n/data/fr_ml.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ml.php rename to web/framework/i18n/data/fr_ml.php diff --git a/web/framework-1.1.17/i18n/data/fr_mq.php b/web/framework/i18n/data/fr_mq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_mq.php rename to web/framework/i18n/data/fr_mq.php diff --git a/web/framework-1.1.17/i18n/data/fr_mr.php b/web/framework/i18n/data/fr_mr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_mr.php rename to web/framework/i18n/data/fr_mr.php diff --git a/web/framework-1.1.17/i18n/data/fr_mu.php b/web/framework/i18n/data/fr_mu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_mu.php rename to web/framework/i18n/data/fr_mu.php diff --git a/web/framework-1.1.17/i18n/data/fr_nc.php b/web/framework/i18n/data/fr_nc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_nc.php rename to web/framework/i18n/data/fr_nc.php diff --git a/web/framework-1.1.17/i18n/data/fr_ne.php b/web/framework/i18n/data/fr_ne.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_ne.php rename to web/framework/i18n/data/fr_ne.php diff --git a/web/framework-1.1.17/i18n/data/fr_pf.php b/web/framework/i18n/data/fr_pf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_pf.php rename to web/framework/i18n/data/fr_pf.php diff --git a/web/framework-1.1.17/i18n/data/fr_re.php b/web/framework/i18n/data/fr_re.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_re.php rename to web/framework/i18n/data/fr_re.php diff --git a/web/framework-1.1.17/i18n/data/fr_rw.php b/web/framework/i18n/data/fr_rw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_rw.php rename to web/framework/i18n/data/fr_rw.php diff --git a/web/framework-1.1.17/i18n/data/fr_sc.php b/web/framework/i18n/data/fr_sc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_sc.php rename to web/framework/i18n/data/fr_sc.php diff --git a/web/framework-1.1.17/i18n/data/fr_sn.php b/web/framework/i18n/data/fr_sn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_sn.php rename to web/framework/i18n/data/fr_sn.php diff --git a/web/framework-1.1.17/i18n/data/fr_sy.php b/web/framework/i18n/data/fr_sy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_sy.php rename to web/framework/i18n/data/fr_sy.php diff --git a/web/framework-1.1.17/i18n/data/fr_td.php b/web/framework/i18n/data/fr_td.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_td.php rename to web/framework/i18n/data/fr_td.php diff --git a/web/framework-1.1.17/i18n/data/fr_tg.php b/web/framework/i18n/data/fr_tg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_tg.php rename to web/framework/i18n/data/fr_tg.php diff --git a/web/framework-1.1.17/i18n/data/fr_tn.php b/web/framework/i18n/data/fr_tn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_tn.php rename to web/framework/i18n/data/fr_tn.php diff --git a/web/framework-1.1.17/i18n/data/fr_vu.php b/web/framework/i18n/data/fr_vu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_vu.php rename to web/framework/i18n/data/fr_vu.php diff --git a/web/framework-1.1.17/i18n/data/fr_yt.php b/web/framework/i18n/data/fr_yt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fr_yt.php rename to web/framework/i18n/data/fr_yt.php diff --git a/web/framework-1.1.17/i18n/data/fur.php b/web/framework/i18n/data/fur.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fur.php rename to web/framework/i18n/data/fur.php diff --git a/web/framework-1.1.17/i18n/data/fur_it.php b/web/framework/i18n/data/fur_it.php similarity index 100% rename from web/framework-1.1.17/i18n/data/fur_it.php rename to web/framework/i18n/data/fur_it.php diff --git a/web/framework-1.1.17/i18n/data/ga.php b/web/framework/i18n/data/ga.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ga.php rename to web/framework/i18n/data/ga.php diff --git a/web/framework-1.1.17/i18n/data/ga_ie.php b/web/framework/i18n/data/ga_ie.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ga_ie.php rename to web/framework/i18n/data/ga_ie.php diff --git a/web/framework-1.1.17/i18n/data/gaa.php b/web/framework/i18n/data/gaa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gaa.php rename to web/framework/i18n/data/gaa.php diff --git a/web/framework-1.1.17/i18n/data/gaa_gh.php b/web/framework/i18n/data/gaa_gh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gaa_gh.php rename to web/framework/i18n/data/gaa_gh.php diff --git a/web/framework-1.1.17/i18n/data/gd.php b/web/framework/i18n/data/gd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gd.php rename to web/framework/i18n/data/gd.php diff --git a/web/framework-1.1.17/i18n/data/gd_gb.php b/web/framework/i18n/data/gd_gb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gd_gb.php rename to web/framework/i18n/data/gd_gb.php diff --git a/web/framework-1.1.17/i18n/data/gez.php b/web/framework/i18n/data/gez.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gez.php rename to web/framework/i18n/data/gez.php diff --git a/web/framework-1.1.17/i18n/data/gez_er.php b/web/framework/i18n/data/gez_er.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gez_er.php rename to web/framework/i18n/data/gez_er.php diff --git a/web/framework-1.1.17/i18n/data/gez_et.php b/web/framework/i18n/data/gez_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gez_et.php rename to web/framework/i18n/data/gez_et.php diff --git a/web/framework-1.1.17/i18n/data/gl.php b/web/framework/i18n/data/gl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gl.php rename to web/framework/i18n/data/gl.php diff --git a/web/framework-1.1.17/i18n/data/gl_es.php b/web/framework/i18n/data/gl_es.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gl_es.php rename to web/framework/i18n/data/gl_es.php diff --git a/web/framework-1.1.17/i18n/data/gsw.php b/web/framework/i18n/data/gsw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gsw.php rename to web/framework/i18n/data/gsw.php diff --git a/web/framework-1.1.17/i18n/data/gsw_ch.php b/web/framework/i18n/data/gsw_ch.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gsw_ch.php rename to web/framework/i18n/data/gsw_ch.php diff --git a/web/framework-1.1.17/i18n/data/gu.php b/web/framework/i18n/data/gu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gu.php rename to web/framework/i18n/data/gu.php diff --git a/web/framework-1.1.17/i18n/data/gu_in.php b/web/framework/i18n/data/gu_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gu_in.php rename to web/framework/i18n/data/gu_in.php diff --git a/web/framework-1.1.17/i18n/data/guz.php b/web/framework/i18n/data/guz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/guz.php rename to web/framework/i18n/data/guz.php diff --git a/web/framework-1.1.17/i18n/data/guz_ke.php b/web/framework/i18n/data/guz_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/guz_ke.php rename to web/framework/i18n/data/guz_ke.php diff --git a/web/framework-1.1.17/i18n/data/gv.php b/web/framework/i18n/data/gv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gv.php rename to web/framework/i18n/data/gv.php diff --git a/web/framework-1.1.17/i18n/data/gv_gb.php b/web/framework/i18n/data/gv_gb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/gv_gb.php rename to web/framework/i18n/data/gv_gb.php diff --git a/web/framework-1.1.17/i18n/data/ha.php b/web/framework/i18n/data/ha.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha.php rename to web/framework/i18n/data/ha.php diff --git a/web/framework-1.1.17/i18n/data/ha_arab.php b/web/framework/i18n/data/ha_arab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_arab.php rename to web/framework/i18n/data/ha_arab.php diff --git a/web/framework-1.1.17/i18n/data/ha_arab_ng.php b/web/framework/i18n/data/ha_arab_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_arab_ng.php rename to web/framework/i18n/data/ha_arab_ng.php diff --git a/web/framework-1.1.17/i18n/data/ha_arab_sd.php b/web/framework/i18n/data/ha_arab_sd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_arab_sd.php rename to web/framework/i18n/data/ha_arab_sd.php diff --git a/web/framework-1.1.17/i18n/data/ha_gh.php b/web/framework/i18n/data/ha_gh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_gh.php rename to web/framework/i18n/data/ha_gh.php diff --git a/web/framework-1.1.17/i18n/data/ha_latn.php b/web/framework/i18n/data/ha_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_latn.php rename to web/framework/i18n/data/ha_latn.php diff --git a/web/framework-1.1.17/i18n/data/ha_latn_gh.php b/web/framework/i18n/data/ha_latn_gh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_latn_gh.php rename to web/framework/i18n/data/ha_latn_gh.php diff --git a/web/framework-1.1.17/i18n/data/ha_latn_ne.php b/web/framework/i18n/data/ha_latn_ne.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_latn_ne.php rename to web/framework/i18n/data/ha_latn_ne.php diff --git a/web/framework-1.1.17/i18n/data/ha_latn_ng.php b/web/framework/i18n/data/ha_latn_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_latn_ng.php rename to web/framework/i18n/data/ha_latn_ng.php diff --git a/web/framework-1.1.17/i18n/data/ha_ne.php b/web/framework/i18n/data/ha_ne.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_ne.php rename to web/framework/i18n/data/ha_ne.php diff --git a/web/framework-1.1.17/i18n/data/ha_ng.php b/web/framework/i18n/data/ha_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_ng.php rename to web/framework/i18n/data/ha_ng.php diff --git a/web/framework-1.1.17/i18n/data/ha_sd.php b/web/framework/i18n/data/ha_sd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ha_sd.php rename to web/framework/i18n/data/ha_sd.php diff --git a/web/framework-1.1.17/i18n/data/haw.php b/web/framework/i18n/data/haw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/haw.php rename to web/framework/i18n/data/haw.php diff --git a/web/framework-1.1.17/i18n/data/haw_us.php b/web/framework/i18n/data/haw_us.php similarity index 100% rename from web/framework-1.1.17/i18n/data/haw_us.php rename to web/framework/i18n/data/haw_us.php diff --git a/web/framework-1.1.17/i18n/data/he.php b/web/framework/i18n/data/he.php similarity index 100% rename from web/framework-1.1.17/i18n/data/he.php rename to web/framework/i18n/data/he.php diff --git a/web/framework-1.1.17/i18n/data/he_il.php b/web/framework/i18n/data/he_il.php similarity index 100% rename from web/framework-1.1.17/i18n/data/he_il.php rename to web/framework/i18n/data/he_il.php diff --git a/web/framework-1.1.17/i18n/data/hi.php b/web/framework/i18n/data/hi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hi.php rename to web/framework/i18n/data/hi.php diff --git a/web/framework-1.1.17/i18n/data/hi_in.php b/web/framework/i18n/data/hi_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hi_in.php rename to web/framework/i18n/data/hi_in.php diff --git a/web/framework-1.1.17/i18n/data/hr.php b/web/framework/i18n/data/hr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hr.php rename to web/framework/i18n/data/hr.php diff --git a/web/framework-1.1.17/i18n/data/hr_ba.php b/web/framework/i18n/data/hr_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hr_ba.php rename to web/framework/i18n/data/hr_ba.php diff --git a/web/framework-1.1.17/i18n/data/hr_hr.php b/web/framework/i18n/data/hr_hr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hr_hr.php rename to web/framework/i18n/data/hr_hr.php diff --git a/web/framework-1.1.17/i18n/data/hu.php b/web/framework/i18n/data/hu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hu.php rename to web/framework/i18n/data/hu.php diff --git a/web/framework-1.1.17/i18n/data/hu_hu.php b/web/framework/i18n/data/hu_hu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hu_hu.php rename to web/framework/i18n/data/hu_hu.php diff --git a/web/framework-1.1.17/i18n/data/hy.php b/web/framework/i18n/data/hy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hy.php rename to web/framework/i18n/data/hy.php diff --git a/web/framework-1.1.17/i18n/data/hy_am.php b/web/framework/i18n/data/hy_am.php similarity index 100% rename from web/framework-1.1.17/i18n/data/hy_am.php rename to web/framework/i18n/data/hy_am.php diff --git a/web/framework-1.1.17/i18n/data/ia.php b/web/framework/i18n/data/ia.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ia.php rename to web/framework/i18n/data/ia.php diff --git a/web/framework-1.1.17/i18n/data/ia_fr.php b/web/framework/i18n/data/ia_fr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ia_fr.php rename to web/framework/i18n/data/ia_fr.php diff --git a/web/framework-1.1.17/i18n/data/id.php b/web/framework/i18n/data/id.php similarity index 100% rename from web/framework-1.1.17/i18n/data/id.php rename to web/framework/i18n/data/id.php diff --git a/web/framework-1.1.17/i18n/data/id_id.php b/web/framework/i18n/data/id_id.php similarity index 100% rename from web/framework-1.1.17/i18n/data/id_id.php rename to web/framework/i18n/data/id_id.php diff --git a/web/framework-1.1.17/i18n/data/ig.php b/web/framework/i18n/data/ig.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ig.php rename to web/framework/i18n/data/ig.php diff --git a/web/framework-1.1.17/i18n/data/ig_ng.php b/web/framework/i18n/data/ig_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ig_ng.php rename to web/framework/i18n/data/ig_ng.php diff --git a/web/framework-1.1.17/i18n/data/ii.php b/web/framework/i18n/data/ii.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ii.php rename to web/framework/i18n/data/ii.php diff --git a/web/framework-1.1.17/i18n/data/ii_cn.php b/web/framework/i18n/data/ii_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ii_cn.php rename to web/framework/i18n/data/ii_cn.php diff --git a/web/framework-1.1.17/i18n/data/in.php b/web/framework/i18n/data/in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/in.php rename to web/framework/i18n/data/in.php diff --git a/web/framework-1.1.17/i18n/data/is.php b/web/framework/i18n/data/is.php similarity index 100% rename from web/framework-1.1.17/i18n/data/is.php rename to web/framework/i18n/data/is.php diff --git a/web/framework-1.1.17/i18n/data/is_is.php b/web/framework/i18n/data/is_is.php similarity index 100% rename from web/framework-1.1.17/i18n/data/is_is.php rename to web/framework/i18n/data/is_is.php diff --git a/web/framework-1.1.17/i18n/data/it.php b/web/framework/i18n/data/it.php similarity index 100% rename from web/framework-1.1.17/i18n/data/it.php rename to web/framework/i18n/data/it.php diff --git a/web/framework-1.1.17/i18n/data/it_ch.php b/web/framework/i18n/data/it_ch.php similarity index 100% rename from web/framework-1.1.17/i18n/data/it_ch.php rename to web/framework/i18n/data/it_ch.php diff --git a/web/framework-1.1.17/i18n/data/it_it.php b/web/framework/i18n/data/it_it.php similarity index 100% rename from web/framework-1.1.17/i18n/data/it_it.php rename to web/framework/i18n/data/it_it.php diff --git a/web/framework-1.1.17/i18n/data/it_sm.php b/web/framework/i18n/data/it_sm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/it_sm.php rename to web/framework/i18n/data/it_sm.php diff --git a/web/framework-1.1.17/i18n/data/iu.php b/web/framework/i18n/data/iu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/iu.php rename to web/framework/i18n/data/iu.php diff --git a/web/framework-1.1.17/i18n/data/iw.php b/web/framework/i18n/data/iw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/iw.php rename to web/framework/i18n/data/iw.php diff --git a/web/framework-1.1.17/i18n/data/ja.php b/web/framework/i18n/data/ja.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ja.php rename to web/framework/i18n/data/ja.php diff --git a/web/framework-1.1.17/i18n/data/ja_jp.php b/web/framework/i18n/data/ja_jp.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ja_jp.php rename to web/framework/i18n/data/ja_jp.php diff --git a/web/framework-1.1.17/i18n/data/jgo.php b/web/framework/i18n/data/jgo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/jgo.php rename to web/framework/i18n/data/jgo.php diff --git a/web/framework-1.1.17/i18n/data/jgo_cm.php b/web/framework/i18n/data/jgo_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/jgo_cm.php rename to web/framework/i18n/data/jgo_cm.php diff --git a/web/framework-1.1.17/i18n/data/jmc.php b/web/framework/i18n/data/jmc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/jmc.php rename to web/framework/i18n/data/jmc.php diff --git a/web/framework-1.1.17/i18n/data/jmc_tz.php b/web/framework/i18n/data/jmc_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/jmc_tz.php rename to web/framework/i18n/data/jmc_tz.php diff --git a/web/framework-1.1.17/i18n/data/ka.php b/web/framework/i18n/data/ka.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ka.php rename to web/framework/i18n/data/ka.php diff --git a/web/framework-1.1.17/i18n/data/ka_ge.php b/web/framework/i18n/data/ka_ge.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ka_ge.php rename to web/framework/i18n/data/ka_ge.php diff --git a/web/framework-1.1.17/i18n/data/kab.php b/web/framework/i18n/data/kab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kab.php rename to web/framework/i18n/data/kab.php diff --git a/web/framework-1.1.17/i18n/data/kab_dz.php b/web/framework/i18n/data/kab_dz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kab_dz.php rename to web/framework/i18n/data/kab_dz.php diff --git a/web/framework-1.1.17/i18n/data/kaj.php b/web/framework/i18n/data/kaj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kaj.php rename to web/framework/i18n/data/kaj.php diff --git a/web/framework-1.1.17/i18n/data/kaj_ng.php b/web/framework/i18n/data/kaj_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kaj_ng.php rename to web/framework/i18n/data/kaj_ng.php diff --git a/web/framework-1.1.17/i18n/data/kam.php b/web/framework/i18n/data/kam.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kam.php rename to web/framework/i18n/data/kam.php diff --git a/web/framework-1.1.17/i18n/data/kam_ke.php b/web/framework/i18n/data/kam_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kam_ke.php rename to web/framework/i18n/data/kam_ke.php diff --git a/web/framework-1.1.17/i18n/data/kcg.php b/web/framework/i18n/data/kcg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kcg.php rename to web/framework/i18n/data/kcg.php diff --git a/web/framework-1.1.17/i18n/data/kcg_ng.php b/web/framework/i18n/data/kcg_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kcg_ng.php rename to web/framework/i18n/data/kcg_ng.php diff --git a/web/framework-1.1.17/i18n/data/kde.php b/web/framework/i18n/data/kde.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kde.php rename to web/framework/i18n/data/kde.php diff --git a/web/framework-1.1.17/i18n/data/kde_tz.php b/web/framework/i18n/data/kde_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kde_tz.php rename to web/framework/i18n/data/kde_tz.php diff --git a/web/framework-1.1.17/i18n/data/kea.php b/web/framework/i18n/data/kea.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kea.php rename to web/framework/i18n/data/kea.php diff --git a/web/framework-1.1.17/i18n/data/kea_cv.php b/web/framework/i18n/data/kea_cv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kea_cv.php rename to web/framework/i18n/data/kea_cv.php diff --git a/web/framework-1.1.17/i18n/data/kfo.php b/web/framework/i18n/data/kfo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kfo.php rename to web/framework/i18n/data/kfo.php diff --git a/web/framework-1.1.17/i18n/data/kfo_ci.php b/web/framework/i18n/data/kfo_ci.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kfo_ci.php rename to web/framework/i18n/data/kfo_ci.php diff --git a/web/framework-1.1.17/i18n/data/khq.php b/web/framework/i18n/data/khq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/khq.php rename to web/framework/i18n/data/khq.php diff --git a/web/framework-1.1.17/i18n/data/khq_ml.php b/web/framework/i18n/data/khq_ml.php similarity index 100% rename from web/framework-1.1.17/i18n/data/khq_ml.php rename to web/framework/i18n/data/khq_ml.php diff --git a/web/framework-1.1.17/i18n/data/ki.php b/web/framework/i18n/data/ki.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ki.php rename to web/framework/i18n/data/ki.php diff --git a/web/framework-1.1.17/i18n/data/ki_ke.php b/web/framework/i18n/data/ki_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ki_ke.php rename to web/framework/i18n/data/ki_ke.php diff --git a/web/framework-1.1.17/i18n/data/kk.php b/web/framework/i18n/data/kk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kk.php rename to web/framework/i18n/data/kk.php diff --git a/web/framework-1.1.17/i18n/data/kk_cyrl.php b/web/framework/i18n/data/kk_cyrl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kk_cyrl.php rename to web/framework/i18n/data/kk_cyrl.php diff --git a/web/framework-1.1.17/i18n/data/kk_cyrl_kz.php b/web/framework/i18n/data/kk_cyrl_kz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kk_cyrl_kz.php rename to web/framework/i18n/data/kk_cyrl_kz.php diff --git a/web/framework-1.1.17/i18n/data/kk_kz.php b/web/framework/i18n/data/kk_kz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kk_kz.php rename to web/framework/i18n/data/kk_kz.php diff --git a/web/framework-1.1.17/i18n/data/kkj.php b/web/framework/i18n/data/kkj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kkj.php rename to web/framework/i18n/data/kkj.php diff --git a/web/framework-1.1.17/i18n/data/kkj_cm.php b/web/framework/i18n/data/kkj_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kkj_cm.php rename to web/framework/i18n/data/kkj_cm.php diff --git a/web/framework-1.1.17/i18n/data/kl.php b/web/framework/i18n/data/kl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kl.php rename to web/framework/i18n/data/kl.php diff --git a/web/framework-1.1.17/i18n/data/kl_gl.php b/web/framework/i18n/data/kl_gl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kl_gl.php rename to web/framework/i18n/data/kl_gl.php diff --git a/web/framework-1.1.17/i18n/data/kln.php b/web/framework/i18n/data/kln.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kln.php rename to web/framework/i18n/data/kln.php diff --git a/web/framework-1.1.17/i18n/data/kln_ke.php b/web/framework/i18n/data/kln_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kln_ke.php rename to web/framework/i18n/data/kln_ke.php diff --git a/web/framework-1.1.17/i18n/data/km.php b/web/framework/i18n/data/km.php similarity index 100% rename from web/framework-1.1.17/i18n/data/km.php rename to web/framework/i18n/data/km.php diff --git a/web/framework-1.1.17/i18n/data/km_kh.php b/web/framework/i18n/data/km_kh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/km_kh.php rename to web/framework/i18n/data/km_kh.php diff --git a/web/framework-1.1.17/i18n/data/kn.php b/web/framework/i18n/data/kn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kn.php rename to web/framework/i18n/data/kn.php diff --git a/web/framework-1.1.17/i18n/data/kn_in.php b/web/framework/i18n/data/kn_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kn_in.php rename to web/framework/i18n/data/kn_in.php diff --git a/web/framework-1.1.17/i18n/data/ko.php b/web/framework/i18n/data/ko.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ko.php rename to web/framework/i18n/data/ko.php diff --git a/web/framework-1.1.17/i18n/data/ko_kp.php b/web/framework/i18n/data/ko_kp.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ko_kp.php rename to web/framework/i18n/data/ko_kp.php diff --git a/web/framework-1.1.17/i18n/data/ko_kr.php b/web/framework/i18n/data/ko_kr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ko_kr.php rename to web/framework/i18n/data/ko_kr.php diff --git a/web/framework-1.1.17/i18n/data/kok.php b/web/framework/i18n/data/kok.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kok.php rename to web/framework/i18n/data/kok.php diff --git a/web/framework-1.1.17/i18n/data/kok_in.php b/web/framework/i18n/data/kok_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kok_in.php rename to web/framework/i18n/data/kok_in.php diff --git a/web/framework-1.1.17/i18n/data/kpe.php b/web/framework/i18n/data/kpe.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kpe.php rename to web/framework/i18n/data/kpe.php diff --git a/web/framework-1.1.17/i18n/data/kpe_gn.php b/web/framework/i18n/data/kpe_gn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kpe_gn.php rename to web/framework/i18n/data/kpe_gn.php diff --git a/web/framework-1.1.17/i18n/data/kpe_lr.php b/web/framework/i18n/data/kpe_lr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kpe_lr.php rename to web/framework/i18n/data/kpe_lr.php diff --git a/web/framework-1.1.17/i18n/data/ks.php b/web/framework/i18n/data/ks.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ks.php rename to web/framework/i18n/data/ks.php diff --git a/web/framework-1.1.17/i18n/data/ks_arab.php b/web/framework/i18n/data/ks_arab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ks_arab.php rename to web/framework/i18n/data/ks_arab.php diff --git a/web/framework-1.1.17/i18n/data/ks_arab_in.php b/web/framework/i18n/data/ks_arab_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ks_arab_in.php rename to web/framework/i18n/data/ks_arab_in.php diff --git a/web/framework-1.1.17/i18n/data/ksb.php b/web/framework/i18n/data/ksb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ksb.php rename to web/framework/i18n/data/ksb.php diff --git a/web/framework-1.1.17/i18n/data/ksb_tz.php b/web/framework/i18n/data/ksb_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ksb_tz.php rename to web/framework/i18n/data/ksb_tz.php diff --git a/web/framework-1.1.17/i18n/data/ksf.php b/web/framework/i18n/data/ksf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ksf.php rename to web/framework/i18n/data/ksf.php diff --git a/web/framework-1.1.17/i18n/data/ksf_cm.php b/web/framework/i18n/data/ksf_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ksf_cm.php rename to web/framework/i18n/data/ksf_cm.php diff --git a/web/framework-1.1.17/i18n/data/ksh.php b/web/framework/i18n/data/ksh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ksh.php rename to web/framework/i18n/data/ksh.php diff --git a/web/framework-1.1.17/i18n/data/ksh_de.php b/web/framework/i18n/data/ksh_de.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ksh_de.php rename to web/framework/i18n/data/ksh_de.php diff --git a/web/framework-1.1.17/i18n/data/ku.php b/web/framework/i18n/data/ku.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku.php rename to web/framework/i18n/data/ku.php diff --git a/web/framework-1.1.17/i18n/data/ku_arab.php b/web/framework/i18n/data/ku_arab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_arab.php rename to web/framework/i18n/data/ku_arab.php diff --git a/web/framework-1.1.17/i18n/data/ku_arab_iq.php b/web/framework/i18n/data/ku_arab_iq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_arab_iq.php rename to web/framework/i18n/data/ku_arab_iq.php diff --git a/web/framework-1.1.17/i18n/data/ku_arab_ir.php b/web/framework/i18n/data/ku_arab_ir.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_arab_ir.php rename to web/framework/i18n/data/ku_arab_ir.php diff --git a/web/framework-1.1.17/i18n/data/ku_iq.php b/web/framework/i18n/data/ku_iq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_iq.php rename to web/framework/i18n/data/ku_iq.php diff --git a/web/framework-1.1.17/i18n/data/ku_ir.php b/web/framework/i18n/data/ku_ir.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_ir.php rename to web/framework/i18n/data/ku_ir.php diff --git a/web/framework-1.1.17/i18n/data/ku_latn.php b/web/framework/i18n/data/ku_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_latn.php rename to web/framework/i18n/data/ku_latn.php diff --git a/web/framework-1.1.17/i18n/data/ku_latn_sy.php b/web/framework/i18n/data/ku_latn_sy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_latn_sy.php rename to web/framework/i18n/data/ku_latn_sy.php diff --git a/web/framework-1.1.17/i18n/data/ku_latn_tr.php b/web/framework/i18n/data/ku_latn_tr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_latn_tr.php rename to web/framework/i18n/data/ku_latn_tr.php diff --git a/web/framework-1.1.17/i18n/data/ku_sy.php b/web/framework/i18n/data/ku_sy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_sy.php rename to web/framework/i18n/data/ku_sy.php diff --git a/web/framework-1.1.17/i18n/data/ku_tr.php b/web/framework/i18n/data/ku_tr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ku_tr.php rename to web/framework/i18n/data/ku_tr.php diff --git a/web/framework-1.1.17/i18n/data/kw.php b/web/framework/i18n/data/kw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kw.php rename to web/framework/i18n/data/kw.php diff --git a/web/framework-1.1.17/i18n/data/kw_gb.php b/web/framework/i18n/data/kw_gb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/kw_gb.php rename to web/framework/i18n/data/kw_gb.php diff --git a/web/framework-1.1.17/i18n/data/ky.php b/web/framework/i18n/data/ky.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ky.php rename to web/framework/i18n/data/ky.php diff --git a/web/framework-1.1.17/i18n/data/ky_kg.php b/web/framework/i18n/data/ky_kg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ky_kg.php rename to web/framework/i18n/data/ky_kg.php diff --git a/web/framework-1.1.17/i18n/data/lag.php b/web/framework/i18n/data/lag.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lag.php rename to web/framework/i18n/data/lag.php diff --git a/web/framework-1.1.17/i18n/data/lag_tz.php b/web/framework/i18n/data/lag_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lag_tz.php rename to web/framework/i18n/data/lag_tz.php diff --git a/web/framework-1.1.17/i18n/data/lg.php b/web/framework/i18n/data/lg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lg.php rename to web/framework/i18n/data/lg.php diff --git a/web/framework-1.1.17/i18n/data/lg_ug.php b/web/framework/i18n/data/lg_ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lg_ug.php rename to web/framework/i18n/data/lg_ug.php diff --git a/web/framework-1.1.17/i18n/data/ln.php b/web/framework/i18n/data/ln.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ln.php rename to web/framework/i18n/data/ln.php diff --git a/web/framework-1.1.17/i18n/data/ln_ao.php b/web/framework/i18n/data/ln_ao.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ln_ao.php rename to web/framework/i18n/data/ln_ao.php diff --git a/web/framework-1.1.17/i18n/data/ln_cd.php b/web/framework/i18n/data/ln_cd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ln_cd.php rename to web/framework/i18n/data/ln_cd.php diff --git a/web/framework-1.1.17/i18n/data/ln_cf.php b/web/framework/i18n/data/ln_cf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ln_cf.php rename to web/framework/i18n/data/ln_cf.php diff --git a/web/framework-1.1.17/i18n/data/ln_cg.php b/web/framework/i18n/data/ln_cg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ln_cg.php rename to web/framework/i18n/data/ln_cg.php diff --git a/web/framework-1.1.17/i18n/data/lo.php b/web/framework/i18n/data/lo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lo.php rename to web/framework/i18n/data/lo.php diff --git a/web/framework-1.1.17/i18n/data/lo_la.php b/web/framework/i18n/data/lo_la.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lo_la.php rename to web/framework/i18n/data/lo_la.php diff --git a/web/framework-1.1.17/i18n/data/lt.php b/web/framework/i18n/data/lt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lt.php rename to web/framework/i18n/data/lt.php diff --git a/web/framework-1.1.17/i18n/data/lt_lt.php b/web/framework/i18n/data/lt_lt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lt_lt.php rename to web/framework/i18n/data/lt_lt.php diff --git a/web/framework-1.1.17/i18n/data/lu.php b/web/framework/i18n/data/lu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lu.php rename to web/framework/i18n/data/lu.php diff --git a/web/framework-1.1.17/i18n/data/lu_cd.php b/web/framework/i18n/data/lu_cd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lu_cd.php rename to web/framework/i18n/data/lu_cd.php diff --git a/web/framework-1.1.17/i18n/data/luo.php b/web/framework/i18n/data/luo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/luo.php rename to web/framework/i18n/data/luo.php diff --git a/web/framework-1.1.17/i18n/data/luo_ke.php b/web/framework/i18n/data/luo_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/luo_ke.php rename to web/framework/i18n/data/luo_ke.php diff --git a/web/framework-1.1.17/i18n/data/luy.php b/web/framework/i18n/data/luy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/luy.php rename to web/framework/i18n/data/luy.php diff --git a/web/framework-1.1.17/i18n/data/luy_ke.php b/web/framework/i18n/data/luy_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/luy_ke.php rename to web/framework/i18n/data/luy_ke.php diff --git a/web/framework-1.1.17/i18n/data/lv.php b/web/framework/i18n/data/lv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lv.php rename to web/framework/i18n/data/lv.php diff --git a/web/framework-1.1.17/i18n/data/lv_lv.php b/web/framework/i18n/data/lv_lv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/lv_lv.php rename to web/framework/i18n/data/lv_lv.php diff --git a/web/framework-1.1.17/i18n/data/mas.php b/web/framework/i18n/data/mas.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mas.php rename to web/framework/i18n/data/mas.php diff --git a/web/framework-1.1.17/i18n/data/mas_ke.php b/web/framework/i18n/data/mas_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mas_ke.php rename to web/framework/i18n/data/mas_ke.php diff --git a/web/framework-1.1.17/i18n/data/mas_tz.php b/web/framework/i18n/data/mas_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mas_tz.php rename to web/framework/i18n/data/mas_tz.php diff --git a/web/framework-1.1.17/i18n/data/mer.php b/web/framework/i18n/data/mer.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mer.php rename to web/framework/i18n/data/mer.php diff --git a/web/framework-1.1.17/i18n/data/mer_ke.php b/web/framework/i18n/data/mer_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mer_ke.php rename to web/framework/i18n/data/mer_ke.php diff --git a/web/framework-1.1.17/i18n/data/mfe.php b/web/framework/i18n/data/mfe.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mfe.php rename to web/framework/i18n/data/mfe.php diff --git a/web/framework-1.1.17/i18n/data/mfe_mu.php b/web/framework/i18n/data/mfe_mu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mfe_mu.php rename to web/framework/i18n/data/mfe_mu.php diff --git a/web/framework-1.1.17/i18n/data/mg.php b/web/framework/i18n/data/mg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mg.php rename to web/framework/i18n/data/mg.php diff --git a/web/framework-1.1.17/i18n/data/mg_mg.php b/web/framework/i18n/data/mg_mg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mg_mg.php rename to web/framework/i18n/data/mg_mg.php diff --git a/web/framework-1.1.17/i18n/data/mgh.php b/web/framework/i18n/data/mgh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mgh.php rename to web/framework/i18n/data/mgh.php diff --git a/web/framework-1.1.17/i18n/data/mgh_mz.php b/web/framework/i18n/data/mgh_mz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mgh_mz.php rename to web/framework/i18n/data/mgh_mz.php diff --git a/web/framework-1.1.17/i18n/data/mgo.php b/web/framework/i18n/data/mgo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mgo.php rename to web/framework/i18n/data/mgo.php diff --git a/web/framework-1.1.17/i18n/data/mgo_cm.php b/web/framework/i18n/data/mgo_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mgo_cm.php rename to web/framework/i18n/data/mgo_cm.php diff --git a/web/framework-1.1.17/i18n/data/mi.php b/web/framework/i18n/data/mi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mi.php rename to web/framework/i18n/data/mi.php diff --git a/web/framework-1.1.17/i18n/data/mi_nz.php b/web/framework/i18n/data/mi_nz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mi_nz.php rename to web/framework/i18n/data/mi_nz.php diff --git a/web/framework-1.1.17/i18n/data/mk.php b/web/framework/i18n/data/mk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mk.php rename to web/framework/i18n/data/mk.php diff --git a/web/framework-1.1.17/i18n/data/mk_mk.php b/web/framework/i18n/data/mk_mk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mk_mk.php rename to web/framework/i18n/data/mk_mk.php diff --git a/web/framework-1.1.17/i18n/data/ml.php b/web/framework/i18n/data/ml.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ml.php rename to web/framework/i18n/data/ml.php diff --git a/web/framework-1.1.17/i18n/data/ml_in.php b/web/framework/i18n/data/ml_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ml_in.php rename to web/framework/i18n/data/ml_in.php diff --git a/web/framework-1.1.17/i18n/data/mn.php b/web/framework/i18n/data/mn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mn.php rename to web/framework/i18n/data/mn.php diff --git a/web/framework-1.1.17/i18n/data/mn_cn.php b/web/framework/i18n/data/mn_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mn_cn.php rename to web/framework/i18n/data/mn_cn.php diff --git a/web/framework-1.1.17/i18n/data/mn_cyrl.php b/web/framework/i18n/data/mn_cyrl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mn_cyrl.php rename to web/framework/i18n/data/mn_cyrl.php diff --git a/web/framework-1.1.17/i18n/data/mn_cyrl_mn.php b/web/framework/i18n/data/mn_cyrl_mn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mn_cyrl_mn.php rename to web/framework/i18n/data/mn_cyrl_mn.php diff --git a/web/framework-1.1.17/i18n/data/mn_mn.php b/web/framework/i18n/data/mn_mn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mn_mn.php rename to web/framework/i18n/data/mn_mn.php diff --git a/web/framework-1.1.17/i18n/data/mn_mong.php b/web/framework/i18n/data/mn_mong.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mn_mong.php rename to web/framework/i18n/data/mn_mong.php diff --git a/web/framework-1.1.17/i18n/data/mn_mong_cn.php b/web/framework/i18n/data/mn_mong_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mn_mong_cn.php rename to web/framework/i18n/data/mn_mong_cn.php diff --git a/web/framework-1.1.17/i18n/data/mo.php b/web/framework/i18n/data/mo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mo.php rename to web/framework/i18n/data/mo.php diff --git a/web/framework-1.1.17/i18n/data/mr.php b/web/framework/i18n/data/mr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mr.php rename to web/framework/i18n/data/mr.php diff --git a/web/framework-1.1.17/i18n/data/mr_in.php b/web/framework/i18n/data/mr_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mr_in.php rename to web/framework/i18n/data/mr_in.php diff --git a/web/framework-1.1.17/i18n/data/ms.php b/web/framework/i18n/data/ms.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ms.php rename to web/framework/i18n/data/ms.php diff --git a/web/framework-1.1.17/i18n/data/ms_bn.php b/web/framework/i18n/data/ms_bn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ms_bn.php rename to web/framework/i18n/data/ms_bn.php diff --git a/web/framework-1.1.17/i18n/data/ms_latn.php b/web/framework/i18n/data/ms_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ms_latn.php rename to web/framework/i18n/data/ms_latn.php diff --git a/web/framework-1.1.17/i18n/data/ms_latn_bn.php b/web/framework/i18n/data/ms_latn_bn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ms_latn_bn.php rename to web/framework/i18n/data/ms_latn_bn.php diff --git a/web/framework-1.1.17/i18n/data/ms_latn_my.php b/web/framework/i18n/data/ms_latn_my.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ms_latn_my.php rename to web/framework/i18n/data/ms_latn_my.php diff --git a/web/framework-1.1.17/i18n/data/ms_latn_sg.php b/web/framework/i18n/data/ms_latn_sg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ms_latn_sg.php rename to web/framework/i18n/data/ms_latn_sg.php diff --git a/web/framework-1.1.17/i18n/data/ms_my.php b/web/framework/i18n/data/ms_my.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ms_my.php rename to web/framework/i18n/data/ms_my.php diff --git a/web/framework-1.1.17/i18n/data/mt.php b/web/framework/i18n/data/mt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mt.php rename to web/framework/i18n/data/mt.php diff --git a/web/framework-1.1.17/i18n/data/mt_mt.php b/web/framework/i18n/data/mt_mt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mt_mt.php rename to web/framework/i18n/data/mt_mt.php diff --git a/web/framework-1.1.17/i18n/data/mua.php b/web/framework/i18n/data/mua.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mua.php rename to web/framework/i18n/data/mua.php diff --git a/web/framework-1.1.17/i18n/data/mua_cm.php b/web/framework/i18n/data/mua_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/mua_cm.php rename to web/framework/i18n/data/mua_cm.php diff --git a/web/framework-1.1.17/i18n/data/my.php b/web/framework/i18n/data/my.php similarity index 100% rename from web/framework-1.1.17/i18n/data/my.php rename to web/framework/i18n/data/my.php diff --git a/web/framework-1.1.17/i18n/data/my_mm.php b/web/framework/i18n/data/my_mm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/my_mm.php rename to web/framework/i18n/data/my_mm.php diff --git a/web/framework-1.1.17/i18n/data/naq.php b/web/framework/i18n/data/naq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/naq.php rename to web/framework/i18n/data/naq.php diff --git a/web/framework-1.1.17/i18n/data/naq_na.php b/web/framework/i18n/data/naq_na.php similarity index 100% rename from web/framework-1.1.17/i18n/data/naq_na.php rename to web/framework/i18n/data/naq_na.php diff --git a/web/framework-1.1.17/i18n/data/nb.php b/web/framework/i18n/data/nb.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nb.php rename to web/framework/i18n/data/nb.php diff --git a/web/framework-1.1.17/i18n/data/nb_no.php b/web/framework/i18n/data/nb_no.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nb_no.php rename to web/framework/i18n/data/nb_no.php diff --git a/web/framework-1.1.17/i18n/data/nd.php b/web/framework/i18n/data/nd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nd.php rename to web/framework/i18n/data/nd.php diff --git a/web/framework-1.1.17/i18n/data/nd_zw.php b/web/framework/i18n/data/nd_zw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nd_zw.php rename to web/framework/i18n/data/nd_zw.php diff --git a/web/framework-1.1.17/i18n/data/nds.php b/web/framework/i18n/data/nds.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nds.php rename to web/framework/i18n/data/nds.php diff --git a/web/framework-1.1.17/i18n/data/nds_de.php b/web/framework/i18n/data/nds_de.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nds_de.php rename to web/framework/i18n/data/nds_de.php diff --git a/web/framework-1.1.17/i18n/data/ne.php b/web/framework/i18n/data/ne.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ne.php rename to web/framework/i18n/data/ne.php diff --git a/web/framework-1.1.17/i18n/data/ne_in.php b/web/framework/i18n/data/ne_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ne_in.php rename to web/framework/i18n/data/ne_in.php diff --git a/web/framework-1.1.17/i18n/data/ne_np.php b/web/framework/i18n/data/ne_np.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ne_np.php rename to web/framework/i18n/data/ne_np.php diff --git a/web/framework-1.1.17/i18n/data/nl.php b/web/framework/i18n/data/nl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nl.php rename to web/framework/i18n/data/nl.php diff --git a/web/framework-1.1.17/i18n/data/nl_aw.php b/web/framework/i18n/data/nl_aw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nl_aw.php rename to web/framework/i18n/data/nl_aw.php diff --git a/web/framework-1.1.17/i18n/data/nl_be.php b/web/framework/i18n/data/nl_be.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nl_be.php rename to web/framework/i18n/data/nl_be.php diff --git a/web/framework-1.1.17/i18n/data/nl_cw.php b/web/framework/i18n/data/nl_cw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nl_cw.php rename to web/framework/i18n/data/nl_cw.php diff --git a/web/framework-1.1.17/i18n/data/nl_nl.php b/web/framework/i18n/data/nl_nl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nl_nl.php rename to web/framework/i18n/data/nl_nl.php diff --git a/web/framework-1.1.17/i18n/data/nl_sr.php b/web/framework/i18n/data/nl_sr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nl_sr.php rename to web/framework/i18n/data/nl_sr.php diff --git a/web/framework-1.1.17/i18n/data/nl_sx.php b/web/framework/i18n/data/nl_sx.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nl_sx.php rename to web/framework/i18n/data/nl_sx.php diff --git a/web/framework-1.1.17/i18n/data/nmg.php b/web/framework/i18n/data/nmg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nmg.php rename to web/framework/i18n/data/nmg.php diff --git a/web/framework-1.1.17/i18n/data/nmg_cm.php b/web/framework/i18n/data/nmg_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nmg_cm.php rename to web/framework/i18n/data/nmg_cm.php diff --git a/web/framework-1.1.17/i18n/data/nn.php b/web/framework/i18n/data/nn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nn.php rename to web/framework/i18n/data/nn.php diff --git a/web/framework-1.1.17/i18n/data/nn_no.php b/web/framework/i18n/data/nn_no.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nn_no.php rename to web/framework/i18n/data/nn_no.php diff --git a/web/framework-1.1.17/i18n/data/nnh.php b/web/framework/i18n/data/nnh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nnh.php rename to web/framework/i18n/data/nnh.php diff --git a/web/framework-1.1.17/i18n/data/nnh_cm.php b/web/framework/i18n/data/nnh_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nnh_cm.php rename to web/framework/i18n/data/nnh_cm.php diff --git a/web/framework-1.1.17/i18n/data/no.php b/web/framework/i18n/data/no.php similarity index 100% rename from web/framework-1.1.17/i18n/data/no.php rename to web/framework/i18n/data/no.php diff --git a/web/framework-1.1.17/i18n/data/nr.php b/web/framework/i18n/data/nr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nr.php rename to web/framework/i18n/data/nr.php diff --git a/web/framework-1.1.17/i18n/data/nr_za.php b/web/framework/i18n/data/nr_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nr_za.php rename to web/framework/i18n/data/nr_za.php diff --git a/web/framework-1.1.17/i18n/data/nso.php b/web/framework/i18n/data/nso.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nso.php rename to web/framework/i18n/data/nso.php diff --git a/web/framework-1.1.17/i18n/data/nso_za.php b/web/framework/i18n/data/nso_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nso_za.php rename to web/framework/i18n/data/nso_za.php diff --git a/web/framework-1.1.17/i18n/data/nus.php b/web/framework/i18n/data/nus.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nus.php rename to web/framework/i18n/data/nus.php diff --git a/web/framework-1.1.17/i18n/data/nus_sd.php b/web/framework/i18n/data/nus_sd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nus_sd.php rename to web/framework/i18n/data/nus_sd.php diff --git a/web/framework-1.1.17/i18n/data/ny.php b/web/framework/i18n/data/ny.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ny.php rename to web/framework/i18n/data/ny.php diff --git a/web/framework-1.1.17/i18n/data/ny_mw.php b/web/framework/i18n/data/ny_mw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ny_mw.php rename to web/framework/i18n/data/ny_mw.php diff --git a/web/framework-1.1.17/i18n/data/nyn.php b/web/framework/i18n/data/nyn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nyn.php rename to web/framework/i18n/data/nyn.php diff --git a/web/framework-1.1.17/i18n/data/nyn_ug.php b/web/framework/i18n/data/nyn_ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/nyn_ug.php rename to web/framework/i18n/data/nyn_ug.php diff --git a/web/framework-1.1.17/i18n/data/oc.php b/web/framework/i18n/data/oc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/oc.php rename to web/framework/i18n/data/oc.php diff --git a/web/framework-1.1.17/i18n/data/oc_fr.php b/web/framework/i18n/data/oc_fr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/oc_fr.php rename to web/framework/i18n/data/oc_fr.php diff --git a/web/framework-1.1.17/i18n/data/om.php b/web/framework/i18n/data/om.php similarity index 100% rename from web/framework-1.1.17/i18n/data/om.php rename to web/framework/i18n/data/om.php diff --git a/web/framework-1.1.17/i18n/data/om_et.php b/web/framework/i18n/data/om_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/om_et.php rename to web/framework/i18n/data/om_et.php diff --git a/web/framework-1.1.17/i18n/data/om_ke.php b/web/framework/i18n/data/om_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/om_ke.php rename to web/framework/i18n/data/om_ke.php diff --git a/web/framework-1.1.17/i18n/data/or.php b/web/framework/i18n/data/or.php similarity index 100% rename from web/framework-1.1.17/i18n/data/or.php rename to web/framework/i18n/data/or.php diff --git a/web/framework-1.1.17/i18n/data/or_in.php b/web/framework/i18n/data/or_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/or_in.php rename to web/framework/i18n/data/or_in.php diff --git a/web/framework-1.1.17/i18n/data/os.php b/web/framework/i18n/data/os.php similarity index 100% rename from web/framework-1.1.17/i18n/data/os.php rename to web/framework/i18n/data/os.php diff --git a/web/framework-1.1.17/i18n/data/os_ge.php b/web/framework/i18n/data/os_ge.php similarity index 100% rename from web/framework-1.1.17/i18n/data/os_ge.php rename to web/framework/i18n/data/os_ge.php diff --git a/web/framework-1.1.17/i18n/data/os_ru.php b/web/framework/i18n/data/os_ru.php similarity index 100% rename from web/framework-1.1.17/i18n/data/os_ru.php rename to web/framework/i18n/data/os_ru.php diff --git a/web/framework-1.1.17/i18n/data/pa.php b/web/framework/i18n/data/pa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pa.php rename to web/framework/i18n/data/pa.php diff --git a/web/framework-1.1.17/i18n/data/pa_arab.php b/web/framework/i18n/data/pa_arab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pa_arab.php rename to web/framework/i18n/data/pa_arab.php diff --git a/web/framework-1.1.17/i18n/data/pa_arab_pk.php b/web/framework/i18n/data/pa_arab_pk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pa_arab_pk.php rename to web/framework/i18n/data/pa_arab_pk.php diff --git a/web/framework-1.1.17/i18n/data/pa_guru.php b/web/framework/i18n/data/pa_guru.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pa_guru.php rename to web/framework/i18n/data/pa_guru.php diff --git a/web/framework-1.1.17/i18n/data/pa_guru_in.php b/web/framework/i18n/data/pa_guru_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pa_guru_in.php rename to web/framework/i18n/data/pa_guru_in.php diff --git a/web/framework-1.1.17/i18n/data/pa_in.php b/web/framework/i18n/data/pa_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pa_in.php rename to web/framework/i18n/data/pa_in.php diff --git a/web/framework-1.1.17/i18n/data/pa_pk.php b/web/framework/i18n/data/pa_pk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pa_pk.php rename to web/framework/i18n/data/pa_pk.php diff --git a/web/framework-1.1.17/i18n/data/pl.php b/web/framework/i18n/data/pl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pl.php rename to web/framework/i18n/data/pl.php diff --git a/web/framework-1.1.17/i18n/data/pl_pl.php b/web/framework/i18n/data/pl_pl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pl_pl.php rename to web/framework/i18n/data/pl_pl.php diff --git a/web/framework-1.1.17/i18n/data/ps.php b/web/framework/i18n/data/ps.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ps.php rename to web/framework/i18n/data/ps.php diff --git a/web/framework-1.1.17/i18n/data/ps_af.php b/web/framework/i18n/data/ps_af.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ps_af.php rename to web/framework/i18n/data/ps_af.php diff --git a/web/framework-1.1.17/i18n/data/pt.php b/web/framework/i18n/data/pt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt.php rename to web/framework/i18n/data/pt.php diff --git a/web/framework-1.1.17/i18n/data/pt_ao.php b/web/framework/i18n/data/pt_ao.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_ao.php rename to web/framework/i18n/data/pt_ao.php diff --git a/web/framework-1.1.17/i18n/data/pt_br.php b/web/framework/i18n/data/pt_br.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_br.php rename to web/framework/i18n/data/pt_br.php diff --git a/web/framework-1.1.17/i18n/data/pt_cv.php b/web/framework/i18n/data/pt_cv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_cv.php rename to web/framework/i18n/data/pt_cv.php diff --git a/web/framework-1.1.17/i18n/data/pt_gw.php b/web/framework/i18n/data/pt_gw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_gw.php rename to web/framework/i18n/data/pt_gw.php diff --git a/web/framework-1.1.17/i18n/data/pt_mo.php b/web/framework/i18n/data/pt_mo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_mo.php rename to web/framework/i18n/data/pt_mo.php diff --git a/web/framework-1.1.17/i18n/data/pt_mz.php b/web/framework/i18n/data/pt_mz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_mz.php rename to web/framework/i18n/data/pt_mz.php diff --git a/web/framework-1.1.17/i18n/data/pt_pt.php b/web/framework/i18n/data/pt_pt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_pt.php rename to web/framework/i18n/data/pt_pt.php diff --git a/web/framework-1.1.17/i18n/data/pt_st.php b/web/framework/i18n/data/pt_st.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_st.php rename to web/framework/i18n/data/pt_st.php diff --git a/web/framework-1.1.17/i18n/data/pt_tl.php b/web/framework/i18n/data/pt_tl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/pt_tl.php rename to web/framework/i18n/data/pt_tl.php diff --git a/web/framework-1.1.17/i18n/data/rm.php b/web/framework/i18n/data/rm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rm.php rename to web/framework/i18n/data/rm.php diff --git a/web/framework-1.1.17/i18n/data/rm_ch.php b/web/framework/i18n/data/rm_ch.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rm_ch.php rename to web/framework/i18n/data/rm_ch.php diff --git a/web/framework-1.1.17/i18n/data/rn.php b/web/framework/i18n/data/rn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rn.php rename to web/framework/i18n/data/rn.php diff --git a/web/framework-1.1.17/i18n/data/rn_bi.php b/web/framework/i18n/data/rn_bi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rn_bi.php rename to web/framework/i18n/data/rn_bi.php diff --git a/web/framework-1.1.17/i18n/data/ro.php b/web/framework/i18n/data/ro.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ro.php rename to web/framework/i18n/data/ro.php diff --git a/web/framework-1.1.17/i18n/data/ro_md.php b/web/framework/i18n/data/ro_md.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ro_md.php rename to web/framework/i18n/data/ro_md.php diff --git a/web/framework-1.1.17/i18n/data/ro_ro.php b/web/framework/i18n/data/ro_ro.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ro_ro.php rename to web/framework/i18n/data/ro_ro.php diff --git a/web/framework-1.1.17/i18n/data/rof.php b/web/framework/i18n/data/rof.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rof.php rename to web/framework/i18n/data/rof.php diff --git a/web/framework-1.1.17/i18n/data/rof_tz.php b/web/framework/i18n/data/rof_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rof_tz.php rename to web/framework/i18n/data/rof_tz.php diff --git a/web/framework-1.1.17/i18n/data/root.php b/web/framework/i18n/data/root.php similarity index 100% rename from web/framework-1.1.17/i18n/data/root.php rename to web/framework/i18n/data/root.php diff --git a/web/framework-1.1.17/i18n/data/ru.php b/web/framework/i18n/data/ru.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ru.php rename to web/framework/i18n/data/ru.php diff --git a/web/framework-1.1.17/i18n/data/ru_by.php b/web/framework/i18n/data/ru_by.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ru_by.php rename to web/framework/i18n/data/ru_by.php diff --git a/web/framework-1.1.17/i18n/data/ru_kg.php b/web/framework/i18n/data/ru_kg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ru_kg.php rename to web/framework/i18n/data/ru_kg.php diff --git a/web/framework-1.1.17/i18n/data/ru_kz.php b/web/framework/i18n/data/ru_kz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ru_kz.php rename to web/framework/i18n/data/ru_kz.php diff --git a/web/framework-1.1.17/i18n/data/ru_md.php b/web/framework/i18n/data/ru_md.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ru_md.php rename to web/framework/i18n/data/ru_md.php diff --git a/web/framework-1.1.17/i18n/data/ru_ru.php b/web/framework/i18n/data/ru_ru.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ru_ru.php rename to web/framework/i18n/data/ru_ru.php diff --git a/web/framework-1.1.17/i18n/data/ru_ua.php b/web/framework/i18n/data/ru_ua.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ru_ua.php rename to web/framework/i18n/data/ru_ua.php diff --git a/web/framework-1.1.17/i18n/data/rw.php b/web/framework/i18n/data/rw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rw.php rename to web/framework/i18n/data/rw.php diff --git a/web/framework-1.1.17/i18n/data/rw_rw.php b/web/framework/i18n/data/rw_rw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rw_rw.php rename to web/framework/i18n/data/rw_rw.php diff --git a/web/framework-1.1.17/i18n/data/rwk.php b/web/framework/i18n/data/rwk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rwk.php rename to web/framework/i18n/data/rwk.php diff --git a/web/framework-1.1.17/i18n/data/rwk_tz.php b/web/framework/i18n/data/rwk_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/rwk_tz.php rename to web/framework/i18n/data/rwk_tz.php diff --git a/web/framework-1.1.17/i18n/data/sa.php b/web/framework/i18n/data/sa.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sa.php rename to web/framework/i18n/data/sa.php diff --git a/web/framework-1.1.17/i18n/data/sa_in.php b/web/framework/i18n/data/sa_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sa_in.php rename to web/framework/i18n/data/sa_in.php diff --git a/web/framework-1.1.17/i18n/data/sah.php b/web/framework/i18n/data/sah.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sah.php rename to web/framework/i18n/data/sah.php diff --git a/web/framework-1.1.17/i18n/data/sah_ru.php b/web/framework/i18n/data/sah_ru.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sah_ru.php rename to web/framework/i18n/data/sah_ru.php diff --git a/web/framework-1.1.17/i18n/data/saq.php b/web/framework/i18n/data/saq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/saq.php rename to web/framework/i18n/data/saq.php diff --git a/web/framework-1.1.17/i18n/data/saq_ke.php b/web/framework/i18n/data/saq_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/saq_ke.php rename to web/framework/i18n/data/saq_ke.php diff --git a/web/framework-1.1.17/i18n/data/sbp.php b/web/framework/i18n/data/sbp.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sbp.php rename to web/framework/i18n/data/sbp.php diff --git a/web/framework-1.1.17/i18n/data/sbp_tz.php b/web/framework/i18n/data/sbp_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sbp_tz.php rename to web/framework/i18n/data/sbp_tz.php diff --git a/web/framework-1.1.17/i18n/data/se.php b/web/framework/i18n/data/se.php similarity index 100% rename from web/framework-1.1.17/i18n/data/se.php rename to web/framework/i18n/data/se.php diff --git a/web/framework-1.1.17/i18n/data/se_fi.php b/web/framework/i18n/data/se_fi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/se_fi.php rename to web/framework/i18n/data/se_fi.php diff --git a/web/framework-1.1.17/i18n/data/se_no.php b/web/framework/i18n/data/se_no.php similarity index 100% rename from web/framework-1.1.17/i18n/data/se_no.php rename to web/framework/i18n/data/se_no.php diff --git a/web/framework-1.1.17/i18n/data/seh.php b/web/framework/i18n/data/seh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/seh.php rename to web/framework/i18n/data/seh.php diff --git a/web/framework-1.1.17/i18n/data/seh_mz.php b/web/framework/i18n/data/seh_mz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/seh_mz.php rename to web/framework/i18n/data/seh_mz.php diff --git a/web/framework-1.1.17/i18n/data/ses.php b/web/framework/i18n/data/ses.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ses.php rename to web/framework/i18n/data/ses.php diff --git a/web/framework-1.1.17/i18n/data/ses_ml.php b/web/framework/i18n/data/ses_ml.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ses_ml.php rename to web/framework/i18n/data/ses_ml.php diff --git a/web/framework-1.1.17/i18n/data/sg.php b/web/framework/i18n/data/sg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sg.php rename to web/framework/i18n/data/sg.php diff --git a/web/framework-1.1.17/i18n/data/sg_cf.php b/web/framework/i18n/data/sg_cf.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sg_cf.php rename to web/framework/i18n/data/sg_cf.php diff --git a/web/framework-1.1.17/i18n/data/sh.php b/web/framework/i18n/data/sh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sh.php rename to web/framework/i18n/data/sh.php diff --git a/web/framework-1.1.17/i18n/data/sh_ba.php b/web/framework/i18n/data/sh_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sh_ba.php rename to web/framework/i18n/data/sh_ba.php diff --git a/web/framework-1.1.17/i18n/data/sh_cs.php b/web/framework/i18n/data/sh_cs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sh_cs.php rename to web/framework/i18n/data/sh_cs.php diff --git a/web/framework-1.1.17/i18n/data/sh_yu.php b/web/framework/i18n/data/sh_yu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sh_yu.php rename to web/framework/i18n/data/sh_yu.php diff --git a/web/framework-1.1.17/i18n/data/shi.php b/web/framework/i18n/data/shi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/shi.php rename to web/framework/i18n/data/shi.php diff --git a/web/framework-1.1.17/i18n/data/shi_latn.php b/web/framework/i18n/data/shi_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/shi_latn.php rename to web/framework/i18n/data/shi_latn.php diff --git a/web/framework-1.1.17/i18n/data/shi_latn_ma.php b/web/framework/i18n/data/shi_latn_ma.php similarity index 100% rename from web/framework-1.1.17/i18n/data/shi_latn_ma.php rename to web/framework/i18n/data/shi_latn_ma.php diff --git a/web/framework-1.1.17/i18n/data/shi_ma.php b/web/framework/i18n/data/shi_ma.php similarity index 100% rename from web/framework-1.1.17/i18n/data/shi_ma.php rename to web/framework/i18n/data/shi_ma.php diff --git a/web/framework-1.1.17/i18n/data/shi_tfng.php b/web/framework/i18n/data/shi_tfng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/shi_tfng.php rename to web/framework/i18n/data/shi_tfng.php diff --git a/web/framework-1.1.17/i18n/data/shi_tfng_ma.php b/web/framework/i18n/data/shi_tfng_ma.php similarity index 100% rename from web/framework-1.1.17/i18n/data/shi_tfng_ma.php rename to web/framework/i18n/data/shi_tfng_ma.php diff --git a/web/framework-1.1.17/i18n/data/si.php b/web/framework/i18n/data/si.php similarity index 100% rename from web/framework-1.1.17/i18n/data/si.php rename to web/framework/i18n/data/si.php diff --git a/web/framework-1.1.17/i18n/data/si_lk.php b/web/framework/i18n/data/si_lk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/si_lk.php rename to web/framework/i18n/data/si_lk.php diff --git a/web/framework-1.1.17/i18n/data/sid.php b/web/framework/i18n/data/sid.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sid.php rename to web/framework/i18n/data/sid.php diff --git a/web/framework-1.1.17/i18n/data/sid_et.php b/web/framework/i18n/data/sid_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sid_et.php rename to web/framework/i18n/data/sid_et.php diff --git a/web/framework-1.1.17/i18n/data/sk.php b/web/framework/i18n/data/sk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sk.php rename to web/framework/i18n/data/sk.php diff --git a/web/framework-1.1.17/i18n/data/sk_sk.php b/web/framework/i18n/data/sk_sk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sk_sk.php rename to web/framework/i18n/data/sk_sk.php diff --git a/web/framework-1.1.17/i18n/data/sl.php b/web/framework/i18n/data/sl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sl.php rename to web/framework/i18n/data/sl.php diff --git a/web/framework-1.1.17/i18n/data/sl_si.php b/web/framework/i18n/data/sl_si.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sl_si.php rename to web/framework/i18n/data/sl_si.php diff --git a/web/framework-1.1.17/i18n/data/sn.php b/web/framework/i18n/data/sn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sn.php rename to web/framework/i18n/data/sn.php diff --git a/web/framework-1.1.17/i18n/data/sn_zw.php b/web/framework/i18n/data/sn_zw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sn_zw.php rename to web/framework/i18n/data/sn_zw.php diff --git a/web/framework-1.1.17/i18n/data/so.php b/web/framework/i18n/data/so.php similarity index 100% rename from web/framework-1.1.17/i18n/data/so.php rename to web/framework/i18n/data/so.php diff --git a/web/framework-1.1.17/i18n/data/so_dj.php b/web/framework/i18n/data/so_dj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/so_dj.php rename to web/framework/i18n/data/so_dj.php diff --git a/web/framework-1.1.17/i18n/data/so_et.php b/web/framework/i18n/data/so_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/so_et.php rename to web/framework/i18n/data/so_et.php diff --git a/web/framework-1.1.17/i18n/data/so_ke.php b/web/framework/i18n/data/so_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/so_ke.php rename to web/framework/i18n/data/so_ke.php diff --git a/web/framework-1.1.17/i18n/data/so_so.php b/web/framework/i18n/data/so_so.php similarity index 100% rename from web/framework-1.1.17/i18n/data/so_so.php rename to web/framework/i18n/data/so_so.php diff --git a/web/framework-1.1.17/i18n/data/sq.php b/web/framework/i18n/data/sq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sq.php rename to web/framework/i18n/data/sq.php diff --git a/web/framework-1.1.17/i18n/data/sq_al.php b/web/framework/i18n/data/sq_al.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sq_al.php rename to web/framework/i18n/data/sq_al.php diff --git a/web/framework-1.1.17/i18n/data/sq_mk.php b/web/framework/i18n/data/sq_mk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sq_mk.php rename to web/framework/i18n/data/sq_mk.php diff --git a/web/framework-1.1.17/i18n/data/sq_xk.php b/web/framework/i18n/data/sq_xk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sq_xk.php rename to web/framework/i18n/data/sq_xk.php diff --git a/web/framework-1.1.17/i18n/data/sr.php b/web/framework/i18n/data/sr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr.php rename to web/framework/i18n/data/sr.php diff --git a/web/framework-1.1.17/i18n/data/sr_ba.php b/web/framework/i18n/data/sr_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_ba.php rename to web/framework/i18n/data/sr_ba.php diff --git a/web/framework-1.1.17/i18n/data/sr_cs.php b/web/framework/i18n/data/sr_cs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cs.php rename to web/framework/i18n/data/sr_cs.php diff --git a/web/framework-1.1.17/i18n/data/sr_cyrl.php b/web/framework/i18n/data/sr_cyrl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cyrl.php rename to web/framework/i18n/data/sr_cyrl.php diff --git a/web/framework-1.1.17/i18n/data/sr_cyrl_ba.php b/web/framework/i18n/data/sr_cyrl_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cyrl_ba.php rename to web/framework/i18n/data/sr_cyrl_ba.php diff --git a/web/framework-1.1.17/i18n/data/sr_cyrl_cs.php b/web/framework/i18n/data/sr_cyrl_cs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cyrl_cs.php rename to web/framework/i18n/data/sr_cyrl_cs.php diff --git a/web/framework-1.1.17/i18n/data/sr_cyrl_me.php b/web/framework/i18n/data/sr_cyrl_me.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cyrl_me.php rename to web/framework/i18n/data/sr_cyrl_me.php diff --git a/web/framework-1.1.17/i18n/data/sr_cyrl_rs.php b/web/framework/i18n/data/sr_cyrl_rs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cyrl_rs.php rename to web/framework/i18n/data/sr_cyrl_rs.php diff --git a/web/framework-1.1.17/i18n/data/sr_cyrl_xk.php b/web/framework/i18n/data/sr_cyrl_xk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cyrl_xk.php rename to web/framework/i18n/data/sr_cyrl_xk.php diff --git a/web/framework-1.1.17/i18n/data/sr_cyrl_yu.php b/web/framework/i18n/data/sr_cyrl_yu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_cyrl_yu.php rename to web/framework/i18n/data/sr_cyrl_yu.php diff --git a/web/framework-1.1.17/i18n/data/sr_latn.php b/web/framework/i18n/data/sr_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_latn.php rename to web/framework/i18n/data/sr_latn.php diff --git a/web/framework-1.1.17/i18n/data/sr_latn_ba.php b/web/framework/i18n/data/sr_latn_ba.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_latn_ba.php rename to web/framework/i18n/data/sr_latn_ba.php diff --git a/web/framework-1.1.17/i18n/data/sr_latn_cs.php b/web/framework/i18n/data/sr_latn_cs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_latn_cs.php rename to web/framework/i18n/data/sr_latn_cs.php diff --git a/web/framework-1.1.17/i18n/data/sr_latn_me.php b/web/framework/i18n/data/sr_latn_me.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_latn_me.php rename to web/framework/i18n/data/sr_latn_me.php diff --git a/web/framework-1.1.17/i18n/data/sr_latn_rs.php b/web/framework/i18n/data/sr_latn_rs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_latn_rs.php rename to web/framework/i18n/data/sr_latn_rs.php diff --git a/web/framework-1.1.17/i18n/data/sr_latn_xk.php b/web/framework/i18n/data/sr_latn_xk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_latn_xk.php rename to web/framework/i18n/data/sr_latn_xk.php diff --git a/web/framework-1.1.17/i18n/data/sr_latn_yu.php b/web/framework/i18n/data/sr_latn_yu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_latn_yu.php rename to web/framework/i18n/data/sr_latn_yu.php diff --git a/web/framework-1.1.17/i18n/data/sr_me.php b/web/framework/i18n/data/sr_me.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_me.php rename to web/framework/i18n/data/sr_me.php diff --git a/web/framework-1.1.17/i18n/data/sr_rs.php b/web/framework/i18n/data/sr_rs.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_rs.php rename to web/framework/i18n/data/sr_rs.php diff --git a/web/framework-1.1.17/i18n/data/sr_yu.php b/web/framework/i18n/data/sr_yu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sr_yu.php rename to web/framework/i18n/data/sr_yu.php diff --git a/web/framework-1.1.17/i18n/data/ss.php b/web/framework/i18n/data/ss.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ss.php rename to web/framework/i18n/data/ss.php diff --git a/web/framework-1.1.17/i18n/data/ss_sz.php b/web/framework/i18n/data/ss_sz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ss_sz.php rename to web/framework/i18n/data/ss_sz.php diff --git a/web/framework-1.1.17/i18n/data/ss_za.php b/web/framework/i18n/data/ss_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ss_za.php rename to web/framework/i18n/data/ss_za.php diff --git a/web/framework-1.1.17/i18n/data/ssy.php b/web/framework/i18n/data/ssy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ssy.php rename to web/framework/i18n/data/ssy.php diff --git a/web/framework-1.1.17/i18n/data/ssy_er.php b/web/framework/i18n/data/ssy_er.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ssy_er.php rename to web/framework/i18n/data/ssy_er.php diff --git a/web/framework-1.1.17/i18n/data/st.php b/web/framework/i18n/data/st.php similarity index 100% rename from web/framework-1.1.17/i18n/data/st.php rename to web/framework/i18n/data/st.php diff --git a/web/framework-1.1.17/i18n/data/st_ls.php b/web/framework/i18n/data/st_ls.php similarity index 100% rename from web/framework-1.1.17/i18n/data/st_ls.php rename to web/framework/i18n/data/st_ls.php diff --git a/web/framework-1.1.17/i18n/data/st_za.php b/web/framework/i18n/data/st_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/st_za.php rename to web/framework/i18n/data/st_za.php diff --git a/web/framework-1.1.17/i18n/data/sv.php b/web/framework/i18n/data/sv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sv.php rename to web/framework/i18n/data/sv.php diff --git a/web/framework-1.1.17/i18n/data/sv_ax.php b/web/framework/i18n/data/sv_ax.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sv_ax.php rename to web/framework/i18n/data/sv_ax.php diff --git a/web/framework-1.1.17/i18n/data/sv_fi.php b/web/framework/i18n/data/sv_fi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sv_fi.php rename to web/framework/i18n/data/sv_fi.php diff --git a/web/framework-1.1.17/i18n/data/sv_se.php b/web/framework/i18n/data/sv_se.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sv_se.php rename to web/framework/i18n/data/sv_se.php diff --git a/web/framework-1.1.17/i18n/data/sw.php b/web/framework/i18n/data/sw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sw.php rename to web/framework/i18n/data/sw.php diff --git a/web/framework-1.1.17/i18n/data/sw_ke.php b/web/framework/i18n/data/sw_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sw_ke.php rename to web/framework/i18n/data/sw_ke.php diff --git a/web/framework-1.1.17/i18n/data/sw_tz.php b/web/framework/i18n/data/sw_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sw_tz.php rename to web/framework/i18n/data/sw_tz.php diff --git a/web/framework-1.1.17/i18n/data/sw_ug.php b/web/framework/i18n/data/sw_ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/sw_ug.php rename to web/framework/i18n/data/sw_ug.php diff --git a/web/framework-1.1.17/i18n/data/swc.php b/web/framework/i18n/data/swc.php similarity index 100% rename from web/framework-1.1.17/i18n/data/swc.php rename to web/framework/i18n/data/swc.php diff --git a/web/framework-1.1.17/i18n/data/swc_cd.php b/web/framework/i18n/data/swc_cd.php similarity index 100% rename from web/framework-1.1.17/i18n/data/swc_cd.php rename to web/framework/i18n/data/swc_cd.php diff --git a/web/framework-1.1.17/i18n/data/syr.php b/web/framework/i18n/data/syr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/syr.php rename to web/framework/i18n/data/syr.php diff --git a/web/framework-1.1.17/i18n/data/syr_sy.php b/web/framework/i18n/data/syr_sy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/syr_sy.php rename to web/framework/i18n/data/syr_sy.php diff --git a/web/framework-1.1.17/i18n/data/ta.php b/web/framework/i18n/data/ta.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ta.php rename to web/framework/i18n/data/ta.php diff --git a/web/framework-1.1.17/i18n/data/ta_in.php b/web/framework/i18n/data/ta_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ta_in.php rename to web/framework/i18n/data/ta_in.php diff --git a/web/framework-1.1.17/i18n/data/ta_lk.php b/web/framework/i18n/data/ta_lk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ta_lk.php rename to web/framework/i18n/data/ta_lk.php diff --git a/web/framework-1.1.17/i18n/data/ta_my.php b/web/framework/i18n/data/ta_my.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ta_my.php rename to web/framework/i18n/data/ta_my.php diff --git a/web/framework-1.1.17/i18n/data/ta_sg.php b/web/framework/i18n/data/ta_sg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ta_sg.php rename to web/framework/i18n/data/ta_sg.php diff --git a/web/framework-1.1.17/i18n/data/te.php b/web/framework/i18n/data/te.php similarity index 100% rename from web/framework-1.1.17/i18n/data/te.php rename to web/framework/i18n/data/te.php diff --git a/web/framework-1.1.17/i18n/data/te_in.php b/web/framework/i18n/data/te_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/te_in.php rename to web/framework/i18n/data/te_in.php diff --git a/web/framework-1.1.17/i18n/data/teo.php b/web/framework/i18n/data/teo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/teo.php rename to web/framework/i18n/data/teo.php diff --git a/web/framework-1.1.17/i18n/data/teo_ke.php b/web/framework/i18n/data/teo_ke.php similarity index 100% rename from web/framework-1.1.17/i18n/data/teo_ke.php rename to web/framework/i18n/data/teo_ke.php diff --git a/web/framework-1.1.17/i18n/data/teo_ug.php b/web/framework/i18n/data/teo_ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/teo_ug.php rename to web/framework/i18n/data/teo_ug.php diff --git a/web/framework-1.1.17/i18n/data/tg.php b/web/framework/i18n/data/tg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tg.php rename to web/framework/i18n/data/tg.php diff --git a/web/framework-1.1.17/i18n/data/tg_cyrl.php b/web/framework/i18n/data/tg_cyrl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tg_cyrl.php rename to web/framework/i18n/data/tg_cyrl.php diff --git a/web/framework-1.1.17/i18n/data/tg_cyrl_tj.php b/web/framework/i18n/data/tg_cyrl_tj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tg_cyrl_tj.php rename to web/framework/i18n/data/tg_cyrl_tj.php diff --git a/web/framework-1.1.17/i18n/data/tg_tj.php b/web/framework/i18n/data/tg_tj.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tg_tj.php rename to web/framework/i18n/data/tg_tj.php diff --git a/web/framework-1.1.17/i18n/data/th.php b/web/framework/i18n/data/th.php similarity index 100% rename from web/framework-1.1.17/i18n/data/th.php rename to web/framework/i18n/data/th.php diff --git a/web/framework-1.1.17/i18n/data/th_th.php b/web/framework/i18n/data/th_th.php similarity index 100% rename from web/framework-1.1.17/i18n/data/th_th.php rename to web/framework/i18n/data/th_th.php diff --git a/web/framework-1.1.17/i18n/data/ti.php b/web/framework/i18n/data/ti.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ti.php rename to web/framework/i18n/data/ti.php diff --git a/web/framework-1.1.17/i18n/data/ti_er.php b/web/framework/i18n/data/ti_er.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ti_er.php rename to web/framework/i18n/data/ti_er.php diff --git a/web/framework-1.1.17/i18n/data/ti_et.php b/web/framework/i18n/data/ti_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ti_et.php rename to web/framework/i18n/data/ti_et.php diff --git a/web/framework-1.1.17/i18n/data/tig.php b/web/framework/i18n/data/tig.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tig.php rename to web/framework/i18n/data/tig.php diff --git a/web/framework-1.1.17/i18n/data/tig_er.php b/web/framework/i18n/data/tig_er.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tig_er.php rename to web/framework/i18n/data/tig_er.php diff --git a/web/framework-1.1.17/i18n/data/tl.php b/web/framework/i18n/data/tl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tl.php rename to web/framework/i18n/data/tl.php diff --git a/web/framework-1.1.17/i18n/data/tl_ph.php b/web/framework/i18n/data/tl_ph.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tl_ph.php rename to web/framework/i18n/data/tl_ph.php diff --git a/web/framework-1.1.17/i18n/data/tn.php b/web/framework/i18n/data/tn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tn.php rename to web/framework/i18n/data/tn.php diff --git a/web/framework-1.1.17/i18n/data/tn_bw.php b/web/framework/i18n/data/tn_bw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tn_bw.php rename to web/framework/i18n/data/tn_bw.php diff --git a/web/framework-1.1.17/i18n/data/tn_za.php b/web/framework/i18n/data/tn_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tn_za.php rename to web/framework/i18n/data/tn_za.php diff --git a/web/framework-1.1.17/i18n/data/to.php b/web/framework/i18n/data/to.php similarity index 100% rename from web/framework-1.1.17/i18n/data/to.php rename to web/framework/i18n/data/to.php diff --git a/web/framework-1.1.17/i18n/data/to_to.php b/web/framework/i18n/data/to_to.php similarity index 100% rename from web/framework-1.1.17/i18n/data/to_to.php rename to web/framework/i18n/data/to_to.php diff --git a/web/framework-1.1.17/i18n/data/tr.php b/web/framework/i18n/data/tr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tr.php rename to web/framework/i18n/data/tr.php diff --git a/web/framework-1.1.17/i18n/data/tr_cy.php b/web/framework/i18n/data/tr_cy.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tr_cy.php rename to web/framework/i18n/data/tr_cy.php diff --git a/web/framework-1.1.17/i18n/data/tr_tr.php b/web/framework/i18n/data/tr_tr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tr_tr.php rename to web/framework/i18n/data/tr_tr.php diff --git a/web/framework-1.1.17/i18n/data/trv.php b/web/framework/i18n/data/trv.php similarity index 100% rename from web/framework-1.1.17/i18n/data/trv.php rename to web/framework/i18n/data/trv.php diff --git a/web/framework-1.1.17/i18n/data/trv_tw.php b/web/framework/i18n/data/trv_tw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/trv_tw.php rename to web/framework/i18n/data/trv_tw.php diff --git a/web/framework-1.1.17/i18n/data/ts.php b/web/framework/i18n/data/ts.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ts.php rename to web/framework/i18n/data/ts.php diff --git a/web/framework-1.1.17/i18n/data/ts_za.php b/web/framework/i18n/data/ts_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ts_za.php rename to web/framework/i18n/data/ts_za.php diff --git a/web/framework-1.1.17/i18n/data/tt.php b/web/framework/i18n/data/tt.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tt.php rename to web/framework/i18n/data/tt.php diff --git a/web/framework-1.1.17/i18n/data/tt_ru.php b/web/framework/i18n/data/tt_ru.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tt_ru.php rename to web/framework/i18n/data/tt_ru.php diff --git a/web/framework-1.1.17/i18n/data/twq.php b/web/framework/i18n/data/twq.php similarity index 100% rename from web/framework-1.1.17/i18n/data/twq.php rename to web/framework/i18n/data/twq.php diff --git a/web/framework-1.1.17/i18n/data/twq_ne.php b/web/framework/i18n/data/twq_ne.php similarity index 100% rename from web/framework-1.1.17/i18n/data/twq_ne.php rename to web/framework/i18n/data/twq_ne.php diff --git a/web/framework-1.1.17/i18n/data/tzm.php b/web/framework/i18n/data/tzm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tzm.php rename to web/framework/i18n/data/tzm.php diff --git a/web/framework-1.1.17/i18n/data/tzm_latn.php b/web/framework/i18n/data/tzm_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tzm_latn.php rename to web/framework/i18n/data/tzm_latn.php diff --git a/web/framework-1.1.17/i18n/data/tzm_latn_ma.php b/web/framework/i18n/data/tzm_latn_ma.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tzm_latn_ma.php rename to web/framework/i18n/data/tzm_latn_ma.php diff --git a/web/framework-1.1.17/i18n/data/tzm_ma.php b/web/framework/i18n/data/tzm_ma.php similarity index 100% rename from web/framework-1.1.17/i18n/data/tzm_ma.php rename to web/framework/i18n/data/tzm_ma.php diff --git a/web/framework-1.1.17/i18n/data/ug.php b/web/framework/i18n/data/ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ug.php rename to web/framework/i18n/data/ug.php diff --git a/web/framework-1.1.17/i18n/data/ug_arab.php b/web/framework/i18n/data/ug_arab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ug_arab.php rename to web/framework/i18n/data/ug_arab.php diff --git a/web/framework-1.1.17/i18n/data/ug_arab_cn.php b/web/framework/i18n/data/ug_arab_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ug_arab_cn.php rename to web/framework/i18n/data/ug_arab_cn.php diff --git a/web/framework-1.1.17/i18n/data/ug_cn.php b/web/framework/i18n/data/ug_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ug_cn.php rename to web/framework/i18n/data/ug_cn.php diff --git a/web/framework-1.1.17/i18n/data/uk.php b/web/framework/i18n/data/uk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uk.php rename to web/framework/i18n/data/uk.php diff --git a/web/framework-1.1.17/i18n/data/uk_ua.php b/web/framework/i18n/data/uk_ua.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uk_ua.php rename to web/framework/i18n/data/uk_ua.php diff --git a/web/framework-1.1.17/i18n/data/ur.php b/web/framework/i18n/data/ur.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ur.php rename to web/framework/i18n/data/ur.php diff --git a/web/framework-1.1.17/i18n/data/ur_in.php b/web/framework/i18n/data/ur_in.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ur_in.php rename to web/framework/i18n/data/ur_in.php diff --git a/web/framework-1.1.17/i18n/data/ur_pk.php b/web/framework/i18n/data/ur_pk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ur_pk.php rename to web/framework/i18n/data/ur_pk.php diff --git a/web/framework-1.1.17/i18n/data/uz.php b/web/framework/i18n/data/uz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz.php rename to web/framework/i18n/data/uz.php diff --git a/web/framework-1.1.17/i18n/data/uz_af.php b/web/framework/i18n/data/uz_af.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_af.php rename to web/framework/i18n/data/uz_af.php diff --git a/web/framework-1.1.17/i18n/data/uz_arab.php b/web/framework/i18n/data/uz_arab.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_arab.php rename to web/framework/i18n/data/uz_arab.php diff --git a/web/framework-1.1.17/i18n/data/uz_arab_af.php b/web/framework/i18n/data/uz_arab_af.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_arab_af.php rename to web/framework/i18n/data/uz_arab_af.php diff --git a/web/framework-1.1.17/i18n/data/uz_cyrl.php b/web/framework/i18n/data/uz_cyrl.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_cyrl.php rename to web/framework/i18n/data/uz_cyrl.php diff --git a/web/framework-1.1.17/i18n/data/uz_cyrl_uz.php b/web/framework/i18n/data/uz_cyrl_uz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_cyrl_uz.php rename to web/framework/i18n/data/uz_cyrl_uz.php diff --git a/web/framework-1.1.17/i18n/data/uz_latn.php b/web/framework/i18n/data/uz_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_latn.php rename to web/framework/i18n/data/uz_latn.php diff --git a/web/framework-1.1.17/i18n/data/uz_latn_uz.php b/web/framework/i18n/data/uz_latn_uz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_latn_uz.php rename to web/framework/i18n/data/uz_latn_uz.php diff --git a/web/framework-1.1.17/i18n/data/uz_uz.php b/web/framework/i18n/data/uz_uz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/uz_uz.php rename to web/framework/i18n/data/uz_uz.php diff --git a/web/framework-1.1.17/i18n/data/vai.php b/web/framework/i18n/data/vai.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vai.php rename to web/framework/i18n/data/vai.php diff --git a/web/framework-1.1.17/i18n/data/vai_latn.php b/web/framework/i18n/data/vai_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vai_latn.php rename to web/framework/i18n/data/vai_latn.php diff --git a/web/framework-1.1.17/i18n/data/vai_latn_lr.php b/web/framework/i18n/data/vai_latn_lr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vai_latn_lr.php rename to web/framework/i18n/data/vai_latn_lr.php diff --git a/web/framework-1.1.17/i18n/data/vai_vaii.php b/web/framework/i18n/data/vai_vaii.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vai_vaii.php rename to web/framework/i18n/data/vai_vaii.php diff --git a/web/framework-1.1.17/i18n/data/vai_vaii_lr.php b/web/framework/i18n/data/vai_vaii_lr.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vai_vaii_lr.php rename to web/framework/i18n/data/vai_vaii_lr.php diff --git a/web/framework-1.1.17/i18n/data/ve.php b/web/framework/i18n/data/ve.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ve.php rename to web/framework/i18n/data/ve.php diff --git a/web/framework-1.1.17/i18n/data/ve_za.php b/web/framework/i18n/data/ve_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/ve_za.php rename to web/framework/i18n/data/ve_za.php diff --git a/web/framework-1.1.17/i18n/data/vi.php b/web/framework/i18n/data/vi.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vi.php rename to web/framework/i18n/data/vi.php diff --git a/web/framework-1.1.17/i18n/data/vi_vn.php b/web/framework/i18n/data/vi_vn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vi_vn.php rename to web/framework/i18n/data/vi_vn.php diff --git a/web/framework-1.1.17/i18n/data/vo.php b/web/framework/i18n/data/vo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vo.php rename to web/framework/i18n/data/vo.php diff --git a/web/framework-1.1.17/i18n/data/vun.php b/web/framework/i18n/data/vun.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vun.php rename to web/framework/i18n/data/vun.php diff --git a/web/framework-1.1.17/i18n/data/vun_tz.php b/web/framework/i18n/data/vun_tz.php similarity index 100% rename from web/framework-1.1.17/i18n/data/vun_tz.php rename to web/framework/i18n/data/vun_tz.php diff --git a/web/framework-1.1.17/i18n/data/wae.php b/web/framework/i18n/data/wae.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wae.php rename to web/framework/i18n/data/wae.php diff --git a/web/framework-1.1.17/i18n/data/wae_ch.php b/web/framework/i18n/data/wae_ch.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wae_ch.php rename to web/framework/i18n/data/wae_ch.php diff --git a/web/framework-1.1.17/i18n/data/wal.php b/web/framework/i18n/data/wal.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wal.php rename to web/framework/i18n/data/wal.php diff --git a/web/framework-1.1.17/i18n/data/wal_et.php b/web/framework/i18n/data/wal_et.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wal_et.php rename to web/framework/i18n/data/wal_et.php diff --git a/web/framework-1.1.17/i18n/data/wo.php b/web/framework/i18n/data/wo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wo.php rename to web/framework/i18n/data/wo.php diff --git a/web/framework-1.1.17/i18n/data/wo_latn.php b/web/framework/i18n/data/wo_latn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wo_latn.php rename to web/framework/i18n/data/wo_latn.php diff --git a/web/framework-1.1.17/i18n/data/wo_latn_sn.php b/web/framework/i18n/data/wo_latn_sn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wo_latn_sn.php rename to web/framework/i18n/data/wo_latn_sn.php diff --git a/web/framework-1.1.17/i18n/data/wo_sn.php b/web/framework/i18n/data/wo_sn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/wo_sn.php rename to web/framework/i18n/data/wo_sn.php diff --git a/web/framework-1.1.17/i18n/data/xh.php b/web/framework/i18n/data/xh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/xh.php rename to web/framework/i18n/data/xh.php diff --git a/web/framework-1.1.17/i18n/data/xh_za.php b/web/framework/i18n/data/xh_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/xh_za.php rename to web/framework/i18n/data/xh_za.php diff --git a/web/framework-1.1.17/i18n/data/xog.php b/web/framework/i18n/data/xog.php similarity index 100% rename from web/framework-1.1.17/i18n/data/xog.php rename to web/framework/i18n/data/xog.php diff --git a/web/framework-1.1.17/i18n/data/xog_ug.php b/web/framework/i18n/data/xog_ug.php similarity index 100% rename from web/framework-1.1.17/i18n/data/xog_ug.php rename to web/framework/i18n/data/xog_ug.php diff --git a/web/framework-1.1.17/i18n/data/yav.php b/web/framework/i18n/data/yav.php similarity index 100% rename from web/framework-1.1.17/i18n/data/yav.php rename to web/framework/i18n/data/yav.php diff --git a/web/framework-1.1.17/i18n/data/yav_cm.php b/web/framework/i18n/data/yav_cm.php similarity index 100% rename from web/framework-1.1.17/i18n/data/yav_cm.php rename to web/framework/i18n/data/yav_cm.php diff --git a/web/framework-1.1.17/i18n/data/yo.php b/web/framework/i18n/data/yo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/yo.php rename to web/framework/i18n/data/yo.php diff --git a/web/framework-1.1.17/i18n/data/yo_ng.php b/web/framework/i18n/data/yo_ng.php similarity index 100% rename from web/framework-1.1.17/i18n/data/yo_ng.php rename to web/framework/i18n/data/yo_ng.php diff --git a/web/framework-1.1.17/i18n/data/zh.php b/web/framework/i18n/data/zh.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh.php rename to web/framework/i18n/data/zh.php diff --git a/web/framework-1.1.17/i18n/data/zh_cn.php b/web/framework/i18n/data/zh_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_cn.php rename to web/framework/i18n/data/zh_cn.php diff --git a/web/framework-1.1.17/i18n/data/zh_hans.php b/web/framework/i18n/data/zh_hans.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hans.php rename to web/framework/i18n/data/zh_hans.php diff --git a/web/framework-1.1.17/i18n/data/zh_hans_cn.php b/web/framework/i18n/data/zh_hans_cn.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hans_cn.php rename to web/framework/i18n/data/zh_hans_cn.php diff --git a/web/framework-1.1.17/i18n/data/zh_hans_hk.php b/web/framework/i18n/data/zh_hans_hk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hans_hk.php rename to web/framework/i18n/data/zh_hans_hk.php diff --git a/web/framework-1.1.17/i18n/data/zh_hans_mo.php b/web/framework/i18n/data/zh_hans_mo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hans_mo.php rename to web/framework/i18n/data/zh_hans_mo.php diff --git a/web/framework-1.1.17/i18n/data/zh_hans_sg.php b/web/framework/i18n/data/zh_hans_sg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hans_sg.php rename to web/framework/i18n/data/zh_hans_sg.php diff --git a/web/framework-1.1.17/i18n/data/zh_hant.php b/web/framework/i18n/data/zh_hant.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hant.php rename to web/framework/i18n/data/zh_hant.php diff --git a/web/framework-1.1.17/i18n/data/zh_hant_hk.php b/web/framework/i18n/data/zh_hant_hk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hant_hk.php rename to web/framework/i18n/data/zh_hant_hk.php diff --git a/web/framework-1.1.17/i18n/data/zh_hant_mo.php b/web/framework/i18n/data/zh_hant_mo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hant_mo.php rename to web/framework/i18n/data/zh_hant_mo.php diff --git a/web/framework-1.1.17/i18n/data/zh_hant_tw.php b/web/framework/i18n/data/zh_hant_tw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hant_tw.php rename to web/framework/i18n/data/zh_hant_tw.php diff --git a/web/framework-1.1.17/i18n/data/zh_hk.php b/web/framework/i18n/data/zh_hk.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_hk.php rename to web/framework/i18n/data/zh_hk.php diff --git a/web/framework-1.1.17/i18n/data/zh_mo.php b/web/framework/i18n/data/zh_mo.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_mo.php rename to web/framework/i18n/data/zh_mo.php diff --git a/web/framework-1.1.17/i18n/data/zh_sg.php b/web/framework/i18n/data/zh_sg.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_sg.php rename to web/framework/i18n/data/zh_sg.php diff --git a/web/framework-1.1.17/i18n/data/zh_tw.php b/web/framework/i18n/data/zh_tw.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zh_tw.php rename to web/framework/i18n/data/zh_tw.php diff --git a/web/framework-1.1.17/i18n/data/zu.php b/web/framework/i18n/data/zu.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zu.php rename to web/framework/i18n/data/zu.php diff --git a/web/framework-1.1.17/i18n/data/zu_za.php b/web/framework/i18n/data/zu_za.php similarity index 100% rename from web/framework-1.1.17/i18n/data/zu_za.php rename to web/framework/i18n/data/zu_za.php diff --git a/web/framework-1.1.17/i18n/gettext/CGettextFile.php b/web/framework/i18n/gettext/CGettextFile.php similarity index 100% rename from web/framework-1.1.17/i18n/gettext/CGettextFile.php rename to web/framework/i18n/gettext/CGettextFile.php diff --git a/web/framework-1.1.17/i18n/gettext/CGettextMoFile.php b/web/framework/i18n/gettext/CGettextMoFile.php similarity index 99% rename from web/framework-1.1.17/i18n/gettext/CGettextMoFile.php rename to web/framework/i18n/gettext/CGettextMoFile.php index 221af6d03..af226f8be 100644 --- a/web/framework-1.1.17/i18n/gettext/CGettextMoFile.php +++ b/web/framework/i18n/gettext/CGettextMoFile.php @@ -62,6 +62,7 @@ public function __construct($useBigEndian=false) * @param string $file file path * @param string $context message context * @return array message translations (source message => translated message) + * @throws CException */ public function load($file,$context) { @@ -137,6 +138,7 @@ public function load($file,$context) * @param array $messages message translations (message id => translated message). * Note if the message has a context, the message id must be prefixed with * the context with chr(4) as the separator. + * @throws CException */ public function save($file,$messages) { diff --git a/web/framework-1.1.17/i18n/gettext/CGettextPoFile.php b/web/framework/i18n/gettext/CGettextPoFile.php similarity index 100% rename from web/framework-1.1.17/i18n/gettext/CGettextPoFile.php rename to web/framework/i18n/gettext/CGettextPoFile.php diff --git a/web/framework-1.1.17/logging/CChainedLogFilter.php b/web/framework/logging/CChainedLogFilter.php similarity index 100% rename from web/framework-1.1.17/logging/CChainedLogFilter.php rename to web/framework/logging/CChainedLogFilter.php diff --git a/web/framework-1.1.17/logging/CDbLogRoute.php b/web/framework/logging/CDbLogRoute.php similarity index 100% rename from web/framework-1.1.17/logging/CDbLogRoute.php rename to web/framework/logging/CDbLogRoute.php diff --git a/web/framework-1.1.17/logging/CEmailLogRoute.php b/web/framework/logging/CEmailLogRoute.php similarity index 100% rename from web/framework-1.1.17/logging/CEmailLogRoute.php rename to web/framework/logging/CEmailLogRoute.php diff --git a/web/framework-1.1.17/logging/CFileLogRoute.php b/web/framework/logging/CFileLogRoute.php similarity index 100% rename from web/framework-1.1.17/logging/CFileLogRoute.php rename to web/framework/logging/CFileLogRoute.php diff --git a/web/framework-1.1.17/logging/CLogFilter.php b/web/framework/logging/CLogFilter.php similarity index 100% rename from web/framework-1.1.17/logging/CLogFilter.php rename to web/framework/logging/CLogFilter.php diff --git a/web/framework-1.1.17/logging/CLogRoute.php b/web/framework/logging/CLogRoute.php similarity index 100% rename from web/framework-1.1.17/logging/CLogRoute.php rename to web/framework/logging/CLogRoute.php diff --git a/web/framework-1.1.17/logging/CLogRouter.php b/web/framework/logging/CLogRouter.php similarity index 100% rename from web/framework-1.1.17/logging/CLogRouter.php rename to web/framework/logging/CLogRouter.php diff --git a/web/framework-1.1.17/logging/CLogger.php b/web/framework/logging/CLogger.php similarity index 100% rename from web/framework-1.1.17/logging/CLogger.php rename to web/framework/logging/CLogger.php diff --git a/web/framework-1.1.17/logging/CProfileLogRoute.php b/web/framework/logging/CProfileLogRoute.php similarity index 100% rename from web/framework-1.1.17/logging/CProfileLogRoute.php rename to web/framework/logging/CProfileLogRoute.php diff --git a/web/framework-1.1.17/logging/CSysLogRoute.php b/web/framework/logging/CSysLogRoute.php similarity index 100% rename from web/framework-1.1.17/logging/CSysLogRoute.php rename to web/framework/logging/CSysLogRoute.php diff --git a/web/framework-1.1.17/logging/CWebLogRoute.php b/web/framework/logging/CWebLogRoute.php similarity index 100% rename from web/framework-1.1.17/logging/CWebLogRoute.php rename to web/framework/logging/CWebLogRoute.php diff --git a/web/framework-1.1.17/messages/ar/yii.php b/web/framework/messages/ar/yii.php similarity index 100% rename from web/framework-1.1.17/messages/ar/yii.php rename to web/framework/messages/ar/yii.php diff --git a/web/framework-1.1.17/messages/ar/zii.php b/web/framework/messages/ar/zii.php similarity index 100% rename from web/framework-1.1.17/messages/ar/zii.php rename to web/framework/messages/ar/zii.php diff --git a/web/framework-1.1.17/messages/bg/yii.php b/web/framework/messages/bg/yii.php similarity index 100% rename from web/framework-1.1.17/messages/bg/yii.php rename to web/framework/messages/bg/yii.php diff --git a/web/framework-1.1.17/messages/bg/zii.php b/web/framework/messages/bg/zii.php similarity index 100% rename from web/framework-1.1.17/messages/bg/zii.php rename to web/framework/messages/bg/zii.php diff --git a/web/framework-1.1.17/messages/bs/yii.php b/web/framework/messages/bs/yii.php similarity index 81% rename from web/framework-1.1.17/messages/bs/yii.php rename to web/framework/messages/bs/yii.php index e177f9d66..d41e4d90f 100644 --- a/web/framework-1.1.17/messages/bs/yii.php +++ b/web/framework/messages/bs/yii.php @@ -16,56 +16,56 @@ return array ( 0 => '0', 'Virtual attribute {name} must specify "asc" and "desc" options.' => 'Virtualni atribut {name} mora specificirati "asc"- i "desc" opcije.', - '"{path}" is not a valid directory.' => '"{path}" nije važeći direktorijum.', + '"{path}" is not a valid directory.' => '"{path}" nije važeći direktorij.', '< Previous' => '< Prethodna', '<< First' => '<< Prva', - 'Active Record requires a "db" CDbConnection application component.' => 'ActiveRecord zahtjeva "db" CDbConnection aplikacionu komponentu.', + 'Active Record requires a "db" CDbConnection application component.' => 'ActiveRecord zahtjeva "db" CDbConnection aplikacijsku komponentu.', 'Active record "{class}" has an invalid configuration for relation "{relation}". It must specify the relation type, the related active record class and the foreign key.' => 'ActiveRecord-Klasa "{class}" ima nevažeću konfiguraciju za odnos "{relation}". Tipa odnosa, odnosni ActiveRecord i strani kljuÄ (foreign key) moraju biti postavljeni.', - 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.' => 'ActiveRecord "{class}" koristi nevažećo polje "{column}" u SELECT. Pripazite da to polje mora da postoji u tabeli ili da bude alias izraz.', + 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.' => 'ActiveRecord "{class}" koristi nevažeće polje "{column}" u SELECT. Pripazite da to polje mora da postoji u tabeli ili da bude alias izraz.', 'Active record class "{class}" does not have a scope named "{scope}".' => 'ActiveRecord-Klasa "{class}" nema polje imenovano "{scope}".', - 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' => 'Alias "{alias}" je nevažan. Molim vas, uspostavite da pokazuje do važećeg direktorija ili fajla.', - 'Application base path "{path}" is not a valid directory.' => 'Glavni put (base path) "{path}" aplikacije je nevažan.', + 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' => 'Alias "{alias}" je validan. Molim vas, uspostavite da pokazuje do važećeg direktorija ili fajla.', + 'Application base path "{path}" is not a valid directory.' => 'Glavni put (base path) "{path}" aplikacije nije važeći.', 'Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.' => 'Prometni put (runtime path) "{path}" aplikacije je nevažan. Pripazite da proces web servera ima pravo da tamo piÅ¡e.', - 'Authorization item "{item}" has already been assigned to user "{user}".' => 'Element autorizacije "{item}" je već namjenjen "{user}".', + 'Authorization item "{item}" has already been assigned to user "{user}".' => 'Element autorizacije "{item}" je već namjenjen korisniku "{user}".', 'Base path "{path}" is not a valid directory.' => 'Glavni put "{path}" je nevažeći direktorijum.', 'CApcCache requires PHP apc extension to be loaded.' => 'CApcCache zahtjeva da je uÄitan PHP APC dodatak.', - 'CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.' => 'CAssetManager.basePath "{path}" je nevažna. Pripazite da postoji taj direktorijum i da proces web servera ima pravo da tamo piÅ¡e.', - 'CCacheHttpSession.cacheID is invalid. Please make sure "{id}" refers to a valid cache application component.' => 'CCacheHttpSession.cacheID je nevažna. Molim vas, uspostavite da se "{id}" odnosi na važeću cache aplikacionu komponentu.', - 'CCaptchaValidator.action "{id}" is invalid. Unable to find such an action in the current controller.' => 'CCaptchaValidator.action "{id}" je nevažna. Nemogu da pronaÄ‘em takvu akciju u trenutnom controlleru.', - 'CDbAuthManager.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbAuthManager.connectionID "{id}" je nevažna. Molim vas, uspostavite da se "{id}" odnosi na važeću aplikacionu komponentu od tipa CDbConnection.', - 'CDbCache.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbCache.connectionID "{id}" je nevažna. Molim vas, uspostavite da se odnosi na važeću aplikacionu komponentu od tipa CDbConnection.', - 'CDbCacheDependency.sql cannot be empty.' => 'CDbCacheDependency.sql nesmije biti prazno.', - 'CDbCommand failed to execute the SQL statement: {error}' => 'CDbCommand nemože da izvrÅ¡i SQL-Statement: {error}', - 'CDbCommand failed to prepare the SQL statement: {error}' => 'CDbCommand nemože da pripremi SQL-Statement: {error}', - 'CDbConnection does not support reading schema for {driver} database.' => 'CDbConnection nepodržava Äitanje Å¡ema za {driver}-datoteke.', - 'CDbConnection failed to open the DB connection: {error}' => 'CDbConnection nemože da uspostavi spoj sa datotekom: {error}', - 'CDbConnection is inactive and cannot perform any DB operations.' => 'CDbConnection nije aktivna i nemože izvrÅ¡avati operacije na datoteki.', - 'CDbConnection.connectionString cannot be empty.' => 'CDbConnection.connectionString nesmije biti prazno.', - 'CDbDataReader cannot rewind. It is a forward-only reader.' => 'CDbDataReader se nemože premotavati. On je forward-only (samo naprijed) ÄitaÄ.', - 'CDbHttpSession.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbHttpSession.connectionID "{id}" je nevažna. Molim vas, uspostavite da se "{id}" odnosi na važeću aplikacionu komponentu od tipa CDbConnection.', - 'CDbLogRoute.connectionID "{id}" does not point to a valid CDbConnection application component.' => 'CDbLogRoute.connectionID "{id}" ne pokazuje na važeću aplikacionu komponentu od tipa Typ CDbConnection.', - 'CDbMessageSource.connectionID is invalid. Please make sure "{id}" refers to a valid database application component.' => 'CDbMessageSource.connectionID je nevažna. Molim vas, uspostavite da se "{id}" odnosi na važeću aplikacionu komponentu od tipa CDbConnection.', - 'CDbTestFixture.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbFixture.connectionID "{id}" je nevažna. Molim vas, uspostavite da se odnosi na važeću aplikacionu komponentu od tipa CDbConnection.', - 'CDbTransaction is inactive and cannot perform commit or roll back operations.' => 'CDbTransaction nije aktivno i nemože da izvrÅ¡i Commit- ili Rollback operaciju.', - 'CDirectoryCacheDependency.directory cannot be empty.' => 'CDirectoryCacheDependency.directory nesmije biti prazno.', - 'CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.' => 'CEAcceleratorCache zahtjeva, da PHP eAccelerator dodatak je uÄitan i aktiviran ili sa kompajlira sa opcijom "--with-eaccelerator-shared-memory".', - 'CFileCacheDependency.fileName cannot be empty.' => 'CFileCacheDependency.fileName nesmije biti prazno.', - 'CFileLogRoute.logPath "{path}" does not point to a valid directory. Make sure the directory exists and is writable by the Web server process.' => 'CFileLogRoute.logPath "{path}" ne pokazuje na važeći direktorijum. Pripazite da postoji taj direktorijum i da proces web servera ima pravo da tamo piÅ¡e.', + 'CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.' => 'CAssetManager.basePath "{path}" nije važeća. Pripazite da postoji taj direktorijum i da proces web servera ima pravo da tamo piÅ¡e.', + 'CCacheHttpSession.cacheID is invalid. Please make sure "{id}" refers to a valid cache application component.' => 'CCacheHttpSession.cacheID nije važeća. Molim vas, uspostavite da se "{id}" odnosi na važeću cache aplikacionu komponentu.', + 'CCaptchaValidator.action "{id}" is invalid. Unable to find such an action in the current controller.' => 'CCaptchaValidator.action "{id}" nije važeća. Ne mogu da pronaÄ‘em takvu akciju u trenutnom controlleru.', + 'CDbAuthManager.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbAuthManager.connectionID "{id}" nije važeća. Molimo vas, uspostavite da se "{id}" odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbCache.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbCache.connectionID "{id}" nije važeća. Molimo vas, uspostavite da se odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbCacheDependency.sql cannot be empty.' => 'CDbCacheDependency.sql ne smije biti prazno.', + 'CDbCommand failed to execute the SQL statement: {error}' => 'CDbCommand ne može da izvrÅ¡i SQL-Statement: {error}', + 'CDbCommand failed to prepare the SQL statement: {error}' => 'CDbCommand ne može da pripremi SQL-Statement: {error}', + 'CDbConnection does not support reading schema for {driver} database.' => 'CDbConnection ne podržava Äitanje Å¡ema za {driver}-datoteke.', + 'CDbConnection failed to open the DB connection: {error}' => 'CDbConnection ne može da uspostavi spoj sa datotekom: {error}', + 'CDbConnection is inactive and cannot perform any DB operations.' => 'CDbConnection nije aktivna i ne može izvrÅ¡avati operacije na datoteci.', + 'CDbConnection.connectionString cannot be empty.' => 'CDbConnection.connectionString ne smije biti prazno.', + 'CDbDataReader cannot rewind. It is a forward-only reader.' => 'CDbDataReader se ne može premotavati. On je forward-only (samo naprijed) ÄitaÄ.', + 'CDbHttpSession.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbHttpSession.connectionID "{id}" nije važeća. Molimo vas, uspostavite da se "{id}" odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbLogRoute.connectionID "{id}" does not point to a valid CDbConnection application component.' => 'CDbLogRoute.connectionID "{id}" ne pokazuje na važeću aplikacijsku komponentu od tipa Typ CDbConnection.', + 'CDbMessageSource.connectionID is invalid. Please make sure "{id}" refers to a valid database application component.' => 'CDbMessageSource.connectionID je nevažna. Molimo vas, uspostavite da se "{id}" odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbTestFixture.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbFixture.connectionID "{id}" je nevažeća. Molim vas, uspostavite da se odnosi na važeću aplikacionu komponentu tipa CDbConnection.', + 'CDbTransaction is inactive and cannot perform commit or roll back operations.' => 'CDbTransaction nije aktivno i ne može da izvrÅ¡i Commit- ili Rollback operaciju.', + 'CDirectoryCacheDependency.directory cannot be empty.' => 'CDirectoryCacheDependency.directory ne smije biti prazno.', + 'CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.' => 'CEAcceleratorCache zahtjeva da je PHP eAccelerator dodatak uÄitan i aktiviran ili se kompajlira sa opcijom "--with-eaccelerator-shared-memory".', + 'CFileCacheDependency.fileName cannot be empty.' => 'CFileCacheDependency.fileName ne smije biti prazno.', + 'CFileLogRoute.logPath "{path}" does not point to a valid directory. Make sure the directory exists and is writable by the Web server process.' => 'CFileLogRoute.logPath "{path}" ne pokazuje na nevažeći direktorij. Pripazite da postoji taj direktorij i da proces web servera ima pravo da tamo piÅ¡e.', 'CFilterChain can only take objects implementing the IFilter interface.' => 'CFilterChain smije primiti samo objekte koje implementiraju IFilter-Interface.', - 'CFlexWidget.baseUrl cannot be empty.' => 'CFlexWidget.baseUrl nesmije biti prazno.', - 'CFlexWidget.name cannot be empty.' => 'CFlexWidget.name nesmije biti prazno.', - 'CGlobalStateCacheDependency.stateName cannot be empty.' => 'CGlobalStateCacheDependency.stateName nesmije biti prazno.', + 'CFlexWidget.baseUrl cannot be empty.' => 'CFlexWidget.baseUrl ne smije biti prazno.', + 'CFlexWidget.name cannot be empty.' => 'CFlexWidget.name ne smije biti prazno.', + 'CGlobalStateCacheDependency.stateName cannot be empty.' => 'CGlobalStateCacheDependency.stateName ne smije biti prazno.', 'CHttpCookieCollection can only hold CHttpCookie objects.' => 'CHttpCookieCollection smije da sadrži samo CHttpCookie-Objekte.', 'CHttpRequest is unable to determine the entry script URL.' => 'CHttpRequest ne može da ustanovi URL ulaznog skripta (entry script).', 'CHttpRequest is unable to determine the path info of the request.' => 'CHttpRequest ne može da ustanovi informacije o putu (path info) za tekući zahtjev (request).', 'CHttpRequest is unable to determine the request URI.' => 'CHttpRequest ne može da ustanovi URI za tekući zahtjev (request).', 'CHttpSession.cookieMode can only be "none", "allow" or "only".' => 'CHttpSession.cookieMode može biti jedino "none", "allow" ili "only".', 'CHttpSession.gcProbability "{value}" is invalid. It must be an integer between 0 and 100.' => 'CHttpSession.gcProbability "{value}" je pogreÅ¡an. Mora biti cijeli broj (integer) izmeÄ‘u 0 i 100.', - 'CHttpSession.savePath "{path}" is not a valid directory.' => 'CHttpSession.savePath "{path}" nije ispravan direktorijum.', + 'CHttpSession.savePath "{path}" is not a valid directory.' => 'CHttpSession.savePath "{path}" nije ispravan direktorij.', 'CMemCache server configuration must be an array.' => 'CMemCache server konfiguracija mora biti niz (array)', 'CMemCache server configuration must have "host" value.' => 'CMemCache server konfiguracija mora imati dodjeljenu vrijednost za "host".', 'CMultiFileUpload.name is required.' => 'CMultiFileUpload.name je obavezno.', - 'CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.' => 'CProfileLogRoute je naÅ¡ao nesaglaÅ¡en blok koda "{token}". Budite sigurni da su pozivi Yii::beginProfile() i Yii::endProfile() ispravno ugnježdeni.', + 'CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.' => 'CProfileLogRoute je naÅ¡ao neusaglaÅ¡en blok koda "{token}". Budite sigurni da su pozivi Yii::beginProfile() i Yii::endProfile() ispravno ugnježdeni.', 'CProfileLogRoute.report "{report}" is invalid. Valid values include "summary" and "callstack".' => 'CProfileLogRoute.report "{report}" je pogreÅ¡an. Ispravne vrijednosti ukljuÄuju "summary" i "callstack".', 'CSecurityManager requires PHP mcrypt extension to be loaded in order to use data encryption feature.' => 'CSecurityManager zahtjeva da PHP mcrypt ekstenzija bude ukljuÄena da bi se koristila mogućnost enkripcije podataka.', 'CSecurityManager.encryptionKey cannot be empty.' => 'CSecurityManager.encryptionKey ne može biti prazan.', @@ -87,11 +87,11 @@ 'Event "{class}.{event}" is attached with an invalid handler "{handler}".' => 'DogaÄ‘aj "{class}.{event}" je zakaÄen za pogreÅ¡an (nevažeći) hendler (handler) "{handler}".', 'Event "{class}.{event}" is not defined.' => 'DogaÄ‘aj (event) "{class}.{event}" nije definisan.', 'Extension path "{path}" does not exist.' => 'Put dodataka (extension path) "{path}" ne postoji.', - 'Failed to write the uploaded file "{file}" to disk.' => 'NeuspjeÅ¡no snimanje podignutog fajla (uploaded file) "{file}" na disk.', - 'File upload was stopped by extension.' => 'Podizanje fajla (file upload) je zaustavljeno od strane ekstenzije.', + 'Failed to write the uploaded file "{file}" to disk.' => 'NeuspjeÅ¡no snimanje uploadovanog fajla (uploaded file) "{file}" na disk.', + 'File upload was stopped by extension.' => 'Upload fajla (file upload) je zaustavljeno od strane ekstenzije.', 'Filter "{filter}" is invalid. Controller "{class}" does have the filter method "filter{filter}".' => 'Filter "{filter}" je pogreÅ¡an. Kontroler "{class}" sadrži filter metod "filter{filter}".', 'Get a new code' => 'Dobavi novi kod', - 'Go to page: ' => 'Do stranice: ', + 'Go to page: ' => 'Idi na stranicu: ', 'Invalid MO file revision: {revision}.' => 'PogreÅ¡na revizija MO fajla: {revision}.', 'Invalid MO file: {file} (magic: {magic}).' => 'PogreÅ¡an (neispravan) MO fajl: {file} (magic: {magic}).', 'Invalid enumerable value "{value}". Please make sure it is among ({enum}).' => 'PogreÅ¡na nabrojiva vrijednost "{value}". Molim vas, budite sigurni da je iz ({enum}).', @@ -101,19 +101,19 @@ 'List index "{index}" is out of bound.' => 'Indeks liste "{index}" je van opsega.', 'Login Required' => 'Potrebna prijava', 'Map data must be an array or an object implementing Traversable.' => 'Podatak mape (Map data) mora biti niz ili objekat koji implementira Traversable.', - 'Missing the temporary folder to store the uploaded file "{file}".' => 'Nedostaje privremeni folder za skladiÅ¡te podignutog fajla "{file}".', - 'Next >' => 'Slijedeća >', - 'No columns are being updated for table "{table}".' => 'Ni jedna kolona neće biti ažurirana u tabeli "{table}".', + 'Missing the temporary folder to store the uploaded file "{file}".' => 'Nedostaje privremeni folder za spremanje uÄitanog fajla "{file}".', + 'Next >' => 'Sljedeća >', + 'No columns are being updated for table "{table}".' => 'Nijedna kolona neće biti ažurirana u tabeli "{table}".', 'No counter columns are being updated for table "{table}".' => 'BrojaÄ kolona neće biti ažuriran za tabelu "{table}".', 'Object configuration must be an array containing a "class" element.' => 'Konfiguracija objekta mora biti niz koji sadrži "class" element.', 'Please fix the following input errors:' => 'Molim vas ispravite greÅ¡ke:', 'Property "{class}.{property}" is not defined.' => 'Svojstvo (property) "{class}.{property}" nije definisano.', 'Property "{class}.{property}" is read only.' => 'Svojstvo (property) "{class}.{property}" je samo za Äitanje.', 'Queue data must be an array or an object implementing Traversable.' => 'Podatak reda (Queue data) mora biti niz ili objekat koji implementira Traversable.', - 'Relation "{name}" is not defined in active record class "{class}".' => 'Odnos "{name}" nije definisana u active record klasi "{class}".', - 'Resetting PK sequence is not supported.' => 'Ne podržava se vraćanja PK sekvencije.', + 'Relation "{name}" is not defined in active record class "{class}".' => 'Odnos "{name}" nije definisan u active record klasi "{class}".', + 'Resetting PK sequence is not supported.' => 'Ne podržava vraćanje PK sekvence.', 'Setting integrity check is not supported.' => 'Ne podržava se aktivacija kontrole integracije postavki.', - 'Stack data must be an array or an object implementing Traversable.' => 'Podatak hrpe (Stack data) mora biti niz ili objekat koji implementira Traversable.', + 'Stack data must be an array or an object implementing Traversable.' => 'Podatak sa steka (Stack data) mora biti niz ili objekat koji implementira Traversable.', 'Table "{table}" does not have a column named "{column}".' => 'Tabela "{table}" ne posjeduje kolonu "{column}".', 'Table "{table}" does not have a primary key defined.' => 'Tabela "{table}" nema definisan primarni kljuÄ (primary key).', 'The "filter" property must be specified with a valid callback.' => '"Filter" svojstvo (property) mora biti specificirano povratnom funkcijom (callback).', @@ -125,35 +125,35 @@ 'The active record cannot be inserted to database because it is not new.' => 'Active record ne može biti ubaÄen u bazu zato Å¡to je nov.', 'The active record cannot be updated because it is new.' => 'Active record ne može biti ažuriran zato Å¡to je nov.', 'The asset "{asset}" to be pulished does not exist.' => 'Resurs "{asset}" koji treba biti objavljen ne postoji.', - 'The command path "{path}" is not a valid directory.' => 'Put direktorijuma do komande (command path) "{path}" nije ispravan.', - 'The controller path "{path}" is not a valid directory.' => 'Put direktorijuma do kontrolera "{path}" nije ispravan.', + 'The command path "{path}" is not a valid directory.' => 'Put direktorija do komande (command path) "{path}" nije ispravan.', + 'The controller path "{path}" is not a valid directory.' => 'Put direktorija do kontrolera "{path}" nije ispravan.', 'The file "{file}" cannot be uploaded. Only files with these extensions are allowed: {extensions}.' => 'Fajl "{file}" ne može biti podignut (uploaded). Dozvoljeni su jedino fajlovi sa slijedećim ekstenzijama: {extensions}.', - 'The file "{file}" is too large. Its size cannot exceed {limit} bytes.' => 'Fajl "{file}" je prevelik. VeliÄina fajla ne sme da prekoraÄi {limit} bytes.', + 'The file "{file}" is too large. Its size cannot exceed {limit} bytes.' => 'Fajl "{file}" je prevelik. VeliÄina fajla ne smije da prekoraÄi {limit} bytes.', 'The file "{file}" is too small. Its size cannot be smaller than {limit} bytes.' => 'Fajl "{file}" je premali. VeliÄina fajla ne smije biti manja od {limit} bytes.', - 'The file "{file}" was only partially uploaded.' => 'Fajl "{file}" je samo delimiÄno podignut (uploaded).', + 'The file "{file}" was only partially uploaded.' => 'Fajl "{file}" je samo djelimiÄno uÄitan (uploaded).', 'The first element in a filter configuration must be the filter class.' => 'Prvi element u konfiguraciji filtera mora biti klasa filtera.', 'The item "{name}" does not exist.' => 'Stavka "{name}" ne postoji.', 'The item "{parent}" already has a child "{child}".' => 'Stavka "{parent}" već ima dijete "{child}".', - 'The layout path "{path}" is not a valid directory.' => 'Put do direktorijuma layout "{path}" nije ispravan.', + 'The layout path "{path}" is not a valid directory.' => 'Put do direktorija layout "{path}" nije ispravan.', 'The list is read only.' => 'Lista (List) je samo za Äitanje', 'The map is read only.' => 'Mapa (Map) je samo za Äitanje', 'The module path "{path}" is not a valid directory.' => 'Put do modula "{path}" je nevažeći direktorijum.', - 'The pattern for 12 hour format must be "h" or "hh".' => 'Å ablona za 12 Äasovni format mora biti "h" ili "hh".', - 'The pattern for 24 hour format must be "H" or "HH".' => 'Å ablona za 24 Äasovni format mora biti "H" ili "HH".', + 'The pattern for 12 hour format must be "h" or "hh".' => 'Å ablon za 12 Äasovni format mora biti "h" ili "hh".', + 'The pattern for 24 hour format must be "H" or "HH".' => 'Å ablon za 24 Äasovni format mora biti "H" ili "HH".', 'The pattern for AM/PM marker must be "a".' => 'Å ablona za AM/PM marker mora biti "a".', 'The pattern for day in month must be "F".' => 'Å ablona za dan u mjesecu mora biti "F".', - 'The pattern for day in year must be "D", "DD" or "DDD".' => 'Å ablona za dan u godini mora biti "D", "DD" ili "DDD".', - 'The pattern for day of the month must be "d" or "dd".' => 'Å ablona za dan mjeseca mora biti "d" ili "dd".', - 'The pattern for day of the week must be "E", "EE", "EEE", "EEEE" or "EEEEE".' => 'Å ablona za dan sedmice mora biti "E", "EE", "EEE", "EEEE" ili "EEEEE".', - 'The pattern for era must be "G", "GG", "GGG", "GGGG" or "GGGGG".' => 'Å ablona za doba mora biti "G", "GG", "GGG", "GGGG" ili "GGGGG".', - 'The pattern for hour in AM/PM must be "K" or "KK".' => 'Å ablona za Äas u AM/PM mora biti "K" ili "KK".', - 'The pattern for hour in day must be "k" or "kk".' => 'Å ablona za Äas u danu mora biti "k" ili "kk".', - 'The pattern for minutes must be "m" or "mm".' => 'Å ablona za minute mora biti "m" ili "mm".', - 'The pattern for month must be "M", "MM", "MMM", or "MMMM".' => 'Å ablona za mjesec mora biti "M", "MM", "MMM" ili "MMMM".', - 'The pattern for seconds must be "s" or "ss".' => 'Å ablona za sekunde mora biti "s" ili "ss".', - 'The pattern for time zone must be "z" or "v".' => 'Å ablona za zonu mora biti "z" ili "v".', - 'The pattern for week in month must be "W".' => 'Å ablona za sedmicu u mjesecu mora biti "W".', - 'The pattern for week in year must be "w".' => 'Å ablona za sedmicu u godini mora biti "w".', + 'The pattern for day in year must be "D", "DD" or "DDD".' => 'Å ablon za dan u godini mora biti "D", "DD" ili "DDD".', + 'The pattern for day of the month must be "d" or "dd".' => 'Å ablon za dan mjeseca mora biti "d" ili "dd".', + 'The pattern for day of the week must be "E", "EE", "EEE", "EEEE" or "EEEEE".' => 'Å ablon za dan sedmice mora biti "E", "EE", "EEE", "EEEE" ili "EEEEE".', + 'The pattern for era must be "G", "GG", "GGG", "GGGG" or "GGGGG".' => 'Å ablon za doba mora biti "G", "GG", "GGG", "GGGG" ili "GGGGG".', + 'The pattern for hour in AM/PM must be "K" or "KK".' => 'Å ablon za Äas u AM/PM mora biti "K" ili "KK".', + 'The pattern for hour in day must be "k" or "kk".' => 'Å ablon za Äas u danu mora biti "k" ili "kk".', + 'The pattern for minutes must be "m" or "mm".' => 'Å ablon za minute mora biti "m" ili "mm".', + 'The pattern for month must be "M", "MM", "MMM", or "MMMM".' => 'Å ablon za mjesec mora biti "M", "MM", "MMM" ili "MMMM".', + 'The pattern for seconds must be "s" or "ss".' => 'Å ablon za sekunde mora biti "s" ili "ss".', + 'The pattern for time zone must be "z" or "v".' => 'Å ablon za zonu mora biti "z" ili "v".', + 'The pattern for week in month must be "W".' => 'Å ablon za sedmicu u mjesecu mora biti "W".', + 'The pattern for week in year must be "w".' => 'Å ablon za sedmicu u godini mora biti "w".', 'The queue is empty.' => 'Red (queue) je prazan.', 'The relation "{relation}" in active record class "{class}" is not specified correctly: The join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'Odnos "{relation}" u active record klasi "{class}" nije specificirana ispravno: pridružena tabela (join table) "{joinTable}" zadata u spoljnom kljuÄu (foreign key) ne može biti pronaÄ‘ena u bazi.', 'The relation "{relation}" in active record class "{class}" is not specified correctly: the join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'Odnos "{relation}" u active record klasi "{class}" nije specificirana ispravno: pridružena tabela (join table) "{joinTable}" zadata u spoljnom kljuÄu (foreign key) ne može biti pronaÄ‘ena u bazi.', @@ -164,13 +164,13 @@ 'The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key. The columns in the key must match the primary keys of the table "{table}".' => 'Odnos "{relation}" u active record klasi "{class}" je specificirana pogreÅ¡nim spoljnim kljuÄem (foreign key). Kolone spoljnog kljuÄa (foreign key) moraju biti iste kao i primarnog kljuÄa od tabele "{table}".', 'The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key. The format of the foreign key must be "joinTable(fk1,fk2,...)".' => 'Odnos "{relation}" u active record klasi "{class}" je specificirana pogreÅ¡nim spoljnim kljuÄem (foreign key). Format spoljnog kljuÄa (foreign key) mora biti "joinTable(fk1,fk2,...)', 'The requested view "{name}" was not found.' => 'zahtjevani pogled (view) "{name}" nije pronaÄ‘en.', - 'The stack is empty.' => 'Hrpa (stack) je prazna.', - 'The system is unable to find the requested action "{action}".' => 'Sistem ne može da pronaÄ‘e zahtjevanu akciju "{action}".', - 'The system view path "{path}" is not a valid directory.' => 'Put direktorijuma do sistemskog pogleda (system view) "{path}" nije ispravan.', + 'The stack is empty.' => 'Stek (stack) je prazna.', + 'The system is unable to find the requested action "{action}".' => 'Sistem ne može da pronaÄ‘e traženu akciju "{action}".', + 'The system view path "{path}" is not a valid directory.' => 'Put direktorija do sistemskog pogleda (system view) "{path}" nije ispravan.', 'The table "{table}" for active record class "{class}" cannot be found in the database.' => 'Tabela "{table}" za active record klasu "{class}" ne može biti pronaÄ‘ena u bazi.', 'The value for the primary key "{key}" is not supplied when querying the table "{table}".' => 'Vrijednost primarnog kljuÄa (primary key) "{key}" nije prosljeÄ‘ena prilikom izvrÅ¡enja upita nad tabelom "{table}".', 'The verification code is incorrect.' => 'Verifikacioni kod je pogreÅ¡an.', - 'The view path "{path}" is not a valid directory.' => 'Put do prikaznog direktorijuma (view path) "{path}" ne važi.', + 'The view path "{path}" is not a valid directory.' => 'Put do prikaznog direktorija (view path) "{path}" nije važeći.', 'Theme directory "{directory}" does not exist.' => 'Direktorijum za teme (theme directory) "{directory}" ne postoji.', 'This content requires the Adobe Flash Player.' => 'Ovaj sadržaj zahtjeva Adobe Flash Player.', 'Unable to add an item whose name is the same as an existing item.' => 'Ne mogu da dodam stavku sa istim imenom kao postojeća stavka.', @@ -184,7 +184,7 @@ 'Unable to write file "{file}".' => 'Ne mogu da upiÅ¡em fajl "{file}".', 'Unknown authorization item "{name}".' => 'Nepoznata stavka ovlašćenja (authorization item) "{name}', 'Unrecognized locale "{locale}".' => 'Lokalizacija nije prepoznata (unrecognized locale) "{locale}".', - 'View file "{file}" does not exist.' => 'Fajl pogleda (view file) "{file}" ne postoji.', + 'View file "{file}" does not exist.' => 'View fajl "{file}" ne postoji.', 'Yii application can only be created once.' => 'Yii aplikacija može biti kreirana samo jedanput.', 'You are not authorized to perform this action.' => 'Niste autorizovani da izvrÅ¡ite ovu akciju.', 'Your request is not valid.' => 'VaÅ¡ zahtjev nije ispravan.', @@ -211,7 +211,7 @@ '{attribute} must be repeated exactly.' => '{attribute} mora biti taÄno ponovljen.', '{attribute} must be {type}.' => '{attribute} mora biti {type}.', '{attribute} must be {value}.' => '{attribute} mora biti {value}.', - '{attribute} must not be equal to "{compareValue}".' => '{attribute} nesmije biti isti kao "{compareValue}".', + '{attribute} must not be equal to "{compareValue}".' => '{attribute} ne smije biti isti kao "{compareValue}".', '{className} does not support add() functionality.' => '{className} ne podržava add() funcionalnost.', '{className} does not support delete() functionality.' => '{className} ne podržava delete() funkcionalnost.', '{className} does not support flush() functionality.' => '{className} ne podržava flush() funkcionalnost.', @@ -223,9 +223,9 @@ '{class} has an invalid validation rule. The rule must specify attributes to be validated and the validator name.' => '{class} ima pogreÅ¡no ovjereno pravilo (validation rule). Pravilo mora da specificira atribute koji ce biti ovjereni i ime ovjerenja.', '{class} must specify "model" and "attribute" or "name" property values.' => '{class} mora da specificira "model" i "attribute" ili "name" svojstvo (property) vrijednosti.', '{class}.allowAutoLogin must be set true in order to use cookie-based authentication.' => '{class}.allowAutoLogin mora biti podeÅ¡en na true da bi se koristila cookies autorizacija.', - '{class}::authenticate() must be implemented.' => '{class}::authenticate() mora biti implementirana.', - '{controller} cannot find the requested view "{view}".' => '{controller} ne može da pronaÄ‘e zahtjevani pogled (view) "{view}".', + '{class}::authenticate() must be implemented.' => '{class}::authenticate() metoda mora biti implementirana.', + '{controller} cannot find the requested view "{view}".' => '{controller} ne može da pronaÄ‘e zahtjevani view "{view}".', '{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} sadrži nepropisno ugnježdene widget tagove u svom pogledu (view) "{view}". {widget} widget nema endWidget() poziv.', - '{controller} has an extra endWidget({id}) call in its view.' => '{controller} ima suviÅ¡an endWidget({id}) poziv u svom pogledu (view).', - '{widget} cannot find the view "{view}".' => '{widget} ne može da pronaÄ‘e pogled (view) "{view}".', + '{controller} has an extra endWidget({id}) call in its view.' => '{controller} ima suviÅ¡an endWidget({id}) poziv u svom view-u.', + '{widget} cannot find the view "{view}".' => '{widget} ne može da pronaÄ‘e view "{view}".', ); \ No newline at end of file diff --git a/web/framework-1.1.17/messages/ca/yii.php b/web/framework/messages/ca/yii.php similarity index 100% rename from web/framework-1.1.17/messages/ca/yii.php rename to web/framework/messages/ca/yii.php diff --git a/web/framework-1.1.17/messages/ca/zii.php b/web/framework/messages/ca/zii.php similarity index 100% rename from web/framework-1.1.17/messages/ca/zii.php rename to web/framework/messages/ca/zii.php diff --git a/web/framework-1.1.17/messages/config.php b/web/framework/messages/config.php similarity index 100% rename from web/framework-1.1.17/messages/config.php rename to web/framework/messages/config.php diff --git a/web/framework-1.1.17/messages/cs/yii.php b/web/framework/messages/cs/yii.php similarity index 100% rename from web/framework-1.1.17/messages/cs/yii.php rename to web/framework/messages/cs/yii.php diff --git a/web/framework-1.1.17/messages/cs/zii.php b/web/framework/messages/cs/zii.php similarity index 100% rename from web/framework-1.1.17/messages/cs/zii.php rename to web/framework/messages/cs/zii.php diff --git a/web/framework-1.1.17/messages/da/yii.php b/web/framework/messages/da/yii.php similarity index 100% rename from web/framework-1.1.17/messages/da/yii.php rename to web/framework/messages/da/yii.php diff --git a/web/framework-1.1.17/messages/da/zii.php b/web/framework/messages/da/zii.php similarity index 100% rename from web/framework-1.1.17/messages/da/zii.php rename to web/framework/messages/da/zii.php diff --git a/web/framework-1.1.17/messages/de/yii.php b/web/framework/messages/de/yii.php similarity index 100% rename from web/framework-1.1.17/messages/de/yii.php rename to web/framework/messages/de/yii.php diff --git a/web/framework-1.1.17/messages/de/zii.php b/web/framework/messages/de/zii.php similarity index 100% rename from web/framework-1.1.17/messages/de/zii.php rename to web/framework/messages/de/zii.php diff --git a/web/framework-1.1.17/messages/el/yii.php b/web/framework/messages/el/yii.php similarity index 100% rename from web/framework-1.1.17/messages/el/yii.php rename to web/framework/messages/el/yii.php diff --git a/web/framework-1.1.17/messages/el/zii.php b/web/framework/messages/el/zii.php similarity index 100% rename from web/framework-1.1.17/messages/el/zii.php rename to web/framework/messages/el/zii.php diff --git a/web/framework-1.1.17/messages/es/yii.php b/web/framework/messages/es/yii.php similarity index 100% rename from web/framework-1.1.17/messages/es/yii.php rename to web/framework/messages/es/yii.php diff --git a/web/framework-1.1.17/messages/es/zii.php b/web/framework/messages/es/zii.php similarity index 100% rename from web/framework-1.1.17/messages/es/zii.php rename to web/framework/messages/es/zii.php diff --git a/web/framework-1.1.17/messages/fa_ir/yii.php b/web/framework/messages/fa_ir/yii.php similarity index 100% rename from web/framework-1.1.17/messages/fa_ir/yii.php rename to web/framework/messages/fa_ir/yii.php diff --git a/web/framework-1.1.17/messages/fa_ir/zii.php b/web/framework/messages/fa_ir/zii.php similarity index 100% rename from web/framework-1.1.17/messages/fa_ir/zii.php rename to web/framework/messages/fa_ir/zii.php diff --git a/web/framework-1.1.17/messages/fi/yii.php b/web/framework/messages/fi/yii.php similarity index 100% rename from web/framework-1.1.17/messages/fi/yii.php rename to web/framework/messages/fi/yii.php diff --git a/web/framework-1.1.17/messages/fi/zii.php b/web/framework/messages/fi/zii.php similarity index 100% rename from web/framework-1.1.17/messages/fi/zii.php rename to web/framework/messages/fi/zii.php diff --git a/web/framework-1.1.17/messages/fr/yii.php b/web/framework/messages/fr/yii.php similarity index 97% rename from web/framework-1.1.17/messages/fr/yii.php rename to web/framework/messages/fr/yii.php index e6fdb682f..df2c86e69 100644 --- a/web/framework-1.1.17/messages/fr/yii.php +++ b/web/framework/messages/fr/yii.php @@ -69,10 +69,10 @@ 'CDbAuthManager.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'La propriété CDbAuthManager.connectionID « {id} » est invalide. Vérifiez qu\'elle référence l\'ID d\'un composant d\'application de type CDbConnection.', 'CDbCache.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'La propriété CDbCache.connectionID « {id} » est invalide. Vérifiez qu\'elle référence l\'ID d\'un composant d\'application de type CDbConnection.', 'CDbCacheDependency.sql cannot be empty.' => 'La propriété CDbCacheDependency.sql ne peut être vide.', - 'CDbCommand failed to execute the SQL statement: {error}' => 'CDbCommand n\'a pas pu exécuter la commande SQL : {error}', - 'CDbCommand failed to prepare the SQL statement: {error}' => 'CDbCommand n\'a pas pu préparer la commande SQL : {error}', - 'CDbConnection does not support reading schema for {driver} database.' => 'CDbConnection ne supporte pas la lecture du schéma de la base de données {driver}.', - 'CDbConnection failed to open the DB connection: {error}' => 'CDbConnection n\'a pu ouvrir la connexion à la base de données : {error}', + 'CDbCommand failed to execute the SQL statement: {error}' => 'CDbCommand n\'a pas pu exécuter la commande SQL: {error}', + 'CDbCommand failed to prepare the SQL statement: {error}' => 'CDbCommand n\'a pas pu préparer la commande SQL: {error}', + 'CDbConnection does not support reading schema for {driver} database.' => 'CDbConnection ne supporte pas la lecture de schéma pour les bases de données {driver}.', + 'CDbConnection failed to open the DB connection: {error}' => 'CDbConnection n\'a pu ouvrir la connexion à la base de données: {error}', 'CDbConnection is inactive and cannot perform any DB operations.' => 'CDbConnection est inactive et ne peut effectuer aucune opération sur la base de données.', 'CDbConnection.connectionString cannot be empty.' => 'La propriété CDbConnection.connectionString ne peut être vide.', 'CDbDataReader cannot rewind. It is a forward-only reader.' => 'CDbDataReader ne peut reculer. Seule la lecture en avant est possible.', @@ -111,9 +111,9 @@ 'Cannot add "{name}" as a child of itself.' => 'Impossible d\'ajouter « {name} » en tant qu\'enfant de lui-même.', 'Cannot add an item of type "{child}" to an item of type "{parent}".' => 'Impossible d\'ajouter un élément de type « {child} » à un élément de type « {parent} ».', 'Column name must be either a string or an array.' => 'Le nom de la colonne doit être une chaine de caractères ou un tableau.', - 'Either "{parent}" or "{child}" does not exist.' => 'Soit « {parent} » soit « {child} » n\'existe pas.', - 'Error: Table "{table}" does not have a primary key.' => 'Erreur : la table « {table} » n\'a pas de clef primaire.', - 'Error: Table "{table}" has a composite primary key which is not supported by crud command.' => 'Erreur : la table « {table} » a une clef primaire composite qui n\'est pas supportée par les commandes CRUD.', + 'Either "{parent}" or "{child}" does not exist.' => '« {parent} » ou « {child} » est inexistant.', + 'Error: Table "{table}" does not have a primary key.' => 'Erreur: la table « {table} » n\'a pas de clef primaire.', + 'Error: Table "{table}" has a composite primary key which is not supported by crud command.' => 'Erreur: la table « {table} » a une clef primaire composite qui n\'est pas supportée par les commandes CRUD.', 'Event "{class}.{event}" is attached with an invalid handler "{handler}".' => 'L\'événement « {class}.{event} » est associé à un gestionnaire d\'événement « {handler} » invalide.', 'Event "{class}.{event}" is not defined.' => 'L\'événement « {class}.{event} » n\'est pas défini.', 'Extension path "{path}" does not exist.' => 'Le chemin d\'accès « {path} » de l\'extension n\'existe pas.', @@ -121,7 +121,7 @@ 'File upload was stopped by extension.' => 'Le téléchargement a été stoppé par l\'extension.', 'Filter "{filter}" is invalid. Controller "{class}" does have the filter method "filter{filter}".' => 'Le filtre « {filter} » est invalide. Le contrôleur « {class} » possède la méthode de filtrage « filter{filter} ».', 'Get a new code' => 'Récupérez un nouveau code', - 'Go to page: ' => 'Aller à la page :', + 'Go to page: ' => 'Aller à la page:', 'Invalid MO file revision: {revision}.' => 'Version du fichier MO invalide: {revision}.', 'Invalid MO file: {file} (magic: {magic}).' => 'Fichier MO invalide: {file} (magic: {magic}).', 'Invalid enumerable value "{value}". Please make sure it is among ({enum}).' => 'Valeur « {value} » invalide. Vérifiez qu\'elle fait partie de ({enum}).', @@ -136,7 +136,7 @@ 'No columns are being updated for table "{table}".' => 'Aucune colonne de la table « {table} » ne sera mise à jour.', 'No counter columns are being updated for table "{table}".' => 'Aucune colonne incrémentale de la table « {table} » ne sera mise à jour.', 'Object configuration must be an array containing a "class" element.' => 'L\'objet configuration doit être un tableau contenant un élément « class ».', - 'Please fix the following input errors:' => 'Veuillez corriger les erreurs de saisie :', + 'Please fix the following input errors:' => 'Veuillez corriger les erreurs de saisie:', 'Property "{class}.{property}" is not defined.' => 'La propriété « {class}.{property} » est indéfinie.', 'Property "{class}.{property}" is read only.' => 'La propriété « {class}.{property} » est en lecture seule.', 'Queue data must be an array or an object implementing Traversable.' => 'Les données de la queue doivent être un tableau ou un objet qui implémente Traversable.', @@ -155,7 +155,7 @@ 'The asset "{asset}" to be published does not exist.' => 'L\'asset « {asset} » à publier n\'existe pas.', 'The command path "{path}" is not a valid directory.' => 'Le chemin d\'accès « {path} » à la ligne de commande n\'est pas un dossier valide.', 'The controller path "{path}" is not a valid directory.' => 'Le chemin d\'accès « {path} » au contrôleur n\'est pas un dossier valide.', - 'The file "{file}" cannot be uploaded. Only files with these extensions are allowed: {extensions}.' => 'Le fichier « {file} » ne peut être téléchargé. Les extensions de fichier autorisées sont : {extensions}.', + 'The file "{file}" cannot be uploaded. Only files with these extensions are allowed: {extensions}.' => 'Le fichier « {file} » ne peut être téléchargé. Les extensions de fichier autorisées sont: {extensions}.', 'The file "{file}" is too large. Its size cannot exceed {limit} bytes.' => 'Le fichier « {file} » est trop gros. Sa taille ne peut être supérieure à {limit} octets.', 'The file "{file}" is too small. Its size cannot be smaller than {limit} bytes.' => 'Le fichier « {file} » est trop petit. Sa taille ne peut être inférieure à {limit} octets.', 'The file "{file}" was only partially uploaded.' => 'Le fichier « {file} » a été téléchargé partiellement.', @@ -182,8 +182,8 @@ 'The pattern for week in month must be "W".' => 'Le motif de définition du numéro de semaine dans le mois doit être « W ».', 'The pattern for week in year must be "w".' => 'Le motif de définition du numéro de semaine dans l\'année doit être « w ».', 'The queue is empty.' => 'La queue est vide.', - 'The relation "{relation}" in active record class "{class}" is not specified correctly. The join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'La relation « {relation} » dans la classe Active record « {class} » n\'est pas définie correctement. La table de jointure « {joinTable} » donnée par la clef étrangère n\'a pas été trouvée dans la base de données.', - 'The relation "{relation}" in active record class "{class}" is not specified correctly: the join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'La relation « {relation} » définie dans la classe Active record « {class} » est incorrecte : la table de jointure « {joinTable} » spécifiée par la clef étrangère est introuvable dans la base de données.', + 'The relation "{relation}" in active record class "{class}" is not specified correctly. The join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'La relation « {relation} » dans la classe Active record « {class} » n\'est pas définie correctement. La table de jointure « {joinTable} » donnée de la clef étrangère n\'est pas trouvée dans la base de données.', + 'The relation "{relation}" in active record class "{class}" is not specified correctly: the join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'La relation « {relation} » définie dans la classe Active record « {class} » est incorrecte: la table de jointure « {joinTable} » spécifiée par la clef étrangère est introuvable dans la base de données.', 'The relation "{relation}" in active record class "{class}" is specified with a foreign key "{key}" that does not point to the parent table "{table}".' => 'La relation « {relation} » dans la classe Active record « {class} » est définie avec la clef étrangère « {key} » qui ne pointe pas vers la table parente « {table} ».', 'The relation "{relation}" in active record class "{class}" is specified with an incomplete foreign key. The foreign key must consist of columns referencing both joining tables.' => 'La relation « {relation} » définie dans l\'active record « {class} » a une clef étrangère incomplète. La clef étrangère doit être constituée de colonnes qui font référence aux deux tables jointes.', 'The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key "{key}". There is no such column in the table "{table}".' => 'La relation « {relation} » définie dans la classe active record « {class} » a une clef étrangère « {key} » invalide. Cette colonne n\'existe pas dans la table « {table} ».', @@ -221,10 +221,10 @@ '{attribute} is not a valid email address.' => '{attribute} n\'est pas une adresse email valide.', '{attribute} is not in the list.' => '{attribute} n\'est pas dans la liste.', '{attribute} is of the wrong length (should be {length} characters).' => '{attribute} n\'est pas de la bonne longueur ({length} caractères autorisés).', - '{attribute} is too big (maximum is {max}).' => '{attribute} est trop grand (maximum : {max}).', - '{attribute} is too long (maximum is {max} characters).' => '{attribute} est trop long (maximum : {max} caractères).', - '{attribute} is too short (minimum is {min} characters).' => '{attribute} est trop court (minimum : {min} caractères).', - '{attribute} is too small (minimum is {min}).' => '{attribute} est trop petit (minimum : {min}).', + '{attribute} is too big (maximum is {max}).' => '{attribute} est trop grand (maximum: {max}).', + '{attribute} is too long (maximum is {max} characters).' => '{attribute} est trop long (maximum: {max} caractères).', + '{attribute} is too short (minimum is {min} characters).' => '{attribute} est trop court (minimum: {min} caractères).', + '{attribute} is too small (minimum is {min}).' => '{attribute} est trop petit (minimum: {min}).', '{attribute} must be a number.' => '{attribute} doit être un nombre.', '{attribute} must be an integer.' => '{attribute} doit être un entier.', '{attribute} must be either {true} or {false}.' => '{attribute} doit être soit {true} soit {false}.', diff --git a/web/framework-1.1.17/messages/fr/zii.php b/web/framework/messages/fr/zii.php similarity index 100% rename from web/framework-1.1.17/messages/fr/zii.php rename to web/framework/messages/fr/zii.php diff --git a/web/framework-1.1.17/messages/he/yii.php b/web/framework/messages/he/yii.php similarity index 100% rename from web/framework-1.1.17/messages/he/yii.php rename to web/framework/messages/he/yii.php diff --git a/web/framework-1.1.17/messages/he/zii.php b/web/framework/messages/he/zii.php similarity index 100% rename from web/framework-1.1.17/messages/he/zii.php rename to web/framework/messages/he/zii.php diff --git a/web/framework/messages/hr/yii.php b/web/framework/messages/hr/yii.php new file mode 100644 index 000000000..d41e4d90f --- /dev/null +++ b/web/framework/messages/hr/yii.php @@ -0,0 +1,231 @@ + '0', + 'Virtual attribute {name} must specify "asc" and "desc" options.' => 'Virtualni atribut {name} mora specificirati "asc"- i "desc" opcije.', + '"{path}" is not a valid directory.' => '"{path}" nije važeći direktorij.', + '< Previous' => '< Prethodna', + '<< First' => '<< Prva', + 'Active Record requires a "db" CDbConnection application component.' => 'ActiveRecord zahtjeva "db" CDbConnection aplikacijsku komponentu.', + 'Active record "{class}" has an invalid configuration for relation "{relation}". It must specify the relation type, the related active record class and the foreign key.' => 'ActiveRecord-Klasa "{class}" ima nevažeću konfiguraciju za odnos "{relation}". Tipa odnosa, odnosni ActiveRecord i strani kljuÄ (foreign key) moraju biti postavljeni.', + 'Active record "{class}" is trying to select an invalid column "{column}". Note, the column must exist in the table or be an expression with alias.' => 'ActiveRecord "{class}" koristi nevažeće polje "{column}" u SELECT. Pripazite da to polje mora da postoji u tabeli ili da bude alias izraz.', + 'Active record class "{class}" does not have a scope named "{scope}".' => 'ActiveRecord-Klasa "{class}" nema polje imenovano "{scope}".', + 'Alias "{alias}" is invalid. Make sure it points to an existing directory or file.' => 'Alias "{alias}" je validan. Molim vas, uspostavite da pokazuje do važećeg direktorija ili fajla.', + 'Application base path "{path}" is not a valid directory.' => 'Glavni put (base path) "{path}" aplikacije nije važeći.', + 'Application runtime path "{path}" is not valid. Please make sure it is a directory writable by the Web server process.' => 'Prometni put (runtime path) "{path}" aplikacije je nevažan. Pripazite da proces web servera ima pravo da tamo piÅ¡e.', + 'Authorization item "{item}" has already been assigned to user "{user}".' => 'Element autorizacije "{item}" je već namjenjen korisniku "{user}".', + 'Base path "{path}" is not a valid directory.' => 'Glavni put "{path}" je nevažeći direktorijum.', + 'CApcCache requires PHP apc extension to be loaded.' => 'CApcCache zahtjeva da je uÄitan PHP APC dodatak.', + 'CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.' => 'CAssetManager.basePath "{path}" nije važeća. Pripazite da postoji taj direktorijum i da proces web servera ima pravo da tamo piÅ¡e.', + 'CCacheHttpSession.cacheID is invalid. Please make sure "{id}" refers to a valid cache application component.' => 'CCacheHttpSession.cacheID nije važeća. Molim vas, uspostavite da se "{id}" odnosi na važeću cache aplikacionu komponentu.', + 'CCaptchaValidator.action "{id}" is invalid. Unable to find such an action in the current controller.' => 'CCaptchaValidator.action "{id}" nije važeća. Ne mogu da pronaÄ‘em takvu akciju u trenutnom controlleru.', + 'CDbAuthManager.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbAuthManager.connectionID "{id}" nije važeća. Molimo vas, uspostavite da se "{id}" odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbCache.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbCache.connectionID "{id}" nije važeća. Molimo vas, uspostavite da se odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbCacheDependency.sql cannot be empty.' => 'CDbCacheDependency.sql ne smije biti prazno.', + 'CDbCommand failed to execute the SQL statement: {error}' => 'CDbCommand ne može da izvrÅ¡i SQL-Statement: {error}', + 'CDbCommand failed to prepare the SQL statement: {error}' => 'CDbCommand ne može da pripremi SQL-Statement: {error}', + 'CDbConnection does not support reading schema for {driver} database.' => 'CDbConnection ne podržava Äitanje Å¡ema za {driver}-datoteke.', + 'CDbConnection failed to open the DB connection: {error}' => 'CDbConnection ne može da uspostavi spoj sa datotekom: {error}', + 'CDbConnection is inactive and cannot perform any DB operations.' => 'CDbConnection nije aktivna i ne može izvrÅ¡avati operacije na datoteci.', + 'CDbConnection.connectionString cannot be empty.' => 'CDbConnection.connectionString ne smije biti prazno.', + 'CDbDataReader cannot rewind. It is a forward-only reader.' => 'CDbDataReader se ne može premotavati. On je forward-only (samo naprijed) ÄitaÄ.', + 'CDbHttpSession.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbHttpSession.connectionID "{id}" nije važeća. Molimo vas, uspostavite da se "{id}" odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbLogRoute.connectionID "{id}" does not point to a valid CDbConnection application component.' => 'CDbLogRoute.connectionID "{id}" ne pokazuje na važeću aplikacijsku komponentu od tipa Typ CDbConnection.', + 'CDbMessageSource.connectionID is invalid. Please make sure "{id}" refers to a valid database application component.' => 'CDbMessageSource.connectionID je nevažna. Molimo vas, uspostavite da se "{id}" odnosi na važeću aplikacijsku komponentu tipa CDbConnection.', + 'CDbTestFixture.connectionID "{id}" is invalid. Please make sure it refers to the ID of a CDbConnection application component.' => 'CDbFixture.connectionID "{id}" je nevažeća. Molim vas, uspostavite da se odnosi na važeću aplikacionu komponentu tipa CDbConnection.', + 'CDbTransaction is inactive and cannot perform commit or roll back operations.' => 'CDbTransaction nije aktivno i ne može da izvrÅ¡i Commit- ili Rollback operaciju.', + 'CDirectoryCacheDependency.directory cannot be empty.' => 'CDirectoryCacheDependency.directory ne smije biti prazno.', + 'CEAcceleratorCache requires PHP eAccelerator extension to be loaded, enabled or compiled with the "--with-eaccelerator-shared-memory" option.' => 'CEAcceleratorCache zahtjeva da je PHP eAccelerator dodatak uÄitan i aktiviran ili se kompajlira sa opcijom "--with-eaccelerator-shared-memory".', + 'CFileCacheDependency.fileName cannot be empty.' => 'CFileCacheDependency.fileName ne smije biti prazno.', + 'CFileLogRoute.logPath "{path}" does not point to a valid directory. Make sure the directory exists and is writable by the Web server process.' => 'CFileLogRoute.logPath "{path}" ne pokazuje na nevažeći direktorij. Pripazite da postoji taj direktorij i da proces web servera ima pravo da tamo piÅ¡e.', + 'CFilterChain can only take objects implementing the IFilter interface.' => 'CFilterChain smije primiti samo objekte koje implementiraju IFilter-Interface.', + 'CFlexWidget.baseUrl cannot be empty.' => 'CFlexWidget.baseUrl ne smije biti prazno.', + 'CFlexWidget.name cannot be empty.' => 'CFlexWidget.name ne smije biti prazno.', + 'CGlobalStateCacheDependency.stateName cannot be empty.' => 'CGlobalStateCacheDependency.stateName ne smije biti prazno.', + 'CHttpCookieCollection can only hold CHttpCookie objects.' => 'CHttpCookieCollection smije da sadrži samo CHttpCookie-Objekte.', + 'CHttpRequest is unable to determine the entry script URL.' => 'CHttpRequest ne može da ustanovi URL ulaznog skripta (entry script).', + 'CHttpRequest is unable to determine the path info of the request.' => 'CHttpRequest ne može da ustanovi informacije o putu (path info) za tekući zahtjev (request).', + 'CHttpRequest is unable to determine the request URI.' => 'CHttpRequest ne može da ustanovi URI za tekući zahtjev (request).', + 'CHttpSession.cookieMode can only be "none", "allow" or "only".' => 'CHttpSession.cookieMode može biti jedino "none", "allow" ili "only".', + 'CHttpSession.gcProbability "{value}" is invalid. It must be an integer between 0 and 100.' => 'CHttpSession.gcProbability "{value}" je pogreÅ¡an. Mora biti cijeli broj (integer) izmeÄ‘u 0 i 100.', + 'CHttpSession.savePath "{path}" is not a valid directory.' => 'CHttpSession.savePath "{path}" nije ispravan direktorij.', + 'CMemCache server configuration must be an array.' => 'CMemCache server konfiguracija mora biti niz (array)', + 'CMemCache server configuration must have "host" value.' => 'CMemCache server konfiguracija mora imati dodjeljenu vrijednost za "host".', + 'CMultiFileUpload.name is required.' => 'CMultiFileUpload.name je obavezno.', + 'CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.' => 'CProfileLogRoute je naÅ¡ao neusaglaÅ¡en blok koda "{token}". Budite sigurni da su pozivi Yii::beginProfile() i Yii::endProfile() ispravno ugnježdeni.', + 'CProfileLogRoute.report "{report}" is invalid. Valid values include "summary" and "callstack".' => 'CProfileLogRoute.report "{report}" je pogreÅ¡an. Ispravne vrijednosti ukljuÄuju "summary" i "callstack".', + 'CSecurityManager requires PHP mcrypt extension to be loaded in order to use data encryption feature.' => 'CSecurityManager zahtjeva da PHP mcrypt ekstenzija bude ukljuÄena da bi se koristila mogućnost enkripcije podataka.', + 'CSecurityManager.encryptionKey cannot be empty.' => 'CSecurityManager.encryptionKey ne može biti prazan.', + 'CSecurityManager.validation must be either "MD5" or "SHA1".' => 'CSecurityManager.validation mora biti "MD5" ili "SHA1".', + 'CSecurityManager.validationKey cannot be empty.' => 'CSecurityManager.validationKey ne može biti prazan', + 'CTypedList<{type}> can only hold objects of {type} class.' => 'CTypedList<{type}> može da sadrži jedino objekte {type} klase.', + 'CUrlManager.UrlFormat must be either "path" or "get".' => 'CUrlManager.UrlFormat mora biti "path" ili "get".', + 'CXCache requires PHP XCache extension to be loaded.' => 'CXCache zahtjeva da ekstenzija PHP XCache bude uÄitana.', + 'CZendDataCache requires PHP Zend Data Cache extension to be loaded.' => 'CZendDataCache zahtjeva da ekstenzija PHP Zend Cache bude uÄitana.', + 'Cannot add "{child}" as a child of "{name}". A loop has been detected.' => 'Ne mogu da dodam "{child}" kao dijete od "{name}". Detektovana je petlja.', + 'Cannot add "{child}" as a child of "{parent}". A loop has been detected.' => 'Ne mogu da dodam "{child}" kao dijete od "{parent}". Detektovana je petlja.', + 'Cannot add an item of type "{child}" to an item of type "{parent}".' => 'Ne mogu da dodam stavku (item) tipa "{child}" u stavku (item) tipa "{parent}".', + 'Cannot add "{name}" as a child of itself.' => 'Ne mogu da dodam "{name}" kao svoje dijete.', + 'Column "{column} does not exist in table "{table}".' => 'Kolona "{column}" ne postoji u tabeli "{table}".', + 'Column name must be either a string or an array.' => 'Ime kolone mora biti string ili array.', + 'Either "{parent}" or "{child}" does not exist.' => 'Ni "{parent}" ni "{child}" ne postoje.', + 'Error: Table "{table}" does not have a primary key.' => 'GreÅ¡ka: Tabela "{table}" nema primarni kljuÄ (primary key).', + 'Error: Table "{table}" has a composite primary key which is not supported by crud command.' => 'GreÅ¡ka: Tabela "{table}" ima kompozitni primarni kljuÄ (composite primary key) koji nije podržan od strane "crud" komande.', + 'Event "{class}.{event}" is attached with an invalid handler "{handler}".' => 'DogaÄ‘aj "{class}.{event}" je zakaÄen za pogreÅ¡an (nevažeći) hendler (handler) "{handler}".', + 'Event "{class}.{event}" is not defined.' => 'DogaÄ‘aj (event) "{class}.{event}" nije definisan.', + 'Extension path "{path}" does not exist.' => 'Put dodataka (extension path) "{path}" ne postoji.', + 'Failed to write the uploaded file "{file}" to disk.' => 'NeuspjeÅ¡no snimanje uploadovanog fajla (uploaded file) "{file}" na disk.', + 'File upload was stopped by extension.' => 'Upload fajla (file upload) je zaustavljeno od strane ekstenzije.', + 'Filter "{filter}" is invalid. Controller "{class}" does have the filter method "filter{filter}".' => 'Filter "{filter}" je pogreÅ¡an. Kontroler "{class}" sadrži filter metod "filter{filter}".', + 'Get a new code' => 'Dobavi novi kod', + 'Go to page: ' => 'Idi na stranicu: ', + 'Invalid MO file revision: {revision}.' => 'PogreÅ¡na revizija MO fajla: {revision}.', + 'Invalid MO file: {file} (magic: {magic}).' => 'PogreÅ¡an (neispravan) MO fajl: {file} (magic: {magic}).', + 'Invalid enumerable value "{value}". Please make sure it is among ({enum}).' => 'PogreÅ¡na nabrojiva vrijednost "{value}". Molim vas, budite sigurni da je iz ({enum}).', + 'Invalid operator "{operator}".' => 'Nevažeći operator "{operator}".', + 'Last >>' => 'Zadnja >>', + 'List data must be an array or an object implementing Traversable.' => 'Podatak liste (List data) mora biti niz ili objekat koji implementira Traversable.', + 'List index "{index}" is out of bound.' => 'Indeks liste "{index}" je van opsega.', + 'Login Required' => 'Potrebna prijava', + 'Map data must be an array or an object implementing Traversable.' => 'Podatak mape (Map data) mora biti niz ili objekat koji implementira Traversable.', + 'Missing the temporary folder to store the uploaded file "{file}".' => 'Nedostaje privremeni folder za spremanje uÄitanog fajla "{file}".', + 'Next >' => 'Sljedeća >', + 'No columns are being updated for table "{table}".' => 'Nijedna kolona neće biti ažurirana u tabeli "{table}".', + 'No counter columns are being updated for table "{table}".' => 'BrojaÄ kolona neće biti ažuriran za tabelu "{table}".', + 'Object configuration must be an array containing a "class" element.' => 'Konfiguracija objekta mora biti niz koji sadrži "class" element.', + 'Please fix the following input errors:' => 'Molim vas ispravite greÅ¡ke:', + 'Property "{class}.{property}" is not defined.' => 'Svojstvo (property) "{class}.{property}" nije definisano.', + 'Property "{class}.{property}" is read only.' => 'Svojstvo (property) "{class}.{property}" je samo za Äitanje.', + 'Queue data must be an array or an object implementing Traversable.' => 'Podatak reda (Queue data) mora biti niz ili objekat koji implementira Traversable.', + 'Relation "{name}" is not defined in active record class "{class}".' => 'Odnos "{name}" nije definisan u active record klasi "{class}".', + 'Resetting PK sequence is not supported.' => 'Ne podržava vraćanje PK sekvence.', + 'Setting integrity check is not supported.' => 'Ne podržava se aktivacija kontrole integracije postavki.', + 'Stack data must be an array or an object implementing Traversable.' => 'Podatak sa steka (Stack data) mora biti niz ili objekat koji implementira Traversable.', + 'Table "{table}" does not have a column named "{column}".' => 'Tabela "{table}" ne posjeduje kolonu "{column}".', + 'Table "{table}" does not have a primary key defined.' => 'Tabela "{table}" nema definisan primarni kljuÄ (primary key).', + 'The "filter" property must be specified with a valid callback.' => '"Filter" svojstvo (property) mora biti specificirano povratnom funkcijom (callback).', + 'The "pattern" property must be specified with a valid regular expression.' => '"Pattern" svojstvo (property) mora biti specificirano ispravnim regularnim izrazom (regular expression).', + 'The "view" property is required.' => '"view" svojstvo (property) je obavezno.', + 'The CSRF token could not be verified.' => 'CSRF token ne može biti potvrÄ‘en (verifikovan).', + 'The URL pattern "{pattern}" for route "{route}" is not a valid regular expression.' => 'URL Å¡ablon (pattern) "{pattern}" za rutu "{route}" nije ispravan regularni izraz (regular expression).', + 'The active record cannot be deleted because it is new.' => 'Active record ne može biti izbrisan zato Å¡to je nov.', + 'The active record cannot be inserted to database because it is not new.' => 'Active record ne može biti ubaÄen u bazu zato Å¡to je nov.', + 'The active record cannot be updated because it is new.' => 'Active record ne može biti ažuriran zato Å¡to je nov.', + 'The asset "{asset}" to be pulished does not exist.' => 'Resurs "{asset}" koji treba biti objavljen ne postoji.', + 'The command path "{path}" is not a valid directory.' => 'Put direktorija do komande (command path) "{path}" nije ispravan.', + 'The controller path "{path}" is not a valid directory.' => 'Put direktorija do kontrolera "{path}" nije ispravan.', + 'The file "{file}" cannot be uploaded. Only files with these extensions are allowed: {extensions}.' => 'Fajl "{file}" ne može biti podignut (uploaded). Dozvoljeni su jedino fajlovi sa slijedećim ekstenzijama: {extensions}.', + 'The file "{file}" is too large. Its size cannot exceed {limit} bytes.' => 'Fajl "{file}" je prevelik. VeliÄina fajla ne smije da prekoraÄi {limit} bytes.', + 'The file "{file}" is too small. Its size cannot be smaller than {limit} bytes.' => 'Fajl "{file}" je premali. VeliÄina fajla ne smije biti manja od {limit} bytes.', + 'The file "{file}" was only partially uploaded.' => 'Fajl "{file}" je samo djelimiÄno uÄitan (uploaded).', + 'The first element in a filter configuration must be the filter class.' => 'Prvi element u konfiguraciji filtera mora biti klasa filtera.', + 'The item "{name}" does not exist.' => 'Stavka "{name}" ne postoji.', + 'The item "{parent}" already has a child "{child}".' => 'Stavka "{parent}" već ima dijete "{child}".', + 'The layout path "{path}" is not a valid directory.' => 'Put do direktorija layout "{path}" nije ispravan.', + 'The list is read only.' => 'Lista (List) je samo za Äitanje', + 'The map is read only.' => 'Mapa (Map) je samo za Äitanje', + 'The module path "{path}" is not a valid directory.' => 'Put do modula "{path}" je nevažeći direktorijum.', + 'The pattern for 12 hour format must be "h" or "hh".' => 'Å ablon za 12 Äasovni format mora biti "h" ili "hh".', + 'The pattern for 24 hour format must be "H" or "HH".' => 'Å ablon za 24 Äasovni format mora biti "H" ili "HH".', + 'The pattern for AM/PM marker must be "a".' => 'Å ablona za AM/PM marker mora biti "a".', + 'The pattern for day in month must be "F".' => 'Å ablona za dan u mjesecu mora biti "F".', + 'The pattern for day in year must be "D", "DD" or "DDD".' => 'Å ablon za dan u godini mora biti "D", "DD" ili "DDD".', + 'The pattern for day of the month must be "d" or "dd".' => 'Å ablon za dan mjeseca mora biti "d" ili "dd".', + 'The pattern for day of the week must be "E", "EE", "EEE", "EEEE" or "EEEEE".' => 'Å ablon za dan sedmice mora biti "E", "EE", "EEE", "EEEE" ili "EEEEE".', + 'The pattern for era must be "G", "GG", "GGG", "GGGG" or "GGGGG".' => 'Å ablon za doba mora biti "G", "GG", "GGG", "GGGG" ili "GGGGG".', + 'The pattern for hour in AM/PM must be "K" or "KK".' => 'Å ablon za Äas u AM/PM mora biti "K" ili "KK".', + 'The pattern for hour in day must be "k" or "kk".' => 'Å ablon za Äas u danu mora biti "k" ili "kk".', + 'The pattern for minutes must be "m" or "mm".' => 'Å ablon za minute mora biti "m" ili "mm".', + 'The pattern for month must be "M", "MM", "MMM", or "MMMM".' => 'Å ablon za mjesec mora biti "M", "MM", "MMM" ili "MMMM".', + 'The pattern for seconds must be "s" or "ss".' => 'Å ablon za sekunde mora biti "s" ili "ss".', + 'The pattern for time zone must be "z" or "v".' => 'Å ablon za zonu mora biti "z" ili "v".', + 'The pattern for week in month must be "W".' => 'Å ablon za sedmicu u mjesecu mora biti "W".', + 'The pattern for week in year must be "w".' => 'Å ablon za sedmicu u godini mora biti "w".', + 'The queue is empty.' => 'Red (queue) je prazan.', + 'The relation "{relation}" in active record class "{class}" is not specified correctly: The join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'Odnos "{relation}" u active record klasi "{class}" nije specificirana ispravno: pridružena tabela (join table) "{joinTable}" zadata u spoljnom kljuÄu (foreign key) ne može biti pronaÄ‘ena u bazi.', + 'The relation "{relation}" in active record class "{class}" is not specified correctly: the join table "{joinTable}" given in the foreign key cannot be found in the database.' => 'Odnos "{relation}" u active record klasi "{class}" nije specificirana ispravno: pridružena tabela (join table) "{joinTable}" zadata u spoljnom kljuÄu (foreign key) ne može biti pronaÄ‘ena u bazi.', + 'The relation "{relation}" in active record class "{class}" is specified with a foreign key "{key}" that does not point to the parent table "{table}".' => 'Odnos "{relation}" u active record klasi "{class}" je ispisan sa spoljnim kljuÄem "{key}", koji ne prikazuje na tabelu "{table}".', + 'The relation "{relation}" in active record class "{class}" is specified with an incomplete foreign key. The foreign key must consist of columns referencing both joining tables.' => 'Odnos "{relation}" u active record klasi "{class}" je specificirana sa nekompletnim spoljnim kljuÄem (foreign key). Spoljni kljuÄ (foreign key) mora se sastojati od kolona koje referenciraju obadvije tabele za spajanje (joining tables).', + 'The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key "{key}". The foreign key does not point to either joining table.' => 'Odnos "{relation}" u active record klasi "{class}" je specificirana pogreÅ¡nim spoljnim kljuÄem (foreign key) "{key}". Spoljni kljuÄ (foreign key) ne pokazuje ni na jednu tabelu za spajanje (joining tables).', + 'The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key "{key}". There is no such column in the table "{table}".' => 'Odnos "{relation}" u active record klasi "{class}" je specificirana sa pogreÅ¡nim spoljnim kljuÄem "{key}". U tabeli "{table}" ne postoji takva kolona.', + 'The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key. The columns in the key must match the primary keys of the table "{table}".' => 'Odnos "{relation}" u active record klasi "{class}" je specificirana pogreÅ¡nim spoljnim kljuÄem (foreign key). Kolone spoljnog kljuÄa (foreign key) moraju biti iste kao i primarnog kljuÄa od tabele "{table}".', + 'The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key. The format of the foreign key must be "joinTable(fk1,fk2,...)".' => 'Odnos "{relation}" u active record klasi "{class}" je specificirana pogreÅ¡nim spoljnim kljuÄem (foreign key). Format spoljnog kljuÄa (foreign key) mora biti "joinTable(fk1,fk2,...)', + 'The requested view "{name}" was not found.' => 'zahtjevani pogled (view) "{name}" nije pronaÄ‘en.', + 'The stack is empty.' => 'Stek (stack) je prazna.', + 'The system is unable to find the requested action "{action}".' => 'Sistem ne može da pronaÄ‘e traženu akciju "{action}".', + 'The system view path "{path}" is not a valid directory.' => 'Put direktorija do sistemskog pogleda (system view) "{path}" nije ispravan.', + 'The table "{table}" for active record class "{class}" cannot be found in the database.' => 'Tabela "{table}" za active record klasu "{class}" ne može biti pronaÄ‘ena u bazi.', + 'The value for the primary key "{key}" is not supplied when querying the table "{table}".' => 'Vrijednost primarnog kljuÄa (primary key) "{key}" nije prosljeÄ‘ena prilikom izvrÅ¡enja upita nad tabelom "{table}".', + 'The verification code is incorrect.' => 'Verifikacioni kod je pogreÅ¡an.', + 'The view path "{path}" is not a valid directory.' => 'Put do prikaznog direktorija (view path) "{path}" nije važeći.', + 'Theme directory "{directory}" does not exist.' => 'Direktorijum za teme (theme directory) "{directory}" ne postoji.', + 'This content requires the Adobe Flash Player.' => 'Ovaj sadržaj zahtjeva Adobe Flash Player.', + 'Unable to add an item whose name is the same as an existing item.' => 'Ne mogu da dodam stavku sa istim imenom kao postojeća stavka.', + 'Unable to change the item name. The name "{name}" is already used by another item.' => 'Ne mogu da promjenim ime stavke (item name). Ime "{name}" već koristi neka druga stavka.', + 'Unable to create application state file "{file}". Make sure the directory containing the file exists and is writable by the Web server process.' => 'Ne mogu da kreiram aplikacioni fajl stanja (state file) "{file}". Budite sigurni da direktorijum koji sadrži fajl postoji i da je omogućeno pisanje od strane Web server procesa.', + 'Unable to lock file "{file}" for reading.' => 'Ne mogu da zakljuÄam fajl "{file}" za Äitanje.', + 'Unable to lock file "{file}" for writing.' => 'Ne mogu da zakljuÄam fajl "{file}" za upisivanje.', + 'Unable to read file "{file}".' => 'Ne mogu da proÄitam fajl "{file}".', + 'Unable to replay the action "{object}.{method}". The method does not exist.' => 'Ne mogu reproducirati (replay) "{object}.{method}". Metoda ne postoji.', + 'Unable to resolve the request "{route}".' => 'Ne mogu da rijeÅ¡im "{route}" zahtjev.', + 'Unable to write file "{file}".' => 'Ne mogu da upiÅ¡em fajl "{file}".', + 'Unknown authorization item "{name}".' => 'Nepoznata stavka ovlašćenja (authorization item) "{name}', + 'Unrecognized locale "{locale}".' => 'Lokalizacija nije prepoznata (unrecognized locale) "{locale}".', + 'View file "{file}" does not exist.' => 'View fajl "{file}" ne postoji.', + 'Yii application can only be created once.' => 'Yii aplikacija može biti kreirana samo jedanput.', + 'You are not authorized to perform this action.' => 'Niste autorizovani da izvrÅ¡ite ovu akciju.', + 'Your request is not valid.' => 'VaÅ¡ zahtjev nije ispravan.', + '{attribute} "{value}" has already been taken.' => '{attribute} "{value}" je već uzeta.', + '{attribute} "{value}" is invalid.' => '{attribute} "{value}" je pogreÅ¡an (neispravan).', + '{attribute} cannot accept more than {limit} files.' => '{attribute} ne prihvata viÅ¡e nego {limit} fajlova.', + '{attribute} cannot be blank.' => 'Morate popuniti polje {attribute}.', + '{attribute} is invalid.' => '{attribute} je pogreÅ¡an (neispravan).', + '{attribute} is not a valid URL.' => '{attribute} nije ispravan URL.', + '{attribute} is not a valid email address.' => '{attribute} nije ispravna email adresa.', + '{attribute} is not in the list.' => '{attribute} nije u listi.', + '{attribute} is of the wrong length (should be {length} characters).' => '{attribute} je pogreÅ¡ne dužine (treba biti {length} karaktera).', + '{attribute} is too big (maximum is {max}).' => '{attribute} je prevelik (maksimum je {max}).', + '{attribute} is too long (maximum is {max} characters).' => '{attribute} je predugaÄak (maksimum je {max} karaktera).', + '{attribute} is too short (minimum is {min} characters).' => '{attribute} je prekratak (minimum je {min} karaktera).', + '{attribute} is too small (minimum is {min}).' => '{attribute} je premali (minimum je {min}).', + '{attribute} must be a number.' => '{attribute} mora biti broj.', + '{attribute} must be an integer.' => '{attribute} mora biti cijeli broj (integer).', + '{attribute} must be either {true} or {false}.' => '{attribute} mora biti makar {true} ili {false}.', + '{attribute} must be greater than "{compareValue}".' => '{attribute} mora biti veći nego "{compareValue}".', + '{attribute} must be greater than or equal to "{compareValue}".' => '{attribute} mora biti veći nego "{compareValue}".', + '{attribute} must be less than "{compareValue}".' => '{attribute} mora biti manji nego "{compareValue}".', + '{attribute} must be less than or equal to "{compareValue}".' => '{attribute} mora biti manji ili isti nego "{compareValue}".', + '{attribute} must be repeated exactly.' => '{attribute} mora biti taÄno ponovljen.', + '{attribute} must be {type}.' => '{attribute} mora biti {type}.', + '{attribute} must be {value}.' => '{attribute} mora biti {value}.', + '{attribute} must not be equal to "{compareValue}".' => '{attribute} ne smije biti isti kao "{compareValue}".', + '{className} does not support add() functionality.' => '{className} ne podržava add() funcionalnost.', + '{className} does not support delete() functionality.' => '{className} ne podržava delete() funkcionalnost.', + '{className} does not support flush() functionality.' => '{className} ne podržava flush() funkcionalnost.', + '{className} does not support get() functionality.' => '{className} ne podržava get() funkcionalnost.', + '{className} does not support set() functionality.' => '{className} ne podržava set() funkcionalnost.', + '{class} does not have a method named "{name}".' => '{class} nema metode imenom "{name}".', + '{class} does not have relation "{name}".' => '{class} nema odnosa "{name}".', + '{class} does not support fetching all table names.' => '{class} ne podržava dobavljanje svih naziva tabela.', + '{class} has an invalid validation rule. The rule must specify attributes to be validated and the validator name.' => '{class} ima pogreÅ¡no ovjereno pravilo (validation rule). Pravilo mora da specificira atribute koji ce biti ovjereni i ime ovjerenja.', + '{class} must specify "model" and "attribute" or "name" property values.' => '{class} mora da specificira "model" i "attribute" ili "name" svojstvo (property) vrijednosti.', + '{class}.allowAutoLogin must be set true in order to use cookie-based authentication.' => '{class}.allowAutoLogin mora biti podeÅ¡en na true da bi se koristila cookies autorizacija.', + '{class}::authenticate() must be implemented.' => '{class}::authenticate() metoda mora biti implementirana.', + '{controller} cannot find the requested view "{view}".' => '{controller} ne može da pronaÄ‘e zahtjevani view "{view}".', + '{controller} contains improperly nested widget tags in its view "{view}". A {widget} widget does not have an endWidget() call.' => '{controller} sadrži nepropisno ugnježdene widget tagove u svom pogledu (view) "{view}". {widget} widget nema endWidget() poziv.', + '{controller} has an extra endWidget({id}) call in its view.' => '{controller} ima suviÅ¡an endWidget({id}) poziv u svom view-u.', + '{widget} cannot find the view "{view}".' => '{widget} ne može da pronaÄ‘e view "{view}".', +); \ No newline at end of file diff --git a/web/framework-1.1.17/messages/hu/yii.php b/web/framework/messages/hu/yii.php similarity index 100% rename from web/framework-1.1.17/messages/hu/yii.php rename to web/framework/messages/hu/yii.php diff --git a/web/framework-1.1.17/messages/hu/zii.php b/web/framework/messages/hu/zii.php similarity index 100% rename from web/framework-1.1.17/messages/hu/zii.php rename to web/framework/messages/hu/zii.php diff --git a/web/framework-1.1.17/messages/id/yii.php b/web/framework/messages/id/yii.php similarity index 100% rename from web/framework-1.1.17/messages/id/yii.php rename to web/framework/messages/id/yii.php diff --git a/web/framework-1.1.17/messages/id/zii.php b/web/framework/messages/id/zii.php similarity index 100% rename from web/framework-1.1.17/messages/id/zii.php rename to web/framework/messages/id/zii.php diff --git a/web/framework-1.1.17/messages/it/yii.php b/web/framework/messages/it/yii.php similarity index 100% rename from web/framework-1.1.17/messages/it/yii.php rename to web/framework/messages/it/yii.php diff --git a/web/framework-1.1.17/messages/it/zii.php b/web/framework/messages/it/zii.php similarity index 100% rename from web/framework-1.1.17/messages/it/zii.php rename to web/framework/messages/it/zii.php diff --git a/web/framework-1.1.17/messages/ja/yii.php b/web/framework/messages/ja/yii.php similarity index 100% rename from web/framework-1.1.17/messages/ja/yii.php rename to web/framework/messages/ja/yii.php diff --git a/web/framework-1.1.17/messages/ja/zii.php b/web/framework/messages/ja/zii.php similarity index 100% rename from web/framework-1.1.17/messages/ja/zii.php rename to web/framework/messages/ja/zii.php diff --git a/web/framework-1.1.17/messages/kk/yii.php b/web/framework/messages/kk/yii.php similarity index 100% rename from web/framework-1.1.17/messages/kk/yii.php rename to web/framework/messages/kk/yii.php diff --git a/web/framework-1.1.17/messages/kk/zii.php b/web/framework/messages/kk/zii.php similarity index 100% rename from web/framework-1.1.17/messages/kk/zii.php rename to web/framework/messages/kk/zii.php diff --git a/web/framework-1.1.17/messages/ko_kr/yii.php b/web/framework/messages/ko_kr/yii.php similarity index 100% rename from web/framework-1.1.17/messages/ko_kr/yii.php rename to web/framework/messages/ko_kr/yii.php diff --git a/web/framework-1.1.17/messages/ko_kr/zii.php b/web/framework/messages/ko_kr/zii.php similarity index 100% rename from web/framework-1.1.17/messages/ko_kr/zii.php rename to web/framework/messages/ko_kr/zii.php diff --git a/web/framework-1.1.17/messages/lt/yii.php b/web/framework/messages/lt/yii.php similarity index 100% rename from web/framework-1.1.17/messages/lt/yii.php rename to web/framework/messages/lt/yii.php diff --git a/web/framework-1.1.17/messages/lt/zii.php b/web/framework/messages/lt/zii.php similarity index 100% rename from web/framework-1.1.17/messages/lt/zii.php rename to web/framework/messages/lt/zii.php diff --git a/web/framework-1.1.17/messages/lv/yii.php b/web/framework/messages/lv/yii.php similarity index 100% rename from web/framework-1.1.17/messages/lv/yii.php rename to web/framework/messages/lv/yii.php diff --git a/web/framework-1.1.17/messages/lv/zii.php b/web/framework/messages/lv/zii.php similarity index 100% rename from web/framework-1.1.17/messages/lv/zii.php rename to web/framework/messages/lv/zii.php diff --git a/web/framework-1.1.17/messages/nl/yii.php b/web/framework/messages/nl/yii.php similarity index 100% rename from web/framework-1.1.17/messages/nl/yii.php rename to web/framework/messages/nl/yii.php diff --git a/web/framework-1.1.17/messages/nl/zii.php b/web/framework/messages/nl/zii.php similarity index 100% rename from web/framework-1.1.17/messages/nl/zii.php rename to web/framework/messages/nl/zii.php diff --git a/web/framework-1.1.17/messages/no/yii.php b/web/framework/messages/no/yii.php similarity index 100% rename from web/framework-1.1.17/messages/no/yii.php rename to web/framework/messages/no/yii.php diff --git a/web/framework-1.1.17/messages/no/zii.php b/web/framework/messages/no/zii.php similarity index 100% rename from web/framework-1.1.17/messages/no/zii.php rename to web/framework/messages/no/zii.php diff --git a/web/framework-1.1.17/messages/pl/yii.php b/web/framework/messages/pl/yii.php similarity index 100% rename from web/framework-1.1.17/messages/pl/yii.php rename to web/framework/messages/pl/yii.php diff --git a/web/framework-1.1.17/messages/pl/zii.php b/web/framework/messages/pl/zii.php similarity index 100% rename from web/framework-1.1.17/messages/pl/zii.php rename to web/framework/messages/pl/zii.php diff --git a/web/framework-1.1.17/messages/pt/yii.php b/web/framework/messages/pt/yii.php similarity index 100% rename from web/framework-1.1.17/messages/pt/yii.php rename to web/framework/messages/pt/yii.php diff --git a/web/framework-1.1.17/messages/pt/zii.php b/web/framework/messages/pt/zii.php similarity index 100% rename from web/framework-1.1.17/messages/pt/zii.php rename to web/framework/messages/pt/zii.php diff --git a/web/framework-1.1.17/messages/pt_br/yii.php b/web/framework/messages/pt_br/yii.php similarity index 100% rename from web/framework-1.1.17/messages/pt_br/yii.php rename to web/framework/messages/pt_br/yii.php diff --git a/web/framework-1.1.17/messages/pt_br/zii.php b/web/framework/messages/pt_br/zii.php similarity index 100% rename from web/framework-1.1.17/messages/pt_br/zii.php rename to web/framework/messages/pt_br/zii.php diff --git a/web/framework-1.1.17/messages/ro/yii.php b/web/framework/messages/ro/yii.php similarity index 100% rename from web/framework-1.1.17/messages/ro/yii.php rename to web/framework/messages/ro/yii.php diff --git a/web/framework-1.1.17/messages/ro/zii.php b/web/framework/messages/ro/zii.php similarity index 100% rename from web/framework-1.1.17/messages/ro/zii.php rename to web/framework/messages/ro/zii.php diff --git a/web/framework-1.1.17/messages/ru/yii.php b/web/framework/messages/ru/yii.php similarity index 100% rename from web/framework-1.1.17/messages/ru/yii.php rename to web/framework/messages/ru/yii.php diff --git a/web/framework-1.1.17/messages/ru/zii.php b/web/framework/messages/ru/zii.php similarity index 100% rename from web/framework-1.1.17/messages/ru/zii.php rename to web/framework/messages/ru/zii.php diff --git a/web/framework-1.1.17/messages/sk/yii.php b/web/framework/messages/sk/yii.php similarity index 100% rename from web/framework-1.1.17/messages/sk/yii.php rename to web/framework/messages/sk/yii.php diff --git a/web/framework-1.1.17/messages/sk/zii.php b/web/framework/messages/sk/zii.php similarity index 100% rename from web/framework-1.1.17/messages/sk/zii.php rename to web/framework/messages/sk/zii.php diff --git a/web/framework-1.1.17/messages/sr_sr/yii.php b/web/framework/messages/sr_sr/yii.php similarity index 100% rename from web/framework-1.1.17/messages/sr_sr/yii.php rename to web/framework/messages/sr_sr/yii.php diff --git a/web/framework-1.1.17/messages/sr_sr/zii.php b/web/framework/messages/sr_sr/zii.php similarity index 100% rename from web/framework-1.1.17/messages/sr_sr/zii.php rename to web/framework/messages/sr_sr/zii.php diff --git a/web/framework-1.1.17/messages/sr_yu/yii.php b/web/framework/messages/sr_yu/yii.php similarity index 100% rename from web/framework-1.1.17/messages/sr_yu/yii.php rename to web/framework/messages/sr_yu/yii.php diff --git a/web/framework-1.1.17/messages/sr_yu/zii.php b/web/framework/messages/sr_yu/zii.php similarity index 100% rename from web/framework-1.1.17/messages/sr_yu/zii.php rename to web/framework/messages/sr_yu/zii.php diff --git a/web/framework-1.1.17/messages/sv/yii.php b/web/framework/messages/sv/yii.php similarity index 100% rename from web/framework-1.1.17/messages/sv/yii.php rename to web/framework/messages/sv/yii.php diff --git a/web/framework-1.1.17/messages/sv/zii.php b/web/framework/messages/sv/zii.php similarity index 100% rename from web/framework-1.1.17/messages/sv/zii.php rename to web/framework/messages/sv/zii.php diff --git a/web/framework-1.1.17/messages/ta_in/yii.php b/web/framework/messages/ta_in/yii.php similarity index 100% rename from web/framework-1.1.17/messages/ta_in/yii.php rename to web/framework/messages/ta_in/yii.php diff --git a/web/framework-1.1.17/messages/ta_in/zii.php b/web/framework/messages/ta_in/zii.php similarity index 100% rename from web/framework-1.1.17/messages/ta_in/zii.php rename to web/framework/messages/ta_in/zii.php diff --git a/web/framework-1.1.17/messages/th/yii.php b/web/framework/messages/th/yii.php similarity index 100% rename from web/framework-1.1.17/messages/th/yii.php rename to web/framework/messages/th/yii.php diff --git a/web/framework-1.1.17/messages/tr/yii.php b/web/framework/messages/tr/yii.php similarity index 100% rename from web/framework-1.1.17/messages/tr/yii.php rename to web/framework/messages/tr/yii.php diff --git a/web/framework-1.1.17/messages/tr/zii.php b/web/framework/messages/tr/zii.php similarity index 100% rename from web/framework-1.1.17/messages/tr/zii.php rename to web/framework/messages/tr/zii.php diff --git a/web/framework-1.1.17/messages/uk/yii.php b/web/framework/messages/uk/yii.php similarity index 100% rename from web/framework-1.1.17/messages/uk/yii.php rename to web/framework/messages/uk/yii.php diff --git a/web/framework-1.1.17/messages/uk/zii.php b/web/framework/messages/uk/zii.php similarity index 100% rename from web/framework-1.1.17/messages/uk/zii.php rename to web/framework/messages/uk/zii.php diff --git a/web/framework-1.1.17/messages/vi/yii.php b/web/framework/messages/vi/yii.php similarity index 100% rename from web/framework-1.1.17/messages/vi/yii.php rename to web/framework/messages/vi/yii.php diff --git a/web/framework-1.1.17/messages/vi/zii.php b/web/framework/messages/vi/zii.php similarity index 100% rename from web/framework-1.1.17/messages/vi/zii.php rename to web/framework/messages/vi/zii.php diff --git a/web/framework-1.1.17/messages/zh_cn/yii.php b/web/framework/messages/zh_cn/yii.php similarity index 100% rename from web/framework-1.1.17/messages/zh_cn/yii.php rename to web/framework/messages/zh_cn/yii.php diff --git a/web/framework-1.1.17/messages/zh_cn/zii.php b/web/framework/messages/zh_cn/zii.php similarity index 100% rename from web/framework-1.1.17/messages/zh_cn/zii.php rename to web/framework/messages/zh_cn/zii.php diff --git a/web/framework-1.1.17/messages/zh_tw/yii.php b/web/framework/messages/zh_tw/yii.php similarity index 100% rename from web/framework-1.1.17/messages/zh_tw/yii.php rename to web/framework/messages/zh_tw/yii.php diff --git a/web/framework-1.1.17/messages/zh_tw/zii.php b/web/framework/messages/zh_tw/zii.php similarity index 100% rename from web/framework-1.1.17/messages/zh_tw/zii.php rename to web/framework/messages/zh_tw/zii.php diff --git a/web/framework-1.1.17/test/CDbFixtureManager.php b/web/framework/test/CDbFixtureManager.php similarity index 100% rename from web/framework-1.1.17/test/CDbFixtureManager.php rename to web/framework/test/CDbFixtureManager.php diff --git a/web/framework-1.1.17/test/CDbTestCase.php b/web/framework/test/CDbTestCase.php similarity index 100% rename from web/framework-1.1.17/test/CDbTestCase.php rename to web/framework/test/CDbTestCase.php diff --git a/web/framework-1.1.17/test/CTestCase.php b/web/framework/test/CTestCase.php similarity index 100% rename from web/framework-1.1.17/test/CTestCase.php rename to web/framework/test/CTestCase.php diff --git a/web/framework-1.1.17/test/CWebTestCase.php b/web/framework/test/CWebTestCase.php similarity index 100% rename from web/framework-1.1.17/test/CWebTestCase.php rename to web/framework/test/CWebTestCase.php diff --git a/web/framework-1.1.17/utils/CDateTimeParser.php b/web/framework/utils/CDateTimeParser.php similarity index 100% rename from web/framework-1.1.17/utils/CDateTimeParser.php rename to web/framework/utils/CDateTimeParser.php diff --git a/web/framework-1.1.17/utils/CFileHelper.php b/web/framework/utils/CFileHelper.php similarity index 99% rename from web/framework-1.1.17/utils/CFileHelper.php rename to web/framework/utils/CFileHelper.php index 3608e14ca..7a3c05903 100644 --- a/web/framework-1.1.17/utils/CFileHelper.php +++ b/web/framework/utils/CFileHelper.php @@ -153,6 +153,7 @@ public static function findFiles($dir,$options=array()) * @param array $options additional options. The following options are supported: * newDirMode - the permission to be set for newly copied directories (defaults to 0777); * newFileMode - the permission to be set for newly copied files (defaults to the current environment setting). + * @throws Exception */ protected static function copyDirectoryRecursive($src,$dst,$base,$fileTypes,$exclude,$level,$options) { @@ -199,6 +200,7 @@ protected static function copyDirectoryRecursive($src,$dst,$base,$fileTypes,$exc * level N means searching for those directories that are within N levels. * @param boolean $absolutePaths whether to return absolute paths or relative ones * @return array files found under the directory. + * @throws Exception */ protected static function findFilesRecursive($dir,$base,$fileTypes,$exclude,$level,$absolutePaths) { diff --git a/web/framework-1.1.17/utils/CFormatter.php b/web/framework/utils/CFormatter.php similarity index 100% rename from web/framework-1.1.17/utils/CFormatter.php rename to web/framework/utils/CFormatter.php diff --git a/web/framework-1.1.17/utils/CLocalizedFormatter.php b/web/framework/utils/CLocalizedFormatter.php similarity index 100% rename from web/framework-1.1.17/utils/CLocalizedFormatter.php rename to web/framework/utils/CLocalizedFormatter.php diff --git a/web/framework-1.1.17/utils/CMarkdownParser.php b/web/framework/utils/CMarkdownParser.php similarity index 100% rename from web/framework-1.1.17/utils/CMarkdownParser.php rename to web/framework/utils/CMarkdownParser.php diff --git a/web/framework-1.1.17/utils/CPasswordHelper.php b/web/framework/utils/CPasswordHelper.php similarity index 100% rename from web/framework-1.1.17/utils/CPasswordHelper.php rename to web/framework/utils/CPasswordHelper.php diff --git a/web/framework-1.1.17/utils/CPropertyValue.php b/web/framework/utils/CPropertyValue.php similarity index 97% rename from web/framework-1.1.17/utils/CPropertyValue.php rename to web/framework/utils/CPropertyValue.php index ddb91810f..addcbe862 100644 --- a/web/framework-1.1.17/utils/CPropertyValue.php +++ b/web/framework/utils/CPropertyValue.php @@ -113,8 +113,14 @@ public static function ensureArray($value) $len = strlen($value); if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')') { - eval('$array=array'.$value.';'); - return $array; + try + { + return eval('return array' . $value . ';'); + } + catch (ParseError $e) + { + return array(); + } } else return $len>0?array($value):array(); diff --git a/web/framework-1.1.17/utils/CTimestamp.php b/web/framework/utils/CTimestamp.php similarity index 100% rename from web/framework-1.1.17/utils/CTimestamp.php rename to web/framework/utils/CTimestamp.php diff --git a/web/framework-1.1.17/utils/CVarDumper.php b/web/framework/utils/CVarDumper.php similarity index 100% rename from web/framework-1.1.17/utils/CVarDumper.php rename to web/framework/utils/CVarDumper.php diff --git a/web/framework-1.1.17/utils/fileExtensions.php b/web/framework/utils/fileExtensions.php similarity index 100% rename from web/framework-1.1.17/utils/fileExtensions.php rename to web/framework/utils/fileExtensions.php diff --git a/web/framework-1.1.17/utils/mimeTypes.php b/web/framework/utils/mimeTypes.php similarity index 100% rename from web/framework-1.1.17/utils/mimeTypes.php rename to web/framework/utils/mimeTypes.php diff --git a/web/framework-1.1.17/validators/CBooleanValidator.php b/web/framework/validators/CBooleanValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CBooleanValidator.php rename to web/framework/validators/CBooleanValidator.php diff --git a/web/framework-1.1.17/validators/CCaptchaValidator.php b/web/framework/validators/CCaptchaValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CCaptchaValidator.php rename to web/framework/validators/CCaptchaValidator.php diff --git a/web/framework-1.1.17/validators/CCompareValidator.php b/web/framework/validators/CCompareValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CCompareValidator.php rename to web/framework/validators/CCompareValidator.php diff --git a/web/framework-1.1.17/validators/CDateValidator.php b/web/framework/validators/CDateValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CDateValidator.php rename to web/framework/validators/CDateValidator.php diff --git a/web/framework-1.1.17/validators/CDefaultValueValidator.php b/web/framework/validators/CDefaultValueValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CDefaultValueValidator.php rename to web/framework/validators/CDefaultValueValidator.php diff --git a/web/framework-1.1.17/validators/CEmailValidator.php b/web/framework/validators/CEmailValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CEmailValidator.php rename to web/framework/validators/CEmailValidator.php diff --git a/web/framework-1.1.17/validators/CExistValidator.php b/web/framework/validators/CExistValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CExistValidator.php rename to web/framework/validators/CExistValidator.php diff --git a/web/framework-1.1.17/validators/CFileValidator.php b/web/framework/validators/CFileValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CFileValidator.php rename to web/framework/validators/CFileValidator.php diff --git a/web/framework-1.1.17/validators/CFilterValidator.php b/web/framework/validators/CFilterValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CFilterValidator.php rename to web/framework/validators/CFilterValidator.php diff --git a/web/framework-1.1.17/validators/CInlineValidator.php b/web/framework/validators/CInlineValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CInlineValidator.php rename to web/framework/validators/CInlineValidator.php diff --git a/web/framework-1.1.17/validators/CNumberValidator.php b/web/framework/validators/CNumberValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CNumberValidator.php rename to web/framework/validators/CNumberValidator.php diff --git a/web/framework-1.1.17/validators/CRangeValidator.php b/web/framework/validators/CRangeValidator.php similarity index 97% rename from web/framework-1.1.17/validators/CRangeValidator.php rename to web/framework/validators/CRangeValidator.php index 27a703db9..a15b6ae28 100644 --- a/web/framework-1.1.17/validators/CRangeValidator.php +++ b/web/framework/validators/CRangeValidator.php @@ -20,7 +20,7 @@ * return array( * array('text, tag', 'required'), * array('text, 'type', 'type' => 'string'), - * array('tag, 'in', 'range' => array('php', 'mysql', 'jquery')), + * array('tag', 'in', 'range' => array('php', 'mysql', 'jquery')), * ); * } * } @@ -121,4 +121,4 @@ public function clientValidateAttribute($object,$attribute) } "; } -} \ No newline at end of file +} diff --git a/web/framework-1.1.17/validators/CRegularExpressionValidator.php b/web/framework/validators/CRegularExpressionValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CRegularExpressionValidator.php rename to web/framework/validators/CRegularExpressionValidator.php diff --git a/web/framework-1.1.17/validators/CRequiredValidator.php b/web/framework/validators/CRequiredValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CRequiredValidator.php rename to web/framework/validators/CRequiredValidator.php diff --git a/web/framework-1.1.17/validators/CSafeValidator.php b/web/framework/validators/CSafeValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CSafeValidator.php rename to web/framework/validators/CSafeValidator.php diff --git a/web/framework-1.1.17/validators/CStringValidator.php b/web/framework/validators/CStringValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CStringValidator.php rename to web/framework/validators/CStringValidator.php diff --git a/web/framework-1.1.17/validators/CTypeValidator.php b/web/framework/validators/CTypeValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CTypeValidator.php rename to web/framework/validators/CTypeValidator.php diff --git a/web/framework-1.1.17/validators/CUniqueValidator.php b/web/framework/validators/CUniqueValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CUniqueValidator.php rename to web/framework/validators/CUniqueValidator.php diff --git a/web/framework-1.1.17/validators/CUnsafeValidator.php b/web/framework/validators/CUnsafeValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CUnsafeValidator.php rename to web/framework/validators/CUnsafeValidator.php diff --git a/web/framework-1.1.17/validators/CUrlValidator.php b/web/framework/validators/CUrlValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CUrlValidator.php rename to web/framework/validators/CUrlValidator.php diff --git a/web/framework-1.1.17/validators/CValidator.php b/web/framework/validators/CValidator.php similarity index 100% rename from web/framework-1.1.17/validators/CValidator.php rename to web/framework/validators/CValidator.php diff --git a/web/framework-1.1.17/vendors/Net_IDNA2/LICENSE.txt b/web/framework/vendors/Net_IDNA2/LICENSE.txt similarity index 100% rename from web/framework-1.1.17/vendors/Net_IDNA2/LICENSE.txt rename to web/framework/vendors/Net_IDNA2/LICENSE.txt diff --git a/web/framework-1.1.17/vendors/Net_IDNA2/Net/IDNA2.php b/web/framework/vendors/Net_IDNA2/Net/IDNA2.php similarity index 99% rename from web/framework-1.1.17/vendors/Net_IDNA2/Net/IDNA2.php rename to web/framework/vendors/Net_IDNA2/Net/IDNA2.php index b8daee146..8db78cf0e 100644 --- a/web/framework-1.1.17/vendors/Net_IDNA2/Net/IDNA2.php +++ b/web/framework/vendors/Net_IDNA2/Net/IDNA2.php @@ -3399,4 +3399,3 @@ function singleton($params = array()) // }}} } -?> diff --git a/web/framework-1.1.17/vendors/Net_IDNA2/Net/IDNA2/Exception.php b/web/framework/vendors/Net_IDNA2/Net/IDNA2/Exception.php similarity index 100% rename from web/framework-1.1.17/vendors/Net_IDNA2/Net/IDNA2/Exception.php rename to web/framework/vendors/Net_IDNA2/Net/IDNA2/Exception.php diff --git a/web/framework-1.1.17/vendors/Net_IDNA2/Net/IDNA2/Exception/Nameprep.php b/web/framework/vendors/Net_IDNA2/Net/IDNA2/Exception/Nameprep.php similarity index 100% rename from web/framework-1.1.17/vendors/Net_IDNA2/Net/IDNA2/Exception/Nameprep.php rename to web/framework/vendors/Net_IDNA2/Net/IDNA2/Exception/Nameprep.php diff --git a/web/framework-1.1.17/vendors/README.html b/web/framework/vendors/README.html similarity index 93% rename from web/framework-1.1.17/vendors/README.html rename to web/framework/vendors/README.html index a0e5fd5e4..0a2bc5fbd 100644 --- a/web/framework-1.1.17/vendors/README.html +++ b/web/framework/vendors/README.html @@ -74,7 +74,7 @@

Third-Party Library List

CTimestamp - Text_Highlighter - Generic Syntax Highlighter (v0.7.0 beta) + Text_Highlighter - Generic Syntax Highlighter (v0.7.3 beta) The PHP License CTextHighlighter (note: many PHP files are modified to make them workable in PHP 5 strict mode and their PEAR dependency are also removed.) @@ -84,7 +84,7 @@

Third-Party Library List

CGettextMoFile - HTML Purifier (v4.5.0) + HTML Purifier (v4.9.2) LGPL CHtmlPurifier @@ -113,6 +113,11 @@

Third-Party Library List

MIT CWebLogRoute + + Zend Escaper - April 1 2015 + BSD + CJavaScript + diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter.php b/web/framework/vendors/TextHighlighter/Text/Highlighter.php similarity index 98% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter.php index 4823feb50..bd0548b54 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter.php +++ b/web/framework/vendors/TextHighlighter/Text/Highlighter.php @@ -46,7 +46,9 @@ /** * for our purpose, it is infinity */ -define ('HL_INFINITY', 1000000000); +if (!defined('HL_INFINITY')) { + define('HL_INFINITY', 1000000000); +} // }}} @@ -81,7 +83,7 @@ * Usage example * *require_once 'Text/Highlighter.php'; - *$hlSQL =& Text_Highlighter::factory('SQL',array('numbers'=>true)); + *$hlSQL = Text_Highlighter::factory('SQL',array('numbers'=>true)); *echo $hlSQL->highlight('SELECT * FROM table a WHERE id = 12'); * * diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/ABAP.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/ABAP.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/ABAP.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/ABAP.php diff --git a/web/framework/vendors/TextHighlighter/Text/Highlighter/AVRC.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/AVRC.php new file mode 100644 index 000000000..319c7e9b6 --- /dev/null +++ b/web/framework/vendors/TextHighlighter/Text/Highlighter/AVRC.php @@ -0,0 +1,877 @@ + + + * + */ + + +/** + * Auto-generated class. AVRC syntax highlighting + * + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.7.0 + * @link http://pear.php.net/package/Text_Highlighter + */ +class Text_Highlighter_AVRC extends Text_Highlighter +{ + var $_language = 'avrc'; + + /** + * Constructor + * + * @param array $options + * @access public + */ + function __construct($options=array()) + { + + $this->_options = $options; + $this->_regs = array ( + -1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 0 => '/((?i)\\\\)/', + 1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 2 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 3 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 4 => '//', + 5 => '/((?i)")|((?i)<)/', + 6 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 7 => '/((?i)\\$\\w+\\s*:.+\\$)/', + 8 => '/((?i)\\$\\w+\\s*:.+\\$)/', + ); + $this->_counts = array ( + -1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 0 => + array ( + 0 => 0, + ), + 1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 2 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 3 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 0, + 1 => 0, + ), + 6 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 2, + 8 => 0, + 9 => 0, + ), + 7 => + array ( + 0 => 0, + ), + 8 => + array ( + 0 => 0, + ), + ); + $this->_delim = array ( + -1 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 0 => + array ( + 0 => '', + ), + 1 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 2 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 3 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 'quotes', + 1 => 'quotes', + ), + 6 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => 'mlcomment', + 9 => 'comment', + ), + 7 => + array ( + 0 => '', + ), + 8 => + array ( + 0 => '', + ), + ); + $this->_inner = array ( + -1 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 0 => + array ( + 0 => 'special', + ), + 1 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 2 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 3 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 'string', + 1 => 'string', + ), + 6 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'identifier', + 4 => 'number', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'mlcomment', + 9 => 'comment', + ), + 7 => + array ( + 0 => 'inlinedoc', + ), + 8 => + array ( + 0 => 'inlinedoc', + ), + ); + $this->_end = array ( + 0 => '/(?i)"/', + 1 => '/(?i)\\}/', + 2 => '/(?i)\\)/', + 3 => '/(?i)\\]/', + 4 => '/(?i)>/', + 5 => '/(?mi)(? '/(?mi)(? '/(?i)\\*\\//', + 8 => '/(?mi)$/', + ); + $this->_states = array ( + -1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 0 => + array ( + 0 => -1, + ), + 1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 2 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 3 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 0, + 1 => 4, + ), + 6 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => -1, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => 7, + 9 => 8, + ), + 7 => + array ( + 0 => -1, + ), + 8 => + array ( + 0 => -1, + ), + ); + $this->_keywords = array ( + -1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 0 => + array ( + 0 => + array ( + ), + ), + 1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 2 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 3 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => -1, + 1 => -1, + ), + 6 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 4 => + array ( + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => -1, + 9 => -1, + ), + 7 => + array ( + 0 => + array ( + ), + ), + 8 => + array ( + 0 => + array ( + ), + ), + ); + $this->_parts = array ( + 0 => + array ( + 0 => NULL, + ), + 1 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 2 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 3 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => NULL, + 1 => NULL, + ), + 6 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + ), + 7 => + array ( + 0 => NULL, + ), + 8 => + array ( + 0 => NULL, + ), + ); + $this->_subst = array ( + -1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 0 => + array ( + 0 => false, + ), + 1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 2 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 3 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => false, + 1 => false, + ), + 6 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + ), + 7 => + array ( + 0 => false, + ), + 8 => + array ( + 0 => false, + ), + ); + $this->_conditions = array ( + ); + $this->_kwmap = array ( + 'reserved' => 'reserved', + 'registers' => 'reserved', + 'types' => 'types', + 'Common Macros' => 'prepro', + ); + $this->_defClass = 'code'; + $this->_checkDefines(); + } + +} \ No newline at end of file diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/CPP.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/CPP.php similarity index 94% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/CPP.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/CPP.php index eccaa084e..229a681ba 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/CPP.php +++ b/web/framework/vendors/TextHighlighter/Text/Highlighter/CPP.php @@ -53,7 +53,7 @@ function __construct($options=array()) $this->_options = $options; $this->_regs = array ( - -1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + -1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', 0 => '/((?i)\\\\)/', 1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', 2 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', @@ -75,8 +75,12 @@ function __construct($options=array()) 5 => 0, 6 => 0, 7 => 0, - 8 => 0, + 8 => 2, 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, ), 0 => array ( @@ -171,11 +175,15 @@ function __construct($options=array()) 2 => 'brackets', 3 => 'brackets', 4 => '', - 5 => 'prepro', - 6 => 'prepro', + 5 => '', + 6 => '', 7 => '', - 8 => 'mlcomment', - 9 => 'comment', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', ), 0 => array ( @@ -270,11 +278,15 @@ function __construct($options=array()) 2 => 'code', 3 => 'code', 4 => 'identifier', - 5 => 'prepro', - 6 => 'code', + 5 => 'number', + 6 => 'number', 7 => 'number', - 8 => 'mlcomment', - 9 => 'comment', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', ), 0 => array ( @@ -380,11 +392,15 @@ function __construct($options=array()) 2 => 2, 3 => 3, 4 => -1, - 5 => 5, - 6 => 6, + 5 => -1, + 6 => -1, 7 => -1, - 8 => 7, - 9 => 8, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, ), 0 => array ( @@ -484,13 +500,25 @@ function __construct($options=array()) 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', ), - 5 => -1, - 6 => -1, + 5 => + array ( + ), + 6 => + array ( + ), 7 => array ( ), - 8 => -1, + 8 => + array ( + ), 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, ), 0 => array ( @@ -740,6 +768,10 @@ function __construct($options=array()) 7 => false, 8 => false, 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, ), 0 => array ( diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/CSS.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/CSS.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/CSS.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/CSS.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/DIFF.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/DIFF.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/DIFF.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/DIFF.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/DTD.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/DTD.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/DTD.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/DTD.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Generator.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Generator.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Generator.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Generator.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/HTML.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/HTML.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/HTML.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/HTML.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/JAVA.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/JAVA.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/JAVA.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/JAVA.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/JAVASCRIPT.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/JAVASCRIPT.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/JAVASCRIPT.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/JAVASCRIPT.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/MYSQL.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/MYSQL.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/MYSQL.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/MYSQL.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/PERL.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/PERL.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/PERL.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/PERL.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/PHP.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/PHP.php similarity index 99% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/PHP.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/PHP.php index 94b3733ee..70da65317 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/PHP.php +++ b/web/framework/vendors/TextHighlighter/Text/Highlighter/PHP.php @@ -46,7 +46,7 @@ function __construct($options=array()) $this->_options = $options; $this->_regs = array ( - -1 => '/((?i)(\\<\\?(php|=)?)?)/', + -1 => '/((?i)\\<\\?(php|=)?)/', 0 => '/((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)\\/\\*)|((?i)")|((?i)`)|((?mi)\\<\\<\\<[\\x20\\x09]*(\\w+)$)|((?i)\')|((?i)(#|\\/\\/))|((?i)[a-z_]\\w*)|((?i)\\((array|int|integer|string|bool|boolean|object|float|double)\\))|((?i)0[xX][\\da-f]+)|((?i)\\$[a-z_]\\w*)|((?i)\\d\\d*|\\b0\\b)|((?i)0[0-7]+)|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)((\\d+|((\\d*\\.\\d+)|(\\d+\\.\\d*)))[eE][+-]?\\d+))/', 1 => '/((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)\\/\\*)|((?i)")|((?i)`)|((?mi)\\<\\<\\<[\\x20\\x09]*(\\w+)$)|((?i)\')|((?i)(#|\\/\\/))|((?i)[a-z_]\\w*)|((?i)\\((array|int|integer|string|bool|boolean|object|float|double)\\))|((?i)\\?\\>)|((?i)0[xX][\\da-f]+)|((?i)\\$[a-z_]\\w*)|((?i)\\d\\d*|\\b0\\b)|((?i)0[0-7]+)|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)((\\d+|((\\d*\\.\\d+)|(\\d+\\.\\d*)))[eE][+-]?\\d+))/', 2 => '/((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)\\/\\*)|((?i)")|((?i)`)|((?mi)\\<\\<\\<[\\x20\\x09]*(\\w+)$)|((?i)\')|((?i)(#|\\/\\/))|((?i)[a-z_]\\w*)|((?i)\\((array|int|integer|string|bool|boolean|object|float|double)\\))|((?i)0[xX][\\da-f]+)|((?i)\\$[a-z_]\\w*)|((?i)\\d\\d*|\\b0\\b)|((?i)0[0-7]+)|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)((\\d+|((\\d*\\.\\d+)|(\\d+\\.\\d*)))[eE][+-]?\\d+))/', @@ -62,7 +62,7 @@ function __construct($options=array()) $this->_counts = array ( -1 => array ( - 0 => 2, + 0 => 1, ), 0 => array ( diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/PYTHON.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/PYTHON.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/PYTHON.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/PYTHON.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/RUBY.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/RUBY.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/RUBY.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/RUBY.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Array.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Array.php similarity index 97% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Array.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Array.php index ef3ffec15..b7442d0af 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Array.php +++ b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Array.php @@ -99,6 +99,7 @@ function preprocess($str) { // normalize whitespace and tabs $str = str_replace("\r\n","\n", $str); + $str = str_replace("\r","\n", $str); // some browsers refuse to display empty lines $str = preg_replace('~^$~m'," ", $str); $str = str_replace("\t",str_repeat(' ', $this->_tabsize), $str); @@ -141,7 +142,9 @@ function reset() */ function acceptToken($class, $content) { - + if (!is_array($this->_output)) { + $this->_output = array(); + } $theClass = $this->_getFullClassName($class); if ($this->_htmlspecialchars) { diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/BB.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/BB.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/BB.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/BB.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Console.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Console.php similarity index 93% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Console.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Console.php index 2bba33b65..0260dff3c 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Console.php +++ b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Console.php @@ -176,14 +176,19 @@ function acceptToken($class, $content) function finalize() { if ($this->_numbers) { - $nlines = substr_count($this->_output, "\n") + 1; - $len = strlen($nlines); - $i = 1; - $this->_output = preg_replace('~^~em', '" " . str_pad($i++, $len, " ", STR_PAD_LEFT) . ": "', $this->_output); + $this->_output = preg_replace_callback('~^~m', array($this, 'replaceCallback'), $this->_output); } $this->_output .= HL_CONSOLE_DEFCOLOR . "\n"; } + function replaceCallback() + { + $nlines = substr_count($this->_output, "\n") + 1; + $len = strlen($nlines); + $i = 1; + return " " . str_pad($i++, $len, " ", STR_PAD_LEFT) . ": "; + } + /** * Get generated output * diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Html.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Html.php similarity index 94% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Html.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Html.php index dcf37ab3a..b9cb4c649 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/Html.php +++ b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/Html.php @@ -52,11 +52,15 @@ /** * Use numbered list */ -define ('HL_NUMBERS_OL', 1); +if (!defined('HL_NUMBERS_OL')) { + define('HL_NUMBERS_OL', 1); +} /** * Use non-numbered list */ -define ('HL_NUMBERS_UL', 3); +if (!defined('HL_NUMBERS_UL')) { + define('HL_NUMBERS_UL', 3); +} /**#@-*/ @@ -188,10 +192,12 @@ class Text_Highlighter_Renderer_Html extends Text_Highlighter_Renderer_Array 'inlinetags' => 'hl-inlinetags', 'mlcomment' => 'hl-mlcomment', 'number' => 'hl-number', + 'prepro' => 'hl-prepro', 'quotes' => 'hl-quotes', 'reserved' => 'hl-reserved', 'special' => 'hl-special', 'string' => 'hl-string', + 'types' => 'hl-types', 'url' => 'hl-url', 'var' => 'hl-var', ); @@ -289,8 +295,6 @@ function finalize() // get parent's output parent::finalize(); $output = parent::getOutput(); - if(empty($output)) - return; $html_output = ''; @@ -320,18 +324,28 @@ function finalize() $span = $this->_getStyling($the_class); $decorated_output = $this->_decorate($content, $key); - //print "
 token = ".var_export($token, true)." -- span = " . htmlentities($span). "-- deco = ".$decorated_output."
\n"; - $html_output .= sprintf($span, $decorated_output); + + + if ($numbers_li == true) { + // end span tags before end of li, and re-open on next line + $lastSpanTag = str_replace("%s", "", $span); + $span = sprintf($span, $decorated_output); + $span = str_replace("\n", "\n
  • $lastSpanTag ", $span); + $html_output .= $span; + } else { + $html_output .= sprintf($span, $decorated_output); + } + + } // format lists if (!empty($this->_numbers) && $numbers_li == true) { - //$html_output = "
    ".$html_output."
    "; + // additional whitespace for browsers that do not display // empty list items correctly - $this->_output = '
  •  ' . str_replace("\n", "
  • \n
  •  ", $html_output) . '
  • '; - + $this->_output = '
  •  ' . $html_output . '
  • '; $start = ''; if ($this->_numbers == HL_NUMBERS_OL && intval($this->_numbers_start) > 0) { diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/HtmlTags.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/JSON.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/JSON.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/JSON.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/JSON.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/XML.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/XML.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/Renderer/XML.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/Renderer/XML.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/SH.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/SH.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/SH.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/SH.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/SQL.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/SQL.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/SQL.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/SQL.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/VBSCRIPT.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/VBSCRIPT.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/VBSCRIPT.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/VBSCRIPT.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/XML.php b/web/framework/vendors/TextHighlighter/Text/Highlighter/XML.php similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/Highlighter/XML.php rename to web/framework/vendors/TextHighlighter/Text/Highlighter/XML.php diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/README b/web/framework/vendors/TextHighlighter/Text/README similarity index 93% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/README rename to web/framework/vendors/TextHighlighter/Text/README index 09b898ce6..88f71aed2 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/README +++ b/web/framework/vendors/TextHighlighter/Text/README @@ -1,455 +1,455 @@ -# $Id: README,v 1.2 2007/06/13 10:09:47 ssttoo Exp $ - -Introduction -============ - -Text_Highlighter is a class for syntax highlighting. The main idea is to -simplify creation of subclasses implementing syntax highlighting for -particular language. Subclasses do not implement any new functioanality, they -just provide syntax highlighting rules. The rules sources are in XML format. -To create a highlighter for a language, there is no need to code a new class -manually. Simply describe the rules in XML file and use Text_Highlighter_Generator -to create a new class. - - -This document does not contain a formal description of API - it is very -simple, and I believe providing some examples of code is sufficient. - - -Highlighter XML source -====================== - -Basics ------- - -Creating a new syntax highlighter begins with describing the highlighting -rules. There are two basic elements: block and region. A block is just a -portion of text matching a regular expression and highlighted with a single -color. Keyword is an example of a block. A region is defined by two regular -expressions: one for start of region, and another for the end. The main -difference from a block is that a region can contain blocks and regions -(including same-named regions). An example of a region is a group of -statements enclosed in curly brackets (this is used in many languages, for -example PHP and C). Also, characters matching start and end of a region may be -highlighted with their own color, and region contents with another. - -Blocks and regions may be declared as contained. Contained blocks and regions -can only appear inside regions. If a region or a block is not declared as -contained, it can appear both on top level and inside regions. Block or region -declared as not-contained can only appear on top level. - -For any region, a list of blocks and regions that can appear inside this -region can be specified. - -In this document, the term "color group" is used. Chunks of text assigned to -same color group will be highlighted with same color. Note that in versions -prior 0.5.0 color goups were refered as CSS classes, but since 0.5.0 not only -HTML output is supported, so "color group" is more appropriate term. - -Elements --------- - -The toplevel element is . Attribute lang is required and denotes -the name of the language. Its value is used as a part of generated class name, -and must only contain letters, digits and underscores. Optional attribute -case, when given value yes, makes the language case sensitive (default is case -insensitive). Allowed subelements are: - - * : Information about the authors of the file. - : Information about a single author of the file. (May be used - multiple times, one per author.) - - name="...": Author's name. Required. - - email="...": Author's email address. Optional. - - * : Default color group. - - innerGroup="...": color group name. Required. - - * : Region definition - - name="...": Region name. Required. - - innerGroup="...": Default color group of region contents. Required. - - delimGroup="...": color group of start and end of region. Optional, - defaults to value of innerGroup attribute. - - start="...", end="...": Regular expression matching start and end - of region. Required. Regular expression delimiters are optional, but - if you need to specify delimiter, use /. The only case when the - delimiters are needed, is specifying regular expression modifiers, - such as m or U. Examples: \/\* or /$/m. - - contained="yes": Marks region as contained. - - never-contained="yes": Marks region as not-contained. - - : Elements allowed inside this region. - - all="yes" Region can contain any other region or block - (except not-contained). May be used multiple times. - - Do not allow certain regions or blocks. - - region="..." Name of region not allowed within - current region. - - block="..." Name of block not allowed within - current region. - - region="..." Name of region allowed within current region. - - block="..." Name of block allowed within current region. - - Only allow this region within certain regions. May be - used multiple times. - - block="..." Name of parent region - - * : Block definition - - name="...": Block name. Required. - - innerGroup="...": color group of block contents. Optional. If not - specified, color group of parent region or default color group will be - used. One would only want to omit this attribute if there are - keyword groups (see below) inherited from this block, and no special - highlighting should apply when the block does not match the keyword. - - match="..." Regular expression matching the block. Required. - Regular expression delimiters are optional, but if you need to - specify delimiter, use /. The only case when the delimiters are - needed, is specifying regular expression modifiers, such as m or U. - Examples: #|\/\/ or /$/m. - - contained="yes": Marks block as contained. - - never-contained="yes": Marks block as not-contained. - - Only allow this block within certain regions. May be used - multiple times. - - block="..." Name of parent region - - multiline="yes": Marks block as multi-line. By default, whole - blocks are assumed to reside in a single line. This make the things - faster. If you need to declare a multi-line block, use this - attribute. - - : Assigns another color group to a part of the block that - matched a subpattern. - - index="n": Subpattern index. Required. - - innerGroup="...": color group name. Required. - - This is an example from CSS highlighter: the measure is matched as - a whole, but the measurement units are highlighted with different - color. - - - - - - - * : Keyword group definition. Keyword groups are useful when you - want to highlight some words that match a condition for a block with a - different color. Keywords are defined with literal match, not regular - expressions. For example, you have a block named identifier matching a - general identifier, and want to highlight reserved words (which match - this block as well) with different color. You inherit a keyword group - "reserved" from "identifier" block. - - name="...": Keyword group. Required. - - ifdef="...", ifndef="..." : Conditional declaration. See - "Conditions" below. - - inherits="...": Inherited block name. Required. - - innerGroup="...": color group of keyword group. Required. - - case="yes|no": Overrides case-sensitivity of the language. - Optional, defaults to global value. - - : Single keyword definition. - - match="..." The keyword. Note: this is not a regular - expression, but literal match (possibly case insensitive). - -Note that for BC reasons element partClass is alias for partGroup, and -attributes innerClass and delimClass are aliases of innerGroup and -delimGroup, respectively. - - -Conditions ----------- - -Conditional declarations allow enabling or disabling certain highlighting -rules at runtime. For example, Java highlighter has a very big list of -keywords matching Java standard classes. Finding a match in this list can take -much time. For that reason, corresponding keyword group is declared with -"ifdef" attribute : - - - - - - ... - ... - - - - - -This keyword group will be only enabled when "java.builtins" is passed as an -element of "defines" option: - - $options = array( - 'defines' => array( - 'java.builtins', - ), - 'numbers' => HL_NUMBERS_TABLE, - ); - $highlighter =& Text_Highlighter::factory('java', $options); - -"ifndef" attribute has reverse meaning. - -Currently, "ifdef" and "ifndef" attributes are only supported for -tag. - - - -Class generation -================ - -Creating XML description of highlighting rules is the most complicated part of -the process. To generate the class, you need just few lines of code: - - generate(); - $generator->saveCode('PHP.php'); - ?> - - - -Command-line class generation tool -================================== - -Example from previous section looks pretty simple, but it does not handle any -errors which may occur during parsing of XML source. The package provides a -command-line script to make generation of classes even more simple, and takes -care of possible errors. It is called generate (on Unix/Linux) or generate.bat -(on Windows). This script is able to process multiple files in one run, and -also to process XML from standard input and write generated code to standard -output. - - Usage: - generate options - - Options: - -x filename, --xml=filename - source XML file. Multiple input files can be specified, in which - case each -x option must be followed by -p unless -d is specified - Defaults to stdin - -p filename, --php=filename - destination PHP file. Defaults to stdout. If specied multiple times, - each -p must follow -x - -d dirname, --dir=dirname - Default destination directory. File names will be taken from XML input - ("lang" attribute of tag) - -h, --help - This help - -Examples - - Read from php.xml, write to PHP.php - - generate -x php.xml -p PHP.php - - Read from php.xml, write to standard output - - generate -x php.xml - - Read from php.xml, write to PHP.php, read from xml.xml, write to XML.php - - generate -x php.xml -p PHP.php -x xml.xml -p XML.php - - Read from php.xml, write to /some/dir/PHP.php, read from xml.xml, write to - /some/dir/XML.php (assuming that xml.xml contains , and - php.xml contains ) - - generate -x php.xml -x xml.xml -d /some/dir/ - - - -Renderers -========= - -Introduction ------------- - -Text_Highlighter supports renderes. Using renderers, you can get output in -different formats. Two renderers are included in the package: - - - HTML renderer. Generates HTML output. A style sheet should be linked to - the document to display colored text - - - Console renderer. Can be used to output highlighted text to - color-capable terminals, either directly or trough less -r - - -Renderers API -------------- - -Renderers are subclasses of Text_Highlighter_Renderer. Renderer should -override at least two methods - acceptToken and getOutput. Overriding other -methods is optional, depending on the nature of renderer's output and details -of implementation. - - string reset() - resets renderer state. This method is called every time before a new - source file is highlighted. - - string preprocess(string $code) - preprocesses code. Can be used, for example, to normalize whitespace - before highlighting. Returns preprocessed string. - - void acceptToken(string $group, string $content) - the core method of the renderer. Highlighter passes chunks of text to - this method in $content, and color group in $group - - void finalize() - signals the renderer that no more tokens are available. - - mixed getOutput() - returns generated output. - - -Setting renderer options --------------------------------- - -Renderers accept an optional argument to their constructor - options array. -Elements of this array are renderer-specific. - -HTML renderer -------------- - -HTML renderer produces HTML output with optional line numbering. The renderer -itself does not provide information about actual colors of highlighted text. -Instead, is used, where XXX is replaced with color group -name (hl-var, hl-string, etc.). It is up to you to create a CSS stylesheet. -If 'use_language' option with value evaluating to true was passed, class names -will be formatted as "LANG-hl-XXX", where LANG is language name as defined in -highlighter XML source ("lang" attribute of tag) in lower case. - -There are 3 special CSS classes: - - hl-main - this class applies to whole output or right table column, - depending on 'numbers' option - hl-gutter - applies to left column in table - hl-table - applies to whole table - -HTML renderer accepts following options (each being optional): - - * numbers - line numbering style. - 0 - no numbering (default) - HL_NUMBERS_LI - use
      for line numbering - HL_NUMBERS_TABLE - create a 2-column table, with line numbers in left - column and highlighted text in right column - - * tabsize - tabulation size. Defaults to 4 - - Example: - - require_once 'Text/Highlighter/Renderer/Html.php'; - $options = array( - 'numbers' => HL_NUMBERS_LI, - 'tabsize' => 8, - ); - $renderer =& new Text_Highlighter_Renderer_HTML($options); - -Console renderer ----------------- - -Console renderer produces output for displaying on a color-capable terminal, -either directly or through less -r, using ANSI escape sequences. By default, -this renderer only highlights most common color groups. Additional colors -can be specified using 'colors' option. This renderer also accepts 'numbers' -option - a boolean value, and 'tabsize' option. - - Example : - - require_once 'Text/Highlighter/Renderer/Console.php'; - $colors = array( - 'prepro' => "\033[35m", - 'types' => "\033[32m", - ); - $options = array( - 'numbers' => true, - 'tabsize' => 8, - 'colors' => $colors, - ); - $renderer =& new Text_Highlighter_Renderer_Console($options); - - -ANSI color escape sequences have the following format: - - ESC[#;#;....;#m - -where ESC is character with ASCII code 27 (033 octal, 0x1B hexadecimal). # is -one of the following: - - 0 for normal display - 1 for bold on - 4 underline (mono only) - 5 blink on - 7 reverse video on - 8 nondisplayed (invisible) - 30 black foreground - 31 red foreground - 32 green foreground - 33 yellow foreground - 34 blue foreground - 35 magenta foreground - 36 cyan foreground - 37 white foreground - 40 black background - 41 red background - 42 green background - 43 yellow background - 44 blue background - 45 magenta background - 46 cyan background - 47 white background - - -How to use Text_Highlighter class -================================= - -Creating a highlighter object ------------------------------ - -To create a highlighter for a certain language, use Text_Highlighter::factory() -static method: - - require_once 'Text/Highlighter.php'; - $hl =& Text_Highlighter::factory('php'); - - -Setting a renderer ------------------- - -Actual output is produced by a renderer. - - require_once 'Text/Highlighter.php'; - require_once 'Text/Highlighter/Renderer/Html.php'; - $options = array( - 'numbers' => HL_NUMBERS_LI, - 'tabsize' => 8, - ); - $renderer =& new Text_Highlighter_Renderer_HTML($options); - $hl =& Text_Highlighter::factory('php'); - $hl->setRenderer($renderer); - -Note that for BC reasons, it is possible to use highlighter without setting a -renderer. If no renderer is set, HTML renderer will be used by default. In -this case, you should pass options as second parameter to factory method. The -following example works exactly as previous one: - - require_once 'Text/Highlighter.php'; - $options = array( - 'numbers' => HL_NUMBERS_LI, - 'tabsize' => 8, - ); - $hl =& Text_Highlighter::factory('php', $options); - - -Getting output --------------- - -And finally, do the highlighting and get the output: - - require_once 'Text/Highlighter.php'; - require_once 'Text/Highlighter/Renderer/Html.php'; - $options = array( - 'numbers' => HL_NUMBERS_LI, - 'tabsize' => 8, - ); - $renderer =& new Text_Highlighter_Renderer_HTML($options); - $hl =& Text_Highlighter::factory('php'); - $hl->setRenderer($renderer); - $html = $hl->highlight(file_get_contents('example.php')); - -# vim: set autoindent tabstop=4 shiftwidth=4 softtabstop=4 tw=78: */ - +# $Id$ + +Introduction +============ + +Text_Highlighter is a class for syntax highlighting. The main idea is to +simplify creation of subclasses implementing syntax highlighting for +particular language. Subclasses do not implement any new functioanality, they +just provide syntax highlighting rules. The rules sources are in XML format. +To create a highlighter for a language, there is no need to code a new class +manually. Simply describe the rules in XML file and use Text_Highlighter_Generator +to create a new class. + + +This document does not contain a formal description of API - it is very +simple, and I believe providing some examples of code is sufficient. + + +Highlighter XML source +====================== + +Basics +------ + +Creating a new syntax highlighter begins with describing the highlighting +rules. There are two basic elements: block and region. A block is just a +portion of text matching a regular expression and highlighted with a single +color. Keyword is an example of a block. A region is defined by two regular +expressions: one for start of region, and another for the end. The main +difference from a block is that a region can contain blocks and regions +(including same-named regions). An example of a region is a group of +statements enclosed in curly brackets (this is used in many languages, for +example PHP and C). Also, characters matching start and end of a region may be +highlighted with their own color, and region contents with another. + +Blocks and regions may be declared as contained. Contained blocks and regions +can only appear inside regions. If a region or a block is not declared as +contained, it can appear both on top level and inside regions. Block or region +declared as not-contained can only appear on top level. + +For any region, a list of blocks and regions that can appear inside this +region can be specified. + +In this document, the term "color group" is used. Chunks of text assigned to +same color group will be highlighted with same color. Note that in versions +prior 0.5.0 color goups were refered as CSS classes, but since 0.5.0 not only +HTML output is supported, so "color group" is more appropriate term. + +Elements +-------- + +The toplevel element is . Attribute lang is required and denotes +the name of the language. Its value is used as a part of generated class name, +and must only contain letters, digits and underscores. Optional attribute +case, when given value yes, makes the language case sensitive (default is case +insensitive). Allowed subelements are: + + * : Information about the authors of the file. + : Information about a single author of the file. (May be used + multiple times, one per author.) + - name="...": Author's name. Required. + - email="...": Author's email address. Optional. + + * : Default color group. + - innerGroup="...": color group name. Required. + + * : Region definition + - name="...": Region name. Required. + - innerGroup="...": Default color group of region contents. Required. + - delimGroup="...": color group of start and end of region. Optional, + defaults to value of innerGroup attribute. + - start="...", end="...": Regular expression matching start and end + of region. Required. Regular expression delimiters are optional, but + if you need to specify delimiter, use /. The only case when the + delimiters are needed, is specifying regular expression modifiers, + such as m or U. Examples: \/\* or /$/m. + - contained="yes": Marks region as contained. + - never-contained="yes": Marks region as not-contained. + - : Elements allowed inside this region. + - all="yes" Region can contain any other region or block + (except not-contained). May be used multiple times. + - Do not allow certain regions or blocks. + - region="..." Name of region not allowed within + current region. + - block="..." Name of block not allowed within + current region. + - region="..." Name of region allowed within current region. + - block="..." Name of block allowed within current region. + - Only allow this region within certain regions. May be + used multiple times. + - block="..." Name of parent region + + * : Block definition + - name="...": Block name. Required. + - innerGroup="...": color group of block contents. Optional. If not + specified, color group of parent region or default color group will be + used. One would only want to omit this attribute if there are + keyword groups (see below) inherited from this block, and no special + highlighting should apply when the block does not match the keyword. + - match="..." Regular expression matching the block. Required. + Regular expression delimiters are optional, but if you need to + specify delimiter, use /. The only case when the delimiters are + needed, is specifying regular expression modifiers, such as m or U. + Examples: #|\/\/ or /$/m. + - contained="yes": Marks block as contained. + - never-contained="yes": Marks block as not-contained. + - Only allow this block within certain regions. May be used + multiple times. + - block="..." Name of parent region + - multiline="yes": Marks block as multi-line. By default, whole + blocks are assumed to reside in a single line. This make the things + faster. If you need to declare a multi-line block, use this + attribute. + - : Assigns another color group to a part of the block that + matched a subpattern. + - index="n": Subpattern index. Required. + - innerGroup="...": color group name. Required. + + This is an example from CSS highlighter: the measure is matched as + a whole, but the measurement units are highlighted with different + color. + + + + + + + * : Keyword group definition. Keyword groups are useful when you + want to highlight some words that match a condition for a block with a + different color. Keywords are defined with literal match, not regular + expressions. For example, you have a block named identifier matching a + general identifier, and want to highlight reserved words (which match + this block as well) with different color. You inherit a keyword group + "reserved" from "identifier" block. + - name="...": Keyword group. Required. + - ifdef="...", ifndef="..." : Conditional declaration. See + "Conditions" below. + - inherits="...": Inherited block name. Required. + - innerGroup="...": color group of keyword group. Required. + - case="yes|no": Overrides case-sensitivity of the language. + Optional, defaults to global value. + - : Single keyword definition. + - match="..." The keyword. Note: this is not a regular + expression, but literal match (possibly case insensitive). + +Note that for BC reasons element partClass is alias for partGroup, and +attributes innerClass and delimClass are aliases of innerGroup and +delimGroup, respectively. + + +Conditions +---------- + +Conditional declarations allow enabling or disabling certain highlighting +rules at runtime. For example, Java highlighter has a very big list of +keywords matching Java standard classes. Finding a match in this list can take +much time. For that reason, corresponding keyword group is declared with +"ifdef" attribute : + + + + + + ... + ... + + + + + +This keyword group will be only enabled when "java.builtins" is passed as an +element of "defines" option: + + $options = array( + 'defines' => array( + 'java.builtins', + ), + 'numbers' => HL_NUMBERS_TABLE, + ); + $highlighter = Text_Highlighter::factory('java', $options); + +"ifndef" attribute has reverse meaning. + +Currently, "ifdef" and "ifndef" attributes are only supported for +tag. + + + +Class generation +================ + +Creating XML description of highlighting rules is the most complicated part of +the process. To generate the class, you need just few lines of code: + + generate(); + $generator->saveCode('PHP.php'); + ?> + + + +Command-line class generation tool +================================== + +Example from previous section looks pretty simple, but it does not handle any +errors which may occur during parsing of XML source. The package provides a +command-line script to make generation of classes even more simple, and takes +care of possible errors. It is called generate (on Unix/Linux) or generate.bat +(on Windows). This script is able to process multiple files in one run, and +also to process XML from standard input and write generated code to standard +output. + + Usage: + generate options + + Options: + -x filename, --xml=filename + source XML file. Multiple input files can be specified, in which + case each -x option must be followed by -p unless -d is specified + Defaults to stdin + -p filename, --php=filename + destination PHP file. Defaults to stdout. If specied multiple times, + each -p must follow -x + -d dirname, --dir=dirname + Default destination directory. File names will be taken from XML input + ("lang" attribute of tag) + -h, --help + This help + +Examples + + Read from php.xml, write to PHP.php + + generate -x php.xml -p PHP.php + + Read from php.xml, write to standard output + + generate -x php.xml + + Read from php.xml, write to PHP.php, read from xml.xml, write to XML.php + + generate -x php.xml -p PHP.php -x xml.xml -p XML.php + + Read from php.xml, write to /some/dir/PHP.php, read from xml.xml, write to + /some/dir/XML.php (assuming that xml.xml contains , and + php.xml contains ) + + generate -x php.xml -x xml.xml -d /some/dir/ + + + +Renderers +========= + +Introduction +------------ + +Text_Highlighter supports renderes. Using renderers, you can get output in +different formats. Two renderers are included in the package: + + - HTML renderer. Generates HTML output. A style sheet should be linked to + the document to display colored text + + - Console renderer. Can be used to output highlighted text to + color-capable terminals, either directly or trough less -r + + +Renderers API +------------- + +Renderers are subclasses of Text_Highlighter_Renderer. Renderer should +override at least two methods - acceptToken and getOutput. Overriding other +methods is optional, depending on the nature of renderer's output and details +of implementation. + + string reset() + resets renderer state. This method is called every time before a new + source file is highlighted. + + string preprocess(string $code) + preprocesses code. Can be used, for example, to normalize whitespace + before highlighting. Returns preprocessed string. + + void acceptToken(string $group, string $content) + the core method of the renderer. Highlighter passes chunks of text to + this method in $content, and color group in $group + + void finalize() + signals the renderer that no more tokens are available. + + mixed getOutput() + returns generated output. + + +Setting renderer options +-------------------------------- + +Renderers accept an optional argument to their constructor - options array. +Elements of this array are renderer-specific. + +HTML renderer +------------- + +HTML renderer produces HTML output with optional line numbering. The renderer +itself does not provide information about actual colors of highlighted text. +Instead, is used, where XXX is replaced with color group +name (hl-var, hl-string, etc.). It is up to you to create a CSS stylesheet. +If 'use_language' option with value evaluating to true was passed, class names +will be formatted as "LANG-hl-XXX", where LANG is language name as defined in +highlighter XML source ("lang" attribute of tag) in lower case. + +There are 3 special CSS classes: + + hl-main - this class applies to whole output or right table column, + depending on 'numbers' option + hl-gutter - applies to left column in table + hl-table - applies to whole table + +HTML renderer accepts following options (each being optional): + + * numbers - line numbering style. + 0 - no numbering (default) + HL_NUMBERS_LI - use
        for line numbering + HL_NUMBERS_TABLE - create a 2-column table, with line numbers in left + column and highlighted text in right column + + * tabsize - tabulation size. Defaults to 4 + + Example: + + require_once 'Text/Highlighter/Renderer/Html.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $renderer = new Text_Highlighter_Renderer_HTML($options); + +Console renderer +---------------- + +Console renderer produces output for displaying on a color-capable terminal, +either directly or through less -r, using ANSI escape sequences. By default, +this renderer only highlights most common color groups. Additional colors +can be specified using 'colors' option. This renderer also accepts 'numbers' +option - a boolean value, and 'tabsize' option. + + Example : + + require_once 'Text/Highlighter/Renderer/Console.php'; + $colors = array( + 'prepro' => "\033[35m", + 'types' => "\033[32m", + ); + $options = array( + 'numbers' => true, + 'tabsize' => 8, + 'colors' => $colors, + ); + $renderer = new Text_Highlighter_Renderer_Console($options); + + +ANSI color escape sequences have the following format: + + ESC[#;#;....;#m + +where ESC is character with ASCII code 27 (033 octal, 0x1B hexadecimal). # is +one of the following: + + 0 for normal display + 1 for bold on + 4 underline (mono only) + 5 blink on + 7 reverse video on + 8 nondisplayed (invisible) + 30 black foreground + 31 red foreground + 32 green foreground + 33 yellow foreground + 34 blue foreground + 35 magenta foreground + 36 cyan foreground + 37 white foreground + 40 black background + 41 red background + 42 green background + 43 yellow background + 44 blue background + 45 magenta background + 46 cyan background + 47 white background + + +How to use Text_Highlighter class +================================= + +Creating a highlighter object +----------------------------- + +To create a highlighter for a certain language, use Text_Highlighter::factory() +static method: + + require_once 'Text/Highlighter.php'; + $hl = Text_Highlighter::factory('php'); + + +Setting a renderer +------------------ + +Actual output is produced by a renderer. + + require_once 'Text/Highlighter.php'; + require_once 'Text/Highlighter/Renderer/Html.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $renderer = new Text_Highlighter_Renderer_HTML($options); + $hl = Text_Highlighter::factory('php'); + $hl->setRenderer($renderer); + +Note that for BC reasons, it is possible to use highlighter without setting a +renderer. If no renderer is set, HTML renderer will be used by default. In +this case, you should pass options as second parameter to factory method. The +following example works exactly as previous one: + + require_once 'Text/Highlighter.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $hl = Text_Highlighter::factory('php', $options); + + +Getting output +-------------- + +And finally, do the highlighting and get the output: + + require_once 'Text/Highlighter.php'; + require_once 'Text/Highlighter/Renderer/Html.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $renderer = new Text_Highlighter_Renderer_HTML($options); + $hl = Text_Highlighter::factory('php'); + $hl->setRenderer($renderer); + $html = $hl->highlight(file_get_contents('example.php')); + +# vim: set autoindent tabstop=4 shiftwidth=4 softtabstop=4 tw=78: */ + diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/TODO b/web/framework/vendors/TextHighlighter/Text/TODO similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/TODO rename to web/framework/vendors/TextHighlighter/Text/TODO diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/abap.xml b/web/framework/vendors/TextHighlighter/Text/abap.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/abap.xml rename to web/framework/vendors/TextHighlighter/Text/abap.xml diff --git a/web/framework/vendors/TextHighlighter/Text/avrc.xml b/web/framework/vendors/TextHighlighter/Text/avrc.xml new file mode 100644 index 000000000..dec571e13 --- /dev/null +++ b/web/framework/vendors/TextHighlighter/Text/avrc.xml @@ -0,0 +1,316 @@ + + + + + + + + + + + C/C++ highlighter specific to Atmel AVR microcontrollers + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/cpp.xml b/web/framework/vendors/TextHighlighter/Text/cpp.xml similarity index 93% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/cpp.xml rename to web/framework/vendors/TextHighlighter/Text/cpp.xml index 81f0328e4..2cbaa930f 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/cpp.xml +++ b/web/framework/vendors/TextHighlighter/Text/cpp.xml @@ -1,201 +1,201 @@ - - - - - - - - - - - -Thanks to Aaron Kalin for initial -implementation of this highlighter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + +Thanks to Aaron Kalin for initial +implementation of this highlighter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/css.xml b/web/framework/vendors/TextHighlighter/Text/css.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/css.xml rename to web/framework/vendors/TextHighlighter/Text/css.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/diff.xml b/web/framework/vendors/TextHighlighter/Text/diff.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/diff.xml rename to web/framework/vendors/TextHighlighter/Text/diff.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/dtd.xml b/web/framework/vendors/TextHighlighter/Text/dtd.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/dtd.xml rename to web/framework/vendors/TextHighlighter/Text/dtd.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/generate b/web/framework/vendors/TextHighlighter/Text/generate similarity index 93% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/generate rename to web/framework/vendors/TextHighlighter/Text/generate index 41048d91a..4e22e82fd 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/generate +++ b/web/framework/vendors/TextHighlighter/Text/generate @@ -1,171 +1,171 @@ -#!@php_bin@ - - * @copyright 2004 Andrey Demenev - * @license http://www.php.net/license/3_0.txt PHP License - * @version CVS: $Id: generate,v 1.1 2007/06/03 02:35:28 ssttoo Exp $ - * @link http://pear.php.net/package/Text_Highlighter - */ - -require_once 'Text/Highlighter/Generator.php'; -require_once 'Console/Getopt.php'; - -$options = Console_Getopt::getopt($argv, 'x:p:d:h', array('xml=', 'php=','dir=', 'help')); - -if (PEAR::isError($options)) { - $message = str_replace('Console_Getopt: ','',$options->message); - usage($message); -} - -$source = array(); -$dest = array(); -$dir = ''; - -$expectp = false; -$expectx = false; -$unexpectedx = false; -$unexpectedp = false; -$si = $di = 0; - -foreach ($options[0] as $option) { - switch ($option[0]) { - case 'x': - case '--xml': - $source[$si] = $option[1]; - if ($si) { - $di++; - } - $si++; - if ($expectp) { - $unexpectedx = true; - } - $expectp = true; - $expectx = false; - break; - - case 'p': - case '--php': - if ($expectx) { - $unexpectedp = true; - } - $dest[$di] = $option[1]; - $expectp = false; - $expectx = true; - break; - - case 'd': - case '--dir': - $dir = $option[1]; - break; - - case 'h': - case '--help': - usage(); - break; - } -} - - -if ($unexpectedx && !$dir) { - usage('Unexpected -x or --xml', STDERR); -} - -if ($unexpectedp) { - usage('Unexpected -p or --php', STDERR); -} - -$nsource = count($source); -$ndest = count($dest); - -if (!$nsource && !$ndest) { - $source[]='php://stdin'; - if (!$dir) { - $dest[]='php://stdout'; - } else { - $dest[] = null; - } -} elseif ($expectp && !$dir && $nsource > 1) { - usage('-x or --xml without following -p or --php', STDERR); -} elseif ($nsource == 1 && !$ndest && !$dir) { - $dest[]='php://stdout'; -} - -if ($dir && substr($dir,-1)!='/' && substr($dir,-1)!=='\\' ) { - $dir .= DIRECTORY_SEPARATOR; -} - - -foreach ($source as $i => $xmlfile) -{ - $gen =& new Text_Highlighter_Generator; - $gen->setInputFile($xmlfile); - if ($gen->hasErrors()) { - break; - } - $gen->generate(); - if ($gen->hasErrors()) { - break; - } - if (isset($dest[$i])) { - $phpfile = $dest[$i]; - } else { - $phpfile = $dir . $gen->language . '.php'; - } - $gen->saveCode($phpfile); - if ($gen->hasErrors()) { - break; - } -} -if ($gen->hasErrors()) { - $errors = $gen->getErrors(); - foreach ($errors as $error) { - fwrite (STDERR, $error . "\n"); - } - exit(1); -} - -function usage($message='', $file=STDOUT) -{ - $code = 0; - if ($message) { - $message .= "\n\n"; - $code = 1; - } - $message .= << tag) - -h, --help - This help -MSG; - fwrite ($file, $message); - exit($code); -} -?> - +#!@php_bin@ + + * @copyright 2004 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Highlighter + */ + +require_once 'Text/Highlighter/Generator.php'; +require_once 'Console/Getopt.php'; + +$options = Console_Getopt::getopt($argv, 'x:p:d:h', array('xml=', 'php=','dir=', 'help')); + +if (PEAR::isError($options)) { + $message = str_replace('Console_Getopt: ','',$options->message); + usage($message); +} + +$source = array(); +$dest = array(); +$dir = ''; + +$expectp = false; +$expectx = false; +$unexpectedx = false; +$unexpectedp = false; +$si = $di = 0; + +foreach ($options[0] as $option) { + switch ($option[0]) { + case 'x': + case '--xml': + $source[$si] = $option[1]; + if ($si) { + $di++; + } + $si++; + if ($expectp) { + $unexpectedx = true; + } + $expectp = true; + $expectx = false; + break; + + case 'p': + case '--php': + if ($expectx) { + $unexpectedp = true; + } + $dest[$di] = $option[1]; + $expectp = false; + $expectx = true; + break; + + case 'd': + case '--dir': + $dir = $option[1]; + break; + + case 'h': + case '--help': + usage(); + break; + } +} + + +if ($unexpectedx && !$dir) { + usage('Unexpected -x or --xml', STDERR); +} + +if ($unexpectedp) { + usage('Unexpected -p or --php', STDERR); +} + +$nsource = count($source); +$ndest = count($dest); + +if (!$nsource && !$ndest) { + $source[]='php://stdin'; + if (!$dir) { + $dest[]='php://stdout'; + } else { + $dest[] = null; + } +} elseif ($expectp && !$dir && $nsource > 1) { + usage('-x or --xml without following -p or --php', STDERR); +} elseif ($nsource == 1 && !$ndest && !$dir) { + $dest[]='php://stdout'; +} + +if ($dir && substr($dir,-1)!='/' && substr($dir,-1)!=='\\' ) { + $dir .= DIRECTORY_SEPARATOR; +} + + +foreach ($source as $i => $xmlfile) +{ + $gen = new Text_Highlighter_Generator; + $gen->setInputFile($xmlfile); + if ($gen->hasErrors()) { + break; + } + $gen->generate(); + if ($gen->hasErrors()) { + break; + } + if (isset($dest[$i])) { + $phpfile = $dest[$i]; + } else { + $phpfile = $dir . $gen->language . '.php'; + } + $gen->saveCode($phpfile); + if ($gen->hasErrors()) { + break; + } +} +if ($gen->hasErrors()) { + $errors = $gen->getErrors(); + foreach ($errors as $error) { + fwrite (STDERR, $error . "\n"); + } + exit(1); +} + +function usage($message='', $file=STDOUT) +{ + $code = 0; + if ($message) { + $message .= "\n\n"; + $code = 1; + } + $message .= << tag) + -h, --help + This help +MSG; + fwrite ($file, $message); + exit($code); +} +?> + diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/generate.bat b/web/framework/vendors/TextHighlighter/Text/generate.bat similarity index 93% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/generate.bat rename to web/framework/vendors/TextHighlighter/Text/generate.bat index 3170190ed..3960486c1 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/generate.bat +++ b/web/framework/vendors/TextHighlighter/Text/generate.bat @@ -1,188 +1,188 @@ -@echo off -rem vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: - -rem Console highlighter class generator - -rem PHP versions 4 and 5 - -rem LICENSE: This source file is subject to version 3.0 of the PHP license -rem that is available through the world-wide-web at the following URI: -rem http://www.php.net/license/3_0.txt. If you did not receive a copy of -rem the PHP License and are unable to obtain it through the web, please -rem send a note to license@php.net so we can mail you a copy immediately. - -rem @category Text -rem @package Text_Highlighter -rem @author Andrey Demenev -rem @copyright 2004 Andrey Demenev -rem @license http://www.php.net/license/3_0.txt PHP License -rem @version CVS: $Id: generate.bat,v 1.1 2007/06/03 02:35:28 ssttoo Exp $ -rem @link http://pear.php.net/package/Text_Highlighter - -set "MHL_PARAMS=" -:doshift -set "MHL_PARAMS=%MHL_PARAMS% %1" -shift -if -%1- == -- GOTO noshift -GOTO doshift -:noshift -@php_bin@ -q -d output_buffering=1 -d include_path="@php_dir@" @bin_dir@/Text/Highlighter/generate.bat %MHL_PARAMS% - -GOTO finish -message); - usage($message); -} - -$source = array(); -$dest = array(); -$dir = ''; - -$expectp = false; -$expectx = false; -$unexpectedx = false; -$unexpectedp = false; -$si = $di = 0; - -foreach ($options[0] as $option) { - switch ($option[0]) { - case 'x': - case '--xml': - $source[$si] = $option[1]; - if ($si) { - $di++; - } - $si++; - if ($expectp) { - $unexpectedx = true; - } - $expectp = true; - $expectx = false; - break; - - case 'p': - case '--php': - if ($expectx) { - $unexpectedp = true; - } - $dest[$di] = $option[1]; - $expectp = false; - $expectx = true; - break; - - case 'd': - case '--dir': - $dir = $option[1]; - break; - - case 'h': - case '--help': - usage(); - break; - } -} - - -if ($unexpectedx && !$dir) { - usage('Unexpected -x or --xml', STDERR); -} - -if ($unexpectedp) { - usage('Unexpected -p or --php', STDERR); -} - -$nsource = count($source); -$ndest = count($dest); - -if (!$nsource && !$ndest) { - $source[]='php://stdin'; - if (!$dir) { - $dest[]='php://stdout'; - } else { - $dest[] = null; - } -} elseif ($expectp && !$dir && $nsource > 1) { - usage('-x or --xml without following -p or --php', STDERR); -} elseif ($nsource == 1 && !$ndest && !$dir) { - $dest[]='php://stdout'; -} - -if ($dir && substr($dir,-1)!='/' && substr($dir,-1)!=='\\' ) { - $dir .= DIRECTORY_SEPARATOR; -} - - -foreach ($source as $i => $xmlfile) -{ - $gen =& new Text_Highlighter_Generator; - $gen->setInputFile($xmlfile); - if ($gen->hasErrors()) { - break; - } - $gen->generate(); - if ($gen->hasErrors()) { - break; - } - if (isset($dest[$i])) { - $phpfile = $dest[$i]; - } else { - $phpfile = $dir . $gen->language . '.php'; - } - $gen->saveCode($phpfile); - if ($gen->hasErrors()) { - break; - } -} -if ($gen->hasErrors()) { - $errors = $gen->getErrors(); - foreach ($errors as $error) { - fwrite (STDERR, $error . "\n"); - } - exit(1); -} - -exit(0); - -function usage($message='', $file=STDOUT) -{ - $code = 0; - if ($message) { - $message .= "\n\n"; - $code = 1; - } - $message .= << tag) - -h, --help - This help -MSG; - fwrite ($file, $message); - exit($code); -} -?> -:finish +@echo off +rem vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: + +rem Console highlighter class generator + +rem PHP versions 4 and 5 + +rem LICENSE: This source file is subject to version 3.0 of the PHP license +rem that is available through the world-wide-web at the following URI: +rem http://www.php.net/license/3_0.txt. If you did not receive a copy of +rem the PHP License and are unable to obtain it through the web, please +rem send a note to license@php.net so we can mail you a copy immediately. + +rem @category Text +rem @package Text_Highlighter +rem @author Andrey Demenev +rem @copyright 2004 Andrey Demenev +rem @license http://www.php.net/license/3_0.txt PHP License +rem @version CVS: $Id: generate.bat,v 1.1 2007-06-03 02:35:28 ssttoo Exp $ +rem @link http://pear.php.net/package/Text_Highlighter + +set "MHL_PARAMS=" +:doshift +set "MHL_PARAMS=%MHL_PARAMS% %1" +shift +if -%1- == -- GOTO noshift +GOTO doshift +:noshift +@php_bin@ -q -d output_buffering=1 -d include_path="@php_dir@" @bin_dir@/Text/Highlighter/generate.bat %MHL_PARAMS% + +GOTO finish +message); + usage($message); +} + +$source = array(); +$dest = array(); +$dir = ''; + +$expectp = false; +$expectx = false; +$unexpectedx = false; +$unexpectedp = false; +$si = $di = 0; + +foreach ($options[0] as $option) { + switch ($option[0]) { + case 'x': + case '--xml': + $source[$si] = $option[1]; + if ($si) { + $di++; + } + $si++; + if ($expectp) { + $unexpectedx = true; + } + $expectp = true; + $expectx = false; + break; + + case 'p': + case '--php': + if ($expectx) { + $unexpectedp = true; + } + $dest[$di] = $option[1]; + $expectp = false; + $expectx = true; + break; + + case 'd': + case '--dir': + $dir = $option[1]; + break; + + case 'h': + case '--help': + usage(); + break; + } +} + + +if ($unexpectedx && !$dir) { + usage('Unexpected -x or --xml', STDERR); +} + +if ($unexpectedp) { + usage('Unexpected -p or --php', STDERR); +} + +$nsource = count($source); +$ndest = count($dest); + +if (!$nsource && !$ndest) { + $source[]='php://stdin'; + if (!$dir) { + $dest[]='php://stdout'; + } else { + $dest[] = null; + } +} elseif ($expectp && !$dir && $nsource > 1) { + usage('-x or --xml without following -p or --php', STDERR); +} elseif ($nsource == 1 && !$ndest && !$dir) { + $dest[]='php://stdout'; +} + +if ($dir && substr($dir,-1)!='/' && substr($dir,-1)!=='\\' ) { + $dir .= DIRECTORY_SEPARATOR; +} + + +foreach ($source as $i => $xmlfile) +{ + $gen = new Text_Highlighter_Generator; + $gen->setInputFile($xmlfile); + if ($gen->hasErrors()) { + break; + } + $gen->generate(); + if ($gen->hasErrors()) { + break; + } + if (isset($dest[$i])) { + $phpfile = $dest[$i]; + } else { + $phpfile = $dir . $gen->language . '.php'; + } + $gen->saveCode($phpfile); + if ($gen->hasErrors()) { + break; + } +} +if ($gen->hasErrors()) { + $errors = $gen->getErrors(); + foreach ($errors as $error) { + fwrite (STDERR, $error . "\n"); + } + exit(1); +} + +exit(0); + +function usage($message='', $file=STDOUT) +{ + $code = 0; + if ($message) { + $message .= "\n\n"; + $code = 1; + } + $message .= << tag) + -h, --help + This help +MSG; + fwrite ($file, $message); + exit($code); +} +?> +:finish diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/html.xml b/web/framework/vendors/TextHighlighter/Text/html.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/html.xml rename to web/framework/vendors/TextHighlighter/Text/html.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/java.xml b/web/framework/vendors/TextHighlighter/Text/java.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/java.xml rename to web/framework/vendors/TextHighlighter/Text/java.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/javascript.xml b/web/framework/vendors/TextHighlighter/Text/javascript.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/javascript.xml rename to web/framework/vendors/TextHighlighter/Text/javascript.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/mysql.xml b/web/framework/vendors/TextHighlighter/Text/mysql.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/mysql.xml rename to web/framework/vendors/TextHighlighter/Text/mysql.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/package.xml b/web/framework/vendors/TextHighlighter/Text/package.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/package.xml rename to web/framework/vendors/TextHighlighter/Text/package.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/perl.xml b/web/framework/vendors/TextHighlighter/Text/perl.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/perl.xml rename to web/framework/vendors/TextHighlighter/Text/perl.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/php.xml b/web/framework/vendors/TextHighlighter/Text/php.xml similarity index 95% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/php.xml rename to web/framework/vendors/TextHighlighter/Text/php.xml index de00096ad..1b08ea203 100644 --- a/web/framework-1.1.17/vendors/TextHighlighter/Text/php.xml +++ b/web/framework/vendors/TextHighlighter/Text/php.xml @@ -1,194 +1,194 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/python.xml b/web/framework/vendors/TextHighlighter/Text/python.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/python.xml rename to web/framework/vendors/TextHighlighter/Text/python.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/ruby.xml b/web/framework/vendors/TextHighlighter/Text/ruby.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/ruby.xml rename to web/framework/vendors/TextHighlighter/Text/ruby.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/sample.css b/web/framework/vendors/TextHighlighter/Text/sample.css similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/sample.css rename to web/framework/vendors/TextHighlighter/Text/sample.css diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/sh.xml b/web/framework/vendors/TextHighlighter/Text/sh.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/sh.xml rename to web/framework/vendors/TextHighlighter/Text/sh.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/sql.xml b/web/framework/vendors/TextHighlighter/Text/sql.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/sql.xml rename to web/framework/vendors/TextHighlighter/Text/sql.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/vbscript.xml b/web/framework/vendors/TextHighlighter/Text/vbscript.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/vbscript.xml rename to web/framework/vendors/TextHighlighter/Text/vbscript.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/Text/xml.xml b/web/framework/vendors/TextHighlighter/Text/xml.xml similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/Text/xml.xml rename to web/framework/vendors/TextHighlighter/Text/xml.xml diff --git a/web/framework-1.1.17/vendors/TextHighlighter/highlight.css b/web/framework/vendors/TextHighlighter/highlight.css similarity index 100% rename from web/framework-1.1.17/vendors/TextHighlighter/highlight.css rename to web/framework/vendors/TextHighlighter/highlight.css diff --git a/web/framework-1.1.17/vendors/adodb/LICENSE.txt b/web/framework/vendors/adodb/LICENSE.txt similarity index 100% rename from web/framework-1.1.17/vendors/adodb/LICENSE.txt rename to web/framework/vendors/adodb/LICENSE.txt diff --git a/web/framework-1.1.17/vendors/bbq/LICENSE.txt b/web/framework/vendors/bbq/LICENSE.txt similarity index 100% rename from web/framework-1.1.17/vendors/bbq/LICENSE.txt rename to web/framework/vendors/bbq/LICENSE.txt diff --git a/web/framework-1.1.17/vendors/cldr/LICENSE.txt b/web/framework/vendors/cldr/LICENSE.txt similarity index 100% rename from web/framework-1.1.17/vendors/cldr/LICENSE.txt rename to web/framework/vendors/cldr/LICENSE.txt diff --git a/web/framework-1.1.17/vendors/console-normalizer/README.md b/web/framework/vendors/console-normalizer/README.md similarity index 100% rename from web/framework-1.1.17/vendors/console-normalizer/README.md rename to web/framework/vendors/console-normalizer/README.md diff --git a/web/framework-1.1.17/vendors/console-normalizer/normalizeconsole.min.js b/web/framework/vendors/console-normalizer/normalizeconsole.min.js similarity index 100% rename from web/framework-1.1.17/vendors/console-normalizer/normalizeconsole.min.js rename to web/framework/vendors/console-normalizer/normalizeconsole.min.js diff --git a/web/framework-1.1.17/vendors/gettext/LICENSE.txt b/web/framework/vendors/gettext/LICENSE.txt similarity index 100% rename from web/framework-1.1.17/vendors/gettext/LICENSE.txt rename to web/framework/vendors/gettext/LICENSE.txt diff --git a/web/framework-1.1.17/vendors/history/license.txt b/web/framework/vendors/history/license.txt similarity index 100% rename from web/framework-1.1.17/vendors/history/license.txt rename to web/framework/vendors/history/license.txt diff --git a/web/framework-1.1.17/vendors/htmlpurifier/HTMLPurifier.standalone.php b/web/framework/vendors/htmlpurifier/HTMLPurifier.standalone.php similarity index 96% rename from web/framework-1.1.17/vendors/htmlpurifier/HTMLPurifier.standalone.php rename to web/framework/vendors/htmlpurifier/HTMLPurifier.standalone.php index 233fed9ce..7adc09c92 100644 --- a/web/framework-1.1.17/vendors/htmlpurifier/HTMLPurifier.standalone.php +++ b/web/framework/vendors/htmlpurifier/HTMLPurifier.standalone.php @@ -7,7 +7,7 @@ * primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS * FILE, changes will be overwritten the next time the script is run. * - * @version 4.6.0 + * @version 4.9.2 * * @warning * You must *not* include any other HTML Purifier files before this file, @@ -39,7 +39,7 @@ */ /* - HTML Purifier 4.6.0 - Standards Compliant HTML Filtering + HTML Purifier 4.9.2 - Standards Compliant HTML Filtering Copyright (C) 2006-2008 Edward Z. Yang This library is free software; you can redistribute it and/or @@ -78,12 +78,12 @@ class HTMLPurifier * Version of HTML Purifier. * @type string */ - public $version = '4.6.0'; + public $version = '4.9.2'; /** * Constant with version of HTML Purifier. */ - const VERSION = '4.6.0'; + const VERSION = '4.9.2'; /** * Global configuration object. @@ -124,7 +124,7 @@ class HTMLPurifier /** * Initializes the purifier. * - * @param HTMLPurifier_Config $config Optional HTMLPurifier_Config object + * @param HTMLPurifier_Config|mixed $config Optional HTMLPurifier_Config object * for all instances of the purifier, if omitted, a default * configuration is supplied (which can be overridden on a * per-use basis). @@ -332,8 +332,8 @@ public static function arborize($tokens, $config, $context) { if ($token instanceof HTMLPurifier_Token_End) { $token->start = null; // [MUT] $r = array_pop($stack); - assert($r->name === $token->name); - assert(empty($token->attr)); + //assert($r->name === $token->name); + //assert(empty($token->attr)); $r->endCol = $token->col; $r->endLine = $token->line; $r->endArmor = $token->armor; @@ -345,7 +345,7 @@ public static function arborize($tokens, $config, $context) { $stack[] = $node; } } - assert(count($stack) == 1); + //assert(count($stack) == 1); return $stack[0]; } @@ -406,6 +406,11 @@ class HTMLPurifier_AttrCollections * @param HTMLPurifier_HTMLModule[] $modules Hash array of HTMLPurifier_HTMLModule members */ public function __construct($attr_types, $modules) + { + $this->doConstruct($attr_types, $modules); + } + + public function doConstruct($attr_types, $modules) { // load extensions from the modules foreach ($modules as $module) { @@ -615,7 +620,13 @@ public function make($string) */ protected function mungeRgb($string) { - return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string); + $p = '\s*(\d+(\.\d+)?([%]?))\s*'; + + if (preg_match('/(rgba|hsla)\(/', $string)) { + return preg_replace('/(rgba|hsla)\('.$p.','.$p.','.$p.','.$p.'\)/', '\1(\2,\5,\8,\11)', $string); + } + + return preg_replace('/(rgb|hsl)\('.$p.','.$p.','.$p.'\)/', '\1(\2,\5,\8)', $string); } /** @@ -1412,6 +1423,10 @@ protected function doSetup($config) ); $max = $config->get('CSS.MaxImgLength'); + $this->info['min-width'] = + $this->info['max-width'] = + $this->info['min-height'] = + $this->info['max-height'] = $this->info['width'] = $this->info['height'] = $max === null ? @@ -1537,8 +1552,7 @@ protected function doSetupProprietary($config) $this->info['scrollbar-highlight-color'] = new HTMLPurifier_AttrDef_CSS_Color(); $this->info['scrollbar-shadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - // technically not proprietary, but CSS3, and no one supports it - $this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + // vendor specific prefixes of opacity $this->info['-moz-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); $this->info['-khtml-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); @@ -1558,6 +1572,19 @@ protected function doSetupProprietary($config) ); $this->info['page-break-inside'] = new HTMLPurifier_AttrDef_Enum(array('auto', 'avoid')); + $border_radius = new HTMLPurifier_AttrDef_CSS_Composite( + array( + new HTMLPurifier_AttrDef_CSS_Percentage(true), // disallow negative + new HTMLPurifier_AttrDef_CSS_Length('0') // disallow negative + )); + + $this->info['border-top-left-radius'] = + $this->info['border-top-right-radius'] = + $this->info['border-bottom-right-radius'] = + $this->info['border-bottom-left-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 2); + // TODO: support SLASH syntax + $this->info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 4); + } /** @@ -1591,6 +1618,7 @@ protected function doSetupTricky($config) array('visible', 'hidden', 'collapse') ); $this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(array('visible', 'hidden', 'auto', 'scroll')); + $this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); } /** @@ -1736,7 +1764,7 @@ class HTMLPurifier_Config * HTML Purifier's version * @type string */ - public $version = '4.6.0'; + public $version = '4.9.2'; /** * Whether or not to automatically finalize @@ -2361,16 +2389,25 @@ public function maybeGetRawDefinition($name) return $this->getDefinition($name, true, true); } + /** + * @return HTMLPurifier_HTMLDefinition + */ public function maybeGetRawHTMLDefinition() { return $this->getDefinition('HTML', true, true); } - + + /** + * @return HTMLPurifier_CSSDefinition + */ public function maybeGetRawCSSDefinition() { return $this->getDefinition('CSS', true, true); } - + + /** + * @return HTMLPurifier_URIDefinition + */ public function maybeGetRawURIDefinition() { return $this->getDefinition('URI', true, true); @@ -3189,7 +3226,7 @@ abstract public function flush($config); /** * Clears all expired (older version or revision) objects from cache - * @note Be carefuly implementing this method as flush. Flush must + * @note Be careful implementing this method as flush. Flush must * not interfere with other Definition types, and cleanup() * should not be repeatedly called by userland code. * @param HTMLPurifier_Config $config @@ -3843,6 +3880,14 @@ public static function iconv($in, $out, $text, $max_chunk_size = 8000) * It will parse according to UTF-8 and return a valid UTF8 string, with * non-SGML codepoints excluded. * + * Specifically, it will permit: + * \x{9}\x{A}\x{D}\x{20}-\x{7E}\x{A0}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF} + * Source: https://www.w3.org/TR/REC-xml/#NT-Char + * Arguably this function should be modernized to the HTML5 set + * of allowed characters: + * https://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream + * which simultaneously expand and restrict the set of allowed characters. + * * @param string $str The string to clean * @param bool $force_php * @return string @@ -3864,15 +3909,12 @@ public static function iconv($in, $out, $text, $max_chunk_size = 8000) * function that needs to be able to understand UTF-8 characters. * As of right now, only smart lossless character encoding converters * would need that, and I'm probably not going to implement them. - * Once again, PHP 6 should solve all our problems. */ public static function cleanUTF8($str, $force_php = false) { // UTF-8 validity is checked since PHP 4.3.5 // This is an optimization: if the string is already valid UTF-8, no // need to do PHP stuff. 99% of the time, this will be the case. - // The regexp matches the XML char production, as well as well as excluding - // non-SGML codepoints U+007F to U+009F if (preg_match( '/^[\x{9}\x{A}\x{D}\x{20}-\x{7E}\x{A0}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]*$/Du', $str @@ -3997,6 +4039,7 @@ public static function cleanUTF8($str, $force_php = false) // 7F-9F is not strictly prohibited by XML, // but it is non-SGML, and thus we don't allow it (0xA0 <= $mUcs4 && 0xD7FF >= $mUcs4) || + (0xE000 <= $mUcs4 && 0xFFFD >= $mUcs4) || (0x10000 <= $mUcs4 && 0x10FFFF >= $mUcs4) ) ) { @@ -4419,6 +4462,138 @@ class HTMLPurifier_EntityParser */ protected $_entity_lookup; + /** + * Callback regex string for entities in text. + * @type string + */ + protected $_textEntitiesRegex; + + /** + * Callback regex string for entities in attributes. + * @type string + */ + protected $_attrEntitiesRegex; + + /** + * Tests if the beginning of a string is a semi-optional regex + */ + protected $_semiOptionalPrefixRegex; + + public function __construct() { + // From + // http://stackoverflow.com/questions/15532252/why-is-reg-being-rendered-as-without-the-bounding-semicolon + $semi_optional = "quot|QUOT|lt|LT|gt|GT|amp|AMP|AElig|Aacute|Acirc|Agrave|Aring|Atilde|Auml|COPY|Ccedil|ETH|Eacute|Ecirc|Egrave|Euml|Iacute|Icirc|Igrave|Iuml|Ntilde|Oacute|Ocirc|Ograve|Oslash|Otilde|Ouml|REG|THORN|Uacute|Ucirc|Ugrave|Uuml|Yacute|aacute|acirc|acute|aelig|agrave|aring|atilde|auml|brvbar|ccedil|cedil|cent|copy|curren|deg|divide|eacute|ecirc|egrave|eth|euml|frac12|frac14|frac34|iacute|icirc|iexcl|igrave|iquest|iuml|laquo|macr|micro|middot|nbsp|not|ntilde|oacute|ocirc|ograve|ordf|ordm|oslash|otilde|ouml|para|plusmn|pound|raquo|reg|sect|shy|sup1|sup2|sup3|szlig|thorn|times|uacute|ucirc|ugrave|uml|uuml|yacute|yen|yuml"; + + // NB: three empty captures to put the fourth match in the right + // place + $this->_semiOptionalPrefixRegex = "/&()()()($semi_optional)/"; + + $this->_textEntitiesRegex = + '/&(?:'. + // hex + '[#]x([a-fA-F0-9]+);?|'. + // dec + '[#]0*(\d+);?|'. + // string (mandatory semicolon) + // NB: order matters: match semicolon preferentially + '([A-Za-z_:][A-Za-z0-9.\-_:]*);|'. + // string (optional semicolon) + "($semi_optional)". + ')/'; + + $this->_attrEntitiesRegex = + '/&(?:'. + // hex + '[#]x([a-fA-F0-9]+);?|'. + // dec + '[#]0*(\d+);?|'. + // string (mandatory semicolon) + // NB: order matters: match semicolon preferentially + '([A-Za-z_:][A-Za-z0-9.\-_:]*);|'. + // string (optional semicolon) + // don't match if trailing is equals or alphanumeric (URL + // like) + "($semi_optional)(?![=;A-Za-z0-9])". + ')/'; + + } + + /** + * Substitute entities with the parsed equivalents. Use this on + * textual data in an HTML document (as opposed to attributes.) + * + * @param string $string String to have entities parsed. + * @return string Parsed string. + */ + public function substituteTextEntities($string) + { + return preg_replace_callback( + $this->_textEntitiesRegex, + array($this, 'entityCallback'), + $string + ); + } + + /** + * Substitute entities with the parsed equivalents. Use this on + * attribute contents in documents. + * + * @param string $string String to have entities parsed. + * @return string Parsed string. + */ + public function substituteAttrEntities($string) + { + return preg_replace_callback( + $this->_attrEntitiesRegex, + array($this, 'entityCallback'), + $string + ); + } + + /** + * Callback function for substituteNonSpecialEntities() that does the work. + * + * @param array $matches PCRE matches array, with 0 the entire match, and + * either index 1, 2 or 3 set with a hex value, dec value, + * or string (respectively). + * @return string Replacement string. + */ + + protected function entityCallback($matches) + { + $entity = $matches[0]; + $hex_part = @$matches[1]; + $dec_part = @$matches[2]; + $named_part = empty($matches[3]) ? @$matches[4] : $matches[3]; + if ($hex_part !== NULL && $hex_part !== "") { + return HTMLPurifier_Encoder::unichr(hexdec($hex_part)); + } elseif ($dec_part !== NULL && $dec_part !== "") { + return HTMLPurifier_Encoder::unichr((int) $dec_part); + } else { + if (!$this->_entity_lookup) { + $this->_entity_lookup = HTMLPurifier_EntityLookup::instance(); + } + if (isset($this->_entity_lookup->table[$named_part])) { + return $this->_entity_lookup->table[$named_part]; + } else { + // exact match didn't match anything, so test if + // any of the semicolon optional match the prefix. + // Test that this is an EXACT match is important to + // prevent infinite loop + if (!empty($matches[3])) { + return preg_replace_callback( + $this->_semiOptionalPrefixRegex, + array($this, 'entityCallback'), + $entity + ); + } + return $entity; + } + } + } + + // LEGACY CODE BELOW + /** * Callback regex string for parsing entities. * @type string @@ -4547,7 +4722,7 @@ protected function specialEntityCallback($matches) $entity; } else { return isset($this->_special_ent2dec[$matches[3]]) ? - $this->_special_ent2dec[$matches[3]] : + $this->_special_dec2str[$this->_special_ent2dec[$matches[3]]] : $entity; } } @@ -6284,6 +6459,14 @@ public function setup($config) if ($config->get('HTML.TargetBlank')) { $modules[] = 'TargetBlank'; } + // NB: HTML.TargetNoreferrer and HTML.TargetNoopener must be AFTER HTML.TargetBlank + // so that its post-attr-transform gets run afterwards. + if ($config->get('HTML.TargetNoreferrer')) { + $modules[] = 'TargetNoreferrer'; + } + if ($config->get('HTML.TargetNoopener')) { + $modules[] = 'TargetNoopener'; + } // merge in custom modules $modules = array_merge($modules, $this->userModules); @@ -7558,21 +7741,24 @@ public function __construct() ''' => "'" ); + public function parseText($string, $config) { + return $this->parseData($string, false, $config); + } + + public function parseAttr($string, $config) { + return $this->parseData($string, true, $config); + } + /** * Parses special entities into the proper characters. * * This string will translate escaped versions of the special characters * into the correct ones. * - * @warning - * You should be able to treat the output of this function as - * completely parsed, but that's only because all other entities should - * have been handled previously in substituteNonSpecialEntities() - * * @param string $string String character data to be parsed. * @return string Parsed character data. */ - public function parseData($string) + public function parseData($string, $is_attr, $config) { // following functions require at least one character if ($string === '') { @@ -7598,7 +7784,15 @@ public function parseData($string) } // hmm... now we have some uncommon entities. Use the callback. - $string = $this->_entity_parser->substituteSpecialEntities($string); + if ($config->get('Core.LegacyEntityDecoder')) { + $string = $this->_entity_parser->substituteSpecialEntities($string); + } else { + if ($is_attr) { + $string = $this->_entity_parser->substituteAttrEntities($string); + } else { + $string = $this->_entity_parser->substituteTextEntities($string); + } + } return $string; } @@ -7712,7 +7906,9 @@ public function normalize($html, $config, $context) } // expand entities that aren't the big five - $html = $this->_entity_parser->substituteNonSpecialEntities($html); + if ($config->get('Core.LegacyEntityDecoder')) { + $html = $this->_entity_parser->substituteNonSpecialEntities($html); + } // clean into wellformed UTF-8 string for an SGML context: this has // to be done after entity expansion because the entities sometimes @@ -7724,6 +7920,13 @@ public function normalize($html, $config, $context) $html = preg_replace('#<\?.+?\?>#s', '', $html); } + $hidden_elements = $config->get('Core.HiddenElements'); + if ($config->get('Core.AggressivelyRemoveScript') && + !($config->get('HTML.Trusted') || !$config->get('Core.RemoveScriptContents') + || empty($hidden_elements["script"]))) { + $html = preg_replace('#]*>.*?#i', '', $html); + } + return $html; } @@ -7734,12 +7937,17 @@ public function normalize($html, $config, $context) public function extractBody($html) { $matches = array(); - $result = preg_match('!]*>(.*)!is', $html, $matches); + $result = preg_match('|(.*?)]*>(.*)|is', $html, $matches); if ($result) { - return $matches[1]; - } else { - return $html; + // Make sure it's not in a comment + $comment_start = strrpos($matches[1], ''); + if ($comment_start === false || + ($comment_end !== false && $comment_end > $comment_start)) { + return $matches[2]; + } } + return $html; } } @@ -8408,7 +8616,7 @@ abstract class HTMLPurifier_Token public $armor = array(); /** - * Used during MakeWellFormed. + * Used during MakeWellFormed. See Note [Injector skips] * @type */ public $skip; @@ -8687,11 +8895,13 @@ public function getSchemeObj($config, $context) $def = $config->getDefinition('URI'); $scheme_obj = $def->getDefaultScheme($config, $context); if (!$scheme_obj) { - // something funky happened to the default scheme object - trigger_error( - 'Default scheme object "' . $def->defaultScheme . '" was not readable', - E_USER_WARNING - ); + if ($def->defaultScheme !== null) { + // something funky happened to the default scheme object + trigger_error( + 'Default scheme object "' . $def->defaultScheme . '" was not readable', + E_USER_WARNING + ); + } // suppress error if it's null return false; } } @@ -10064,15 +10274,42 @@ public function validate($css, $config, $context) $css = $this->parseCDATA($css); $definition = $config->getCSSDefinition(); + $allow_duplicates = $config->get("CSS.AllowDuplicates"); - // we're going to break the spec and explode by semicolons. - // This is because semicolon rarely appears in escaped form - // Doing this is generally flaky but fast - // IT MIGHT APPEAR IN URIs, see HTMLPurifier_AttrDef_CSSURI - // for details - $declarations = explode(';', $css); + // According to the CSS2.1 spec, the places where a + // non-delimiting semicolon can appear are in strings + // escape sequences. So here is some dumb hack to + // handle quotes. + $len = strlen($css); + $accum = ""; + $declarations = array(); + $quoted = false; + for ($i = 0; $i < $len; $i++) { + $c = strcspn($css, ";'\"", $i); + $accum .= substr($css, $i, $c); + $i += $c; + if ($i == $len) break; + $d = $css[$i]; + if ($quoted) { + $accum .= $d; + if ($d == $quoted) { + $quoted = false; + } + } else { + if ($d == ";") { + $declarations[] = $accum; + $accum = ""; + } else { + $accum .= $d; + $quoted = $d; + } + } + } + if ($accum != "") $declarations[] = $accum; + $propvalues = array(); + $new_declarations = ''; /** * Name of the current CSS property being validated. @@ -10122,7 +10359,11 @@ public function validate($css, $config, $context) if ($result === false) { continue; } - $propvalues[$property] = $result; + if ($allow_duplicates) { + $new_declarations .= "$property:$result;"; + } else { + $propvalues[$property] = $result; + } } $context->destroy('CurrentCSSProperty'); @@ -10131,7 +10372,6 @@ public function validate($css, $config, $context) // slightly inefficient, but it's the only way of getting rid of // duplicates. Perhaps config to optimize it, but not now. - $new_declarations = ''; foreach ($propvalues as $prop => $value) { $new_declarations .= "$prop:$value;"; } @@ -11085,6 +11325,16 @@ public function validate($string, $config, $context) class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef { + /** + * @type HTMLPurifier_AttrDef_CSS_AlphaValue + */ + protected $alpha; + + public function __construct() + { + $this->alpha = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + } + /** * @param string $color * @param HTMLPurifier_Config $config @@ -11108,59 +11358,104 @@ public function validate($color, $config, $context) return $colors[$lower]; } - if (strpos($color, 'rgb(') !== false) { - // rgb literal handling + if (preg_match('#(rgb|rgba|hsl|hsla)\(#', $color, $matches) === 1) { $length = strlen($color); if (strpos($color, ')') !== $length - 1) { return false; } - $triad = substr($color, 4, $length - 4 - 1); - $parts = explode(',', $triad); - if (count($parts) !== 3) { + + // get used function : rgb, rgba, hsl or hsla + $function = $matches[1]; + + $parameters_size = 3; + $alpha_channel = false; + if (substr($function, -1) === 'a') { + $parameters_size = 4; + $alpha_channel = true; + } + + /* + * Allowed types for values : + * parameter_position => [type => max_value] + */ + $allowed_types = array( + 1 => array('percentage' => 100, 'integer' => 255), + 2 => array('percentage' => 100, 'integer' => 255), + 3 => array('percentage' => 100, 'integer' => 255), + ); + $allow_different_types = false; + + if (strpos($function, 'hsl') !== false) { + $allowed_types = array( + 1 => array('integer' => 360), + 2 => array('percentage' => 100), + 3 => array('percentage' => 100), + ); + $allow_different_types = true; + } + + $values = trim(str_replace($function, '', $color), ' ()'); + + $parts = explode(',', $values); + if (count($parts) !== $parameters_size) { return false; } - $type = false; // to ensure that they're all the same type + + $type = false; $new_parts = array(); + $i = 0; + foreach ($parts as $part) { + $i++; $part = trim($part); + if ($part === '') { return false; } - $length = strlen($part); - if ($part[$length - 1] === '%') { - // handle percents - if (!$type) { - $type = 'percentage'; - } elseif ($type !== 'percentage') { + + // different check for alpha channel + if ($alpha_channel === true && $i === count($parts)) { + $result = $this->alpha->validate($part, $config, $context); + + if ($result === false) { return false; } - $num = (float)substr($part, 0, $length - 1); - if ($num < 0) { - $num = 0; - } - if ($num > 100) { - $num = 100; - } - $new_parts[] = "$num%"; + + $new_parts[] = (string)$result; + continue; + } + + if (substr($part, -1) === '%') { + $current_type = 'percentage'; } else { - // handle integers - if (!$type) { - $type = 'integer'; - } elseif ($type !== 'integer') { - return false; - } - $num = (int)$part; - if ($num < 0) { - $num = 0; - } - if ($num > 255) { - $num = 255; - } - $new_parts[] = (string)$num; + $current_type = 'integer'; + } + + if (!array_key_exists($current_type, $allowed_types[$i])) { + return false; + } + + if (!$type) { + $type = $current_type; + } + + if ($allow_different_types === false && $type != $current_type) { + return false; + } + + $max_value = $allowed_types[$i][$current_type]; + + if ($current_type == 'integer') { + // Return value between range 0 -> $max_value + $new_parts[] = (int)max(min($part, $max_value), 0); + } elseif ($current_type == 'percentage') { + $new_parts[] = (float)max(min(rtrim($part, '%'), $max_value), 0) . '%'; } } - $new_triad = implode(',', $new_parts); - $color = "rgb($new_triad)"; + + $new_values = implode(',', $new_parts); + + $color = $function . '(' . $new_values . ')'; } else { // hexadecimal handling if ($color[0] === '#') { @@ -11179,6 +11474,7 @@ public function validate($color, $config, $context) } return $color; } + } @@ -12079,7 +12375,7 @@ public function __construct($single, $max = 4) */ public function validate($string, $config, $context) { - $string = $this->parseCDATA($string); + $string = $this->mungeRgb($this->parseCDATA($string)); if ($string === '') { return false; } @@ -12242,6 +12538,9 @@ public function validate($uri_string, $config, $context) return false; } $uri_string = substr($uri_string, 4); + if (strlen($uri_string) == 0) { + return false; + } $new_length = strlen($uri_string) - 1; if ($uri_string[$new_length] != ')') { return false; @@ -12316,9 +12615,6 @@ public function __construct($name = false) */ public function validate($string, $config, $context) { - if (empty($string)) { - return false; - } return $this->name; } @@ -12619,18 +12915,26 @@ public function validate($id, $config, $context) // we purposely avoid using regex, hopefully this is faster - if (ctype_alpha($id)) { - $result = true; - } else { - if (!ctype_alpha(@$id[0])) { + if ($config->get('Attr.ID.HTML5') === true) { + if (preg_match('/[\t\n\x0b\x0c ]/', $id)) { return false; } - // primitive style of regexps, I suppose - $trim = trim( - $id, - 'A..Za..z0..9:-._' - ); - $result = ($trim === ''); + } else { + if (ctype_alpha($id)) { + // OK + } else { + if (!ctype_alpha(@$id[0])) { + return false; + } + // primitive style of regexps, I suppose + $trim = trim( + $id, + 'A..Za..z0..9:-._' + ); + if ($trim !== '') { + return false; + } + } } $regexp = $config->get('Attr.IDBlacklistRegexp'); @@ -12638,14 +12942,14 @@ public function validate($id, $config, $context) return false; } - if (!$this->selector && $result) { + if (!$this->selector) { $id_accumulator->add($id); } // if no change was made to the ID, return the result // else, return the new id if stripping whitespace made it // valid, or return false. - return $result ? $id : false; + return $id; } } @@ -13018,24 +13322,33 @@ public function validate($string, $config, $context) // fairly well supported. $underscore = $config->get('Core.AllowHostnameUnderscore') ? '_' : ''; + // Based off of RFC 1738, but amended so that + // as per RFC 3696, the top label need only not be all numeric. // The productions describing this are: $a = '[a-z]'; // alpha $an = '[a-z0-9]'; // alphanum $and = "[a-z0-9-$underscore]"; // alphanum | "-" // domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum - $domainlabel = "$an($and*$an)?"; - // toplabel = alpha | alpha *( alphanum | "-" ) alphanum - $toplabel = "$a($and*$an)?"; + $domainlabel = "$an(?:$and*$an)?"; + // AMENDED as per RFC 3696 + // toplabel = alphanum | alphanum *( alphanum | "-" ) alphanum + // side condition: not all numeric + $toplabel = "$an(?:$and*$an)?"; // hostname = *( domainlabel "." ) toplabel [ "." ] - if (preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string)) { - return $string; + if (preg_match("/^(?:$domainlabel\.)*($toplabel)\.?$/i", $string, $matches)) { + if (!ctype_digit($matches[1])) { + return $string; + } } + // PHP 5.3 and later support this functionality natively + if (function_exists('idn_to_ascii')) { + $string = idn_to_ascii($string); + // If we have Net_IDNA2 support, we can support IRIs by // punycoding them. (This is the most portable thing to do, // since otherwise we have to assume browsers support - - if ($config->get('Core.EnableIDNA')) { + } elseif ($config->get('Core.EnableIDNA')) { $idna = new Net_IDNA2(array('encoding' => 'utf8', 'overlong' => false, 'strict' => true)); // we need to encode each period separately $parts = explode('.', $string); @@ -13056,13 +13369,14 @@ public function validate($string, $config, $context) } } $string = implode('.', $new_parts); - if (preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string)) { - return $string; - } } catch (Exception $e) { // XXX error reporting } } + // Try again + if (preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string)) { + return $string; + } return false; } } @@ -13499,8 +13813,7 @@ public function transform($attr, $config, $context) if ($src) { $alt = $config->get('Attr.DefaultImageAlt'); if ($alt === null) { - // truncate if the alt is too long - $attr['alt'] = substr(basename($attr['src']), 0, 40); + $attr['alt'] = basename($attr['src']); } else { $attr['alt'] = $alt; } @@ -14047,6 +14360,82 @@ public function transform($attr, $config, $context) +// must be called POST validation + +/** + * Adds rel="noopener" to any links which target a different window + * than the current one. This is used to prevent malicious websites + * from silently replacing the original window, which could be used + * to do phishing. + * This transform is controlled by %HTML.TargetNoopener. + */ +class HTMLPurifier_AttrTransform_TargetNoopener extends HTMLPurifier_AttrTransform +{ + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (isset($attr['rel'])) { + $rels = explode(' ', $attr['rel']); + } else { + $rels = array(); + } + if (isset($attr['target']) && !in_array('noopener', $rels)) { + $rels[] = 'noopener'; + } + if (!empty($rels) || isset($attr['rel'])) { + $attr['rel'] = implode(' ', $rels); + } + + return $attr; + } +} + + + + +// must be called POST validation + +/** + * Adds rel="noreferrer" to any links which target a different window + * than the current one. This is used to prevent malicious websites + * from silently replacing the original window, which could be used + * to do phishing. + * This transform is controlled by %HTML.TargetNoreferrer. + */ +class HTMLPurifier_AttrTransform_TargetNoreferrer extends HTMLPurifier_AttrTransform +{ + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (isset($attr['rel'])) { + $rels = explode(' ', $attr['rel']); + } else { + $rels = array(); + } + if (isset($attr['target']) && !in_array('noreferrer', $rels)) { + $rels[] = 'noreferrer'; + } + if (!empty($rels) || isset($attr['rel'])) { + $attr['rel'] = implode(' ', $rels); + } + + return $attr; + } +} + + + + /** * Sets height/width defaults for