Crypt-MatrixSSL3

 view release on metacpan or  search on metacpan

t/matrixSslEncodeRehandshake.t  view on Meta::CPAN

use warnings;
use strict;
use Test::More;
use Test::Exception;

use Crypt::MatrixSSL3 qw(:all);

Crypt::MatrixSSL3::Open();

my $certFile            = 't/cert/server.crt';
my $privFile            = 't/cert/server.key';
my $privPass            = undef;
my $trustedCAcertFiles  = 't/cert/testCA.crt';
my $trustedCAbundle     = $Crypt::MatrixSSL3::CA_CERTIFICATES;

my ($Server_Keys, $Client_Keys);
my ($Server_SSL, $Client_SSL);

my @Alert;

my ($client2server, $server2client) = (q{}, q{});

is MATRIXSSL_SUCCESS, Crypt::MatrixSSL3::set_cipher_suite_enabled_status(TLS_RSA_WITH_AES_128_CBC_SHA, PS_FALSE),
    'disable TLS_RSA_WITH_AES_128_CBC_SHA';

new($trustedCAcertFiles, undef);
handshake();
io();
is $Client_SSL->encode_rehandshake(undef, undef, SSL_OPTION_FULL_HANDSHAKE, [SSL_RSA_WITH_RC4_128_MD5]), PS_UNSUPPORTED_FAIL,
    '--- Rehandshake: unsupported cipher';
io();
fin();

new($trustedCAcertFiles, undef);
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, undef, 0, undef),
    '--- Rehandshake: change nothing';
handshake();
io();
fin();

new($trustedCAcertFiles, undef);
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, undef, SSL_OPTION_FULL_HANDSHAKE, undef),
    '--- Rehandshake: change nothing (full rehandshake)';
handshake();
io();
fin();

new($trustedCAcertFiles, undef);
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake($Client_Keys, undef, 0, undef),
    '--- Rehandshake: change nothing (same keys)';
handshake();
io();
fin();

new($trustedCAcertFiles, undef);
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, undef, SSL_OPTION_FULL_HANDSHAKE, [TLS_RSA_WITH_AES_256_CBC_SHA]),
    '--- Rehandshake: change cipher to TLS_RSA_WITH_AES_256_CBC_SHA';
handshake();
io();
fin();

=for not allowed anymore

new($trustedCAcertFiles, undef);
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, undef, SSL_OPTION_FULL_HANDSHAKE, [SSL_NULL_WITH_NULL_NULL]),
    '--- Rehandshake: change cipher to SSL_NULL_WITH_NULL_NULL';
handshake();
io(1);
fin();

new($trustedCAcertFiles, undef);
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, undef, SSL_OPTION_FULL_HANDSHAKE, [SSL_RSA_WITH_NULL_SHA]),
    '--- Rehandshake: change cipher to SSL_RSA_WITH_NULL_SHA';
handshake();
io(1);
fin();

new($trustedCAcertFiles, undef);
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, undef, 0, [SSL_RSA_WITH_NULL_SHA]),
    '--- Rehandshake: change cipher to SSL_RSA_WITH_NULL_SHA (without FULL_HANDSHAKE)';
handshake();
io(1);
fin();

=cut

new($trustedCAcertFiles, sub{0});
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, undef, 0, undef),
    '--- Rehandshake: change nothing';
handshake();
io();
fin();

# TODO crash 3.3.0
# new($trustedCAcertFiles, sub{0});
# handshake();
# io();
# is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake($Client_Keys, undef, 0, 0),
#     '--- Rehandshake: change nothing (same keys)';
# handshake();
# io();
# fin();

new($trustedCAcertFiles, sub{0});
handshake();
io();
is MATRIXSSL_SUCCESS, $Client_SSL->encode_rehandshake(undef, sub{0}, 0, undef),
    '--- Rehandshake: change nothing (same callback)';
handshake();



( run in 1.854 second using v1.01-cache-2.11-cpan-e1769b4cff6 )