RE: [PHP-CVS] com php-src: Add new test for openssl_pkey_new: ext/openssl/tests/openssl_pkey_new_basic.phpt
ext/openssl/tests/openssl_pkey_new_error.phpt

From: Date: Mon, 06 Jun 2016 19:46:49 +0000
Subject: RE: [PHP-CVS] com php-src: Add new test for openssl_pkey_new: ext/openssl/tests/openssl_pkey_new_basic.phpt
ext/openssl/tests/openssl_pkey_new_error.phpt
References: 1 2 3  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92334@lists.php.net to get a copy of this message
Hi Jakub, > -----Original Message----- > From: jakub.php@gmail.com [mailto:jakub.php@gmail.com] On Behalf Of Jakub > Zelenka > Sent: Monday, June 6, 2016 3:55 PM > To: Anatol Belski <anatol.php@belski.net> > Cc: php-cvs@lists.php.net > Subject: Re: [PHP-CVS] com php-src: Add new test for openssl_pkey_new: > ext/openssl/tests/openssl_pkey_new_basic.phpt > ext/openssl/tests/openssl_pkey_new_error.phpt > > Hi Anatol, > > Ah sorry for that! I tested just locally with OpenSSL 0.9.8 - 1.0.2 but should have > used PR for this one to check travis first. > > I have got an idea for a better way how to test OpenSSL errors - to check that > just some error codes are present which should be much more cross platform > compatible. I would be quite interested what the output and diff was on win. If > you could gist it for me, that would be awesome! > Here you are https://gist.github.com/weltling/de1aa801434625f2ec91e69bcfd3bbe7 > Also in cases anyone else has also got a failing Linux output (it works for me but > might be specific) that would be awesome too! It's quite important for me to > have that test as it will allow me to make sure that my error storing patch works > fine. > That's fine, it's just XFAIL for now. Splitting is indeed a good idea, as it's easier to track failures. I haven't seen the patch yet. If it's what it sounds like, unifying error messages, IMHO it could be a wasted effort. If a dependency library changes something, it'll be quite a tedious work to synchronize it again. But as mentioned, I haven't seen so don't know what it is exactly. Probably it would make sense to carry the tests along the patch, to not to cause false positives on the current branch. I for sure can run tests again if you'll need it. Regards Anatol > > On Mon, Jun 6, 2016 at 7:26 AM, Anatol Belski <anatol.php@belski.net > <mailto:anatol.php@belski.net> > wrote: > > > Hi Jakub, > > Please check ext/openssl/tests/openssl_error_string_basic.phpt with > Travis. Generally, checking for the exact error messages is barely stable, fe I see > yet different error texts on Windows. I've set it to XFAIL for now, so other > patches don't interfere with false positives. > > Thanks > > Anatol > > > -----Original Message----- > > From: Jakub Zelenka [mailto:bukka@php.net > <mailto:bukka@php.net> ] > > Sent: Sunday, June 5, 2016 6:28 PM > > To: php-cvs@lists.php.net > > <mailto:php-cvs@lists.php.net> > > Subject: [PHP-CVS] com php-src: Add new test for openssl_pkey_new: > > ext/openssl/tests/openssl_pkey_new_basic.phpt > > ext/openssl/tests/openssl_pkey_new_error.phpt > > > > Commit: d4615d1118e965be10d7c8b4d627ee90492b646b > > Author: Jakub Zelenka <bukka@php.net > > <mailto:bukka@php.net> > > Sun, 5 Jun 2016 17:27:47 +0100 > > Parents: 497fe33d6f1bbea5a62a8068169e351eb70d2db6 > > Branches: PHP-5.6 > > > > Link: http://git.php.net/?p=php- > > > src.git;a=commitdiff;h=d4615d1118e965be10d7c8b4d627ee90492b646b > > > > Log: > > Add new test for openssl_pkey_new > > > > Changed paths: > > M ext/openssl/tests/openssl_pkey_new_basic.phpt > > A ext/openssl/tests/openssl_pkey_new_error.phpt > > > > > > Diff: > > diff --git a/ext/openssl/tests/openssl_pkey_new_basic.phpt > > b/ext/openssl/tests/openssl_pkey_new_basic.phpt > > index 3c43497..b0fd530 100644 > > --- a/ext/openssl/tests/openssl_pkey_new_basic.phpt > > +++ b/ext/openssl/tests/openssl_pkey_new_basic.phpt > > @@ -1,25 +1,106 @@ > > --TEST-- > > -openssl_pkey_new() tests > > +openssl_pkey_new() basic usage tests > > --SKIPIF-- > > <?php if (!extension_loaded("openssl")) print "skip"; ?> > > --FILE-- > > <?php > > -/* openssl_pkey_get_details() segfaults when getting the information > > - from openssl_pkey_new() with an empty sub-array arg */ > > +function openssl_pkey_test_cmp($expected, $bin_key) { > > + var_dump(strcasecmp(ltrim($expected, '0'), bin2hex($bin_key))); } > > > > -$rsa = array("rsa" => array()); > > -$dsa = array("dsa" => array()); > > -$dh = array("dh" => array()); > > +// RSA > > +$nhex = > > > "BBF82F090682CE9C2338AC2B9DA871F7368D07EED41043A440D6B6F07454F51 > > F" . > > + > > > "B8DFBAAF035C02AB61EA48CEEB6FCD4876ED520D60E1EC4619719D8 > > A5B8B807F" . > > + > > > "AFB8E0A3DFC737723EE6B4B7D93A2584EE6A649D060953748834B245 > > 4598394E" . > > + > > > "E0AAB12D7B61A51F527A9A41F6C1687FE2537298CA2A8F5946F8E5FD > > 091DBDCB"; > > > > -openssl_pkey_get_details(openssl_pkey_new($rsa)); > > -openssl_pkey_get_details(openssl_pkey_new($dsa)); > > -openssl_pkey_get_details(openssl_pkey_new($dh)); > > -?> > > ---EXPECTF-- > > +$ehex = "11"; > > +$dhex = > > > "A5DAFC5341FAF289C4B988DB30C1CDF83F31251E0668B42784813801579641B > > 2" . > > + > > > "9410B3C7998D6BC465745E5C392669D6870DA2C082A939E37FDCB82E > > C93EDAC9" . > > + > > > "7FF3AD5950ACCFBC111C76F1A9529444E56AAF68C56C092CD38DC3BE > > F5D20A93" . > > + > > > "9926ED4F74A13EDDFBE1A1CECC4894AF9428C2B7B8883FE4463A4BC8 > > 5B1CB3C1"; > > + > > +$phex = > > > "EECFAE81B1B9B3C908810B10A1B5600199EB9F44AEF4FDA493B81A9E3D84F63 > > 2" . > > + > > > "124EF0236E5D1E3B7E28FAE7AA040A2D5B252176459D1F397541BA2A > > 58FB6599"; > > + > > +$qhex = > > > "C97FB1F027F453F6341233EAAAD1D9353F6C42D08866B1D05A0F2035028B9D8 > > 6" . > > + > > > "9840B41666B42E92EA0DA3B43204B5CFCE3352524D0416A5A441E700 > > AF461503"; > > > > -Warning: openssl_pkey_get_details() expects parameter 1 to be > resource, > > boolean given in %s on line %d > > +$rsa= openssl_pkey_new(array( > > + 'rsa' => array( > > + 'n' => hex2bin($nhex), > > + 'e' => hex2bin($ehex), > > + 'd' => hex2bin($dhex), > > + 'p' => hex2bin($phex), > > + 'q' => hex2bin($qhex), > > + ) > > +)); > > +$details = openssl_pkey_get_details($rsa); $rsa_details = > > +$details['rsa']; openssl_pkey_test_cmp($nhex, $rsa_details['n']); > > +openssl_pkey_test_cmp($ehex, $rsa_details['e']); > > +openssl_pkey_test_cmp($dhex, $rsa_details['d']); > > +openssl_pkey_test_cmp($phex, $rsa_details['p']); > > +openssl_pkey_test_cmp($qhex, $rsa_details['q']); > > > > -Warning: openssl_pkey_get_details() expects parameter 1 to be > resource, > > boolean given in %s on line %d > > +// DSA > > +$phex = > > > '00f8000ae45b2dacb47dd977d58b719d097bdf07cb2c17660ad898518c08' . > > + > > > '1a61659a16daadfaa406a0a994c743df5eda07e36bd0adcad921b77432f > > f' . > > + > > > '24ccc31e782d647e66768122b578857e9293df78387dc8b44af2a4a3f30 > > 5' . > > + > > > '1f236b1000a3e31da489c6681b0031f7ec37c2e1091bdb698e7660f135b > > 6' . > > + '996def90090303b7ad'; > > > > -Warning: openssl_pkey_get_details() expects parameter 1 to be > resource, > > boolean given in %s on line %d > > +$qhex = '009b3734fc9f7a4a9d6437ec314e0a78c2889af64b'; > > > > +$ghex = > > > '00b320300a0bc55b8f0ec6edc218e2185250f38fbb8291db8a89227f6e41' . > > + > > > '00d47d6ccb9c7d42fc43280ecc2ed386e81ff65bc5d6a2ae78db7372f5dc' > > . > > + > > > 'f780f4558e7ed3dd0c96a1b40727ac56c5165aed700a3b63997893a1fb2 > > 1' . > > + > > > '4e882221f0dd9604820dc34e2725dd6901c93e0ca56f6d76d495c332edc > > 5' . > > + 'b81747c4c447a941f3'; > > +$dsa = openssl_pkey_new(array( > > + 'dsa' => array( > > + 'p' => hex2bin($phex), > > + 'q' => hex2bin($qhex), > > + 'g' => hex2bin($ghex) > > + ) > > +)); > > +$details = openssl_pkey_get_details($dsa); $dsa_details = > > +$details['dsa']; openssl_pkey_test_cmp($phex, $dsa_details['p']); > > +openssl_pkey_test_cmp($qhex, $dsa_details['q']); > > +openssl_pkey_test_cmp($ghex, $dsa_details['g']); > > +var_dump(strlen($dsa_details['priv_key'])); > > +var_dump(strlen($dsa_details['pub_key'])); > > + > > +// DH > > +$phex = > > > 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' . > > + > > > 'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d2683 > > 70557' . > > + > > > '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45 > > e382' . > > + > > > '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c5 > > 83ab'; > > + > > +$dh_details = array('p' => $phex, 'g' => '2'); $dh = > > +openssl_pkey_new(array( > > + 'dh'=> array('p' => hex2bin($phex), 'g' => > > '2')) ); $details = > > +openssl_pkey_get_details($dh); $dh_details = $details['dh']; > > +openssl_pkey_test_cmp($phex, $dh_details['p']); > > +var_dump($dh_details['g']); > var_dump(strlen($dh_details['pub_key'])); > > +var_dump(strlen($dh_details['priv_key'])); > > +?> > > +--EXPECT-- > > +int(0) > > +int(0) > > +int(0) > > +int(0) > > +int(0) > > +int(0) > > +int(0) > > +int(0) > > +int(20) > > +int(128) > > +int(0) > > +string(1) "2" > > +int(128) > > +int(128) > > diff --git a/ext/openssl/tests/openssl_pkey_new_error.phpt > > b/ext/openssl/tests/openssl_pkey_new_error.phpt > > new file mode 100644 > > index 0000000..c599341 > > --- /dev/null > > +++ b/ext/openssl/tests/openssl_pkey_new_error.phpt > > @@ -0,0 +1,25 @@ > > +--TEST-- > > +openssl_pkey_new() error tests > > +--SKIPIF-- > > +<?php if (!extension_loaded("openssl")) print "skip"; ?> > > +--FILE-- > > +<?php > > +/* openssl_pkey_get_details() segfaults when getting the > information > > + from openssl_pkey_new() with an empty sub-array arg */ > > + > > +$rsa = array("rsa" => array()); > > +$dsa = array("dsa" => array()); > > +$dh = array("dh" => array()); > > + > > +openssl_pkey_get_details(openssl_pkey_new($rsa)); > > +openssl_pkey_get_details(openssl_pkey_new($dsa)); > > +openssl_pkey_get_details(openssl_pkey_new($dh)); > > +?> > > +--EXPECTF-- > > + > > +Warning: openssl_pkey_get_details() expects parameter 1 to be > resource, > > +boolean given in %s on line %d > > + > > +Warning: openssl_pkey_get_details() expects parameter 1 to be > resource, > > +boolean given in %s on line %d > > + > > +Warning: openssl_pkey_get_details() expects parameter 1 to be > resource, > > +boolean given in %s on line %d > > + > > > > > > -- > > PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: > > http://www.php.net/unsub.php > >

« previous php.cvs (#92334) next »