コード例 #1
0
ファイル: SecretTest.php プロジェクト: firehed/security
 /**
  * @covers ::__construct
  * @covers ::reveal
  */
 public function testMaskingStringLongerThanNoiseLength()
 {
     $noise = SecretKey::getKey();
     $noise_length = mb_strlen($noise, '8bit');
     $string = str_repeat('asdf', $noise_length);
     $secret = new Secret($string);
     $this->assertSame($string, $secret->reveal(), 'Secret was destroyed');
 }
コード例 #2
0
 /**
  * @param string $keyMaterial - The actual key data
  * @param bool $signing - Is this a signing key?
  */
 public function __construct($keyMaterial = '', ...$args)
 {
     parent::__construct($keyMaterial, true);
 }
コード例 #3
0
ファイル: SecretKeyTest.php プロジェクト: firehed/security
 /**
  * @covers ::getKey
  */
 public function testGetKey()
 {
     $this->assertInternalType('string', SecretKey::getKey());
 }
コード例 #4
0
ファイル: GPG.php プロジェクト: nicholasryan/CorePlus
	/**
	 * Internal function to parse output lines, (usually from gpg --recv-keys or gpg --list-keys),
	 * into an array of valid Key and SecretKey objects.
	 *
	 * @param array $output
	 *
	 * @return array
	 */
	private function _parseOutputLines($output){
		$keys = [];
		$k    = null; // Last Key

		foreach($output as $line){
			$type = substr($line, 0, 4);

			switch($type){
				case 'gpg:':
					// This is a GPG comment, skip it.
					continue;
					break;
				case 'tru:':
					// This is a trust definition, skip it for now.
					continue;
					break;
				case 'pub:':
					if($k !== null){
						// This is a new key.
						// Save the previous one.
						$keys[] = $k;
					}

					// This is a new key object.
					$k = new PublicKey();
					$k->parseLine($line);
					break;
				case 'sec:':
					if($k !== null){
						// This is a new key.
						// Save the previous one.
						$keys[] = $k;
					}

					// This is a new key object.
					$k = new SecretKey();
					$k->parseLine($line);
					break;
				default:
					if($k !== null) {
						// Let the previous key handle it!
						$k->parseLine($line);
					}
					break;
			}
		}

		// End of output and there is data?
		if($k !== null){
			$keys[] = $k;
		}


		return $keys;
	}
コード例 #5
0
ファイル: Secret.php プロジェクト: firehed/security
 /**
  * @return string The original secret
  */
 public function reveal() : string
 {
     return $this->mask($this->value, SecretKey::getKey());
 }