/** * Saves file name and TTL for further garbage collection, increments counter of sent packages */ public function postPhase(StashedDataPackage $stashedDataPackage) { $cipherFile = $this->_cipherFileManager->create(); $fileName = $this->_yamler->getCipherFileName(); $cipherFile->setTimeOfDying($stashedDataPackage->getTimeOfDying())->setFileName($fileName); $this->_cipherFileManager->persist($cipherFile); $this->_packageCounterManager->incrementSentPackages(); }
/** * Encrypts hash γ same way as during ravel process to find corresponding message */ public function prePhase(StashedDataPackage $stashedDataPackage) { $stashedDataPackage->setHashGamma($this->_hasher->hashSha($stashedDataPackage->getHashGamma())); $cipherCredentials = $this->_yamler->readCipherFile($fileName = $stashedDataPackage->getHashGamma()); if (!$cipherCredentials) { return $stashedDataPackage->setError('UnravelFilter::prePhase - cipher file not found'); } $this->_flashStorage->rememberCipherFileName($stashedDataPackage->getHashGamma()); $this->_flashStorage->rememberCipherCredentials($cipherCredentials); $stashedDataPackage->setHashGamma($this->_cipher->encrypt($stashedDataPackage->getHashGamma(), $cipherCredentials['key'], $cipherCredentials['iv'])); return $stashedDataPackage; }
/** * @ORM\PostLoad * * Decrypting data after finding one in DB */ public function UnravelPhase(StashedDataPackage $stashedDataPackage, LifecycleEventArgs $event) { //Event triggers only if hash β is present in current request $clientHashBeta = $this->_stashedDataPackageManager->getClientHashBeta(); if ($clientHashBeta) { $cipherCredentials = $this->_flashStorage->recallCipherCredentials(); $hashServerBeta = $this->_cipher->decrypt(stream_get_contents($stashedDataPackage->getHashBeta()), $cipherCredentials['key'], $cipherCredentials['iv']); if ($this->_hasher->verifyHashBcrypt($clientHashBeta, $hashServerBeta)) { $cipherData = stream_get_contents($stashedDataPackage->getData()); $stashedDataPackage->setData($this->_cipher->decrypt($cipherData, $clientHashBeta, $stashedDataPackage->getSaltBeta())); } else { $stashedDataPackage->setError("StashedDataPackagePhase::UnravelPhase - no record found"); } } }
public function buildForm(FormBuilderInterface $builder, array $options) { $timeToLiveMeasureChoices = StashedDataPackage::getTimeToLiveMeasures(); $builder->add('passPhrase', 'password', ['mapped' => FALSE, 'label' => "ravel.pass_phrase.label", 'attr' => ['placeholder' => "ravel.pass_phrase.placeholder"]])->add('timeToLiveNumber', 'text', ['data' => '42', 'label' => "ravel.time_to_live_number.label", 'attr' => ['placeholder' => "ravel.time_to_live_number.placeholder"]])->add('timeToLiveMeasure', 'choice', ['choices' => array_combine($timeToLiveMeasureChoices, ["ravel.choice.minutes", "ravel.choice.hours", "ravel.choice.days"]), 'expanded' => TRUE, 'multiple' => FALSE, 'data' => $timeToLiveMeasureChoices[0], 'invalid_message' => "ravel.choice.invalid_message"])->add('data', 'textarea', ['label' => "ravel.data.label", 'attr' => ['placeholder' => "ravel.data.placeholder"]])->add('hashBeta')->add('hashGamma')->add('blankField', 'text'); }