Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyen Van Nguyen <nguyennv1981@gmail.com>
  • Loading branch information
nguyennv committed Aug 28, 2024
1 parent 3a6a6cb commit d2e3a90
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Common/Armor.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static function decode(
}

$data = Strings::base64_decode(implode($dataLines));
if (strcmp($checksum, $self::crc24Checksum($data)) !== 0 &&
if (strcmp($checksum, self::crc24Checksum($data)) !== 0 &&
(!empty($checksum) || $checksumRequired))
{
throw new \UnexpectedValueException(
Expand Down
2 changes: 1 addition & 1 deletion src/Cryptor/Aead/OCB.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private function crypt(
$offset = self::xor($offset, $this->mask[self::ntz($i + 1)]);
// C_i = Offset_i xor ENCIPHER(K, P_i xor Offset_i)
// P_i = Offset_i xor DECIPHER(K, C_i xor Offset_i)
if (strcmp($cipher, $this->encipher) === 0) {
if ($cipher === $this->encipher) {
$encrypted = self::xor($cipher->encryptBlock(self::xor($offset, $text)), $offset);
}
else {
Expand Down
5 changes: 4 additions & 1 deletion src/Packet/PublicKeyEncryptedSessionKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,13 @@ public function decrypt(SecretKeyPacketInterface $secretKey): self
}
else {
return new self(
$this->version,
$secretKey->getKeyID(),
$secretKey->getVersion(),
$secretKey->getFingerprint(),
$secretKey->getKeyAlgorithm(),
$this->sessionKeyCryptor,
$this->decryptSessionKey($secretKey)
$this->decryptSessionKey($secretKey),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Packet/AeadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testAeadEncrypt()
new PacketList([LiteralData::fromText(self::LITERAL_TEXT)])
);
$this->assertEquals($aedp->getSymmetricAlgorithm(), SymmetricAlgorithm::Aes128);
$this->assertEquals($aedp->getAeadAlgorithm(), AeadAlgorithm::Eax);
$this->assertEquals($aedp->getAeadAlgorithm(), AeadAlgorithm::Gcm);
$this->assertTrue(!empty($aedp->getEncrypted()));

$aedp = $aedp->decrypt($sessionKey->getEncryptionKey());
Expand Down

0 comments on commit d2e3a90

Please sign in to comment.