From 69ade89111d7f2334d447a3eb8c54489aa6c5cad Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 25 Jul 2011 12:28:33 -0500 Subject: [PATCH] refactor SecretKeyPacket read --- lib/openpgp.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/openpgp.php b/lib/openpgp.php index c1e5df6..08588ee 100644 --- a/lib/openpgp.php +++ b/lib/openpgp.php @@ -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() { if(!$this->data) return NULL; // Not decrypted yet $this->input = $this->data; - static $key_fields = array( - 1 => array('d', 'p', 'q', 'u'), // RSA - 16 => array('x'), // ELG-E - 17 => array('x'), // DSA - ); - foreach($key_fields[$this->algorithm] as $field) { + foreach(self::$secret_key_fields[$this->algorithm] as $field) { $this->key[$field] = $this->read_mpi(); }