コード例 #1
0
ファイル: Notary.php プロジェクト: paragonie/airship
 /**
  * This function is called after the dependencies have been injected by
  * AutoPilot. Think of it as a user-land constructor.
  */
 public function airshipLand()
 {
     parent::airshipLand();
     $config = State::instance();
     if (empty($config->universal['notary']['enabled'])) {
         \Airship\json_response(['status' => 'error', 'message' => 'This Airship does not offer Notary services.']);
     }
     $this->sk = $config->keyring['notary.online_signing_key'];
     $this->pk = $this->sk->derivePublicKey();
     $this->channel = $config->universal['notary']['channel'];
     $this->chanUp = $this->blueprint('ChannelUpdates', $this->channel);
 }
コード例 #2
0
ファイル: OpenSSL.php プロジェクト: sagarjethi/pco_prototype
 /**
  * Sign a message, using your secret key
  * 
  * @param string|resource $sealed
  * @param EncryptionPublicKey $publicKey
  * @return string
  */
 public function signAsymmetric($message, SignatureSecretKey $secretKey, array $options = []) : string
 {
     $signature = '';
     $signed = \openssl_sign($message, $signature, $secretKey->getPEM(), 'sha384WithRSAEncryption');
     if ($signed) {
         return binhex($signature);
     }
 }
コード例 #3
0
ファイル: File.php プロジェクト: AndrewCarterUK/halite
 /**
  * Sign the contents of a file
  *
  * @param ReadOnlyFile $input
  * @param SignatureSecretKey $secretkey
  * @param bool $raw_binary Don't hex encode?
  * @return string
  * @throws CryptoException\InvalidKey
  */
 protected static function signData(ReadOnlyFile $input, SignatureSecretKey $secretkey, bool $raw_binary = false) : string
 {
     if (!$secretkey instanceof SignatureSecretKey) {
         throw new CryptoException\InvalidKey('Argument 1: Expected an instance of SignatureSecretKey');
     }
     $csum = self::checksumData($input, $secretkey->derivePublicKey(), true);
     return AsymmetricCrypto::sign($csum, $secretkey, $raw_binary);
 }
コード例 #4
0
ファイル: SignatureKeyPair.php プロジェクト: paragonie/halite
 /**
  * Set up our key pair
  *
  * @param SignatureSecretKey $secret
  */
 protected function setupKeyPair(SignatureSecretKey $secret)
 {
     $this->secretKey = $secret;
     $this->publicKey = $this->secretKey->derivePublicKey();
 }
コード例 #5
0
ファイル: File.php プロジェクト: paragonie/halite
 /**
  * Sign the contents of a file
  *
  * @param ReadOnlyFile $input
  * @param SignatureSecretKey $secretKey
  * @param bool $raw_binary Don't hex encode?
  * @return string
  */
 protected static function signData(ReadOnlyFile $input, SignatureSecretKey $secretKey, bool $raw_binary = false) : string
 {
     $checksum = self::checksumData($input, $secretKey->derivePublicKey(), true);
     return AsymmetricCrypto::sign($checksum, $secretKey, $raw_binary);
 }
コード例 #6
0
ファイル: Crypto.php プロジェクト: paragonie/halite
 /**
  * Sign a message with our private key
  * 
  * @param string $message Message to sign
  * @param SignatureSecretKey $privateKey
  * @param mixed $encoding Which encoding scheme to use?
  * @return string Signature (detached)
  */
 public static function sign(string $message, SignatureSecretKey $privateKey, $encoding = Halite::ENCODE_BASE64URLSAFE) : string
 {
     $signed = \Sodium\crypto_sign_detached($message, $privateKey->getRawKeyMaterial());
     $encoder = Halite::chooseEncoder($encoding);
     if ($encoder) {
         return $encoder($signed);
     }
     return $signed;
 }
コード例 #7
0
ファイル: File.php プロジェクト: paragonie/halite
 /**
  * Sign the contents of a file
  *
  * @param ReadOnlyFile $input
  * @param SignatureSecretKey $secretKey
  * @param mixed $encoding Which encoding scheme to use for the signature?
  * @return string
  */
 protected static function signData(ReadOnlyFile $input, SignatureSecretKey $secretKey, $encoding = Halite::ENCODE_BASE64URLSAFE) : string
 {
     $checksum = self::checksumData($input, $secretKey->derivePublicKey(), true);
     return AsymmetricCrypto::sign($checksum, $secretKey, $encoding);
 }