Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /** * This file is a part of the miniorange-saml-20-single-sign-on plugin. * ..

Decoded Output download

<?php 
/** 
 * This file is a part of the miniorange-saml-20-single-sign-on plugin. 
 * 
 * @link https://plugins.miniorange.com/ 
 * @author miniOrange 
 * @package miniorange-saml-20-single-sign-on 
 */ 
 
 
namespace RobRichards\XMLSecLibs; 
 
use DOMElement; 
use Exception; 
class XMLSecurityKey 
{ 
    const TRIPLEDES_CBC = "http://www.w3.org/2001/04/xmlenc#tripledes-cbc"; 
    const AES128_CBC = "http://www.w3.org/2001/04/xmlenc#aes128-cbc"; 
    const AES192_CBC = "http://www.w3.org/2001/04/xmlenc#aes192-cbc"; 
    const AES256_CBC = "http://www.w3.org/2001/04/xmlenc#aes256-cbc"; 
    const AES128_GCM = "http://www.w3.org/2009/xmlenc11#aes128-gcm"; 
    const AES192_GCM = "http://www.w3.org/2009/xmlenc11#aes192-gcm"; 
    const AES256_GCM = "http://www.w3.org/2009/xmlenc11#aes256-gcm"; 
    const RSA_1_5 = "http://www.w3.org/2001/04/xmlenc#rsa-1_5"; 
    const RSA_OAEP_MGF1P = "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"; 
    const RSA_OAEP = "http://www.w3.org/2009/xmlenc11#rsa-oaep"; 
    const DSA_SHA1 = "http://www.w3.org/2000/09/xmldsig#dsa-sha1"; 
    const RSA_SHA1 = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; 
    const RSA_SHA256 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"; 
    const RSA_SHA384 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384"; 
    const RSA_SHA512 = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"; 
    const HMAC_SHA1 = "http://www.w3.org/2000/09/xmldsig#hmac-sha1"; 
    const AUTHTAG_LENGTH = 16; 
    private $cryptParams = array(); 
    public $type = 0; 
    public $key = null; 
    public $passphrase = ''; 
    public $iv = null; 
    public $name = null; 
    public $keyChain = null; 
    public $isEncrypted = false; 
    public $encryptedCtx = null; 
    public $guid = null; 
    private $x509Certificate = null; 
    private $X509Thumbprint = null; 
    public function __construct($CL, $rD = null) 
    { 
        switch ($CL) { 
            case self::TRIPLEDES_CBC: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["cipher"] = "des-ede3-cbc"; 
                $this->cryptParams["type"] = "symmetric"; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmlenc#tripledes-cbc"; 
                $this->cryptParams["keysize"] = 24; 
                $this->cryptParams["blocksize"] = 8; 
                goto Zc; 
            case self::AES128_CBC: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["cipher"] = "aes-128-cbc"; 
                $this->cryptParams["type"] = "symmetric"; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmlenc#aes128-cbc"; 
                $this->cryptParams["keysize"] = 16; 
                $this->cryptParams["blocksize"] = 16; 
                goto Zc; 
            case self::AES192_CBC: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["cipher"] = "aes-192-cbc"; 
                $this->cryptParams["type"] = "symmetric"; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmlenc#aes192-cbc"; 
                $this->cryptParams["keysize"] = 24; 
                $this->cryptParams["blocksize"] = 16; 
                goto Zc; 
            case self::AES256_CBC: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["cipher"] = "aes-256-cbc"; 
                $this->cryptParams["type"] = "symmetric"; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmlenc#aes256-cbc"; 
                $this->cryptParams["keysize"] = 32; 
                $this->cryptParams["blocksize"] = 16; 
                goto Zc; 
            case self::AES128_GCM: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["cipher"] = "aes-128-gcm"; 
                $this->cryptParams["type"] = "symmetric"; 
                $this->cryptParams["method"] = "http://www.w3.org/2009/xmlenc11#aes128-gcm"; 
                $this->cryptParams["keysize"] = 16; 
                $this->cryptParams["blocksize"] = 16; 
                goto Zc; 
            case self::AES192_GCM: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["cipher"] = "aes-192-gcm"; 
                $this->cryptParams["type"] = "symmetric"; 
                $this->cryptParams["method"] = "http://www.w3.org/2009/xmlenc11#aes192-gcm"; 
                $this->cryptParams["keysize"] = 24; 
                $this->cryptParams["blocksize"] = 16; 
                goto Zc; 
            case self::AES256_GCM: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["cipher"] = "aes-256-gcm"; 
                $this->cryptParams["type"] = "symmetric"; 
                $this->cryptParams["method"] = "http://www.w3.org/2009/xmlenc11#aes256-gcm"; 
                $this->cryptParams["keysize"] = 32; 
                $this->cryptParams["blocksize"] = 16; 
                goto Zc; 
            case self::RSA_1_5: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["padding"] = OPENSSL_PKCS1_PADDING; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmlenc#rsa-1_5"; 
                if (!(is_array($rD) && !empty($rD["type"]))) { 
                    goto c4; 
                } 
                if (!($rD["type"] == "public" || $rD["type"] == "private")) { 
                    goto mH; 
                } 
                $this->cryptParams["type"] = $rD["type"]; 
                goto Zc; 
                mH: 
                c4: 
                throw new Exception("Certificate "type" (private/public) must be passed via parameters"); 
            case self::RSA_OAEP_MGF1P: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["padding"] = OPENSSL_PKCS1_OAEP_PADDING; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"; 
                $this->cryptParams["hash"] = null; 
                if (!(is_array($rD) && !empty($rD["type"]))) { 
                    goto lB; 
                } 
                if (!($rD["type"] == "public" || $rD["type"] == "private")) { 
                    goto Ko; 
                } 
                $this->cryptParams["type"] = $rD["type"]; 
                goto Zc; 
                Ko: 
                lB: 
                throw new Exception("Certificate "type" (private/public) must be passed via parameters"); 
            case self::RSA_OAEP: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["padding"] = OPENSSL_PKCS1_OAEP_PADDING; 
                $this->cryptParams["method"] = "http://www.w3.org/2009/xmlenc11#rsa-oaep"; 
                $this->cryptParams["hash"] = "http://www.w3.org/2009/xmlenc11#mgf1sha1"; 
                if (!(is_array($rD) && !empty($rD["type"]))) { 
                    goto lb; 
                } 
                if (!($rD["type"] == "public" || $rD["type"] == "private")) { 
                    goto ZH; 
                } 
                $this->cryptParams["type"] = $rD["type"]; 
                goto Zc; 
                ZH: 
                lb: 
                throw new Exception("Certificate "type" (private/public) must be passed via parameters"); 
            case self::RSA_SHA1: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["method"] = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; 
                $this->cryptParams["padding"] = OPENSSL_PKCS1_PADDING; 
                if (!(is_array($rD) && !empty($rD["type"]))) { 
                    goto jF; 
                } 
                if (!($rD["type"] == "public" || $rD["type"] == "private")) { 
                    goto wy; 
                } 
                $this->cryptParams["type"] = $rD["type"]; 
                goto Zc; 
                wy: 
                jF: 
                throw new Exception("Certificate "type" (private/public) must be passed via parameters"); 
            case self::RSA_SHA256: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"; 
                $this->cryptParams["padding"] = OPENSSL_PKCS1_PADDING; 
                $this->cryptParams["digest"] = "SHA256"; 
                if (!(is_array($rD) && !empty($rD["type"]))) { 
                    goto sf; 
                } 
                if (!($rD["type"] == "public" || $rD["type"] == "private")) { 
                    goto PP; 
                } 
                $this->cryptParams["type"] = $rD["type"]; 
                goto Zc; 
                PP: 
                sf: 
                throw new Exception("Certificate "type" (private/public) must be passed via parameters"); 
            case self::RSA_SHA384: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384"; 
                $this->cryptParams["padding"] = OPENSSL_PKCS1_PADDING; 
                $this->cryptParams["digest"] = "SHA384"; 
                if (!(is_array($rD) && !empty($rD["type"]))) { 
                    goto uG; 
                } 
                if (!($rD["type"] == "public" || $rD["type"] == "private")) { 
                    goto ol; 
                } 
                $this->cryptParams["type"] = $rD["type"]; 
                goto Zc; 
                ol: 
                uG: 
                throw new Exception("Certificate "type" (private/public) must be passed via parameters"); 
            case self::RSA_SHA512: 
                $this->cryptParams["library"] = "openssl"; 
                $this->cryptParams["method"] = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"; 
                $this->cryptParams["padding"] = OPENSSL_PKCS1_PADDING; 
                $this->cryptParams["digest"] = "SHA512"; 
                if (!(is_array($rD) && !empty($rD["type"]))) { 
                    goto ck; 
                } 
                if (!($rD["type"] == "public" || $rD["type"] == "private")) { 
                    goto HH; 
                } 
                $this->cryptParams["type"] = $rD["type"]; 
                goto Zc; 
                HH: 
                ck: 
                throw new Exception("Certificate "type" (private/public) must be passed via parameters"); 
            case self::HMAC_SHA1: 
                $this->cryptParams["library"] = $CL; 
                $this->cryptParams["method"] = "http://www.w3.org/2000/09/xmldsig#hmac-sha1"; 
                goto Zc; 
            default: 
                throw new Exception("Invalid Key Type"); 
        } 
        GK: 
        Zc: 
        $this->type = $CL; 
    } 
    public function getSymmetricKeySize() 
    { 
        if (isset($this->cryptParams["keysize"])) { 
            goto Ea; 
        } 
        return null; 
        Ea: 
        return $this->cryptParams["keysize"]; 
    } 
    public function generateSessionKey() 
    { 
        if (isset($this->cryptParams["keysize"])) { 
            goto Vu; 
        } 
        throw new Exception("Unknown key size for type "" . $this->type . ""."); 
        Vu: 
        $vy = $this->cryptParams["keysize"]; 
        $ns = openssl_random_pseudo_bytes($vy); 
        if (!($this->type === self::TRIPLEDES_CBC)) { 
            goto DG; 
        } 
        $zL = 0; 
        cD: 
        if (!($zL < strlen($ns))) { 
            goto oP; 
        } 
        $Fj = ord($ns[$zL]) & 0xfe; 
        $u8 = 1; 
        $F2 = 1; 
        MX: 
        if (!($F2 < 8)) { 
            goto t6; 
        } 
        $u8 ^= $Fj >> $F2 & 1; 
        UV: 
        $F2++; 
        goto MX; 
        t6: 
        $Fj |= $u8; 
        $ns[$zL] = chr($Fj); 
        Na: 
        $zL++; 
        goto cD; 
        oP: 
        DG: 
        $this->key = $ns; 
        return $ns; 
    } 
    public static function getRawThumbprint($eH) 
    { 
        $ic = explode("
", $eH); 
        $jQ = ''; 
        $pr = false; 
        foreach ($ic as $ne) { 
            if (!$pr) { 
                goto TQ; 
            } 
            if (!(strncmp($ne, "-----END CERTIFICATE", 20) == 0)) { 
                goto bA; 
            } 
            goto kA; 
            bA: 
            $jQ .= trim($ne); 
            goto ui; 
            TQ: 
            if (!(strncmp($ne, "-----BEGIN CERTIFICATE", 22) == 0)) { 
                goto Eg; 
            } 
            $pr = true; 
            Eg: 
            ui: 
            pJ: 
        } 
        kA: 
        if (empty($jQ)) { 
            goto YJ; 
        } 
        return strtolower(sha1(base64_decode($jQ))); 
        YJ: 
        return null; 
    } 
    public function loadKey($ns, $Z1 = false, $ko = false) 
    { 
        if ($Z1) { 
            goto MA; 
        } 
        $this->key = $ns; 
        goto lT; 
        MA: 
        $this->key = file_get_contents($ns); 
        lT: 
        if ($ko) { 
            goto DF; 
        } 
        $this->x509Certificate = null; 
        goto le; 
        DF: 
        $this->key = openssl_x509_read($this->key); 
        openssl_x509_export($this->key, $Fk); 
        $this->x509Certificate = $Fk; 
        $this->key = $Fk; 
        le: 
        if (!($this->cryptParams["library"] == "openssl")) { 
            goto eV; 
        } 
        switch ($this->cryptParams["type"]) { 
            case "public": 
                if (!$ko) { 
                    goto OM; 
                } 
                $this->X509Thumbprint = self::getRawThumbprint($this->key); 
                OM: 
                $this->key = openssl_get_publickey($this->key); 
                if ($this->key) { 
                    goto DC; 
                } 
                throw new Exception("Unable to extract public key"); 
                DC: 
                goto Uy; 
            case "private": 
                $this->key = openssl_get_privatekey($this->key, $this->passphrase); 
                goto Uy; 
            case "symmetric": 
                if (!(strlen($this->key) < $this->cryptParams["keysize"])) { 
                    goto rY; 
                } 
                throw new Exception("Key must contain at least " . $this->cryptParams["keysize"] . " characters for this cipher, contains " . strlen($this->key)); 
                rY: 
                goto Uy; 
            default: 
                throw new Exception("Unknown type"); 
        } 
        BZ: 
        Uy: 
        eV: 
    } 
    private function padISO10126($jQ, $ty) 
    { 
        if (!($ty > 256)) { 
            goto kG; 
        } 
        throw new Exception("Block size higher than 256 not allowed"); 
        kG: 
        $cG = $ty - strlen($jQ) % $ty; 
        $Gr = chr($cG); 
        return $jQ . str_repeat($Gr, $cG); 
    } 
    private function unpadISO10126($jQ) 
    { 
        $cG = substr($jQ, -1); 
        $Ds = ord($cG); 
        return substr($jQ, 0, -$Ds); 
    } 
    private function encryptSymmetric($jQ) 
    { 
        $this->iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cryptParams["cipher"])); 
        $h2 = null; 
        if (in_array($this->cryptParams["cipher"], ["aes-128-gcm", "aes-192-gcm", "aes-256-gcm"])) { 
            goto Eb; 
        } 
        $jQ = $this->padISO10126($jQ, $this->cryptParams["blocksize"]); 
        $zq = openssl_encrypt($jQ, $this->cryptParams["cipher"], $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $this->iv); 
        goto er; 
        Eb: 
        if (!(version_compare(PHP_VERSION, "7.1.0") < 0)) { 
            goto g_; 
        } 
        throw new Exception("PHP 7.1.0 is required to use AES GCM algorithms"); 
        g_: 
        $h2 = openssl_random_pseudo_bytes(self::AUTHTAG_LENGTH); 
        $zq = openssl_encrypt($jQ, $this->cryptParams["cipher"], $this->key, OPENSSL_RAW_DATA, $this->iv, $h2); 
        er: 
        if (!(false === $zq)) { 
            goto TU; 
        } 
        throw new Exception("Failure encrypting Data (openssl symmetric) - " . openssl_error_string()); 
        TU: 
        return $this->iv . $zq . $h2; 
    } 
    private function decryptSymmetric($jQ) 
    { 
        $NY = openssl_cipher_iv_length($this->cryptParams["cipher"]); 
        $this->iv = substr($jQ, 0, $NY); 
        $jQ = substr($jQ, $NY); 
        $h2 = null; 
        if (in_array($this->cryptParams["cipher"], ["aes-128-gcm", "aes-192-gcm", "aes-256-gcm"])) { 
            goto wC; 
        } 
        $tN = openssl_decrypt($jQ, $this->cryptParams["cipher"], $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $this->iv); 
        goto S0; 
        wC: 
        if (!(version_compare(PHP_VERSION, "7.1.0") < 0)) { 
            goto xw; 
        } 
        throw new Exception("PHP 7.1.0 is required to use AES GCM algorithms"); 
        xw: 
        $Sn = 0 - self::AUTHTAG_LENGTH; 
        $h2 = substr($jQ, $Sn); 
        $jQ = substr($jQ, 0, $Sn); 
        $tN = openssl_decrypt($jQ, $this->cryptParams["cipher"], $this->key, OPENSSL_RAW_DATA, $this->iv, $h2); 
        S0: 
        if (!(false === $tN)) { 
            goto HV; 
        } 
        throw new Exception("Failure decrypting Data (openssl symmetric) - " . openssl_error_string()); 
        HV: 
        return null !== $h2 ? $tN : $this->unpadISO10126($tN); 
    } 
    private function encryptPublic($jQ) 
    { 
        if (openssl_public_encrypt($jQ, $zq, $this->key, $this->cryptParams["padding"])) { 
            goto bW; 
        } 
        throw new Exception("Failure encrypting Data (openssl public) - " . openssl_error_string()); 
        bW: 
        return $zq; 
    } 
    private function decryptPublic($jQ) 
    { 
        if (openssl_public_decrypt($jQ, $tN, $this->key, $this->cryptParams["padding"])) { 
            goto ka; 
        } 
        throw new Exception("Failure decrypting Data (openssl public) - " . openssl_error_string()); 
        ka: 
        return $tN; 
    } 
    private function encryptPrivate($jQ) 
    { 
        if (openssl_private_encrypt($jQ, $zq, $this->key, $this->cryptParams["padding"])) { 
            goto dE; 
        } 
        throw new Exception("Failure encrypting Data (openssl private) - " . openssl_error_string()); 
        dE: 
        return $zq; 
    } 
    private function decryptPrivate($jQ) 
    { 
        if (openssl_private_decrypt($jQ, $tN, $this->key, $this->cryptParams["padding"])) { 
            goto ZL; 
        } 
        throw new Exception("Failure decrypting Data (openssl private) - " . openssl_error_string()); 
        ZL: 
        return $tN; 
    } 
    private function signOpenSSL($jQ) 
    { 
        $QW = OPENSSL_ALGO_SHA1; 
        if (empty($this->cryptParams["digest"])) { 
            goto Fq; 
        } 
        $QW = $this->cryptParams["digest"]; 
        Fq: 
        if (openssl_sign($jQ, $Pw, $this->key, $QW)) { 
            goto PU; 
        } 
        throw new Exception("Failure Signing Data: " . openssl_error_string() . " - " . $QW); 
        PU: 
        return $Pw; 
    } 
    private function verifyOpenSSL($jQ, $Pw) 
    { 
        $QW = OPENSSL_ALGO_SHA1; 
        if (empty($this->cryptParams["digest"])) { 
            goto iW; 
        } 
        $QW = $this->cryptParams["digest"]; 
        iW: 
        return openssl_verify($jQ, $Pw, $this->key, $QW); 
    } 
    public function encryptData($jQ) 
    { 
        if (!($this->cryptParams["library"] === "openssl")) { 
            goto RF; 
        } 
        switch ($this->cryptParams["type"]) { 
            case "symmetric": 
                return $this->encryptSymmetric($jQ); 
            case "public": 
                return $this->encryptPublic($jQ); 
            case "private": 
                return $this->encryptPrivate($jQ); 
        } 
        JX: 
        uZ: 
        RF: 
    } 
    public function decryptData($jQ) 
    { 
        if (!($this->cryptParams["library"] === "openssl")) { 
            goto qz; 
        } 
        switch ($this->cryptParams["type"]) { 
            case "symmetric": 
                return $this->decryptSymmetric($jQ); 
            case "public": 
                return $this->decryptPublic($jQ); 
            case "private": 
                return $this->decryptPrivate($jQ); 
        } 
        aX: 
        ST: 
        qz: 
    } 
    public function signData($jQ) 
    { 
        switch ($this->cryptParams["library"]) { 
            case "openssl": 
                return $this->signOpenSSL($jQ); 
            case self::HMAC_SHA1: 
                return hash_hmac("sha1", $jQ, $this->key, true); 
        } 
        Hs: 
        uf: 
    } 
    public function verifySignature($jQ, $Pw) 
    { 
        switch ($this->cryptParams["library"]) { 
            case "openssl": 
                return $this->verifyOpenSSL($jQ, $Pw); 
            case self::HMAC_SHA1: 
                $nd = hash_hmac("sha1", $jQ, $this->key, true); 
                return strcmp($Pw, $nd) == 0; 
        } 
        WW: 
        bn: 
    } 
    public function getAlgorith() 
    { 
        return $this->getAlgorithm(); 
    } 
    public function getAlgorithm() 
    { 
        return $this->cryptParams["method"]; 
    } 
    public static function makeAsnSegment($CL, $D6) 
    { 
        switch ($CL) { 
            case 0x2: 
                if (!(ord($D6) > 0x7f)) { 
                    goto RQ; 
                } 
                $D6 = chr(0) . $D6; 
                RQ: 
                goto gW; 
            case 0x3: 
                $D6 = chr(0) . $D6; 
                goto gW; 
        } 
        PL: 
        gW: 
        $mX = strlen($D6); 
        if ($mX < 128) { 
            goto o0; 
        } 
        if ($mX < 0x100) { 
            goto L2; 
        } 
        if ($mX < 0x10000) { 
            goto So; 
        } 
        $ay = null; 
        goto Rz; 
        So: 
        $ay = sprintf("%c%c%c%c%s", $CL, 0x82, $mX / 0x100, $mX % 0x100, $D6); 
        Rz: 
        goto Xn; 
        L2: 
        $ay = sprintf("%c%c%c%s", $CL, 0x81, $mX, $D6); 
        Xn: 
        goto od; 
        o0: 
        $ay = sprintf("%c%c%s", $CL, $mX, $D6); 
        od: 
        return $ay; 
    } 
    public static function convertRSA($HR, $qN) 
    { 
        $z5 = self::makeAsnSegment(0x2, $qN); 
        $CG = self::makeAsnSegment(0x2, $HR); 
        $ff = self::makeAsnSegment(0x30, $CG . $z5); 
        $uH = self::makeAsnSegment(0x3, $ff); 
        $B0 = pack("H*", "300D06092A864886F70D0101010500"); 
        $uM = self::makeAsnSegment(0x30, $B0 . $uH); 
        $vK = base64_encode($uM); 
        $D3 = "-----BEGIN PUBLIC KEY-----\xa"; 
        $Sn = 0; 
        vQ: 
        if (!($YG = substr($vK, $Sn, 64))) { 
            goto E8; 
        } 
        $D3 = $D3 . $YG . "
"; 
        $Sn += 64; 
        goto vQ; 
        E8: 
        return $D3 . "-----END PUBLIC KEY-----
"; 
    } 
    public function serializeKey($dV) 
    { 
    } 
    public function getX509Certificate() 
    { 
        return $this->x509Certificate; 
    } 
    public function getX509Thumbprint() 
    { 
        return $this->X509Thumbprint; 
    } 
    public static function fromEncryptedKeyElement(DOMElement $Nd) 
    { 
        $ii = new XMLSecEnc(); 
        $ii->setNode($Nd); 
        if ($px = $ii->locateKey()) { 
            goto H8; 
        } 
        throw new Exception("Unable to locate algorithm for this Encrypted Key"); 
        H8: 
        $px->isEncrypted = true; 
        $px->encryptedCtx = $ii; 
        XMLSecEnc::staticLocateKeyInfo($px, $Nd); 
        return $px; 
    } 
} 
 ?>

Did this file decode correctly?

Original Code

<?php
/**
 * This file is a part of the miniorange-saml-20-single-sign-on plugin.
 *
 * @link https://plugins.miniorange.com/
 * @author miniOrange
 * @package miniorange-saml-20-single-sign-on
 */


namespace RobRichards\XMLSecLibs;

use DOMElement;
use Exception;
class XMLSecurityKey
{
    const TRIPLEDES_CBC = "\150\164\x74\x70\x3a\x2f\x2f\x77\x77\167\x2e\x77\x33\56\x6f\162\147\x2f\x32\60\60\x31\57\x30\x34\57\170\x6d\x6c\145\156\x63\43\164\x72\x69\160\x6c\x65\x64\145\163\x2d\x63\142\x63";
    const AES128_CBC = "\x68\164\164\160\x3a\x2f\57\x77\167\x77\56\167\63\56\x6f\x72\147\x2f\x32\x30\60\x31\x2f\x30\64\57\x78\155\154\x65\156\x63\43\141\x65\163\x31\x32\x38\55\x63\142\x63";
    const AES192_CBC = "\x68\164\x74\160\72\x2f\x2f\167\167\x77\56\x77\63\56\x6f\162\x67\57\x32\60\x30\x31\57\60\x34\57\170\x6d\x6c\145\156\x63\x23\x61\145\x73\x31\71\62\x2d\143\142\x63";
    const AES256_CBC = "\x68\x74\164\x70\x3a\57\57\167\167\x77\x2e\x77\x33\56\157\162\147\57\x32\x30\60\x31\57\60\64\57\170\155\154\145\x6e\x63\43\141\x65\x73\62\65\66\x2d\143\x62\143";
    const AES128_GCM = "\x68\x74\164\x70\x3a\x2f\x2f\167\x77\x77\56\x77\x33\x2e\157\x72\x67\57\x32\x30\60\71\57\170\155\154\x65\156\x63\61\x31\x23\x61\145\x73\61\x32\70\x2d\147\x63\x6d";
    const AES192_GCM = "\150\x74\x74\160\72\x2f\x2f\167\167\x77\56\167\63\x2e\157\162\x67\57\62\60\x30\x39\x2f\170\x6d\154\x65\x6e\143\x31\61\43\141\x65\163\x31\x39\62\x2d\x67\x63\x6d";
    const AES256_GCM = "\150\x74\164\x70\x3a\57\57\x77\167\x77\56\167\63\56\157\x72\x67\x2f\x32\x30\60\x39\x2f\x78\155\154\x65\156\143\x31\61\x23\x61\145\163\x32\65\66\55\x67\x63\x6d";
    const RSA_1_5 = "\150\164\164\160\72\x2f\x2f\167\x77\167\56\x77\63\56\157\162\x67\57\x32\x30\60\61\x2f\x30\64\x2f\x78\155\154\x65\156\x63\43\x72\163\141\x2d\61\x5f\65";
    const RSA_OAEP_MGF1P = "\150\164\164\160\x3a\x2f\x2f\x77\x77\167\x2e\x77\x33\x2e\157\x72\147\x2f\62\60\60\61\x2f\60\x34\57\x78\155\154\x65\156\143\x23\x72\163\x61\x2d\157\x61\145\x70\x2d\155\x67\x66\61\x70";
    const RSA_OAEP = "\150\x74\164\160\72\57\x2f\167\x77\x77\56\167\63\56\157\162\x67\x2f\x32\60\60\x39\57\x78\155\154\x65\x6e\x63\61\x31\x23\162\163\x61\x2d\157\x61\145\x70";
    const DSA_SHA1 = "\150\x74\164\x70\72\57\x2f\167\167\x77\56\167\x33\x2e\x6f\x72\147\x2f\62\x30\x30\x30\57\60\71\57\170\x6d\154\x64\163\x69\x67\x23\x64\x73\x61\x2d\x73\x68\x61\x31";
    const RSA_SHA1 = "\150\164\x74\160\72\57\x2f\167\x77\167\x2e\167\x33\x2e\157\x72\x67\57\x32\60\60\x30\57\60\x39\57\170\x6d\154\144\163\x69\147\x23\162\x73\x61\x2d\163\150\x61\61";
    const RSA_SHA256 = "\x68\x74\x74\160\x3a\x2f\x2f\167\x77\167\x2e\167\63\56\157\x72\x67\57\62\60\x30\x31\x2f\60\64\57\170\x6d\x6c\144\163\151\147\55\x6d\157\x72\145\43\x72\163\141\x2d\x73\x68\141\x32\65\66";
    const RSA_SHA384 = "\x68\164\x74\160\x3a\57\57\167\x77\x77\x2e\167\63\56\157\x72\147\57\x32\60\60\x31\x2f\x30\x34\x2f\170\155\154\144\x73\x69\x67\55\x6d\157\162\145\x23\x72\x73\x61\x2d\x73\150\x61\x33\70\64";
    const RSA_SHA512 = "\x68\164\x74\160\x3a\x2f\57\x77\167\x77\x2e\x77\x33\x2e\x6f\x72\147\57\62\x30\x30\61\x2f\60\64\57\170\x6d\154\144\x73\151\147\x2d\155\157\x72\x65\x23\162\163\x61\x2d\163\150\x61\65\61\62";
    const HMAC_SHA1 = "\x68\x74\x74\160\x3a\57\57\x77\167\x77\x2e\x77\x33\x2e\x6f\x72\147\x2f\x32\60\60\60\57\x30\71\x2f\170\x6d\154\x64\x73\x69\147\x23\150\x6d\141\143\55\163\150\x61\61";
    const AUTHTAG_LENGTH = 16;
    private $cryptParams = array();
    public $type = 0;
    public $key = null;
    public $passphrase = '';
    public $iv = null;
    public $name = null;
    public $keyChain = null;
    public $isEncrypted = false;
    public $encryptedCtx = null;
    public $guid = null;
    private $x509Certificate = null;
    private $X509Thumbprint = null;
    public function __construct($CL, $rD = null)
    {
        switch ($CL) {
            case self::TRIPLEDES_CBC:
                $this->cryptParams["\154\151\142\162\141\162\171"] = "\157\160\x65\156\x73\163\154";
                $this->cryptParams["\143\x69\x70\150\145\x72"] = "\x64\x65\163\55\x65\x64\x65\63\x2d\143\142\x63";
                $this->cryptParams["\164\x79\160\x65"] = "\x73\171\155\155\x65\x74\x72\151\143";
                $this->cryptParams["\x6d\x65\164\x68\x6f\x64"] = "\150\164\164\x70\x3a\x2f\57\x77\x77\167\56\x77\63\x2e\x6f\x72\147\x2f\x32\x30\60\x31\57\x30\x34\57\x78\x6d\154\x65\x6e\x63\43\x74\162\151\160\x6c\x65\x64\x65\x73\55\x63\x62\143";
                $this->cryptParams["\153\x65\x79\163\x69\x7a\145"] = 24;
                $this->cryptParams["\x62\154\157\143\x6b\x73\151\172\145"] = 8;
                goto Zc;
            case self::AES128_CBC:
                $this->cryptParams["\x6c\151\142\162\141\162\x79"] = "\157\160\x65\156\163\163\x6c";
                $this->cryptParams["\143\151\160\150\x65\x72"] = "\x61\x65\163\x2d\61\x32\x38\x2d\143\142\x63";
                $this->cryptParams["\x74\171\x70\x65"] = "\163\171\155\155\x65\x74\x72\x69\143";
                $this->cryptParams["\x6d\x65\164\x68\157\144"] = "\x68\164\x74\160\72\x2f\x2f\167\x77\167\56\x77\63\x2e\x6f\x72\147\57\62\60\x30\61\57\x30\x34\x2f\170\155\x6c\145\x6e\143\x23\x61\145\x73\x31\62\x38\55\x63\142\x63";
                $this->cryptParams["\x6b\145\171\x73\x69\172\x65"] = 16;
                $this->cryptParams["\142\x6c\x6f\x63\153\x73\x69\172\x65"] = 16;
                goto Zc;
            case self::AES192_CBC:
                $this->cryptParams["\154\x69\142\162\141\x72\171"] = "\157\x70\x65\156\163\163\x6c";
                $this->cryptParams["\x63\151\160\150\x65\x72"] = "\141\x65\163\55\61\71\62\55\x63\142\x63";
                $this->cryptParams["\x74\x79\x70\145"] = "\x73\171\155\155\145\164\x72\x69\x63";
                $this->cryptParams["\155\x65\164\x68\x6f\x64"] = "\150\x74\x74\x70\72\57\x2f\167\167\x77\x2e\167\x33\x2e\157\162\x67\57\x32\60\60\61\57\60\x34\57\x78\x6d\x6c\x65\x6e\x63\43\x61\x65\x73\x31\71\x32\x2d\x63\x62\x63";
                $this->cryptParams["\x6b\x65\x79\163\x69\x7a\145"] = 24;
                $this->cryptParams["\142\x6c\157\143\x6b\x73\x69\x7a\145"] = 16;
                goto Zc;
            case self::AES256_CBC:
                $this->cryptParams["\154\151\142\x72\x61\x72\171"] = "\x6f\x70\145\156\163\x73\x6c";
                $this->cryptParams["\143\151\x70\x68\x65\162"] = "\x61\x65\163\55\62\65\66\55\x63\142\143";
                $this->cryptParams["\x74\171\x70\145"] = "\x73\x79\x6d\155\145\x74\x72\x69\143";
                $this->cryptParams["\155\145\164\x68\x6f\x64"] = "\150\164\164\x70\x3a\57\x2f\x77\x77\x77\56\x77\63\x2e\157\162\x67\57\62\60\x30\x31\x2f\x30\x34\57\170\x6d\x6c\x65\156\143\x23\141\x65\x73\x32\x35\x36\55\x63\x62\x63";
                $this->cryptParams["\x6b\x65\x79\x73\x69\x7a\x65"] = 32;
                $this->cryptParams["\142\154\x6f\143\x6b\x73\x69\172\x65"] = 16;
                goto Zc;
            case self::AES128_GCM:
                $this->cryptParams["\x6c\151\142\x72\x61\162\x79"] = "\x6f\160\145\156\x73\163\154";
                $this->cryptParams["\x63\x69\x70\x68\x65\x72"] = "\x61\x65\163\55\x31\x32\x38\55\x67\143\x6d";
                $this->cryptParams["\x74\171\x70\145"] = "\163\x79\155\155\145\164\x72\151\143";
                $this->cryptParams["\x6d\145\x74\x68\157\144"] = "\150\164\x74\160\72\57\x2f\x77\167\167\x2e\x77\x33\56\157\162\x67\57\62\60\60\x39\x2f\170\155\x6c\x65\156\x63\61\x31\x23\x61\145\163\x31\x32\70\x2d\x67\143\x6d";
                $this->cryptParams["\153\x65\x79\x73\x69\172\x65"] = 16;
                $this->cryptParams["\x62\x6c\x6f\x63\153\163\x69\x7a\145"] = 16;
                goto Zc;
            case self::AES192_GCM:
                $this->cryptParams["\154\x69\142\162\141\162\171"] = "\157\160\x65\x6e\163\x73\x6c";
                $this->cryptParams["\x63\151\x70\x68\145\x72"] = "\141\145\163\x2d\x31\71\x32\55\147\x63\155";
                $this->cryptParams["\164\171\160\145"] = "\x73\x79\x6d\x6d\x65\x74\x72\151\143";
                $this->cryptParams["\x6d\145\164\x68\157\144"] = "\x68\x74\x74\x70\72\x2f\x2f\x77\167\x77\x2e\x77\63\x2e\157\x72\x67\x2f\62\60\60\x39\57\x78\155\x6c\x65\156\x63\x31\x31\43\141\x65\x73\61\x39\62\x2d\147\x63\155";
                $this->cryptParams["\153\145\171\163\x69\172\x65"] = 24;
                $this->cryptParams["\142\154\x6f\143\153\163\x69\172\145"] = 16;
                goto Zc;
            case self::AES256_GCM:
                $this->cryptParams["\x6c\x69\142\x72\x61\162\171"] = "\x6f\160\145\x6e\x73\x73\154";
                $this->cryptParams["\x63\x69\x70\150\x65\x72"] = "\x61\x65\163\x2d\62\x35\x36\x2d\147\x63\x6d";
                $this->cryptParams["\164\x79\x70\x65"] = "\x73\171\x6d\155\x65\x74\162\151\143";
                $this->cryptParams["\x6d\145\x74\x68\157\x64"] = "\x68\164\164\160\x3a\x2f\57\167\x77\x77\56\x77\63\56\157\x72\x67\x2f\62\x30\x30\x39\57\170\x6d\154\x65\156\143\61\x31\43\141\x65\163\62\65\x36\55\147\143\155";
                $this->cryptParams["\153\x65\x79\x73\151\172\x65"] = 32;
                $this->cryptParams["\142\x6c\157\x63\153\x73\151\x7a\145"] = 16;
                goto Zc;
            case self::RSA_1_5:
                $this->cryptParams["\154\x69\142\x72\141\162\171"] = "\157\160\x65\156\163\x73\x6c";
                $this->cryptParams["\160\141\x64\x64\151\x6e\x67"] = OPENSSL_PKCS1_PADDING;
                $this->cryptParams["\155\145\164\150\x6f\x64"] = "\150\164\x74\160\x3a\x2f\x2f\167\167\167\x2e\167\63\x2e\157\162\147\57\62\x30\x30\61\57\60\64\57\x78\x6d\x6c\145\156\x63\x23\x72\163\141\x2d\x31\137\65";
                if (!(is_array($rD) && !empty($rD["\164\x79\x70\145"]))) {
                    goto c4;
                }
                if (!($rD["\x74\171\160\145"] == "\160\x75\142\x6c\151\x63" || $rD["\164\x79\160\145"] == "\x70\x72\151\x76\141\164\x65")) {
                    goto mH;
                }
                $this->cryptParams["\164\x79\x70\145"] = $rD["\164\x79\x70\x65"];
                goto Zc;
                mH:
                c4:
                throw new Exception("\103\145\x72\x74\x69\x66\x69\x63\x61\x74\x65\40\x22\164\171\160\x65\x22\40\x28\x70\162\x69\x76\x61\x74\145\x2f\x70\x75\x62\154\151\143\x29\40\x6d\x75\x73\x74\40\142\145\40\x70\141\x73\163\145\144\40\x76\x69\141\x20\x70\x61\162\141\x6d\145\164\145\162\x73");
            case self::RSA_OAEP_MGF1P:
                $this->cryptParams["\x6c\151\x62\x72\x61\162\171"] = "\x6f\x70\145\156\x73\x73\154";
                $this->cryptParams["\x70\141\144\144\x69\156\x67"] = OPENSSL_PKCS1_OAEP_PADDING;
                $this->cryptParams["\155\x65\164\150\157\x64"] = "\150\164\164\160\72\57\x2f\167\167\x77\56\167\63\x2e\157\x72\x67\57\62\x30\60\x31\57\x30\64\x2f\x78\x6d\x6c\145\x6e\143\43\x72\163\141\x2d\157\141\x65\160\55\x6d\147\x66\61\160";
                $this->cryptParams["\150\141\x73\x68"] = null;
                if (!(is_array($rD) && !empty($rD["\164\x79\x70\145"]))) {
                    goto lB;
                }
                if (!($rD["\164\171\160\145"] == "\160\165\x62\x6c\151\x63" || $rD["\164\x79\160\145"] == "\160\162\151\166\141\164\145")) {
                    goto Ko;
                }
                $this->cryptParams["\x74\171\160\145"] = $rD["\164\171\160\x65"];
                goto Zc;
                Ko:
                lB:
                throw new Exception("\x43\x65\162\x74\151\x66\x69\143\x61\x74\x65\40\x22\x74\171\160\145\42\40\x28\160\162\x69\166\141\x74\x65\x2f\x70\165\142\x6c\151\143\x29\x20\155\x75\x73\x74\40\142\x65\40\160\141\x73\163\x65\x64\x20\x76\x69\141\40\160\141\162\x61\155\145\164\145\162\x73");
            case self::RSA_OAEP:
                $this->cryptParams["\154\151\x62\x72\141\162\171"] = "\157\160\x65\x6e\163\163\154";
                $this->cryptParams["\160\x61\x64\144\x69\156\147"] = OPENSSL_PKCS1_OAEP_PADDING;
                $this->cryptParams["\155\145\x74\x68\x6f\x64"] = "\x68\x74\164\160\x3a\57\57\167\167\x77\56\x77\63\56\x6f\162\147\57\x32\60\60\71\x2f\170\x6d\154\145\156\143\61\61\43\x72\163\141\x2d\x6f\141\145\x70";
                $this->cryptParams["\150\141\163\150"] = "\x68\164\x74\x70\72\57\57\x77\167\167\56\x77\x33\56\157\162\147\57\x32\60\60\71\57\170\155\x6c\x65\156\x63\x31\61\x23\x6d\x67\146\61\163\150\141\x31";
                if (!(is_array($rD) && !empty($rD["\x74\171\160\x65"]))) {
                    goto lb;
                }
                if (!($rD["\164\x79\x70\145"] == "\x70\165\142\154\151\x63" || $rD["\x74\x79\160\x65"] == "\x70\x72\x69\166\x61\x74\x65")) {
                    goto ZH;
                }
                $this->cryptParams["\164\171\160\x65"] = $rD["\x74\x79\x70\145"];
                goto Zc;
                ZH:
                lb:
                throw new Exception("\x43\145\x72\x74\x69\146\151\x63\141\x74\145\40\42\x74\x79\x70\x65\x22\x20\50\160\x72\x69\166\x61\164\x65\57\160\165\142\154\x69\143\51\40\x6d\165\163\164\40\x62\145\40\160\x61\x73\x73\x65\144\40\x76\151\x61\40\x70\x61\x72\x61\155\x65\164\145\162\x73");
            case self::RSA_SHA1:
                $this->cryptParams["\154\x69\142\162\141\x72\171"] = "\157\x70\145\156\x73\163\154";
                $this->cryptParams["\155\145\x74\150\157\144"] = "\150\164\x74\x70\72\57\57\x77\x77\x77\56\167\x33\x2e\157\162\x67\57\62\60\x30\60\57\60\x39\x2f\170\x6d\x6c\144\163\x69\147\x23\x72\x73\x61\x2d\x73\150\141\61";
                $this->cryptParams["\x70\141\x64\144\x69\156\x67"] = OPENSSL_PKCS1_PADDING;
                if (!(is_array($rD) && !empty($rD["\x74\x79\x70\145"]))) {
                    goto jF;
                }
                if (!($rD["\164\x79\x70\145"] == "\160\165\x62\x6c\x69\143" || $rD["\x74\171\x70\145"] == "\x70\x72\x69\166\x61\x74\x65")) {
                    goto wy;
                }
                $this->cryptParams["\x74\x79\x70\145"] = $rD["\164\x79\x70\145"];
                goto Zc;
                wy:
                jF:
                throw new Exception("\x43\x65\x72\x74\151\146\151\x63\x61\164\x65\x20\42\164\171\x70\x65\x22\x20\x28\x70\x72\151\166\141\164\x65\x2f\160\x75\x62\x6c\x69\143\51\40\x6d\x75\163\164\40\142\145\x20\160\141\x73\163\x65\144\x20\x76\151\141\40\160\141\162\141\155\145\164\145\x72\163");
            case self::RSA_SHA256:
                $this->cryptParams["\154\x69\x62\162\141\x72\x79"] = "\x6f\x70\145\156\x73\163\x6c";
                $this->cryptParams["\155\145\164\150\x6f\144"] = "\150\164\x74\160\x3a\57\x2f\167\x77\167\56\x77\63\56\x6f\x72\147\x2f\62\60\x30\x31\x2f\60\64\x2f\x78\155\154\144\x73\151\x67\x2d\x6d\x6f\x72\x65\x23\x72\x73\x61\x2d\x73\x68\x61\x32\x35\66";
                $this->cryptParams["\x70\141\x64\144\x69\156\147"] = OPENSSL_PKCS1_PADDING;
                $this->cryptParams["\x64\151\x67\x65\x73\164"] = "\x53\x48\x41\62\65\x36";
                if (!(is_array($rD) && !empty($rD["\164\171\160\145"]))) {
                    goto sf;
                }
                if (!($rD["\x74\171\x70\x65"] == "\x70\x75\x62\x6c\x69\x63" || $rD["\x74\171\x70\x65"] == "\x70\162\x69\166\141\x74\x65")) {
                    goto PP;
                }
                $this->cryptParams["\x74\x79\x70\145"] = $rD["\x74\x79\160\x65"];
                goto Zc;
                PP:
                sf:
                throw new Exception("\103\145\x72\164\x69\x66\x69\x63\141\164\x65\40\x22\x74\x79\x70\145\42\40\x28\160\162\x69\166\141\x74\x65\x2f\x70\x75\x62\154\x69\143\51\x20\155\165\163\164\x20\142\145\x20\160\x61\163\x73\145\x64\40\166\151\x61\40\160\x61\x72\x61\155\x65\164\145\x72\x73");
            case self::RSA_SHA384:
                $this->cryptParams["\x6c\151\x62\162\x61\x72\x79"] = "\157\160\145\x6e\x73\x73\154";
                $this->cryptParams["\155\x65\x74\x68\157\144"] = "\x68\x74\164\160\x3a\x2f\x2f\167\167\167\x2e\167\x33\56\157\162\x67\x2f\x32\x30\x30\61\x2f\x30\x34\57\170\x6d\x6c\x64\x73\151\x67\x2d\x6d\157\162\x65\43\162\x73\141\x2d\x73\x68\x61\x33\x38\x34";
                $this->cryptParams["\160\x61\144\x64\x69\x6e\x67"] = OPENSSL_PKCS1_PADDING;
                $this->cryptParams["\x64\x69\147\145\x73\164"] = "\x53\110\x41\63\x38\64";
                if (!(is_array($rD) && !empty($rD["\164\x79\160\x65"]))) {
                    goto uG;
                }
                if (!($rD["\164\171\x70\x65"] == "\160\165\142\154\151\x63" || $rD["\x74\171\x70\145"] == "\160\162\151\166\141\164\145")) {
                    goto ol;
                }
                $this->cryptParams["\164\171\160\145"] = $rD["\164\171\x70\145"];
                goto Zc;
                ol:
                uG:
                throw new Exception("\103\x65\x72\x74\151\146\x69\143\x61\x74\145\x20\42\x74\171\160\x65\x22\x20\50\160\162\x69\166\141\x74\145\57\160\165\x62\x6c\151\143\x29\x20\x6d\x75\x73\x74\x20\142\x65\40\x70\x61\x73\163\145\x64\40\x76\151\x61\40\160\x61\162\x61\155\x65\164\x65\x72\163");
            case self::RSA_SHA512:
                $this->cryptParams["\154\151\x62\162\141\x72\171"] = "\x6f\160\x65\x6e\x73\163\x6c";
                $this->cryptParams["\x6d\x65\164\x68\x6f\144"] = "\x68\x74\164\x70\72\x2f\x2f\x77\x77\167\56\x77\63\56\x6f\162\x67\57\62\60\x30\x31\57\60\64\x2f\x78\155\154\x64\163\151\147\x2d\155\157\x72\x65\43\162\x73\141\55\163\x68\141\65\61\62";
                $this->cryptParams["\160\x61\x64\144\151\156\147"] = OPENSSL_PKCS1_PADDING;
                $this->cryptParams["\x64\151\x67\x65\163\164"] = "\x53\110\x41\65\x31\x32";
                if (!(is_array($rD) && !empty($rD["\x74\171\160\145"]))) {
                    goto ck;
                }
                if (!($rD["\164\x79\160\x65"] == "\160\165\142\154\151\143" || $rD["\164\171\160\145"] == "\x70\x72\151\x76\141\164\145")) {
                    goto HH;
                }
                $this->cryptParams["\164\171\x70\x65"] = $rD["\x74\171\160\x65"];
                goto Zc;
                HH:
                ck:
                throw new Exception("\103\145\162\x74\x69\x66\151\143\x61\164\x65\x20\x22\164\171\160\145\42\40\50\160\x72\x69\x76\x61\x74\145\x2f\x70\165\142\x6c\x69\143\51\40\x6d\165\x73\164\x20\x62\x65\x20\x70\141\x73\163\145\144\x20\x76\151\x61\40\x70\x61\162\x61\155\x65\x74\145\x72\x73");
            case self::HMAC_SHA1:
                $this->cryptParams["\154\151\142\162\x61\162\171"] = $CL;
                $this->cryptParams["\155\145\x74\x68\x6f\144"] = "\150\164\x74\x70\x3a\57\x2f\167\167\167\x2e\167\x33\56\157\162\x67\x2f\62\60\x30\x30\57\x30\x39\x2f\170\x6d\154\144\x73\151\x67\x23\x68\x6d\x61\143\x2d\163\x68\141\x31";
                goto Zc;
            default:
                throw new Exception("\x49\x6e\x76\141\x6c\x69\x64\x20\113\x65\x79\x20\x54\x79\x70\x65");
        }
        GK:
        Zc:
        $this->type = $CL;
    }
    public function getSymmetricKeySize()
    {
        if (isset($this->cryptParams["\153\145\x79\x73\151\172\145"])) {
            goto Ea;
        }
        return null;
        Ea:
        return $this->cryptParams["\x6b\x65\x79\x73\x69\172\x65"];
    }
    public function generateSessionKey()
    {
        if (isset($this->cryptParams["\153\145\171\x73\x69\172\x65"])) {
            goto Vu;
        }
        throw new Exception("\x55\156\153\156\x6f\x77\156\40\153\145\171\x20\163\x69\x7a\x65\40\146\157\162\40\164\171\x70\145\40\x22" . $this->type . "\42\x2e");
        Vu:
        $vy = $this->cryptParams["\153\x65\171\163\151\172\145"];
        $ns = openssl_random_pseudo_bytes($vy);
        if (!($this->type === self::TRIPLEDES_CBC)) {
            goto DG;
        }
        $zL = 0;
        cD:
        if (!($zL < strlen($ns))) {
            goto oP;
        }
        $Fj = ord($ns[$zL]) & 0xfe;
        $u8 = 1;
        $F2 = 1;
        MX:
        if (!($F2 < 8)) {
            goto t6;
        }
        $u8 ^= $Fj >> $F2 & 1;
        UV:
        $F2++;
        goto MX;
        t6:
        $Fj |= $u8;
        $ns[$zL] = chr($Fj);
        Na:
        $zL++;
        goto cD;
        oP:
        DG:
        $this->key = $ns;
        return $ns;
    }
    public static function getRawThumbprint($eH)
    {
        $ic = explode("\12", $eH);
        $jQ = '';
        $pr = false;
        foreach ($ic as $ne) {
            if (!$pr) {
                goto TQ;
            }
            if (!(strncmp($ne, "\x2d\55\55\x2d\55\105\x4e\104\x20\103\x45\x52\124\111\x46\111\x43\101\x54\105", 20) == 0)) {
                goto bA;
            }
            goto kA;
            bA:
            $jQ .= trim($ne);
            goto ui;
            TQ:
            if (!(strncmp($ne, "\x2d\55\55\x2d\x2d\102\x45\x47\x49\x4e\40\103\105\x52\124\x49\x46\x49\103\x41\x54\x45", 22) == 0)) {
                goto Eg;
            }
            $pr = true;
            Eg:
            ui:
            pJ:
        }
        kA:
        if (empty($jQ)) {
            goto YJ;
        }
        return strtolower(sha1(base64_decode($jQ)));
        YJ:
        return null;
    }
    public function loadKey($ns, $Z1 = false, $ko = false)
    {
        if ($Z1) {
            goto MA;
        }
        $this->key = $ns;
        goto lT;
        MA:
        $this->key = file_get_contents($ns);
        lT:
        if ($ko) {
            goto DF;
        }
        $this->x509Certificate = null;
        goto le;
        DF:
        $this->key = openssl_x509_read($this->key);
        openssl_x509_export($this->key, $Fk);
        $this->x509Certificate = $Fk;
        $this->key = $Fk;
        le:
        if (!($this->cryptParams["\154\x69\x62\162\x61\x72\171"] == "\x6f\x70\145\156\163\x73\154")) {
            goto eV;
        }
        switch ($this->cryptParams["\164\171\160\145"]) {
            case "\160\x75\142\154\x69\143":
                if (!$ko) {
                    goto OM;
                }
                $this->X509Thumbprint = self::getRawThumbprint($this->key);
                OM:
                $this->key = openssl_get_publickey($this->key);
                if ($this->key) {
                    goto DC;
                }
                throw new Exception("\x55\156\141\142\154\x65\x20\164\157\x20\x65\170\164\x72\x61\143\x74\x20\x70\x75\142\x6c\151\x63\x20\153\145\x79");
                DC:
                goto Uy;
            case "\160\x72\151\x76\x61\164\x65":
                $this->key = openssl_get_privatekey($this->key, $this->passphrase);
                goto Uy;
            case "\x73\171\155\x6d\x65\x74\x72\151\143":
                if (!(strlen($this->key) < $this->cryptParams["\153\145\x79\163\151\172\x65"])) {
                    goto rY;
                }
                throw new Exception("\113\x65\171\40\155\165\163\x74\x20\143\157\x6e\164\x61\x69\156\40\x61\164\40\x6c\145\x61\163\164\x20" . $this->cryptParams["\x6b\145\x79\x73\x69\172\x65"] . "\x20\x63\150\x61\162\x61\x63\x74\145\x72\x73\40\x66\157\162\x20\164\150\x69\163\x20\x63\x69\x70\x68\145\162\54\x20\x63\157\x6e\x74\x61\x69\156\x73\40" . strlen($this->key));
                rY:
                goto Uy;
            default:
                throw new Exception("\x55\x6e\x6b\156\x6f\x77\156\40\164\171\160\x65");
        }
        BZ:
        Uy:
        eV:
    }
    private function padISO10126($jQ, $ty)
    {
        if (!($ty > 256)) {
            goto kG;
        }
        throw new Exception("\102\154\157\143\153\40\x73\x69\x7a\x65\40\x68\x69\147\x68\145\x72\x20\164\150\x61\156\40\x32\65\66\40\x6e\x6f\164\x20\141\x6c\x6c\157\167\x65\144");
        kG:
        $cG = $ty - strlen($jQ) % $ty;
        $Gr = chr($cG);
        return $jQ . str_repeat($Gr, $cG);
    }
    private function unpadISO10126($jQ)
    {
        $cG = substr($jQ, -1);
        $Ds = ord($cG);
        return substr($jQ, 0, -$Ds);
    }
    private function encryptSymmetric($jQ)
    {
        $this->iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cryptParams["\x63\151\x70\x68\x65\162"]));
        $h2 = null;
        if (in_array($this->cryptParams["\143\151\x70\x68\x65\x72"], ["\141\145\x73\55\x31\x32\70\x2d\x67\143\155", "\x61\145\163\55\61\71\x32\x2d\x67\143\155", "\141\145\x73\x2d\x32\x35\66\55\x67\143\x6d"])) {
            goto Eb;
        }
        $jQ = $this->padISO10126($jQ, $this->cryptParams["\142\x6c\x6f\143\153\163\151\x7a\145"]);
        $zq = openssl_encrypt($jQ, $this->cryptParams["\x63\x69\x70\x68\x65\162"], $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $this->iv);
        goto er;
        Eb:
        if (!(version_compare(PHP_VERSION, "\x37\56\x31\56\x30") < 0)) {
            goto g_;
        }
        throw new Exception("\x50\x48\120\40\x37\x2e\x31\56\60\40\151\163\40\162\x65\161\165\x69\162\x65\x64\x20\164\x6f\40\x75\x73\145\40\x41\x45\123\x20\x47\103\x4d\x20\x61\154\x67\x6f\162\x69\x74\x68\155\163");
        g_:
        $h2 = openssl_random_pseudo_bytes(self::AUTHTAG_LENGTH);
        $zq = openssl_encrypt($jQ, $this->cryptParams["\x63\x69\x70\150\145\162"], $this->key, OPENSSL_RAW_DATA, $this->iv, $h2);
        er:
        if (!(false === $zq)) {
            goto TU;
        }
        throw new Exception("\106\141\x69\154\x75\x72\x65\40\145\x6e\143\162\x79\x70\x74\151\156\x67\x20\104\141\164\x61\40\50\157\160\x65\x6e\163\x73\x6c\40\163\171\155\x6d\145\x74\x72\151\143\x29\40\x2d\x20" . openssl_error_string());
        TU:
        return $this->iv . $zq . $h2;
    }
    private function decryptSymmetric($jQ)
    {
        $NY = openssl_cipher_iv_length($this->cryptParams["\143\x69\160\x68\x65\162"]);
        $this->iv = substr($jQ, 0, $NY);
        $jQ = substr($jQ, $NY);
        $h2 = null;
        if (in_array($this->cryptParams["\143\x69\160\x68\x65\x72"], ["\x61\145\163\55\x31\x32\70\55\147\x63\x6d", "\141\x65\x73\x2d\x31\x39\x32\x2d\x67\143\155", "\x61\x65\x73\x2d\x32\x35\x36\x2d\x67\x63\155"])) {
            goto wC;
        }
        $tN = openssl_decrypt($jQ, $this->cryptParams["\x63\151\x70\150\145\162"], $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $this->iv);
        goto S0;
        wC:
        if (!(version_compare(PHP_VERSION, "\x37\x2e\61\56\x30") < 0)) {
            goto xw;
        }
        throw new Exception("\x50\110\x50\x20\x37\56\61\56\x30\x20\x69\x73\x20\162\x65\x71\x75\x69\x72\x65\144\40\164\x6f\40\165\x73\x65\x20\x41\x45\x53\40\x47\x43\115\x20\141\154\147\157\162\151\x74\150\x6d\163");
        xw:
        $Sn = 0 - self::AUTHTAG_LENGTH;
        $h2 = substr($jQ, $Sn);
        $jQ = substr($jQ, 0, $Sn);
        $tN = openssl_decrypt($jQ, $this->cryptParams["\x63\x69\160\150\x65\x72"], $this->key, OPENSSL_RAW_DATA, $this->iv, $h2);
        S0:
        if (!(false === $tN)) {
            goto HV;
        }
        throw new Exception("\x46\141\x69\154\x75\162\x65\40\144\145\143\x72\171\x70\164\x69\x6e\x67\x20\104\141\164\x61\x20\50\x6f\x70\x65\156\163\x73\154\x20\163\171\155\x6d\x65\164\162\x69\x63\51\x20\x2d\40" . openssl_error_string());
        HV:
        return null !== $h2 ? $tN : $this->unpadISO10126($tN);
    }
    private function encryptPublic($jQ)
    {
        if (openssl_public_encrypt($jQ, $zq, $this->key, $this->cryptParams["\x70\141\x64\x64\151\156\147"])) {
            goto bW;
        }
        throw new Exception("\106\x61\x69\x6c\x75\x72\145\40\x65\x6e\x63\162\x79\160\x74\151\x6e\147\40\x44\x61\x74\x61\x20\50\x6f\160\145\156\163\163\x6c\40\160\165\142\x6c\151\x63\x29\40\55\x20" . openssl_error_string());
        bW:
        return $zq;
    }
    private function decryptPublic($jQ)
    {
        if (openssl_public_decrypt($jQ, $tN, $this->key, $this->cryptParams["\x70\141\144\x64\151\x6e\147"])) {
            goto ka;
        }
        throw new Exception("\106\141\x69\x6c\x75\x72\x65\x20\x64\145\x63\162\171\x70\x74\x69\x6e\x67\40\104\141\x74\x61\x20\x28\157\160\145\156\163\x73\x6c\40\160\x75\x62\x6c\151\x63\51\40\x2d\x20" . openssl_error_string());
        ka:
        return $tN;
    }
    private function encryptPrivate($jQ)
    {
        if (openssl_private_encrypt($jQ, $zq, $this->key, $this->cryptParams["\x70\141\x64\144\x69\156\x67"])) {
            goto dE;
        }
        throw new Exception("\x46\x61\151\x6c\x75\x72\145\x20\x65\x6e\143\162\171\160\x74\x69\x6e\147\40\104\x61\x74\x61\40\50\157\x70\x65\156\163\163\154\40\160\x72\151\166\141\164\145\x29\40\55\x20" . openssl_error_string());
        dE:
        return $zq;
    }
    private function decryptPrivate($jQ)
    {
        if (openssl_private_decrypt($jQ, $tN, $this->key, $this->cryptParams["\x70\x61\144\x64\151\156\x67"])) {
            goto ZL;
        }
        throw new Exception("\106\141\151\x6c\165\162\145\40\x64\x65\x63\x72\x79\160\x74\x69\156\147\40\104\x61\x74\x61\x20\50\x6f\160\145\156\x73\163\154\40\160\162\x69\166\x61\164\145\x29\40\x2d\40" . openssl_error_string());
        ZL:
        return $tN;
    }
    private function signOpenSSL($jQ)
    {
        $QW = OPENSSL_ALGO_SHA1;
        if (empty($this->cryptParams["\x64\151\147\145\x73\164"])) {
            goto Fq;
        }
        $QW = $this->cryptParams["\x64\x69\147\145\163\x74"];
        Fq:
        if (openssl_sign($jQ, $Pw, $this->key, $QW)) {
            goto PU;
        }
        throw new Exception("\x46\141\151\154\x75\162\x65\x20\123\x69\x67\x6e\151\x6e\147\x20\x44\141\164\x61\x3a\x20" . openssl_error_string() . "\x20\55\x20" . $QW);
        PU:
        return $Pw;
    }
    private function verifyOpenSSL($jQ, $Pw)
    {
        $QW = OPENSSL_ALGO_SHA1;
        if (empty($this->cryptParams["\144\x69\x67\145\x73\x74"])) {
            goto iW;
        }
        $QW = $this->cryptParams["\144\151\x67\x65\163\x74"];
        iW:
        return openssl_verify($jQ, $Pw, $this->key, $QW);
    }
    public function encryptData($jQ)
    {
        if (!($this->cryptParams["\154\151\x62\162\141\162\171"] === "\x6f\160\x65\x6e\163\163\154")) {
            goto RF;
        }
        switch ($this->cryptParams["\x74\x79\x70\145"]) {
            case "\x73\x79\155\155\x65\x74\162\151\143":
                return $this->encryptSymmetric($jQ);
            case "\x70\165\142\x6c\x69\x63":
                return $this->encryptPublic($jQ);
            case "\160\162\x69\x76\141\x74\145":
                return $this->encryptPrivate($jQ);
        }
        JX:
        uZ:
        RF:
    }
    public function decryptData($jQ)
    {
        if (!($this->cryptParams["\154\x69\142\162\141\x72\x79"] === "\x6f\x70\145\156\x73\x73\x6c")) {
            goto qz;
        }
        switch ($this->cryptParams["\x74\x79\x70\x65"]) {
            case "\163\x79\155\x6d\x65\164\162\x69\143":
                return $this->decryptSymmetric($jQ);
            case "\160\165\x62\x6c\151\x63":
                return $this->decryptPublic($jQ);
            case "\160\162\151\x76\x61\x74\x65":
                return $this->decryptPrivate($jQ);
        }
        aX:
        ST:
        qz:
    }
    public function signData($jQ)
    {
        switch ($this->cryptParams["\154\151\142\162\x61\x72\x79"]) {
            case "\157\160\x65\x6e\163\163\x6c":
                return $this->signOpenSSL($jQ);
            case self::HMAC_SHA1:
                return hash_hmac("\163\x68\141\x31", $jQ, $this->key, true);
        }
        Hs:
        uf:
    }
    public function verifySignature($jQ, $Pw)
    {
        switch ($this->cryptParams["\x6c\x69\142\162\x61\162\171"]) {
            case "\157\160\145\156\163\x73\154":
                return $this->verifyOpenSSL($jQ, $Pw);
            case self::HMAC_SHA1:
                $nd = hash_hmac("\x73\150\141\x31", $jQ, $this->key, true);
                return strcmp($Pw, $nd) == 0;
        }
        WW:
        bn:
    }
    public function getAlgorith()
    {
        return $this->getAlgorithm();
    }
    public function getAlgorithm()
    {
        return $this->cryptParams["\155\145\164\150\x6f\x64"];
    }
    public static function makeAsnSegment($CL, $D6)
    {
        switch ($CL) {
            case 0x2:
                if (!(ord($D6) > 0x7f)) {
                    goto RQ;
                }
                $D6 = chr(0) . $D6;
                RQ:
                goto gW;
            case 0x3:
                $D6 = chr(0) . $D6;
                goto gW;
        }
        PL:
        gW:
        $mX = strlen($D6);
        if ($mX < 128) {
            goto o0;
        }
        if ($mX < 0x100) {
            goto L2;
        }
        if ($mX < 0x10000) {
            goto So;
        }
        $ay = null;
        goto Rz;
        So:
        $ay = sprintf("\x25\x63\45\143\x25\x63\45\x63\45\163", $CL, 0x82, $mX / 0x100, $mX % 0x100, $D6);
        Rz:
        goto Xn;
        L2:
        $ay = sprintf("\45\x63\45\x63\45\143\x25\163", $CL, 0x81, $mX, $D6);
        Xn:
        goto od;
        o0:
        $ay = sprintf("\x25\x63\x25\143\x25\163", $CL, $mX, $D6);
        od:
        return $ay;
    }
    public static function convertRSA($HR, $qN)
    {
        $z5 = self::makeAsnSegment(0x2, $qN);
        $CG = self::makeAsnSegment(0x2, $HR);
        $ff = self::makeAsnSegment(0x30, $CG . $z5);
        $uH = self::makeAsnSegment(0x3, $ff);
        $B0 = pack("\x48\52", "\x33\60\x30\104\60\66\60\x39\62\101\70\66\x34\70\x38\x36\x46\67\60\x44\x30\61\x30\x31\x30\x31\x30\x35\60\60");
        $uM = self::makeAsnSegment(0x30, $B0 . $uH);
        $vK = base64_encode($uM);
        $D3 = "\x2d\x2d\x2d\55\55\x42\x45\107\111\x4e\40\x50\x55\102\114\x49\x43\40\x4b\x45\131\55\55\55\55\x2d\xa";
        $Sn = 0;
        vQ:
        if (!($YG = substr($vK, $Sn, 64))) {
            goto E8;
        }
        $D3 = $D3 . $YG . "\12";
        $Sn += 64;
        goto vQ;
        E8:
        return $D3 . "\x2d\x2d\x2d\55\55\105\116\104\40\120\x55\x42\114\x49\103\x20\x4b\x45\131\55\55\x2d\x2d\55\12";
    }
    public function serializeKey($dV)
    {
    }
    public function getX509Certificate()
    {
        return $this->x509Certificate;
    }
    public function getX509Thumbprint()
    {
        return $this->X509Thumbprint;
    }
    public static function fromEncryptedKeyElement(DOMElement $Nd)
    {
        $ii = new XMLSecEnc();
        $ii->setNode($Nd);
        if ($px = $ii->locateKey()) {
            goto H8;
        }
        throw new Exception("\x55\x6e\x61\142\154\x65\40\x74\157\40\x6c\x6f\x63\141\164\x65\x20\x61\154\147\x6f\162\151\164\x68\155\x20\x66\x6f\x72\x20\164\x68\x69\x73\x20\x45\156\143\x72\171\x70\164\145\x64\40\x4b\145\x79");
        H8:
        $px->isEncrypted = true;
        $px->encryptedCtx = $ii;
        XMLSecEnc::staticLocateKeyInfo($px, $Nd);
        return $px;
    }
}

Function Calls

None

Variables

None

Stats

MD5 2554913432b6a1feb54916a7b632b0ac
Eval Count 0
Decode Time 104 ms