mattosaurus / PgpCore

.NET Core class library for using PGP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PGP Error codes

MB34 opened this issue · comments

commented

The one thing that I haven't seen documented anywhere, here, in your examples or your tests, is how you handle error codes from the encryption/decryption.

PGP has a list of error codes that are being returned from the command line:
0 PGP Command Line exited successfully.
64 Parser error.
71 Bad data was received from the operating system at startup.
128 An internal error occurred.
129 An initialization failure occurred on startup.
130 A user interrupt occurred.
145 Error purging a cache: passphrase, keyring, or both.
146 Error creating keyring files.
147 Error during a speed test operation.
160 Complete failure during a file wipe.
161 Partial fail, partial success during a file wipe (one file wiped, one not, for example).
162 Complete failure during an encode.
163 Partial failure during an encode.
164 Complete failure during a decode.
165 Partial failure during a decode.
210 Error during one of the key list operations.
220 Error during key maintenance.
221 Error when checking signatures.
222 Error when checking user IDs.
230 Error during one of the key edit operations.
240 Error during one of the key server operations.
245 Error with supplied license.
251 License is expired.
255 An unknown error occurred.

We'd like to be able to detect errors in the handling and am unsure how.

I think mostly the exceptions are just passed up the chain. So in the case of PGP specific errors we'll just be passing back whatever is returned by BouncyCastle.

You'd probably need to catch these errors and handle them accordingly which would be down to your application to do. Probably you'd just need 128, 162, 163, 164 and 255 and you could decide these in whatever wrapper you have around PGPCore.

commented

Maybe you should amend your documentation? So your package is, essentially, a wrapper around BouncyCastle. I'll head over there to see if they have anything on the exception handling

Well it's a bit more than a wrapper but I certainly agree there's scope to improve the error handling and documentation around it.