@@ -150,10 +150,12 @@ class OpenPGP_S2K {
|
||||
$bytes .= chr($this->hash_algorithm);
|
||||
break;
|
||||
case 1:
|
||||
if(strlen($this->salt) != 8) throw new Exception("Invalid salt length");
|
||||
$bytes .= chr($this->hash_algorithm);
|
||||
$bytes .= $this->salt;
|
||||
break;
|
||||
case 3:
|
||||
if(strlen($this->salt) != 8) throw new Exception("Invalid salt length");
|
||||
$bytes .= chr($this->hash_algorithm);
|
||||
$bytes .= $this->salt;
|
||||
$bytes .= chr(OpenPGP::encode_s2k_count($this->count));
|
||||
|
@@ -40,7 +40,7 @@ class OpenPGP_Crypt_Symmetric {
|
||||
$esk = pack('n', OpenPGP::bitlength($esk)) . $esk;
|
||||
array_unshift($encrypted, new OpenPGP_AsymmetricSessionKeyPacket($pass->algorithm, $pass->fingerprint(), $esk));
|
||||
} else if(is_string($pass)) {
|
||||
$s2k = new OpenPGP_S2K(Random::string(10));
|
||||
$s2k = new OpenPGP_S2K(Random::string(8));
|
||||
$cipher->setKey($s2k->make_key($pass, $key_bytes));
|
||||
$esk = $cipher->encrypt(chr($symmetric_algorithm) . $key);
|
||||
array_unshift($encrypted, new OpenPGP_SymmetricSessionKeyPacket($s2k, $esk, $symmetric_algorithm));
|
||||
|
Reference in New Issue
Block a user