z/OS Open Cryptographic Services Facility Application Programming
Previous topic | Next topic | Contents | Index | Contact z/OS | Library | PDF


MAIN.C

z/OS Open Cryptographic Services Facility Application Programming
SC24-5899-01

//-------------------------------------------------------------------------
//
// COMPONENT_NAME: file_encrypt
//
// (C) COPYRIGHT International Business Machines Corp. 1999
// All Rights Reserved
// Licensed Materials - Property of IBM
//
//-------------------------------------------------------------------------
//
// FILE: main.c
//
// This file contains the main program of the file_encrypt program.
// The command line arguments are processed here and other functions
// are called to perform subtasks such as initializing the CSSM,
// attaching the required service providers.
//
//-------------------------------------------------------------------------

#include <stdio.h>
#include <stdlib.h>

#include "cssm.h"
#include "file_encrypt.h"

//-------------------------------------------------------------------------
//
// Function: ProcessArguments
//
// This function checks the command line arguments and provides syntax.
//  
//-------------------------------------------------------------------------
static void ProcessArguments(int argc, char *argv[], char **ClearFilename)
{
    // Check the number of arguments
    if (argc != 2) {
        printf("\n");
        printf("Usage: file_encrypt <file to encrypt>\n");
        printf("\n");
        printf("  This utility encrypts the given file and \n");
        printf("  the and creates the encrypted file.  This is the file\n");
        printf("  generated:\n");
        printf("\n");
        printf("    <filename>.enc - the encrypted file\n");
        printf("\n");
        exit(1);
    }

    // Get the name of the clear file
    *ClearFilename = argv[1];
}

//-------------------------------------------------------------------------
//
// Function: main
//
//-------------------------------------------------------------------------
int main(int argc, char *argv[])
{
    // Handle to the cryptographic service provider
    CSSM_CSP_HANDLE             hCSP;
    char                        *ClearFilename;

    ProcessArguments(argc, argv, &ClearFilename);

    Initialize();

    // Set up cryptographic service provider
    AttachCSPByAlgorithm(&hCSP, CSSM_ALGID_DES);

    // Generate required key recovery fields and then encrypt
    GenerateContextAndEncrypt(hCSP, ClearFilename);

    return 0;
}

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014