Logo Search packages:      
Sourcecode: acidbase version File versions  Download package

Cpdf::o_encryption ( id,
action,
options = '' 
)

encryption object.

Definition at line 1015 of file class.pdf.php.

References $options, ARC4(), ARC4_init(), and md5_16().

Referenced by setEncryption().

                                              {
  if ($action!='new'){
    $o =& $this->objects[$id];
  }
  switch($action){
    case 'new':
      // make the new object
      $this->objects[$id]=array('t'=>'encryption','info'=>$options);
      $this->arc4_objnum=$id;
      // figure out the additional paramaters required
      $pad = chr(0x28).chr(0xBF).chr(0x4E).chr(0x5E).chr(0x4E).chr(0x75).chr(0x8A).chr(0x41).chr(0x64).chr(0x00).chr(0x4E).chr(0x56).chr(0xFF).chr(0xFA).chr(0x01).chr(0x08).chr(0x2E).chr(0x2E).chr(0x00).chr(0xB6).chr(0xD0).chr(0x68).chr(0x3E).chr(0x80).chr(0x2F).chr(0x0C).chr(0xA9).chr(0xFE).chr(0x64).chr(0x53).chr(0x69).chr(0x7A);
      $len = strlen($options['owner']);
      if ($len>32){
        $owner = substr($options['owner'],0,32);
      } else if ($len<32){
        $owner = $options['owner'].substr($pad,0,32-$len);
      } else {
        $owner = $options['owner'];
      }
      $len = strlen($options['user']);
      if ($len>32){
        $user = substr($options['user'],0,32);
      } else if ($len<32){
        $user = $options['user'].substr($pad,0,32-$len);
      } else {
        $user = $options['user'];
      }
      $tmp = $this->md5_16($owner);
      $okey = substr($tmp,0,5);
      $this->ARC4_init($okey);
      $ovalue=$this->ARC4($user);
      $this->objects[$id]['info']['O']=$ovalue;
      // now make the u value, phew.
      $tmp = $this->md5_16($user.$ovalue.chr($options['p']).chr(255).chr(255).chr(255).$this->fileIdentifier);
      $ukey = substr($tmp,0,5);

      $this->ARC4_init($ukey);
      $this->encryptionKey = $ukey;
      $this->encrypted=1;
      $uvalue=$this->ARC4($pad);

      $this->objects[$id]['info']['U']=$uvalue;
      $this->encryptionKey=$ukey;
     
      // initialize the arc4 array
      break;
    case 'out':
      $res= "\n".$id." 0 obj\n<<";
      $res.="\n/Filter /Standard";
      $res.="\n/V 1";
      $res.="\n/R 2";
      $res.="\n/O (".$this->filterText($o['info']['O']).')';
      $res.="\n/U (".$this->filterText($o['info']['U']).')';
      // and the p-value needs to be converted to account for the twos-complement approach
      $o['info']['p'] = (($o['info']['p']^255)+1)*-1;
      $res.="\n/P ".($o['info']['p']);
      $res.="\n>>\nendobj\n";
      
      return $res;
      break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index