Merge pull request #433 from PartialVolume/PDFGen6

PDFGen6 - further work on PDF certificate
This commit is contained in:
PartialVolume
2023-02-18 00:20:54 +00:00
committed by GitHub
4 changed files with 74 additions and 6 deletions

View File

@@ -524,8 +524,8 @@ int pdf_add_custom_path(struct pdf_doc *pdf, struct pdf_object *page,
* @param y Y offset of the center of the ellipse
* @param xradius Radius of the ellipse in the X axis
* @param yradius Radius of the ellipse in the Y axis
* @param colour Colour to draw the ellipse outline stroke
* @param width Width of the ellipse outline stroke
* @param colour Colour to draw the ellipse outline stroke
* @param fill_colour Colour to fill the ellipse
* @return 0 on success, < 0 on failure
*/

View File

@@ -46,15 +46,18 @@ int create_pdf( nwipe_context_t* ptr )
c = ptr;
char model_header[50] = ""; /* Model text in the header */
char serial_header[30] = ""; /* Serial number text in the header */
char device_size[50] = ""; /* Device size in the form xMB (xxxx bytes) */
char barcode[100] = ""; /* Contents of the barcode, i.e model:serial */
char dimm[50] = ""; /* Disk Information: Model */
char verify[20] = ""; /* Verify option text */
char blank[10] = ""; /* blanking pass, none, zeros, ones */
char rounds[10] = ""; /* rounds ASCII numeric */
char prng_type[20] = ""; /* type of prng, twister, isaac, isaac64 */
char wipe_status[8] = ""; /* Erased or Failed */
char start_time_text[50] = "";
char end_time_text[50] = "";
char HPA_pre_erase[50] = "";
char HPA_post_erase[50] = "";
char DCO_pre_erase[50] = "";
char DCO_post_erase[50] = "";
struct pdf_info info = { .creator = "https://github.com/PartialVolume/shredos.x86_64",
.producer = "https://github.com/martijnvanbrummelen/nwipe",
@@ -117,11 +120,13 @@ int create_pdf( nwipe_context_t* ptr )
pdf_add_line( pdf, NULL, 50, 330, 550, 330, 1, PDF_GRAY );
pdf_add_text( pdf, NULL, "Disk Information", 12, 50, 430, PDF_BLUE );
/* Make/model */
pdf_add_text( pdf, NULL, "Make/Model:", 12, 60, 410, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, c->device_model, 12, 135, 410, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* Serial no. */
pdf_add_text( pdf, NULL, "Serial:", 12, 300, 410, PDF_GRAY );
if( c->device_serial_no[0] == 0 )
{
@@ -131,9 +136,11 @@ int create_pdf( nwipe_context_t* ptr )
pdf_add_text( pdf, NULL, c->device_serial_no, 12, 340, 410, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* Capacity (Size) of disk */
pdf_add_text( pdf, NULL, "Size:", 12, 60, 390, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, c->device_size_text, 12, 85, 390, PDF_BLACK );
snprintf( device_size, sizeof( device_size ), "%s, %lli bytes", c->device_size_text, c->device_size );
pdf_add_text( pdf, NULL, device_size, 12, 85, 390, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
pdf_add_text( pdf, NULL, "Bus:", 12, 300, 390, PDF_GRAY );
@@ -143,8 +150,23 @@ int create_pdf( nwipe_context_t* ptr )
pdf_add_text( pdf, NULL, "Health:", 12, 60, 370, PDF_GRAY );
pdf_add_text( pdf, NULL, "Remapped Sectors:", 12, 300, 370, PDF_GRAY );
/* HPA, DCO, pre-erase */
if( !strcmp( c->device_type_str, "NVME" ) )
{
snprintf( HPA_pre_erase, sizeof( HPA_pre_erase ), "Not applicable to NVME" );
snprintf( HPA_post_erase, sizeof( HPA_post_erase ), "Not applicable to NVME" );
snprintf( DCO_pre_erase, sizeof( DCO_pre_erase ), "Not applicable to NVME" );
snprintf( DCO_post_erase, sizeof( DCO_post_erase ), "Not applicable to NVME" );
}
pdf_add_text( pdf, NULL, "HPA(pre-erase):", 12, 60, 350, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_pre_erase, 12, 150, 350, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
pdf_add_text( pdf, NULL, "DCO(pre-erase):", 12, 300, 350, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, DCO_pre_erase, 12, 393, 350, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* --------------- */
/* Erasure Details */
@@ -191,16 +213,28 @@ int create_pdf( nwipe_context_t* ptr )
/* Status */
pdf_add_text( pdf, NULL, "Status:", 12, 300, 270, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
if( !strcmp( c->wipe_status_txt, "ERASED" ) )
{
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 345, 270, PDF_DARK_GREEN );
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 365, 270, PDF_DARK_GREEN );
pdf_add_ellipse( pdf, NULL, 390, 275, 45, 10, 2, PDF_DARK_GREEN, PDF_TRANSPARENT );
}
else
{
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 345, 270, PDF_RED );
if( !strcmp( c->wipe_status_txt, "FAILED" ) )
{
// text shifted left slightly in ellipse due to extra character
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 370, 270, PDF_RED );
}
else
{
pdf_add_text( pdf, NULL, c->wipe_status_txt, 12, 360, 270, PDF_RED );
}
pdf_add_ellipse( pdf, NULL, 390, 275, 45, 10, 2, PDF_RED, PDF_TRANSPARENT );
}
pdf_set_font( pdf, "Helvetica" );
/* Method */
pdf_add_text( pdf, NULL, "Method:", 12, 60, 250, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, nwipe_method_label( nwipe_options.method ), 12, 110, 250, PDF_BLACK );
@@ -268,14 +302,28 @@ int create_pdf( nwipe_context_t* ptr )
pdf_add_text( pdf, NULL, verify, 12, 450, 230, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* bytes erased */
pdf_add_text( pdf, NULL, "Bytes Erased:", 12, 60, 210, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, "", 12, 60, 210, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* rounds */
pdf_add_text( pdf, NULL, "Rounds:", 12, 300, 210, PDF_GRAY );
snprintf( rounds, sizeof( rounds ), "%i", nwipe_options.rounds );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, rounds, 12, 350, 210, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
/* HPA, DCO, post erase */
pdf_add_text( pdf, NULL, "HPA(post-erase):", 12, 60, 190, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, HPA_post_erase, 12, 155, 190, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
pdf_add_text( pdf, NULL, "DCO(post-erase):", 12, 300, 190, PDF_GRAY );
pdf_set_font( pdf, "Helvetica-Bold" );
pdf_add_text( pdf, NULL, DCO_post_erase, 12, 397, 190, PDF_BLACK );
pdf_set_font( pdf, "Helvetica" );
pdf_add_text( pdf, NULL, "Information:", 12, 60, 170, PDF_GRAY );
/* ---------------------- */

View File

@@ -31,6 +31,11 @@
/*! Utility macro to provide gray */
#define PDF_GRAY PDF_RGB( 0x5A, 0x5A, 0x5A )
/**
* Create the disk erase report in PDF format
* @param pointer to a drive context
* @return returns 0 on success < 1 on error
*/
int create_pdf( nwipe_context_t* ptr );
#endif /* CREATE_PDF_H_ */

View File

@@ -40,7 +40,22 @@ typedef enum nwipe_log_t_ {
NWIPE_LOG_NOTIMESTAMP // logs the message without the timestamp
} nwipe_log_t;
/**
* Writes a string to the log. nwipe_log timestamps the string
* @param level the tag to display:
* NWIPE_LOG_NONE Don't display a tag
* NWIPE_LOG_DEBUG, Very verbose logging.
* NWIPE_LOG_INFO, Verbose logging.
* NWIPE_LOG_NOTICE, Most logging happens at this level.
* NWIPE_LOG_WARNING, Things that the user should know about.
* NWIPE_LOG_ERROR, Non-fatal errors that result in failure.
* NWIPE_LOG_FATAL, Errors that cause the program to exit.
* NWIPE_LOG_SANITY, Programming errors.
* NWIPE_LOG_NOTIMESTAMP logs the message without the timestamp
* @param format the string to be logged
*/
void nwipe_log( nwipe_log_t level, const char* format, ... );
void nwipe_perror( int nwipe_errno, const char* f, const char* s );
void nwipe_log_OSinfo();
int nwipe_log_sysinfo();