Ejemplo n.º 1
0
 public static function encodeCek($encryptionMaterials, $cek)
 {
     $encrypKeyAlg = EncryptionUtil::getKeyEncryptionAlgm($encryptionMaterials);
     if ($encrypKeyAlg === "AES") {
         $secretKey = $encryptionMaterials;
         $encryptedSek = EncryptionUtil::encode_AES_ECB($cek, $secretKey);
         if (empty($encryptedSek)) {
             throw new Ks3ClientException("can not encode cek useing AES");
         }
     } else {
         if ($encrypKeyAlg === "RSA") {
             $encryptedSek = "";
             openssl_public_encrypt($cek, $encryptedSek, $encryptionMaterials[0]);
             if (empty($encryptedSek)) {
                 throw new Ks3ClientException("can not encode cek useing RSA");
             }
         }
     }
     return $encryptedSek;
 }