Package com.sun.jna.platform.win32

# Class Crypt32Util

java.lang.Object
com.sun.jna.platform.win32.Crypt32Util

public abstract class Crypt32Util extends Object
Crypt32 utility API.

Author:
  dblock[at]dblock.org

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Crypt32Util()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `CertNameToStr(int dwCertEncodingType, int dwStrType, WinCrypt.DATA_BLOB pName)`
  Utility method to call to Crypt32's CertNameToStr that allocates the assigns the required memory for the psz parameter based on the type mapping used, calls to CertNameToStr, and returns the received string.
  `static byte[]`
  `cryptProtectData(byte[] data)`
  Protect a blob of data.
  `static byte[]`
  `cryptProtectData(byte[] data, byte[] entropy, int flags, String description, WinCrypt.CRYPTPROTECT_PROMPTSTRUCT prompt)`
  Protect a blob of data.
  `static byte[]`
  `cryptProtectData(byte[] data, int flags)`
  Protect a blob of data with optional flags.
  `static byte[]`
  `cryptUnprotectData(byte[] data)`
  Unprotect a blob of data.
  `static byte[]`
  `cryptUnprotectData(byte[] data, byte[] entropy, int flags, WinCrypt.CRYPTPROTECT_PROMPTSTRUCT prompt)`
  Unprotect a blob of data.
  `static byte[]`
  `cryptUnprotectData(byte[] data, int flags)`
  Unprotect a blob of data.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Crypt32Util

    public Crypt32Util()

- ## Method Details

  - ### cryptProtectData

    public static byte[] cryptProtectData(byte[] data)
    Protect a blob of data.
    Parameters:
      `data` - Data to protect.
    Returns:
      Protected data.

  - ### cryptProtectData

    public static byte[] cryptProtectData(byte[] data, int flags)
    Protect a blob of data with optional flags.
    Parameters:
      `data` - Data to protect.
      `flags` - Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
    Returns:
      Protected data.

  - ### cryptProtectData

    public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags, String description, WinCrypt.CRYPTPROTECT_PROMPTSTRUCT prompt)
    Protect a blob of data.
    Parameters:
      `data` - Data to protect.
      `entropy` - Optional entropy.
      `flags` - Optional flags.
      `description` - Optional description.
      `prompt` - Prompt structure.
    Returns:
      Protected bytes.

  - ### cryptUnprotectData

    public static byte[] cryptUnprotectData(byte[] data)
    Unprotect a blob of data.
    Parameters:
      `data` - Data to unprotect.
    Returns:
      Unprotected blob of data.

  - ### cryptUnprotectData

    public static byte[] cryptUnprotectData(byte[] data, int flags)
    Unprotect a blob of data.
    Parameters:
      `data` - Data to unprotect.
      `flags` - Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
    Returns:
      Unprotected blob of data.

  - ### cryptUnprotectData

    public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags, WinCrypt.CRYPTPROTECT_PROMPTSTRUCT prompt)
    Unprotect a blob of data.
    Parameters:
      `data` - Data to unprotect.
      `entropy` - Optional entropy.
      `flags` - Optional flags.
      `prompt` - Optional prompt structure.
    Returns:
      Unprotected blob of data.

  - ### CertNameToStr

    public static String CertNameToStr(int dwCertEncodingType, int dwStrType, WinCrypt.DATA_BLOB pName)
    Utility method to call to Crypt32's CertNameToStr that allocates the assigns the required memory for the psz parameter based on the type mapping used, calls to CertNameToStr, and returns the received string.
    Parameters:
      `dwCertEncodingType` - The certificate encoding type that was used to encode the name. The message encoding type identifier, contained in the high WORD of this value, is ignored by this function.
      `pName` - A pointer to the CERT_NAME_BLOB structure to be converted.
      `dwStrType` - This parameter specifies the format of the output string. This parameter also specifies other options for the contents of the string.
    Returns:
      Returns the retrieved string.