Slide 27
Slide 27 text
class EncryptedDatabase implements ReviewDatabase {
// ...
function hashIndex($value, $index)
{
$hmac_key = $this->hmac_keys[$index];
return hash_hmac('sha256', $value, $hmac_key);
}
function create(Review $review)
{
$statement = $this->db->prepare("INSERT INTO reviews (title, review, reviewer) VALUES (:title,
:review, :reviewer, :reviewer_idx)");
$statement->bindParam(':title', encryptString($review->title));
$statement->bindParam(':review', encryptString($review->review));
$statement->bindParam(':reviewer', encryptString($review->reviewer));
$statement->bindParam(':reviewer_idx', hashIndex($review->reviewer, 'reviewer'));
$statement->execute();
}
// ... and so on
}