Fingerprint calculation works on secret keys now

This commit is contained in:
Stephen Paul Weber 2010-06-28 12:33:42 -05:00
parent 377a86aee9
commit 66ab5ccf46

View File

@ -848,12 +848,7 @@ class OpenPGP_PublicKeyPacket extends OpenPGP_Packet {
* @see http://tools.ietf.org/html/rfc4880#section-5.5.2 * @see http://tools.ietf.org/html/rfc4880#section-5.5.2
*/ */
function read_key_material() { function read_key_material() {
static $key_fields = array( foreach (self::$key_fields[$this->algorithm] as $field) {
1 => array('n', 'e'), // RSA
16 => array('p', 'g', 'y'), // ELG-E
17 => array('p', 'q', 'g', 'y'), // DSA
);
foreach ($key_fields[$this->algorithm] as $field) {
$this->key[$field] = $this->read_mpi(); $this->key[$field] = $this->read_mpi();
} }
$this->key_id = substr($this->fingerprint(), -8); $this->key_id = substr($this->fingerprint(), -8);
@ -875,9 +870,9 @@ class OpenPGP_PublicKeyPacket extends OpenPGP_Packet {
chr($this->algorithm), chr($this->algorithm),
); );
$material = array(); $material = array();
foreach ($this->key as $data) { foreach (self::$key_fields[$this->algorithm] as $i) {
$material[] = pack('n', OpenPGP::bitlength($data)); $material[] = pack('n', OpenPGP::bitlength($this->key[$i]));
$material[] = $data; $material[] = $this->key[$i];
} }
$material = implode('', $material); $material = implode('', $material);
$head[1] = pack('n', 6 + strlen($material)); $head[1] = pack('n', 6 + strlen($material));
@ -885,6 +880,12 @@ class OpenPGP_PublicKeyPacket extends OpenPGP_Packet {
} }
} }
static $key_fields = array(
1 => array('n', 'e'), // RSA
16 => array('p', 'g', 'y'), // ELG-E
17 => array('p', 'q', 'g', 'y'), // DSA
);
static $algorithms = array( static $algorithms = array(
1 => 'RSA', 1 => 'RSA',
2 => 'RSA', 2 => 'RSA',