2
$\begingroup$

Let's say I have a text field somewhere (i.e. an interactive user submitted text field on a PHP script, or a console application. Basically anything that accepts user input.)

How can I detect if said text field contains only a PGP encrypted/signed message? I could just fingerprint the BEGIN PGP ENCRYPTED MESSAGE header/footer but I was hoping there was a more accurate solution.

I wouldn't need to decrypt said message as I wouldn't control the private key, I just need to check if the message is a PGP encrypted message in the proper format, so to speak.

$\endgroup$
1
  • 1
    $\begingroup$ Somewhat related: there's even an XKCD on this ;-) xkcd.com/1181 $\endgroup$
    – Joost
    Commented Aug 20, 2015 at 8:22

1 Answer 1

3
$\begingroup$

The only possible answer to this is to check out the OpenPGP format and see if the message adheres to that format. You may need to build in some mechanisms to filter out tiny mistakes or extensions in the message though.

As Open PGP is, well, open, there should be plenty libraries that perform this parsing for you. Library recommendations are off topic here but you should be able to find one to your liking using a search engine.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.