Package com.sun.jna.platform.win32.WinCrypt

Examples of com.sun.jna.platform.win32.WinCrypt.DATA_BLOB


  public OleAutoTest() {
  }

  public void testSysAllocString() {
    assertEquals(null, OleAuto.INSTANCE.SysAllocString(null));
    BSTR p = OleAuto.INSTANCE.SysAllocString("hello world");
    assertEquals("hello world", p.getValue());
    OleAuto.INSTANCE.SysFreeString(p);
  }
View Full Code Here


      IntByReference lpcValues = new IntByReference();
      IntByReference lpcMaxClassLen = new IntByReference();
      IntByReference lpcMaxValueNameLen = new IntByReference();
      IntByReference lpcMaxValueLen = new IntByReference();
      IntByReference lpcbSecurityDescriptor = new IntByReference();
      FILETIME lpftLastWriteTime = new FILETIME();
      assertEquals(W32Errors.ERROR_SUCCESS, Advapi32.INSTANCE.RegQueryInfoKey(
          WinReg.HKEY_LOCAL_MACHINE, null, lpcClass, null,
          lpcSubKeys, lpcMaxSubKeyLen, lpcMaxClassLen, lpcValues,
          lpcMaxValueNameLen, lpcMaxValueLen, lpcbSecurityDescriptor,
          lpftLastWriteTime));
View Full Code Here

    public static void main(String[] args) {
        junit.textui.TestRunner.run(Crypt32Test.class);
    }
   
    public void testCryptProtectUnprotectData() {
      DATA_BLOB pDataIn = new DATA_BLOB("hello world");
      DATA_BLOB pDataEncrypted = new DATA_BLOB();
      assertTrue(Crypt32.INSTANCE.CryptProtectData(pDataIn, "description",
          null, null, null, 0, pDataEncrypted));
      PointerByReference pDescription = new PointerByReference();
      DATA_BLOB pDataDecrypted = new DATA_BLOB();
      assertTrue(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription,
          null, null, null, 0, pDataDecrypted));
      assertEquals("description", pDescription.getValue().getWideString(0));
      assertEquals("hello world", pDataDecrypted.pbData.getString(0));
      Kernel32.INSTANCE.LocalFree(pDataEncrypted.pbData);
View Full Code Here

      Kernel32.INSTANCE.LocalFree(pDataDecrypted.pbData);
      Kernel32.INSTANCE.LocalFree(pDescription.getValue());
    }
   
    public void testCryptProtectUnprotectDataWithEntropy() {
      DATA_BLOB pDataIn = new DATA_BLOB("hello world");
      DATA_BLOB pDataEncrypted = new DATA_BLOB();
      DATA_BLOB pEntropy = new DATA_BLOB("entropy");
      assertTrue(Crypt32.INSTANCE.CryptProtectData(pDataIn, "description",
          pEntropy, null, null, 0, pDataEncrypted));
      PointerByReference pDescription = new PointerByReference();
      DATA_BLOB pDataDecrypted = new DATA_BLOB();
      // can't decrypt without entropy
      assertFalse(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription,
          null, null, null, 0, pDataDecrypted));
      // decrypt with entropy
      assertTrue(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription,
View Full Code Here

   * @return
   *  Protected bytes.
   */
  public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
      String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
      DATA_BLOB pDataIn = new DATA_BLOB(data);
      DATA_BLOB pDataProtected = new DATA_BLOB();
      DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
      try {
        if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
            pEntropy, null, prompt, flags, pDataProtected)) {
          throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }
View Full Code Here

   * @return
   *  Unprotected blob of data.
   */
  public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
      CRYPTPROTECT_PROMPTSTRUCT prompt) {
      DATA_BLOB pDataIn = new DATA_BLOB(data);
      DATA_BLOB pDataUnprotected = new DATA_BLOB();
      DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
      PointerByReference pDescription = new PointerByReference();
      try {
        if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
            pEntropy, null, prompt, flags, pDataUnprotected)) {
          throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
View Full Code Here

    public static void main(String[] args) {
        junit.textui.TestRunner.run(Crypt32Test.class);
    }
   
    public void testCryptProtectUnprotectData() {
      DATA_BLOB pDataIn = new DATA_BLOB("hello world");
      DATA_BLOB pDataEncrypted = new DATA_BLOB();
      assertTrue(Crypt32.INSTANCE.CryptProtectData(pDataIn, "description",
          null, null, null, 0, pDataEncrypted));
      PointerByReference pDescription = new PointerByReference();
      DATA_BLOB pDataDecrypted = new DATA_BLOB();
      assertTrue(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription,
          null, null, null, 0, pDataDecrypted));
      assertEquals("description", pDescription.getValue().getString(0, true));
      assertEquals("hello world", pDataDecrypted.pbData.getString(0));
      Kernel32.INSTANCE.LocalFree(pDataEncrypted.pbData);
View Full Code Here

      Kernel32.INSTANCE.LocalFree(pDataDecrypted.pbData);
      Kernel32.INSTANCE.LocalFree(pDescription.getValue());
    }
   
    public void testCryptProtectUnprotectDataWithEntropy() {
      DATA_BLOB pDataIn = new DATA_BLOB("hello world");
      DATA_BLOB pDataEncrypted = new DATA_BLOB();
      DATA_BLOB pEntropy = new DATA_BLOB("entropy");
      assertTrue(Crypt32.INSTANCE.CryptProtectData(pDataIn, "description",
          pEntropy, null, null, 0, pDataEncrypted));
      PointerByReference pDescription = new PointerByReference();
      DATA_BLOB pDataDecrypted = new DATA_BLOB();
      // can't decrypt without entropy
      assertFalse(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription,
          null, null, null, 0, pDataDecrypted));
      // decrypt with entropy
      assertTrue(Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription,
View Full Code Here

    /**
     *
     */
    public MONITORINFO() {
        this.cbSize = new DWORD(size());
    }
View Full Code Here

    private void newAppBar() {
        APPBARDATA data = new APPBARDATA.ByReference();
        data.cbSize.setValue(data.size());
        data.uCallbackMessage.setValue(WM_USER + 1);

        UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage(new DWORD(ShellAPI.ABM_NEW), data);
        assertNotNull(result);
    }
View Full Code Here

TOP

Related Classes of com.sun.jna.platform.win32.WinCrypt.DATA_BLOB

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.