PHP Classes

File: web/SSO/vendor/simplesamlphp/xmlseclibs/tests/generatesessionkey-basics.phpt

Recommend this page to a friend!
  Classes of william amed   Raptor 2   web/SSO/vendor/simplesamlphp/xmlseclibs/tests/generatesessionkey-basics.phpt   Download  
File: web/SSO/vendor/simplesamlphp/xmlseclibs/tests/generatesessionkey-basics.phpt
Role: Example script
Content type: text/plain
Description: Example script
Class: Raptor 2
Framework that takes routes from annotations
Author: By
Last change:
Date: 8 years ago
Size: 799 bytes
 

Contents

Class file image Download
--TEST--
Basic tests for generateSessionKey().
--FILE--
<?php
require(dirname(__FILE__) . '/../xmlseclibs.php');

$key = new XMLSecurityKey(XMLSecurityKey::TRIPLEDES_CBC);
$k = $key->generateSessionKey();
if (
$key->key !== $k) {
    echo
"Return value does not match generated key.";
    exit(
1);
}

$keysizes = array(
   
XMLSecurityKey::TRIPLEDES_CBC => 24,
   
XMLSecurityKey::AES128_CBC => 16,
   
XMLSecurityKey::AES192_CBC => 24,
   
XMLSecurityKey::AES256_CBC => 32,
);

foreach (
$keysizes as $type => $keysize) {
   
$key = new XMLSecurityKey($type);
   
$k = $key->generateSessionKey();
    if (
strlen($k) !== $keysize) {
       
printf("Invalid keysize for key type %s. Was %d, should have been %d.", $type, strlen($k), $keysize);
        exit(
1);
    }
}

echo
"OK\n";

?>
--EXPECTF--
OK