jasonhinkle / php-gpg

GPG / PGP port written in pure PHP with no binary dependencies
116 stars 28 forks source link

retrieve keysize #19

Closed DanielRuf closed 7 years ago

DanielRuf commented 8 years ago

I am not sure if this is the right solution.

Advice is very welcome.

In file Public_Key.php I added

class GPG_Public_Key {
    var $version;
    var $fp;
    var $key_id;
    var $user;
    var $public_key;
    var $type;
    var $size;
...
function GetKeySize()
    {
        return $this->size;
    }
...
function GPG_Public_Key($asc) {
...
        $len = 0;
        $s =  base64_decode($asc);
        $sa = str_split($s);
        $this->size=(ord($sa[1])<<8)*8;

Which gives me 2048, 4096 and so on (plus 13 extra bytes in $sa[2] which seem to be headers and so on?).

DanielRuf commented 8 years ago

@raedslab @maikuolan any thoughts about this?

Maikuolan commented 8 years ago

I think I still need to do a little more research myself to get a better understanding of it, before I'm able to make any useful suggestions; I'll look into this though. :-)

DanielRuf commented 8 years ago

Ok, no problem =) I just need feedback as we should decide together what features are needed and I want to add features, which are needed by the community and especially other developers.