1
0
mirror of https://github.com/danog/tgseclib.git synced 2024-11-27 12:44:38 +01:00
Commit Graph

217 Commits

Author SHA1 Message Date
terrafrost
eb860d275e RSA: Add support for AES-256-CBC 2013-02-27 20:00:20 -06:00
Hans-Jürgen Petrich
e90708297a Removed Debug function...
Removed Debug function...
2013-02-25 17:54:06 +07:00
Hans-Jürgen Petrich
afa5465e63 AES/Rijndael Performance Update [3]
Performance Update for AES/Rijndael
2013-02-25 12:19:51 +07:00
Patrick Monnerat
90ff746ad1 Make all sources 7-bit ASCII. 2013-02-20 19:25:47 +01:00
Gemorroj
cc2c844d0e some minor fixes 2013-02-20 16:46:13 +03:00
Hans-Jürgen Petrich
93f9922410 Small CS fix [2] 2013-02-07 00:45:03 +07:00
Hans-Jürgen Petrich
323396df3c Small CS fix 2013-02-03 23:19:09 +07:00
Hans-Jürgen Petrich
b4bbb27ef6 AES: Performance update
Performance update for AES
2013-01-31 00:59:53 +07:00
terrafrost
13eb688c90 AES, RC4: CS adjustments 2013-01-30 08:39:02 -06:00
terrafrost
248e3bb085 Undo last commit 2013-01-30 08:37:50 -06:00
terrafrost
bfb04dcf4d Add __construct() constructor to make namespace'ing easier for those wishing to do it 2013-01-29 22:09:31 -06:00
terrafrost
6765cb3b2b Rijndael, AES: CS adjustments 2013-01-27 01:21:28 -06:00
terrafrost
7894fd98f5 Merge pull request #65 from petrich/patch-3
Rijndael: Performance update
2013-01-26 16:29:26 -08:00
terrafrost
01be859b44 Merge pull request #66 from petrich/patch-5
AES: Performance update
2013-01-26 16:29:10 -08:00
terrafrost
d774476bcf RC4: keys were never being set in continuous mode 2013-01-26 11:16:42 -06:00
Hans-Jürgen Petrich
7dceef6ef4 AES: Performance update
Performance update for AES
Related to: https://github.com/phpseclib/phpseclib/pull/65
2013-01-26 16:58:31 +07:00
Hans-Jürgen Petrich
c95b997fa7 Rijndael: Performance update
Performance update for Rijndael
2013-01-26 16:54:19 +07:00
terrafrost
111544428e Merge pull request #63 from petrich/patch-3
Rijndael: little code optimizing
2013-01-25 21:52:40 -08:00
Hans-Jürgen Petrich
376b2759c9 RC4: fixed ContinuousBuffer() using MODE_MCRYPT
Fixed multiple calls to ContinuousBuffer() using MODE_MCRYPT
2013-01-21 21:01:37 +07:00
Hans-Jürgen Petrich
d81563d6f3 Rijndael: little code optimizing
little code optimizing
2013-01-21 15:46:44 +07:00
terrafrost
45976002c7 Merge pull request #61 from petrich/patch-3
AES: Fixed CFB decrypt() using MODE_MCRYPT and ContinuousBuffer
2013-01-20 22:57:43 -08:00
Hans-Jürgen Petrich
bfab4c47f9 DES: Fixed CFB decrypt() using MODE_MCRYPT and ContinuousBuffer
DES: Fixed small bug from commit d94f1b252d (DES.php in line 739-740)
in CFB decrypt() using CRYPT_DES_MODE_MCRYPT and enableContinuousBuffer()
2013-01-21 10:15:13 +07:00
Hans-Jürgen Petrich
2deea8b491 AES: Fixed CFB decrypt() using MODE_MCRYPT and ContinuousBuffer
AES: Fixed small bug from commit d94f1b252d (AES.php in line 425-426)
in CFB decrypt() using CRYPT_AES_MODE_MCRYPT and enableContinuousBuffer()
2013-01-21 10:08:49 +07:00
terrafrost
d94f1b252d AES, DES, RC4, Rijndael, TripleDES: multiple changes
- apply petrich's TripleDES / CFB decrypt to AES and DES
- make DES use the updated _generate_xor
- correct a comment typo
2013-01-20 10:11:19 -06:00
Hans-Jürgen Petrich
f7dc23a18e 3DES: Fixed ContinuousBuffer() in CTR/CFB/OFB
FIXED: multiple calls to enable/enableContinuousBuffer() work's now in CTR/CFB/OFB
FIXED: "Illegal string offset" and strlen(array()) Warning/Notice
Performance improvement in CFB Mode with enableContinuousBuffer() using MODE_MCRYPT
2013-01-14 21:23:20 +07:00
Hans-Jürgen Petrich
c624c785ee DES: Fixed CFB/OFB and continuousBuffer
FIXED: multiple calls to enable/disableCMode() will work now
FIXED: CFB/OFB modes
FIXED: "Illegal string offset" and strlen(array()) Warning/Notice
2013-01-13 01:48:48 +07:00
terrafrost
76a24dc546 AES: $pos will always be 0 in the last if statement for CFB 2013-01-11 18:09:28 -06:00
terrafrost
7c0926d94a Merge remote-tracking branch 'origin/petrich'
Conflicts:
	phpseclib/Crypt/AES.php
2013-01-11 18:06:43 -06:00
terrafrost
74e61deb4f AES: CFB: decrypted strings were being truncated 2013-01-11 15:30:06 -06:00
terrafrost
4a1cbfa7fd Merge remote-tracking branch 'petrich/patch-3' into petrich
Conflicts:
	phpseclib/Crypt/AES.php
2013-01-10 23:49:59 -06:00
terrafrost
bbd62f6490 AES: CFB mode fix 2013-01-10 20:42:38 -06:00
terrafrost
5ce9ad6a42 Random: $urandom -> $fp 2013-01-10 13:19:31 -06:00
Hans-Jürgen Petrich
20461866ef AES: Fix broken CFB and disableContinuousBuffer()
Related to: https://github.com/phpseclib/phpseclib/pull/45
2013-01-10 23:27:12 +07:00
terrafrost
d741def23c AES: Fix broken CFB and disableContinuousBuffer()
Quoting from petrich's pull request (from which this commit was inspired):

Fixed: Broken CFB in continuous mode when using CRYPT_AES_MODE_MCRYPT (related to: #39 )
Fixed: Multiple calls to enable/disableContinuousBuffer()
Fixed: Some PHP Notice/Warnings about strlen(array())
2013-01-09 17:39:57 -06:00
terrafrost
e71fc97913 Revamp SSH1 logging and go back to using user_error
(_handle_error returned the line number in _handle_error - not the line number triggering the error)
2013-01-08 22:09:27 -06:00
terrafrost
a890c6d127 Merge remote-tracking branch 'origin/petrich' 2013-01-06 19:14:05 -06:00
terrafrost
5e882d57fe Merge remote-tracking branch 'origin/petrich' 2013-01-06 19:10:25 -06:00
terrafrost
edc6d9cf5b AES.php in mcrypt mode always treated CFB as though it was a continuous cipher 2013-01-06 19:09:43 -06:00
terrafrost
fc2bf41588 Fix E_NOTICEs in the rewritten CFB mode 2013-01-06 19:08:36 -06:00
terrafrost
1626c0a3c7 CS adjustments to petrich's code and optimizations 2013-01-05 17:55:30 -06:00
terrafrost
fba455dfb2 Merge remote-tracking branch 'petrich/patch-2' into petrich
Conflicts:
	phpseclib/Crypt/Rijndael.php
2013-01-05 17:54:22 -06:00
Hans-Jürgen Petrich
d1f71cc5a7 Fixed CFB Decrypt(). Fixed OFB warnings
Fixed/rewritten: Decrypt() in CFB mode to work clean with enableContinuousBuffer()

Fixed: PHP's strlen(array()) warning in OFB mode,

Fixed: disableContinuousBuffer() clear's now also the $enbuffer/$debuffer arrays so that multiple calls to enable/disableContinuousBuffer() will work without old buffers
2013-01-05 16:23:35 +07:00
terrafrost
c1244dd339 CFB didn't always work in continuous mode 2013-01-04 20:53:23 -06:00
Hans-Jürgen Petrich
359e38b4d4 fixed corrupted decrypt() in CTR mode
$buffer['encrypted'] (which is always empty) should be $buffer['ciphertext'] or buffered stream will get corrupt...

Example:
define('CRYPT_AES_MODE',CRYPT_AES_MODE_INTERNAL);//in MODE_MCRYPT all is fine
$aes = new Crypt_AES(CRYPT_AES_MODE_CTR);
$aes->setKey(':-8');
$aes->enableContinuousBuffer();
$plaintext = ':-):-):-):-):-):-)';
for($i=0; $i<strlen($plaintext); $i++) {
 echo $aes->Decrypt($aes->Encrypt($plaintext[$i]));
}

Output:
:-):-):-):-):-):-(

Expected:
:-):-):-):-):-):-)


After Bugfix, output is:
:-):-):-):-):-):-)
2013-01-04 14:23:34 +07:00
terrafrost
61ad80fd64 More strlen() / empty() changes 2013-01-03 00:26:27 -06:00
terrafrost
9b4240c104 Use !empty('0') instead of strlen('0')
Thanks petrich!
2013-01-03 00:21:09 -06:00
terrafrost
e4ccaef7bf Make PEM lines be 64 bytes long instead of 72
Also, add more notes to Crypt_Random's comments
2012-12-18 07:11:24 -06:00
terrafrost
7f5e9f404a Random: expand on the explanations as to how things work 2012-12-17 08:41:47 -06:00
terrafrost
35832fe2a1 Refactor crypt_random (renaming it to crypt_random_string)
...and update all the calls to it accordingly
2012-12-16 02:20:16 -06:00
Patrick Monnerat
06779a92de Merge branch 'master' of https://github.com/phpseclib/phpseclib into pmexts 2012-12-10 12:10:06 +01:00
Patrick Monnerat
f039a6ebc2 RSA: Allow changing openssl configuration file. X509: process HoldInstructionCode.
Also fixes HoldInstruction* OIDs.
2012-12-10 12:07:49 +01:00
terrafrost
3c6ae4312f The user_error in _handle_error shouldn't be replaced.. 2012-11-29 00:19:09 -06:00
terrafrost
3caaa91160 Replace user_error() with new _handle_error() function
To use exceptions do define('PHPSECLIB_USE_EXCEPTIONS', true).

To have the exceptions thrown by phpseclib be of a certain class define PHPSECLIB_EXCEPTION_CLASS.
2012-11-28 23:33:15 -06:00
terrafrost
fbf3ba353e Null pad RSA ciphertext's to be the length of the modulo and improve XML parsing 2012-11-19 23:00:04 -06:00
terrafrost
2a1909fd71 Set $this->paddable to true in a few missing places 2012-11-16 02:59:06 -06:00
Patrick Monnerat
26b842be5b X509: compute public key identifiers.
Force subject public key identifier when signing a CA.
2012-10-29 18:21:25 +01:00
terrafrost
7ba006ccdc Add getSize() function to Crypt_RSA 2012-10-07 18:53:26 -05:00
terrafrost
ee25c73a44 Three fixes
- Ingore white space in keys
- Handle negative numbers in the same way OpenSSL seems to handle them
- Fix signature verification (thanks Richard Odekerken!)
2012-09-29 14:32:27 -05:00
terrafrost
13eed6147a Do CRYPT_DES_MODE_CBC instead of CRYPT_MODE_DES_CBC 2012-09-22 11:38:09 -05:00
terrafrost
6686e203e7 Reformat keys even if private key format is the same OpenSSL uses
As is private keys weren't being encrypted when a private key was being set and OpenSSL was being used.

Thanks TeigneuX!
2012-09-18 05:17:14 -05:00
terrafrost
26776b486e Update a few comments 2012-09-03 01:42:50 -05:00
terrafrost
a3781bd172 Changing the public key format broke File_X509 2012-09-03 01:32:57 -05:00
terrafrost
2f8d1055ea Use OpenSSL for Math_BigInteger::modPow speedups
Also, make Crypt_RSA's public keys compatible with OpenSSL and make it so __toString will return the key even when it's the public key that's loaded and it hasn't been set as the public key.
2012-08-26 01:36:34 -05:00
terrafrost
6c4fcd34d3 Misc fixes
- make it so '' is a legit password and doesn't unset the pw to pass bantu's unit tests (unit test could have been updated too but whatever)
- make it so not passing in any parameters to Crypt_RSA::setPassword() works without E_NOTICE or E_WARNING as per example in docs
- add missing phpdoc headers to File_ANSI
- cryan -> cyan in File_ANSI
2012-08-23 08:59:49 -05:00
terrafrost
6e1b79ba24 - add __toString magic method to Crypt_RSA 2012-07-26 13:14:18 -05:00
terrafrost
f292931aed - make Net_SSH2 return more printer friendly server public host keys 2012-07-04 13:36:26 -05:00
terrafrost
1417463eba - make Crypt_RSA use openssl for key generation (if openssl is available) and make it so File_X509 can create CSRs 2012-07-01 12:07:42 -05:00
terrafrost
f0e1b2deec - add second function_exists call to prevent require_once from being called if autoloader was called 2012-06-27 20:56:36 -05:00
terrafrost
5eacf2b05d - do class_exists(Crypt_Random) too to facilitate auto-loading 2012-06-24 16:53:16 -05:00
terrafrost
6ee991f604 Merge branch 'master' of https://github.com/phpseclib/phpseclib 2012-06-20 10:43:20 -05:00
terrafrost
1e3778dc4f - auto loading fixes (thanks skydiablo) 2012-06-20 10:36:36 -05:00
terrafrost
dfe264594f Merge pull request #9 from bantu/feature/consistent-file-endings
[feature/consistent-file-endings] Remove ?> and make sure there is an empty line at the end of files.
2012-06-16 21:06:15 -07:00
terrafrost
ccd2b6ae78 - PBKDF2 updates 2012-06-16 16:42:54 -05:00
Andreas Fischer
eb64dfef7d [feature/consistent-file-endings] Make sure files have empty line at the end. 2012-06-11 10:34:07 +02:00
Andreas Fischer
5923f4ad68 [feature/consistent-file-endings] Remove remaining ?> from PHP files. 2012-06-11 10:33:39 +02:00
Rob Loach
7e9a975296 Add Composer support to phpseclib 2012-06-08 15:38:27 -04:00
Andreas Fischer
71dea1fc2b [topic/40730] Use strlen() instead of count() in function _equals() of Crypt_RSA.
It appears that count() always returns int(1) on strings. Thus, this check is
pointless as is. strlen() was meant here and is actually required to prevent
E_NOTICEs from invalid array accesses using $y[$i].
2012-06-06 13:12:48 +02:00
Jim Wigginton
7f1c861c1a - $this->mcrypt was removed in a commit from yesterday
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@222 21d32557-59b3-4da0-833f-c5933fad653e
2012-05-14 18:20:11 +00:00
Jim Wigginton
b39d2597dd - if the algorithm is not supported upon mcrypt's initial initialization use the internal implementation
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@220 21d32557-59b3-4da0-833f-c5933fad653e
2012-05-14 01:21:21 +00:00
Jim Wigginton
5db0f88218 - add blinded rsa equality test (thanks singpolyma!)
- make validateSignature behave more like openssl_verify()

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@218 21d32557-59b3-4da0-833f-c5933fad653e
2012-05-05 23:57:30 +00:00
Jim Wigginton
6d60fa63e5 - make it so the following all do the same thing:
$pubKey = new Crypt_RSA();
$pubKey->loadKey($privKey->getPublicKey());
$pubKey->setPublicKey();

$pubKey = new Crypt_RSA();
$pubKey->loadKey($privKey->getPublicKey());
$pubKey->setPublicKey($privKey->getPublicKey());

$pubKey = new Crypt_RSA();
$pubKey->setPublicKey($privKey->getPublicKey());

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@211 21d32557-59b3-4da0-833f-c5933fad653e
2012-04-17 06:21:42 +00:00
Jim Wigginton
60340d5466 - make it so setPublicKey() can guess at the format like loadKey() can
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@204 21d32557-59b3-4da0-833f-c5933fad653e
2012-03-11 19:13:34 +00:00
Jim Wigginton
257b18501e - make setHash non case sensitive (thanks e1ven!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@191 21d32557-59b3-4da0-833f-c5933fad653e
2011-12-14 13:36:31 +00:00
Jim Wigginton
019edc6694 - the key has to be truncated before setKey() is called or else it'll be rounded up to the nearest key size - not down
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@190 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-25 00:11:19 +00:00
Jim Wigginton
f600a9bb50 - !== is faster than !=
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@189 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-24 19:03:56 +00:00
Jim Wigginton
70ea9ceec8 - update link to svn.php.net
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@188 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-24 18:46:12 +00:00
Jim Wigginton
e8d6d8d165 - use openssl_random_pseudo_bytes if available (thanks wise.man!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@187 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-24 18:32:49 +00:00
Jim Wigginton
b1c7fed946 - the IV wasn't resetting when mcrypt was being used
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@186 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-16 06:53:36 +00:00
Jim Wigginton
a00a5e6ba4 - add pbkdf2 support via setPassword()
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@185 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-13 02:23:56 +00:00
Jim Wigginton
bc1c12357d - CRYPT_RSA_PUBLIC_FORMAT_XML didn't work correctly
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@184 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-07 08:25:59 +00:00
Jim Wigginton
cfcf20cce5 - add the ability to save newly created keys in the XML and PuTTY formats
- add the ability to save private keys that have already been loaded

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@182 21d32557-59b3-4da0-833f-c5933fad653e
2011-11-07 01:35:12 +00:00
Jim Wigginton
d7c43d03a2 - fix bug with pure-PHP CTR mode (thanks, Max!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@177 21d32557-59b3-4da0-833f-c5933fad653e
2011-09-04 16:23:50 +00:00
Jim Wigginton
2676ca1d91 - password protected PuTTY keys error out ungracefully when a bad password is used to decrypt
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@176 21d32557-59b3-4da0-833f-c5933fad653e
2011-08-17 00:12:42 +00:00
Jim Wigginton
a5d702346a - improved handling of malformed RSA keys: part II
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@172 21d32557-59b3-4da0-833f-c5933fad653e
2011-07-11 00:37:46 +00:00
Jim Wigginton
d4a3d61ff5 - improved handling of malformed RSA keys (thanks scope_v24!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@171 21d32557-59b3-4da0-833f-c5933fad653e
2011-07-11 00:02:53 +00:00
Jim Wigginton
96471cf1dd - fix an E_NOTE error in Rijndael.php (thanks, tchamness!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@164 21d32557-59b3-4da0-833f-c5933fad653e
2011-06-04 16:10:05 +00:00
Jim Wigginton
737ea2c9e9 - add support for a new type of key format (thanks spotweb2!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@159 21d32557-59b3-4da0-833f-c5933fad653e
2011-05-28 16:23:15 +00:00
Jim Wigginton
c61b3f9da9 - fix E_NOTICE (thanks, loige!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@157 21d32557-59b3-4da0-833f-c5933fad653e
2011-05-08 03:09:11 +00:00
Jim Wigginton
392d96445e - add support for PuTTY and XML formatted RSA keys
- remove ?>'s from PHP_Compat files
- update LICENSE block
- make it so NET_SSH2_MSG_USERAUTH_PK_OK records direction and time

git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@152 21d32557-59b3-4da0-833f-c5933fad653e
2011-04-18 12:17:40 +00:00
Jim Wigginton
06e8afb418 - fixed a bug that could prevent _emsa_pss_verify from working in rare circumstances (thanks Lesque!)
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@148 21d32557-59b3-4da0-833f-c5933fad653e
2011-03-19 03:32:22 +00:00