5

I'm trying to verify the PGP Signature of the latest version of KeePass 2.14's setup file against this signature, but this is the output I receive:

C:\Program Files (x86)\GNU\GnuPG>gpg.exe --verify C:\Users\User\Desktop\KeePass-2.14-Setup.exe
gpg: no valid OpenPGP data found.
gpg: the signature could not be verified.
Please remember that the signature file (.sig or .asc)
should be the first file given on the command line.

C:\Program Files (x86)\GNU\GnuPG>

I found this command here, but it made no mention about ".sig" or ".asc" files, so I figured I did something wrong. By reading the man pages, I further tried the following:

C:\Program Files (x86)\GNU\GnuPG>gpg.exe --pgpfile C:\Users\User\Desktop\KeePass-2.14-Setup.exe
gpg: Invalid option "--pgpfile"

C:\Program Files (x86)\GNU\GnuPG>

As you can see, the results are quite obfuscating...

I took a look at this on SuperUser, but none of the links seemed to really address my question, at least not directly enough for me to get any idea on how to move forward on this.

Can anybody here help me with the esoteric technicality of OpenPGP & the associated use of the GnuPG program? I've felt pretty dumb learning VBS, but this is beyond humiliating: it's absolutely debilitating and maiming whatever confidence I had with my IT skills (then again, I have no justification for making any boast either, as I have yet to get my A+ Cert, lol).


UPDATE 04-04-2011

Okay, so I got tired of fooling around with Windows and decided I'd do it right by booting up Ubuntu; this alone made things much more logical!

So here's my list of commands and where I'm at:

  1. proto@type:~$ cd Desktop/
  2. proto@type:~/Desktop$ gpg --import KeePass-2.14-Setup.exe.asc gpg: no valid OpenPGP data found. gpg: Total number processed: 0
  3. proto@type:~/Desktop$ gpg --import Dominik_Reichl.asc gpg: /home/proto/.gnupg/trustdb.gpg: trustdb created gpg: key FEB7C7BC: public key "Dominik Reichl " imported gpg: Total number processed: 1 gpg: imported: 1
  4. proto@type:~/Desktop$ gpg --verify KeePass-2.14-Setup.exe gpg: no valid OpenPGP data found. gpg: the signature could not be verified. Please remember that the signature file (.sig or .asc) should be the first file given on the command line.
  5. proto@type:~/Desktop$ gpg --verify KeePass-2.14-Setup.exe.asc gpg: Signature made Sun 02 Jan 2011 05:25:24 AM MST using DSA key ID FEB7C7BC gpg: Good signature from "Dominik Reichl " gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 2171 BEEA D0DD 92A1 8065 5626 DCCA A5B3 FEB7 C7BC
  6. proto@type:~/Desktop$ gpg --verify Dominik_Reichl.asc gpg: verify signatures failed: unexpected data

As Mike instructed, I placed ".exe" & the ".asc" files in the same directory, that being the Desktop. As you can see in the code, I also placed the public key "Dominik_Reichl.asc" in the Desktop directory.

Please be patient with me, as I've been thoroughly spoiled by MD5; I'm assuming that Step 5 from above is the GPG equivalent to this:

C:\Users\user\>CD Desktop

C:\Users\user\Desktop>MD5Sum KeePass-2.14-Setup.exe
bae59065b24f0a6f2ed4bb9e0d6fc65f *KeePass-2.14-Setup.exe

I say this because the behavior changes whenever I move the "KeePass-2.14-Setup.exe" file into a "temp" folder on the Desktop. When I run the command this is the result I get:

proto@type:~/Desktop$ gpg --verify KeePass-2.14-Setup.exe.asc
gpg: no signed data
gpg: can't hash datafile: file open error

These results have lead me to believe that I'm supposed to extract the "DSA key ID" & the "Primary key fingerprint", from Step 5, and compare them to the values at the top of the Signature Page. So, is this where the similarity is at with MD5 verification? Is this all there is to it? Or is there a further step? Is there a command that I use to verify these two strings? Are those strings what I really need to check? What are those strings?



Now there's one other issue that I'm having to contend with. In the "Primary key fingerprint" results, I have 2 spaces between the "8065" and the "5626". When I use a spreadsheet to verify my results with the string on the Signature Page, I get a "FALSE" result because of the extra whitespace in my results. I checked the source of the Signature Page to see if the browser was ignoring the extra white space, but that's not the case.

2171 BEEA D0DD 92A1 8065 5626 DCCA A5B3 FEB7 C7BC    # From Source of Signature Page
2171 BEEA D0DD 92A1 8065  5626 DCCA A5B3 FEB7 C7BC    # From My Results

As long as I remove that extra whitespace, my results match with that from the Signature Page, but shouldn't they match without any intervention on my part? Should a difference in whitespace be cause for alarm?

Unfortunately, the GPG Man Pages are still quite obscure to me, or as some may put it "user-hostile" (search "user hostile gpg"), so I'll need a couple extra carrots tossed my way. I'll admit it: I'm dumb. In fact, when I was still learning how to use MD5 verification, I floundered around with it almost as much as I did with this.

Stisfa
  • 173
  • 2
  • 10
  • Honestly what a rigmarole! Why could KeepassX developers not have just published a MD5 so that one could use ExactFile to check the downloaded installer. – therobyouknow Apr 05 '16 at 13:20

5 Answers5

4

On the first command you provided you should be referencing the .asc signature file - not the .exe file. The .exe file should also be residing in the same directory as the .asc file.

From the gpg man page:

--verify
      Assume that the first argument is a signed file or a detached signature and verify it without generat-
      ing any output. With no arguments, the signature packet is read from STDIN. If only a sigfile is given,
      it may be a complete signature or a detached signature, in which case the signed stuff is expected in a
      file without the ".sig" or ".asc" extension.  With more than 1 argument, the first should be a detached
      signature and the remaining files are the signed stuff. To read the signed stuff from STDIN,  use  '-''
      as the second filename.  For security reasons a detached signature cannot read the signed material from
      STDIN without denoting it in the above way.
Mike Fitzpatrick
  • 16,789
  • 4
  • 46
  • 48
  • Woops! I left out important details. When [downloading](http://keepass.info/download.html) KeePass 2.14, I only get that EXE file. There was no folder, zipped or otherwise, that I downloaded. If you download using the top right link, "KeePass 2.14 (Installer EXE for Windows)", you'll see it. That's why I assumed I would run the '--verify' command against the EXE file & it would produce an .asc/.sig file. So why would they have a GnuPG Signature for the .asc [file](http://keepass.info/integrity_sig.html), but not provide it in the download? Is it in a folder _after_ KeePass is installed? – Stisfa Mar 08 '11 at 22:42
  • 1
    The .exe.asc file IS the signature for the .exe file. You need both files in the same folder when you try to verify. When you pass the .exe.asc file to gpg --verify it looks for the related file (.exe) in the same folder. This is all before you run/install the .exe file. When I verify it tells me that the signing public key ID is 0xFEB7C7BC which matches the [public key](http://keepass.info/integrity/Dominik_Reichl.asc) published on the [signatures page](http://keepass.info/integrity_sig.html) but this doesn't really verify much since the sig and public key both come from the same source. – Mike Fitzpatrick Mar 09 '11 at 03:36
  • Where do I get the .exe.asc file? I understand that I need to verify that file, but it's never downloaded whenever I'm downloading from [SourceForge](http://sourceforge.net/projects/keepass/files/KeePass%202.x/2.14/KeePass-2.14-Setup.exe/download). – Stisfa Mar 09 '11 at 15:49
  • Okay, looks like you're going to have to make me less stupid for a little longer: I went to the signatures page you linked and tried something else. I right-clicked (in Chrome) the exe.asc file link, then clicked "Save link as...". From there, I saved it to my desktop, then I ran gpg.exe again. This time I get this output: `C:\Program Files (x86)\GNU\GnuPG>gpg.exe --verify "C:\Users\User\Desktop\KeePass-2.14-Setup.exe.asc" gpg: Signature made 01/02/11 05:25:24 using DSA key ID FEB7C7BC gpg: Can't check signature: public key not found` – Stisfa Mar 09 '11 at 15:59
  • "...this doesn't really verify much since the sig and public key both come from the same source." - this is where I get caught whenever I think about PGP/GPG. I think part of the problem may have to do with the fact that I'm thinking about PGP sigs from the standpoint of MD5SUM/SHA1SUM hashes. In those instances, I run MD5 & SHA1 verifications against any given file and compare the resulting values with the published values, like [here](http://keepass.info/integrity.html). So would it be correct that I need to stop thinking from the hash sum paradigm? If so, how should I see PGP sigs? – Stisfa Mar 09 '11 at 16:09
  • 2
    Here are the links: [.exe](http://downloads.sourceforge.net/keepass/KeePass-2.14-Setup.exe), [.exe.asc](http://keepass.info/integrity/v2/KeePass-2.14-Setup.exe.asc) and the author's [public key](http://keepass.info/integrity/Dominik_Reichl.asc). You should **import the author's public key into your key chain** and have the other two files in the same directory. You should probably also make that directory the current working directory, instead of the gpg directory, just to be sure. The validation process relies on you trusting the validity of the author's public key... – Mike Fitzpatrick Mar 09 '11 at 22:36
  • 1
    To my understanding, successfully verifying a file with its signature file **will** help detect any download errors (or man in the middle attacks) but it doesn't help you to verify that the file realy came from that person who owns the public signature. If you alreay had a trusted copy of the author's public key on your gpg key ring then you could verify the .exe file really was signed by them but getting the public key and the signature from the same source doesn't prove anything about the signer's identity. – Mike Fitzpatrick Mar 09 '11 at 22:43
  • @Stisfa: Deep down, a PGP signature *is* a hash, but it is behind a layer of asymmetric encryption so that you can verify its authenticity. – u1686_grawity Mar 17 '11 at 05:44
  • 1
    @Mike: s/owns the public signature/owns the keypair/ – u1686_grawity Mar 17 '11 at 05:45
  • @grawity: I've kind of got the idea (Mike's got me in the right direction, I think), but I still need to invest some more time into learning about PGP. Right now I'm going through the [GPG Mini HowTo](http://www.dewinter.com/gnupg_howto/english/GPGMiniHowto.html) before I make any further posts. Basically, forcing myself to RTM since Mike's been able to simplify it a little for me. If only there was an anthropomorphized, yet succinct explanation for n00bs like me... I must ask for more patience from everybody, as I have many more questions coming =D – Stisfa Mar 17 '11 at 05:59
  • @grawity: "s/owns the public signature/owns the keypair/" I'm embarrassed to ask, what's that mean? I'm assuming it's a reference to IRC commands? If so, the meaning is lost on me...sorry. – Stisfa Apr 05 '11 at 07:50
  • 2
    @Stisfa: @grawity correctly means that I should have written "owns the keypair" instead of "owns the public signature". – Mike Fitzpatrick Apr 05 '11 at 08:37
  • 1
    @Stisfa: `s/from/to/` usually means "substitute regular expression `from` with text `to`"; it's commonly seen on IRC but originates from Unix text editors *ed*, *sed* and *vi*. Originally from [QED](http://cm.bell-labs.com/cm/cs/who/dmr/qedman.pdf) on GE-635. – u1686_grawity Apr 05 '11 at 08:49
  • +1 guys; thanks. By the by, I've updated the question, so I was wondering if I could get just a little more feedback, please? Thanks in advance ^.^ – Stisfa Apr 05 '11 at 15:39
  • 1
    @Stisfa: **1)** `Dominik_Reichl.asc` contains a public key that you can import (but not verify); `KeePass-2.14-Setup.exe.asc` contains a detached signature that can be verified (but not imported); `KeePass-2.14-Setup.exe` is an executable and does not contain any PGP data. The output of all 6 commands is correct. – u1686_grawity Apr 05 '11 at 15:59
  • 1
    @Stisfa: **2)** It's not exactly equivalent. The verification indeed uses a hash (more likely to be SHA1 or SHA256, though, as MD5 is considered insecure). But it does _more_ than just `md5sum`: the calculated hash is not displayed, but compared with the one recorded in `KeePass...exe.asc`. (In your case, they match.) And it's not a plain hash in the file, but a digital signature -- a hash encrypted with the signer's private key, to ensure that it is indeed Dominik Reichl who had signed the file. *(I'm bad at explaining things. Look up "Digital signature" on Wikipedia.)* – u1686_grawity Apr 05 '11 at 16:05
  • 1
    @Stisfa: **3)** The key's fingerprint is nothing else than a hash of the public key. "`2171 BEEA D0DD ...`" are just pieces of a long hexadecimal number (like the ones `md5sum` outputs), and they're space-separated for readability; `2171beead0dd...` would mean exactly the same. – u1686_grawity Apr 05 '11 at 16:09
  • @grawity: Thanks for point #3. I've seen difference in case where the MD5 result was all in upper-case and the verification on the source's website was all lower case; this left me with some lingering doubts, but you've cleared them! Thank you! I'm still trying to get my mind around how PGP/GPG works, so you'll have to continue exhibiting long-suffering with my inadequacies. – Stisfa Apr 05 '11 at 18:52
  • @Stisfa: If you have questions about PGP in general, it would be easier if you submitted separate [posts](http://superuser.com/questions/ask), instead of asking in comments. – u1686_grawity Apr 05 '11 at 19:03
  • @grawity: Apologies; I'm just afraid that I'd spam SuperUser with all my inquiries, so I thought it would be better to clutter this post. After more reading (Man Pages/Tutorials/Wiki/ETC), I'll make a single post with several questions. In this instance, though, my main concerns are these: **Did the 5th Command successfully verify the validity of my copy of KeePass? Was it even necessary, since my MD5 & SHA1 verifications were good? No such thing as 100% secure, but is there anything else I can/should do to ensure my KeePass copy is untampered/clean?** Sorry, I have OCD-fueled paranoia... – Stisfa Apr 06 '11 at 02:00
  • 1
    @Stisfa: **Yes**, the hash of your copy matched the hash published. ("Good signature from ...") **But**, as I said, a digital signature is *more* than just a hash -- it is also intended to ensure the file's authenticity. In the case of simple SHA1/MD5 hashes, someone could have broken into the KeePass website's servers, uploaded a fake `.exe`, published its SHA1 hash, and it would look *completely normal*. On the other hand, if the attacker had to publish a PGP signature, you would instantly see that it was made by a _different person_. – u1686_grawity Apr 06 '11 at 11:47
  • 1
    @Stisfa: (cont'd) Although you have to be careful and notice key changes; don't just rely on seeing "Good signature from Dominik Reichl". You have to actually verify that key. In this particular case, you compared the key fingerprint with one from website. (This unfortunately is not much more secure than just comparing SHA hashes of KeePass.) However, now that you have it in your GPG keyring, you can sign DR's key (`gpg --lsign-key FEB7C7BC` to add a _local_ signature) and all future verifications of KeePass will show that the key is trusted. – u1686_grawity Apr 06 '11 at 11:53
  • 1
    @Stisfa: (cont'd) See [Web of trust](http://en.wikipedia.org/wiki/Web_of_trust) for more information on how the whole mess works. – u1686_grawity Apr 06 '11 at 11:54
  • @grawity: +1 across the board. Thanks for the response. It's starting to dawn on me that this is a topic that doesn't have a real "straight" answer; I guess it could be compared to asking an Electrical Engineer to simplify how a CPU works and then asking him to teach me how to make one myself. I'll do some more personal research, which makes me wonder, has anybody else bothered to go this far to make sure their copy of KeePass is legitimate, lol? – Stisfa Apr 06 '11 at 16:12
1

You are overcomplicating things it seems :-) Try to do a search for DSA key ID FEB7C7BC at https://keyserver.pgp.com/vkd/GetWelcomeScreen.event and I think you get it!

  • Well, I didn't "get it" at first. After having had a chance to work with GPG, correspond with both Mike Fitzpatrick and grawity, read about the "Web of trust" concept from Wikipedia, and finally use the link you posted, I think I get the idea. If I can get the DSA Key ID from another source (the link you provided) and download KeePass, along with it's corresponding signature, from a separate source (the KeePass homepage), then verify it, I have a proper validation. I think. – Stisfa Apr 07 '11 at 22:49
0

This post is mostly for an "A-to-Z" breakdown, this way anybody who's stuck on this can get an answer without having to dig through all the comments. Please don't vote this up; as credit goes to the participants (Mike Fitzpatrick, grawity and Jan Ivar Beddari).

Another thing: don't trust this post! Counterintuitive statement, but I'm posting this with a flawed/limited understanding of how GPG works. I'll be updating this as I get a better comprehension of this; right now I have a foggy grasp of how it works.

  1. Download your desired copy of KeePass, the corresponding Signature, and the Public Key to the same directory on your favorite Linux distro (in my case, I've been using Ubuntu and made the Desktop the working directory)
  • This is Important! The Public Key on the KeePass website should not be downloaded! You need to download a Public Key that is trusted by other users, hopefully those users being individuals you trust. How do you do that? Ask a friend who has a trusted Public Key to give you a copy; but you may not necessarily have a friend who has that. Well, thanks to Jan Ivar Beddari's post, one can download a Public Key published by Dominik Reichl from here and use the Import the Public Key from there.
  • Open a Terminal ("CTRL+ALT+T" in Ubuntu)
  • Run cd Desktop/
  • Run gpg --import %KEYNAME%.asc
  • Run gpg --verify %SIGNATURE%.asc
  • Compare the Resulting Key Fingerprint with that from the KeePass Website

  • Here are my results when using the Public Key from keyserver.pgp.com:

    proto@type:~$ cd Desktop/
    
    proto@type:~/Desktop$ gpg --import key0xDCCAA5B3FEB7C7BC.asc 
    gpg: key FEB7C7BC: public key "Dominik Reichl " imported
    gpg: Total number processed: 1
    gpg:               imported: 1
    gpg: no ultimately trusted keys found
    
    proto@type:~/Desktop$ gpg --verify KeePass-2.14-Setup.exe.asc
    gpg: Signature made Sun 02 Jan 2011 05:25:24 AM MST using DSA key ID FEB7C7BC
    gpg: Good signature from "Dominik Reichl "
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: 2171 BEEA D0DD 92A1 8065  5626 DCCA A5B3 FEB7 C7BC
    

    Then here are my results when using the Public Key from the KeePass website:

    proto@type:~$ cd Desktop
    
    proto@type:~/Desktop$ gpg --import Dominik_Reichl.asc
    gpg: key FEB7C7BC: public key "Dominik Reichl " imported
    gpg: Total number processed: 1
    gpg:               imported: 1
    
    proto@type:~/Desktop$ gpg --verify KeePass-2.14-Setup.exe.asc
    gpg: Signature made Sun 02 Jan 2011 05:25:24 AM MST using DSA key ID FEB7C7BC
    gpg: Good signature from "Dominik Reichl "
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: 2171 BEEA D0DD 92A1 8065  5626 DCCA A5B3 FEB7 C7BC
    

    As you can see, the results are all the same, excluding the "gpg: no ultimately trusted keys found" portion. I'm not sure what to make of it, but the Key Fingerprints match those on the KeePass website, which matters when verifying the File. This is vastly different from verifying that the Public Key is trustworthy, though. The Public Key is something you trust to use or don't, like whether you trust a stranger. One way for them to come across as trustworthy is if they have several individuals to vouch for them, which is the same for the Public Key. Again, this is from my limited scope, so due diligence is required on your part too!

    If you can wait though, I'll slowly be editing my posts to favor a succinct, simple, and, hopefully, an accurate representation of the proper use of GPG in verifying one's copy of KeePass.

    Stisfa
    • 173
    • 2
    • 10
    0

    Have you tried running this?

    gpg --verify KeePass-2.14-Setup.exe.asc KeePass-2.14-Setup.exe
    

    Try it on Ubuntu of course. Windows tends to be a pain, if you take my meaning...

    the_midget_17
    • 807
    • 2
    • 11
    • 27
    0

    IMPORTANT ! This is just FYI. If you migrating from one platform to another (for example from Win. to Linux) and reinstalling KeepAss, please verify you are installing the correct package. There is KeepAssX first available in repos but if you use the KeepAss2 database with it, it will throw the above mentioned error. Please use KeepAss2 package for .kbdx database.

    Milan
    • 101
    • 1