Article: KB-041

SSD Sanitize Tutorial

This tutorial illustrates how to sanitize a storage device with a few lines of code.

This code is part of the provided sample code. Please request the full API documentation and the StorKit API.

#include “StorageKitSecurityDelegateFactory.h”
#include “StorageKitStorageDeviceUtils.h”

void Sanitize::doSanitize(const std::string &devPath, const SKSanitizeSubCommand &cmd)
{
ObjectTuple *tuple = CmdUtils::getSecurityDelegate(devPath);
std::cout << “Processing Sanitize\n”;
SKSSecurityReturnCode returnCode = SKSSecurityReturnCode::SKSErrorFeatureNotSupported;
MeasureTimer measureTimer;
if (SKSanitizeSubCommand::BlockErase == cmd)
{
returnCode = tuple->Delegate->sanitizeBlockErase();
}
else if (SKSanitizeSubCommand::CryptoScramble == cmd)
{
returnCode = tuple->Delegate->sanitizeCryptoScramble();
}
else if (SKSanitizeSubCommand::Overwrite == cmd)
{
returnCode = tuple->Delegate->sanitizeOverwrite();
}
delete tuple;
string output = CmdUtils::toString(returnCode, “Sanitize”, measureTimer.getTimeElapsed());
if (SKSSecurityReturnCode::SKSSucceeded == returnCode)
{
std::cout << output + “\n”;
}
else
{
std::cerr << output + “\n”;
exit(ExitCode::SANITIZE_ERROR);
}
}