refactor SecretKeyPacket read

This commit is contained in:
Stephen Paul Weber 2011-07-25 12:28:33 -05:00
parent 0f5742ba0d
commit 69ade89111

View File

@ -985,16 +985,19 @@ class OpenPGP_SecretKeyPacket extends OpenPGP_PublicKeyPacket {
} }
} }
static $secret_key_fields = array(
1 => array('d', 'p', 'q', 'u'), // RSA
2 => array('d', 'p', 'q', 'u'), // RSA-E
3 => array('d', 'p', 'q', 'u'), // RSA-S
16 => array('x'), // ELG-E
17 => array('x'), // DSA
);
function key_from_data() { function key_from_data() {
if(!$this->data) return NULL; // Not decrypted yet if(!$this->data) return NULL; // Not decrypted yet
$this->input = $this->data; $this->input = $this->data;
static $key_fields = array( foreach(self::$secret_key_fields[$this->algorithm] as $field) {
1 => array('d', 'p', 'q', 'u'), // RSA
16 => array('x'), // ELG-E
17 => array('x'), // DSA
);
foreach($key_fields[$this->algorithm] as $field) {
$this->key[$field] = $this->read_mpi(); $this->key[$field] = $this->read_mpi();
} }