Пример #1
0
 /**
  * Return an encoded message containing the updates,
  * and an encoded Ed25519 signature of the message.
  *
  * @param SignatureSecretKey $sk
  * @param string $challenge
  * @return string[]
  */
 public function verifyUpdate(SignatureSecretKey $sk, string $challenge) : array
 {
     $tree = $this->getUpdatedMerkleTree();
     $now = new \DateTime('now');
     $updates = ['challenge' => $challenge, 'root' => $tree->getRoot(), 'timestamp' => $now->format(\AIRSHIP_DATE_FORMAT)];
     $response = \json_encode($updates);
     return [Base64UrlSafe::encode($response), Base64UrlSafe::encode(AsymmetricCrypto::sign($response, $sk, true))];
 }
Пример #2
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);
 }
Пример #3
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);
 }
Пример #4
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);
 }