File: tests/KeyExchangeTest.php

Recommend this page to a friend!
  Classes of Scott Arciszewski  >  sapient  >  tests/KeyExchangeTest.php  >  Download  
File: tests/KeyExchangeTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: sapient
Add a security layer to server to server requests
Author: By
Last change: Proposal: Inject adapters, punt to adapter where appropriate.
Merge remote-tracking branch 'origin/master'
Date: 3 years ago
Size: 1,376 bytes
 

Contents

Class file image Download
<?php
namespace ParagonIE\Sapient\UnitTests;

use
ParagonIE\Sapient\CryptographyKeys\{
   
SealingPublicKey,
   
SealingSecretKey
};
use
PHPUnit\Framework\TestCase;

/**
 * Class SapientTest
 * @package ParagonIE\Sapient\UnitTests
 */
class KeyExchangeTest extends TestCase
{
   
/** @var SealingSecretKey */
   
protected $clientSealSecret;

   
/** @var SealingPublicKey */
   
protected $clientSealPublic;

   
/** @var SealingSecretKey */
   
protected $serverSealSecret;

   
/** @var SealingPublicKey */
   
protected $serverSealPublic;

   
/**
     * Setup the class properties
     */
   
public function setUp()
    {
       
$this->clientSealSecret = SealingSecretKey::generate();
       
$this->clientSealPublic = $this->clientSealSecret->getPublickey();

       
$this->serverSealSecret = SealingSecretKey::generate();
       
$this->serverSealPublic = $this->serverSealSecret->getPublickey();
    }

   
/**
     * @covers SealingSecretKey::deriveSharedEncryptionkey()
     */
   
public function testKeyExchange()
    {
       
$clientShared = $this->clientSealSecret->deriveSharedEncryptionkey($this->serverSealPublic, false);
       
$serverShared = $this->serverSealSecret->deriveSharedEncryptionkey($this->clientSealPublic, true);

       
$this->assertSame(
           
$clientShared->getString(),
           
$serverShared->getString()
        );
    }
}


For more information send a message to info at phpclasses dot org.