1*0a6a1f1dSLionel Sambuc.\" $NetBSD: libnetpgpverify.3,v 1.6 2014/02/17 07:23:18 agc Exp $ 2ebfedea0SLionel Sambuc.\" 3ebfedea0SLionel Sambuc.\" Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org> 4ebfedea0SLionel Sambuc.\" All rights reserved. 5ebfedea0SLionel Sambuc.\" 6ebfedea0SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 7ebfedea0SLionel Sambuc.\" modification, are permitted provided that the following conditions 8ebfedea0SLionel Sambuc.\" are met: 9ebfedea0SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 10ebfedea0SLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 11ebfedea0SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 12ebfedea0SLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 13ebfedea0SLionel Sambuc.\" documentation and/or other materials provided with the distribution. 14ebfedea0SLionel Sambuc.\" 15ebfedea0SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16ebfedea0SLionel Sambuc.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17ebfedea0SLionel Sambuc.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18ebfedea0SLionel Sambuc.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19ebfedea0SLionel Sambuc.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20ebfedea0SLionel Sambuc.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21ebfedea0SLionel Sambuc.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22ebfedea0SLionel Sambuc.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23ebfedea0SLionel Sambuc.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24ebfedea0SLionel Sambuc.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25ebfedea0SLionel Sambuc.\" 26*0a6a1f1dSLionel Sambuc.Dd February 16, 2014 27ebfedea0SLionel Sambuc.Dt LIBNETPGPVERIFY 3 28ebfedea0SLionel Sambuc.Os 29ebfedea0SLionel Sambuc.Sh NAME 30ebfedea0SLionel Sambuc.Nm libnetpgpverify 31ebfedea0SLionel Sambuc.Nd library to verify digital signatures 32ebfedea0SLionel Sambuc.Sh LIBRARY 33ebfedea0SLionel Sambuc.Lb libnetpgpverify 34ebfedea0SLionel Sambuc.Sh SYNOPSIS 35ebfedea0SLionel Sambuc.In netpgp/verify.h 36ebfedea0SLionel Sambuc.Ft int 37ebfedea0SLionel Sambuc.Fo pgpv_read_pubring 38ebfedea0SLionel Sambuc.Fa "pgpv_t *pgp" "const void *keyring" "ssize_t size" 39ebfedea0SLionel Sambuc.Fc 40ebfedea0SLionel Sambuc.Ft size_t 41ebfedea0SLionel Sambuc.Fo pgpv_verify 42ebfedea0SLionel Sambuc.Fa "pgpv_cursor_t *cursor" "pgpv_t *pgp" "const void *ptr" "ssize_t size" 43ebfedea0SLionel Sambuc.Fc 44ebfedea0SLionel Sambuc.Ft size_t 45ebfedea0SLionel Sambuc.Fo pgpv_get_verified 46ebfedea0SLionel Sambuc.Fa "pgpv_cursor_t *cursor" "size_t cookie" "char **ret" 47ebfedea0SLionel Sambuc.Fc 48ebfedea0SLionel Sambuc.Ft size_t 49ebfedea0SLionel Sambuc.Fo pgpv_get_entry 50ebfedea0SLionel Sambuc.Fa "pgpv_t *pgp" "unsigned ent" "char **ret" 51ebfedea0SLionel Sambuc.Fc 52ebfedea0SLionel Sambuc.Ft int 53ebfedea0SLionel Sambuc.Fo pgpv_close 54ebfedea0SLionel Sambuc.Fa "pgpv_t *pgp" 55ebfedea0SLionel Sambuc.Fc 56ebfedea0SLionel Sambuc.Sh DESCRIPTION 57ebfedea0SLionel Sambuc.Nm 58ebfedea0SLionel Sambucis a small library which will verify a digital signature on a text or 59ebfedea0SLionel Sambucbinary document. 60ebfedea0SLionel SambucIt has been kept deliberately small and only uses compression libraries 61ebfedea0SLionel Sambucto function. 62ebfedea0SLionel Sambuc.Pp 63ebfedea0SLionel SambucPGP messages, including key rings, are made up of PGP packets, defined 64ebfedea0SLionel Sambucin RFC 4880. 65ebfedea0SLionel SambucTo match a digital signature, the public key of the signer must be 66ebfedea0SLionel Sambuclocated in a public key ring. 67ebfedea0SLionel SambucThis library has enough functionality to parse a pubkey keyring, 68ebfedea0SLionel Sambucusing 69ebfedea0SLionel Sambuc.Fn pgpv_read_pubring 70ebfedea0SLionel Sambucto read the public keys of trusted identities, 71ebfedea0SLionel Sambucand to read files or memory which has already been signed. 72ebfedea0SLionel SambucThe 73ebfedea0SLionel Sambuc.Fn pgpv_verify 74ebfedea0SLionel Sambucfunction is used to verify the signature, either on data, or on memory. 75ebfedea0SLionel SambucTo signal to 76ebfedea0SLionel Sambuc.Fn pgpv_verify 77ebfedea0SLionel Sambucto read a file and verify it, the 78ebfedea0SLionel Sambuc.Dv size 79ebfedea0SLionel Sambucargument should be set to 80ebfedea0SLionel Sambuc.Dv -1 81ebfedea0SLionel Sambucwhilst a positive size signals that the pointer value should be that 82ebfedea0SLionel Sambucof signed memory. 83ebfedea0SLionel Sambuc.Fn pgpv_verify 84ebfedea0SLionel Sambucreturns a cookie if the ignature was verified, or 0 if it did not. 85ebfedea0SLionel SambucThis cookie can subsequently be used to retrieve the data which 86ebfedea0SLionel Sambucwas verified. 87ebfedea0SLionel Sambuc.Pp 88ebfedea0SLionel SambucIf the signature does match, then the file or memory can be considered as being 89ebfedea0SLionel Sambucverified as being unmodified and unchanged, integrally sound. 90ebfedea0SLionel Sambuc.Pp 91ebfedea0SLionel SambucSignatures have validity dates on them, and it is possible for a signature to 92ebfedea0SLionel Sambuchave expired when it is being checked. 93ebfedea0SLionel SambucIf for any reason the signature does not match, then the reason for not 94ebfedea0SLionel Sambucverifying the signature will be stored in the 95ebfedea0SLionel Sambuc.Dv why 96ebfedea0SLionel Sambucbuffer in the 97ebfedea0SLionel Sambuc.Dv pgpv_cursor_t 98ebfedea0SLionel Sambucstructure. 99ebfedea0SLionel Sambuc.Pp 100ebfedea0SLionel SambucOccasionally, the memory or contents of the file which matched the signature 101ebfedea0SLionel Sambucwill be needed, rather than a boolean value of whether it was verified. 102ebfedea0SLionel SambucTo do this, the 103ebfedea0SLionel Sambuc.Fn pgpv_get_verified 104ebfedea0SLionel Sambucfunction is used. 105ebfedea0SLionel SambucArguments to 106ebfedea0SLionel Sambuc.Fn pgpv_get_verified 107ebfedea0SLionel Sambucare the cookie returned from the verification, and a buffer 108ebfedea0SLionel Sambucallocated for the returned data and its size. 109ebfedea0SLionel SambucIf an error occurs, or the signature is not verified, a zero value is returned 110ebfedea0SLionel Sambucfor the size. 111ebfedea0SLionel Sambuc.Nm 112ebfedea0SLionel Sambucstores the starts of the data of all verified matches, and so the entry 113ebfedea0SLionel Sambucnumber argument is the index of the occurrence of verification. 114ebfedea0SLionel SambucThe first match will have an entry number of 0, the second 1, and so on. 115ebfedea0SLionel Sambuc.Pp 116ebfedea0SLionel SambucThe 117ebfedea0SLionel Sambuc.Fn pgpv_close 118ebfedea0SLionel Sambucfunction is used to clean up after all matching and verification has taken place. 119ebfedea0SLionel SambucIt frees and de-allocates all resources used in the verification of the signature. 120ebfedea0SLionel Sambuc.Pp 121ebfedea0SLionel SambucThe program used for signing may encode into base64 encoding, and it may also 122ebfedea0SLionel Sambucuse embedded compression to make the output smaller than it would otherwise be. 123ebfedea0SLionel SambucThis is handled automatically by 124*0a6a1f1dSLionel Sambuc.Nm . 125ebfedea0SLionel Sambuc.Sh SEE ALSO 126ebfedea0SLionel Sambuc.Xr bn 3 , 127ebfedea0SLionel Sambuc.\" .Xr bzlib2 3 , 128ebfedea0SLionel Sambuc.Xr zlib 3 129ebfedea0SLionel Sambuc.Sh STANDARDS 130*0a6a1f1dSLionel Sambuc.Rs 131*0a6a1f1dSLionel Sambuc.%A J. Callas 132*0a6a1f1dSLionel Sambuc.%A L. Donnerhacke 133*0a6a1f1dSLionel Sambuc.%A H. Finney 134*0a6a1f1dSLionel Sambuc.%A D. Shaw 135*0a6a1f1dSLionel Sambuc.%A R. Thayer 136*0a6a1f1dSLionel Sambuc.%D November 2007 137*0a6a1f1dSLionel Sambuc.%R RFC 4880 138*0a6a1f1dSLionel Sambuc.%T OpenPGP Message Format 139*0a6a1f1dSLionel Sambuc.Re 140ebfedea0SLionel Sambuc.Sh HISTORY 141ebfedea0SLionel SambucThe 142ebfedea0SLionel Sambuc.Nm 143ebfedea0SLionel Sambuclibrary first appeared in 144ebfedea0SLionel Sambuc.Nx 7.0 . 145ebfedea0SLionel Sambuc.Sh AUTHORS 146ebfedea0SLionel Sambuc.An Alistair Crooks Aq Mt agc@NetBSD.org 147