loadEncryptionPublicKey() public static méthode

Load, specifically, an encryption public key from a file
public static loadEncryptionPublicKey ( string $filePath ) : EncryptionPublicKey
$filePath string
Résultat EncryptionPublicKey
Exemple #1
0
 }
 $state = \Airship\Engine\State::instance();
 $keys = [];
 foreach ($keyRing as $index => $keyConfig) {
     $path = ROOT . '/config/keyring/' . $keyConfig['file'];
     if (\file_exists($path)) {
         // Load it from disk
         switch ($keyConfig['type']) {
             case 'AuthenticationKey':
                 $keys[$index] = KeyFactory::loadAuthenticationKey($path);
                 break;
             case 'EncryptionKey':
                 $keys[$index] = KeyFactory::loadEncryptionKey($path);
                 break;
             case 'EncryptionPublicKey':
                 $keys[$index] = KeyFactory::loadEncryptionPublicKey($path);
                 break;
             case 'EncryptionSecretKey':
                 $keys[$index] = KeyFactory::loadEncryptionSecretKey($path);
                 break;
             case 'SignaturePublicKey':
                 $keys[$index] = KeyFactory::loadSignaturePublicKey($path);
                 break;
             case 'SignatureSecretKey':
                 $keys[$index] = KeyFactory::loadSignatureSecretKey($path);
                 break;
             case 'EncryptionKeyPair':
                 $keys[$index] = KeyFactory::loadEncryptionKeyPair($path);
                 break;
             case 'SignatureKeyPair':
                 $keys[$index] = KeyFactory::loadSignatureKeyPair($path);
Exemple #2
0
 public function testLegacyEncKeyStorage()
 {
     $enc_keypair = KeyFactory::deriveEncryptionKeyPair('apple', "\t\n\v\f\r" . "", true);
     $enc_secret = $enc_keypair->getSecretKey();
     $enc_public = $enc_keypair->getPublicKey();
     $file_secret = \tempnam(__DIR__ . '/tmp', 'key');
     $file_public = \tempnam(__DIR__ . '/tmp', 'key');
     $this->assertTrue(KeyFactory::save($enc_secret, $file_secret) !== false);
     $this->assertTrue(KeyFactory::save($enc_public, $file_public) !== false);
     $load_public = KeyFactory::loadEncryptionPublicKey($file_public);
     $this->assertTrue($load_public instanceof EncryptionPublicKey);
     $this->assertTrue(\hash_equals($enc_public->getRawKeyMaterial(), $load_public->getRawKeyMaterial()));
     \unlink($file_secret);
     \unlink($file_public);
 }