lib/openpgp_crypt_rsa.php
// TODO: merge this with the normal sign function
merge this with the normal sign function
merge this with the normal sign function
function sign_key_userid($packet, $hash='SHA256', $keyid=NULL) {
    if(is_array($packet)) {
      $packet = new OpenPGP_Message($packet);
    } else if(!is_object($packet)) {
      $packet = OpenPGP_Message::parse($packet);
    }
    $key = $this->private_key($keyid);
    if(!$key || !$packet) return NULL; 
    if(!$keyid) $keyid = substr($this->key->fingerprint, -16);
    $key->setHash(strtolower($hash));
    $sig = NULL;
    foreach($packet as $p) {
      if($p instanceof OpenPGP_SignaturePacket) $sig = $p;
    }
    if(!$sig) {
      $sig = new OpenPGP_SignaturePacket($packet, 'RSA', strtoupper($hash)); 
      $sig->signature_type = 0x13;
      $sig->hashed_subpackets[] = new OpenPGP_SignaturePacket_KeyFlagsPacket(array(0x01 | 0x02));
      $sig->hashed_subpackets[] = new OpenPGP_SignaturePacket_IssuerPacket($keyid);
      $packet[] = $sig;
    }
    $sig->sign_data(array('RSA' => array($hash => function($data) use($key) {return array($key->sign($data));})));
    return $packet;
  }
function sign_key_userid ( $ packet , $ hash = 'SHA256' , $ keyid = NULL ) { if ( is_array ( $ packet ) ) { $ packet = new OpenPGP_Message ( $ packet ) ; } else if ( ! is_object ( $ packet ) ) { $ packet = OpenPGP_Message :: parse ( $ packet ) ; } $ key = $ this -> private_key ( $ keyid ) ; if ( ! $ key || ! $ packet ) return NULL ; if ( ! $ keyid ) $ keyid = substr ( $ this -> key -> fingerprint , - 16 ) ; $ key -> setHash ( strtolower ( $ hash ) ) ; $ sig = NULL ; foreach ( $ packet as $ p ) { if ( $ p instanceof OpenPGP_SignaturePacket ) $ sig = $ p ; } if ( ! $ sig ) { $ sig = new OpenPGP_SignaturePacket ( $ packet , 'RSA' , strtoupper ( $ hash ) ) ; $ sig -> signature_type = 0x13 ; $ sig -> hashed_subpackets [ ] = new OpenPGP_SignaturePacket_KeyFlagsPacket ( array ( 0x01 | 0x02 ) ) ; $ sig -> hashed_subpackets [ ] = new OpenPGP_SignaturePacket_IssuerPacket ( $ keyid ) ; $ packet [ ] = $ sig ; } $ sig -> sign_data ( array ( 'RSA' => array ( $ hash => function ( $ data ) use ( $ key ) { return array ( $ key -> sign ( $ data ) ) ; } ) ) ) ; return $ packet ; }
TODO: merge this with the normal sign function
TODO : merge this with the normal sign function
// Missing some data