Exemple #1
0
 /**
  * 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);
 }
Exemple #2
0
 /**
  * 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);
     }
 }
Exemple #3
0
 /**
  * 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);
 }
 /**
  * Set up our key pair
  *
  * @param SignatureSecretKey $secret
  */
 protected function setupKeyPair(SignatureSecretKey $secret)
 {
     $this->secretKey = $secret;
     $this->publicKey = $this->secretKey->derivePublicKey();
 }
Exemple #5
0
 /**
  * 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);
 }
Exemple #6
0
 /**
  * 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;
 }
Exemple #7
0
 /**
  * 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);
 }