Пример #1
0
  public void testTimestampAuthenticode() throws Exception {
    File sourceFile = new File("target/test-classes/wineyes.exe");
    File targetFile = new File("target/test-classes/wineyes-timestamped-authenticode.exe");

    FileUtils.copyFile(sourceFile, targetFile);

    PEFile peFile = new PEFile(targetFile);

    PESigner signer = new PESigner(getKeyStore(), ALIAS, PRIVATE_KEY_PASSWORD);
    signer.withDigestAlgorithm(DigestAlgorithm.SHA1);
    signer.withTimestamping(true);
    signer.withTimestampingMode(TimestampingMode.AUTHENTICODE);
    signer.sign(peFile);

    peFile = new PEFile(targetFile);
    List<CMSSignedData> signatures = peFile.getSignatures();
    assertNotNull(signatures);
    assertEquals(1, signatures.size());

    CMSSignedData signature = signatures.get(0);

    assertNotNull(signature);

    peFile.printInfo(System.out);
  }
Пример #2
0
  public void testSign() throws Exception {
    File sourceFile = new File("target/test-classes/wineyes.exe");
    File targetFile = new File("target/test-classes/wineyes-signed.exe");

    FileUtils.copyFile(sourceFile, targetFile);

    PEFile peFile = new PEFile(targetFile);

    PESigner signer =
        new PESigner(getKeyStore(), ALIAS, PRIVATE_KEY_PASSWORD)
            .withTimestamping(false)
            .withProgramName("WinEyes")
            .withProgramURL("http://www.steelblue.com/WinEyes");

    signer.sign(peFile);

    peFile = new PEFile(targetFile);
    List<CMSSignedData> signatures = peFile.getSignatures();
    assertNotNull(signatures);
    assertEquals(1, signatures.size());

    CMSSignedData signature = signatures.get(0);

    assertNotNull(signature);

    peFile.printInfo(System.out);
  }