Lire en anglais

Partager via


Music Bundle Signature Sample

A sample application that uses the Packaging APIs to sign a custom-format package, called a music bundle, and then validate the generated signature.

This topic contains the following sections.

Description

This sample demonstrates how to use Packaging Digital Signature APIs to sign a custom package format and to validate the resultant signature.

The sample demonstrates the following features:

  • Signing the music bundle.
  • Validating the music bundle.

Requirements

Product Version
Microsoft Windows Software Development Kit (SDK) Windows 7
ATL .NET Framework

Downloading the Sample

This sample is available in the following locations:

Location Path/URL
Windows SDK \Program Files\Microsoft SDKs\Windows\v7.0\Samples\dataaccess\OPC
Code Gallery Download from MSDN Code Gallery

Building the Sample

The following procedure describes how to build the sample.

  1. Install the Microsoft Windows Software Development Kit (SDK).

  2. Register the Windows SDK.

  3. Follow steps for building, using Visual Studio or the command prompt.

    Using Visual Studio 2008:

    1. Open Windows Explorer.
    2. Navigate to the directory that contains the MusicBundleSignature.sln file.
    3. Double-click the MusicBundleSignature.sln file to open it with Visual Studio 2008.
    4. Go to the Build menu in Visual Studio 2008 and select Build Solution.

      Notes

      If the sample does not build successfully, close Visual Studio 2008 and run the .NET Framework Configuration Tool (Mscorcfg.msc) before attempting to build the sample.

    Using the command prompt:

    1. Open the command prompt.
    2. Navigate to the directory that contains the MusicBundleSignature.vcproj file.
    3. Enter the following command: msbuild MusicBundleSignature.vcproj.

Either the Debug or Release build mode may be used.

Running the Sample

Before running the sample application, ensure that the sample project has been built in the Debug or Release mode that corresponds to the build mode that will be used to run the sample.

Notes

To run the sample successfully, at least one X.509 certificate must be present. If an X.509 certificate is not present, the Certificate Creation Tool (Makecert.exe) can be used to generate a certificate for testing purposes.

The following procedures describe how to run the sample using Visual Studio or the command prompt.

Using Visual Studio 2008:
  1. Open the Properties of the sample project.
  2. Under Configuration Properties, click the Debugging item.
  3. Type following argument into the Command Arguments text box and then click OK: MusicBundleSignature.exe.
  4. Run the sample.

Using the command prompt:

  1. Open the command prompt.
  2. Navigate to the directory that contains either the \Debug or the \Release project directory, as determined by the mode used to build and run the sample.
  3. Run the sample by entering the command: MusicBundleSignature.exe.

Additional Information

When run, the sample creates two files.

  • "SampleMusicBundle_signed.zip": the signed version of the original "SampleMusicBundle.zip" package.
  • "signer1.cer": a certificate file that can be used to identify the signer of the package.

Sample Files

File Description
MusicBundleSignature.sln Visual Studio 2008 solution file.
MusicBundleSignature.vcproj Visual Studio 2008 project file.
sign.h Declaration of a function to sign the sample package. Also contains a description of the signing policy used for the sample.
sign.cpp Definitions of the sign function and helper functions used to sign the sample package.
validate.h Declaration of a function to validate the signature of the signed sample package.
validate.cpp Definitions of the validate function and helper functions used to validate the signature of the signed sample package.
util.h Declarations for helper utility functions for using OPC, COM, and managing resources.
util.cpp Definitions for helper utility functions for using OPC, COM, and managing resources.
SampleMusicBundle.zip An unsigned music bundle package containing music files and information.