Ejemplo n.º 1
0
 /**
  * @see AbstractKeyInstance::deserializeFromObject($obj)
  */
 protected function deserializeFromObject($obj)
 {
     $this->key_p = new MathBigInteger($obj["p"], 16);
     $this->key_q = new MathBigInteger($obj["q"], 16);
     $this->key_g = new MathBigInteger($obj["g"], 16);
     $this->key_x = new MathBigInteger($obj["x"], 16);
     $this->keysize = DSAKeyPair::_getKeySizeFromRSAKeySize(strlen($this->key_p->toBits()));
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @see AbstractKeyInstance::deserializeFromObject($obj)
  */
 protected function deserializeFromObject($obj)
 {
     $this->key_p = new MathBigInteger($obj["p"], 16);
     $this->key_q = new MathBigInteger($obj["q"], 16);
     $this->key_g = new MathBigInteger($obj["g"], 16);
     $this->key_y = new MathBigInteger($obj["y"], 16);
     $this->keysize = DSAKeyPair::_getKeySizeFromRSAKeySize(strlen($this->key_y->toBits()));
     $this->key_values = DSAKeyPair::$KEYSIZES[$this->keysize];
     return $this;
 }
Ejemplo n.º 3
0
    {
        return new DSASecretKey();
    }
    /**
     * Generate keypair
     *
     * Generates a keypair for a given keysize in bits
     *
     * @abstract
     * @access public
     * @static
     * @param int $keysize Keysize in bits
     * @return DSAKeyPair Returning an instance of the key pair
     */
    public static function generate($keysize)
    {
        if (!isset(self::$KEYSIZES[$keysize])) {
            throw new NoSuchAlgorithmException("keysize not supported");
        }
        $static_keys = self::$KEYSIZES[$keysize];
        $instance = new DSAKeyPair();
        $keys = CryptDSA::generate($static_keys["p"], $static_keys["q"], $static_keys["g"]);
        $instance->keysize = $keysize;
        $instance->secretKey = new DSASecretKey($keys["x"], $keysize);
        $instance->publicKey = new DSAPublicKey($keys["y"], $keysize);
        $instance->algorithm = $instance->publicKey->algorithm = $instance->secretKey->algorithm = "DS";
        return $instance;
    }
}
DSAKeyPair::initialize();