Esempio n. 1
0
 public static function decodeCek($encryptionMaterials, $cekEncrypted)
 {
     $encrypKeyAlg = EncryptionUtil::getKeyEncryptionAlgm($encryptionMaterials);
     if ($encrypKeyAlg === "AES") {
         $secretKey = $encryptionMaterials;
         $cek = EncryptionUtil::decode_AES_ECB($cekEncrypted, $secretKey);
         if (empty($cek)) {
             throw new Ks3ClientException("can not decode cek useing AES,secret key maybe not correct");
         }
     } else {
         if ($encrypKeyAlg === "RSA") {
             $cek = "";
             openssl_private_decrypt($cekEncrypted, $cek, $encryptionMaterials[1]);
             if (empty($cek)) {
                 throw new Ks3ClientException("can not decode cek useing RSA,public/private key pair maybe not correct");
             }
         }
     }
     return $cek;
 }