Crypt32 (JNA API)

com.sun.jna.platform.win32

## Interface Crypt32

- All Superinterfaces:
    AltCallingConvention, Library, StdCall, StdCallLibrary

      public interface Crypt32
      extends StdCallLibrary

  Crypt32.dll Interface.
  Author:
    dblock[at]dblock.org

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.sun.jna.win32.StdCallLibrary

      `StdCallLibrary.StdCallCallback`

    - ### Nested classes/interfaces inherited from interface com.sun.jna.Library

      `Library.Handler`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Crypt32` | `INSTANCE`

    - ### Fields inherited from interface com.sun.jna.win32.StdCallLibrary

      `FUNCTION_MAPPER, STDCALL_CONVENTION`

    - ### Fields inherited from interface com.sun.jna.Library

      `OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_TYPE_MAPPER`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `CertAddEncodedCertificateToSystemStore(java.lang.String szCertStoreName, Pointer pbCertEncoded, int cbCertEncoded)` The CertAddEncodedCertificateToSystemStore function opens the specified system store and adds the encoded certificate to it.
    `boolean` | `CryptProtectData(WinCrypt.DATA_BLOB pDataIn, java.lang.String szDataDescr, WinCrypt.DATA_BLOB pOptionalEntropy, Pointer pvReserved, WinCrypt.CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, int dwFlags, WinCrypt.DATA_BLOB pDataOut)` The CryptProtectData function performs encryption on the data in a DATA_BLOB structure.
    `boolean` | `CryptUnprotectData(WinCrypt.DATA_BLOB pDataIn, PointerByReference szDataDescr, WinCrypt.DATA_BLOB pOptionalEntropy, Pointer pvReserved, WinCrypt.CRYPTPROTECT_PROMPTSTRUCT pPromptStruct, int dwFlags, WinCrypt.DATA_BLOB pDataOut)` The CryptUnprotectData function decrypts and does an integrity check of the data in a DATA_BLOB structure.

- - ### Field Detail

    - #### INSTANCE

          static final Crypt32 INSTANCE

  - ### Method Detail

    - #### CryptProtectData

          boolean CryptProtectData(WinCrypt.DATA_BLOB pDataIn,
                                 java.lang.String szDataDescr,
                                 WinCrypt.DATA_BLOB pOptionalEntropy,
                                 Pointer pvReserved,
                                 WinCrypt.CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
                                 int dwFlags,
                                 WinCrypt.DATA_BLOB pDataOut)

      The CryptProtectData function performs encryption on the data in a DATA_BLOB structure. Typically, only a user with the same logon credential as the encrypter can decrypt the data. In addition, the encryption and decryption usually must be done on the same computer.
      Parameters:
        `pDataIn` - Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
        `szDataDescr` - String with a readable description of the data to be encrypted. This description string is included with the encrypted data. This parameter is optional and can be set to NULL, except on Windows 2000.
        `pOptionalEntropy` - Pointer to a DATA_BLOB structure that contains a password or other additional entropy used to encrypt the data. The DATA_BLOB structure used in the encryption phase must also be used in the decryption phase. This parameter can be set to NULL for no additional entropy.
        `pvReserved` - Reserved for future use and must be set to NULL.
        `pPromptStruct` - Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about where and when prompts are to be displayed and what the content of those prompts should be. This parameter can be set to NULL in both the encryption and decryption phases.
        `dwFlags` - One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT, CRYPTPROTECT_VERIFY_PROTECTION.
        `pDataOut` - Pointer to a DATA_BLOB structure that receives the encrypted data. When you have finished using the DATA_BLOB structure, free its pbData member by calling the LocalFree function.
      Returns:
        If the function succeeds, the function returns TRUE. If the function fails, it returns FALSE. For extended error information, call GetLastError.

    - #### CryptUnprotectData

          boolean CryptUnprotectData(WinCrypt.DATA_BLOB pDataIn,
                                   PointerByReference szDataDescr,
                                   WinCrypt.DATA_BLOB pOptionalEntropy,
                                   Pointer pvReserved,
                                   WinCrypt.CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
                                   int dwFlags,
                                   WinCrypt.DATA_BLOB pDataOut)

      The CryptUnprotectData function decrypts and does an integrity check of the data in a DATA_BLOB structure. Usually, only a user with the same logon credentials as the encrypter can decrypt the data. In addition, the encryption and decryption must be done on the same computer.
      Parameters:
        `pDataIn` - Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB structure's cbData member holds the length of the pbData member's byte string that contains the text to be encrypted.
        `szDataDescr` - Pointer to a string-readable description of the encrypted data included with the encrypted data. This parameter can be set to NULL. When you have finished using ppszDataDescr, free it by calling the LocalFree function.
        `pOptionalEntropy` - Pointer to a DATA_BLOB structure that contains a password or other additional entropy used when the data was encrypted. This parameter can be set to NULL; however, if an optional entropy DATA_BLOB structure was used in the encryption phase, that same DATA_BLOB structure must be used for the decryption phase.
        `pvReserved` - Reserved for future use; must be set to NULL.
        `pPromptStruct` - Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about where and when prompts are to be displayed and what the content of those prompts should be. This parameter can be set to NULL.
        `dwFlags` - DWORD value that specifies options for this function. This parameter can be zero, in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
        `pDataOut` - Pointer to a DATA_BLOB structure where the function stores the decrypted data. When you have finished using the DATA_BLOB structure, free its pbData member by calling the LocalFree function.
      Returns:
        If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE.

    - #### CertAddEncodedCertificateToSystemStore

          boolean CertAddEncodedCertificateToSystemStore(java.lang.String szCertStoreName,
                                                       Pointer pbCertEncoded,
                                                       int cbCertEncoded)

      The CertAddEncodedCertificateToSystemStore function opens the specified system store and adds the encoded certificate to it.
      Parameters:
        `szCertStoreName` - A null-terminated string that contains the name of the system store for the encoded certificate.
        `pbCertEncoded` - A pointer to a buffer that contains the encoded certificate to add.
        `cbCertEncoded` - The size, in bytes, of the pbCertEncoded buffer.
      Returns:
        If the function succeeds, the return value is TRUE.
        If the function fails, the return value is FALSE.
        CertAddEncodedCertificateToSystemStore depends on the functions listed in the following remarks for error handling.
        Refer to those function topics for their respective error handling behaviors.
        For extended error information, call GetLastError.
      See Also:
        MSDN

Copyright © 2007-2016 Timothy Wall. All Rights Reserved.