getRawKeyMaterial() public method

Get the actual key material
public getRawKeyMaterial ( ) : string
return string
Example #1
0
 public function __construct($file, Key $key = null)
 {
     if (is_string($file)) {
         $this->fp = \fopen($file, 'rb');
         $this->closeAfter = true;
         $this->pos = 0;
         $this->stat = \fstat($this->fp);
     } elseif (is_resource($file)) {
         $this->fp = $file;
         $this->pos = \ftell($this->fp);
         $this->stat = \fstat($this->fp);
     } else {
         throw new \ParagonIE\Halite\Alerts\InvalidType('Argument 1: Expected a filename or resource');
     }
     $this->hashKey = !empty($key) ? $key->getRawKeyMaterial() : '';
     $this->hash = $this->getHash();
 }
Example #2
0
 /**
  * Split a key using HKDF
  *
  * @param Key $master
  * @param string $salt
  * @param Config $config
  * @return string[]
  */
 protected static function splitKeys(Key $master, string $salt = '', Config $config = null) : array
 {
     $binary = $master->getRawKeyMaterial();
     return [Util::hkdfBlake2b($binary, \Sodium\CRYPTO_SECRETBOX_KEYBYTES, $config->HKDF_SBOX, $salt), Util::hkdfBlake2b($binary, \Sodium\CRYPTO_AUTH_KEYBYTES, $config->HKDF_AUTH, $salt)];
 }
Example #3
0
 /**
  * Save a key to a file
  * 
  * @param Key|KeyPair $key
  * @param string $filename
  * @return bool
  */
 public static function save($key, string $filename = '') : bool
 {
     if ($key instanceof KeyPair) {
         return self::saveKeyFile($filename, $key->getSecretKey()->getRawKeyMaterial());
     }
     return self::saveKeyFile($filename, $key->getRawKeyMaterial());
 }