title: How may I force the gpg signature timestamp to be taken prior to the beginning of signing, not upon completion?
body: <p>My system for ensuring the integrity of a results file produced by my program:</p>
  
  <ol>
  <li>My program does some work appending to <code>results.txt</code> which becomes several gigabytes in size.</li>
  <li>My program appends the current-time timestamp to the file.    </li>
  <li><code>results.txt</code> is closed.</li>
  <li>My program calls <code>gpg --sign --detach results.txt</code> to create a detached signature.  This takes several minutes due to the size of <code>results.txt</code>.  The pinentry program pops up and the person executing the program is prompted for their secret key passphrase.</li>
  </ol>
  
  <p><i>Time goes by... The results file is archived...</i></p>
  
  <ol start="5">
  <li>Much later, in addition to verifying the signature to attribute the file's contents to the signatory, I want to be able to check that the signature was made immediately after the file was closed, to provide assurance that the file was not edited between closing and signing.</li>
  </ol>
  
  <p>When I developed this system using gpg 2.0.17 (libgcrypt 1.5.0) on Ubuntu, I learned that the timestamp to go into the signature was essentially that at the time <code>gpg --sign</code> was called.  This worked well, as I could rely on less than 1 second ever elapsed between the timestamp being written to the file and the beginning of gpg signing, much too little time for any manual tampering I think.  As part of checking the integrity of the results, I checked that the gpg signature timestamp was less than 1 second after the timestamp written at the end of the file.  That worked great, until...</p>
  
  <p>I ported the system to Windows 7 using gpg 2.0.27 (Gpg4win 2.2.4, libgcrypt 1.6.3), and I noticed that in this environment the timestamp to be included in the gpg signature was actually that at the <i>end</i> of gpg signing, or about 2 minutes after the file is closed.  This is a long enough period of time to possibly tamper with the file.</p>
  
  <p>Is there a way to ask gpg2 to take the timestamp prior to the actual signature being calculated?</p>