function copyAnddeleteObject($client, $bucket, $keyprefix)
{
    $content = EncryptionUtil::genereateOnceUsedKey(rand(100, 1000));
    $args = array("Bucket" => $bucket, "Key" => $keyprefix . "EOFile", "ACL" => "public-read", "Content" => $content);
    $client->putObjectByContent($args);
    if ($client->objectExists(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy"))) {
        $client->deleteObject(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy"));
    }
    if ($client->objectExists(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy.instruction"))) {
        $client->deleteObject(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy.instruction"));
    }
    $copyReq = array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy", "CopySource" => array("Bucket" => $bucket, "Key" => $keyprefix . "EOFile"));
    $client->copyObject($copyReq);
    if (!$client->objectExists(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy"))) {
        throw new Exception("not found " . $keyprefix . "EOFileCopy");
    }
    if (!$client->objectExists(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy.instruction"))) {
        throw new Exception("not found " . $keyprefix . "EOFileCopy.instruction");
    }
    $client->deleteObject(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy"));
    if ($client->objectExists(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy"))) {
        throw new Exception("found " . $keyprefix . "EOFileCopy");
    }
    if ($client->objectExists(array("Bucket" => $bucket, "Key" => $keyprefix . "EOFileCopy.instruction"))) {
        throw new Exception("found " . $keyprefix . "EOFileCopy.instruction");
    }
}
function putObjectByContentAndGetObjectUsingMeta($client, $bucket, $keyprefix)
{
    for ($i = 45; $i < 60; $i++) {
        $content = EncryptionUtil::genereateOnceUsedKey($i);
        $args = array("Bucket" => $bucket, "Key" => $keyprefix . "EOMeta", "ACL" => "public-read", "Content" => $content);
        $client->putObjectByContent($args);
        rangeGetAndCheckMd5($client, $bucket, $keyprefix . "EOMeta", "D://testdown/down", base64_encode(md5($args["Content"])));
    }
}
Esempio n. 3
0
 public function testPutObjectByContentAndGetObject()
 {
     @unlink($this->cachedir . "down");
     $content = EncryptionUtil::genereateOnceUsedKey(500);
     $args = array("Bucket" => $this->bucket, "Key" => $this->key, "ACL" => "public-read", "Content" => $content);
     $this->encryptionClient->putObjectByContent($args);
     $start = (int) rand(0, 520);
     $end = (int) rand($start, 520);
     $s3Object = $this->encryptionClient->getObject(array("Bucket" => $this->bucket, "Key" => $this->key, "Range" => "bytes=" . $start . "-" . $end));
     $this->assertEquals(substr($content, $start, $end - $start + 1), $s3Object["Content"]);
 }
Esempio n. 4
0
 public function initMultipartUploadSecurely($args = array())
 {
     $sek = EncryptionUtil::genereateOnceUsedKey();
     $encryptedSek = EncryptionUtil::encodeCek($this->encryptionMaterials, $sek);
     $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
     $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
     $matdesc = "{}";
     if (ENCRYPTPTION_STORAGE_MODE == "ObjectMetadata") {
         $args["UserMeta"]["x-kss-meta-x-kss-key"] = base64_encode($encryptedSek);
         $args["UserMeta"]["x-kss-meta-x-kss-iv"] = base64_encode($iv);
         $args["UserMeta"]["x-kss-meta-x-kss-matdesc"] = $matdesc;
     }
     $initResult = $this->ks3client->initMultipartUpload($args);
     EncryptionUtil::initMultipartUploadContext($initResult, $iv, $sek, $encryptedSek, $matdesc);
     return $initResult;
 }