Documentation for public API
+SUBDIRS = examples/01_decrypt
+
pkglib_LTLIBRARIES = libsimplepgp.la
pkginclude_HEADERS = src/simplepgp.h
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = simplepgp.pc
+
libsimplepgp_la_LDFLAGS = -version-info 0:1:0
libsimplepgp_la_SOURCES = \
src/packet.c \
AC_CONFIG_SRCDIR([src/packet.c])
AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile simplepgp.pc])
AM_INIT_AUTOMAKE([subdir-objects foreign])
AC_PROG_LIBTOOL
+LDFLAGS=`pkg-config --libs simplepgp`
+CFLAGS=`pkg-config --cflags simplepgp`
+
+EXEC=decrypt
+OBJS=decrypt.c
+
+default: $(EXEC)
+
+all: default
\ No newline at end of file
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include <simplepgp.h>
+
+#define SECKEY_BUF 2048
+#define CTEXT_BUF 1024
+
+#define KEY_PASS "test"
+
+int main(int argc, char **argv) {
+ char seckey[SECKEY_BUF];
+ char ctext[CTEXT_BUF];
+ int fd;
+ int seckey_len, ctext_len;
+ spgp_packet_t *pkt;
+
+ printf("simplepgp decrypt example.\n");
+
+ fd = open("test1_sec.pgp", O_RDONLY);
+ if (fd < 0) { perror("seckey open"); return 1; }
+ if ((seckey_len = read(fd, seckey, SECKEY_BUF)) < 0) {
+ perror("seckey read"); return 1;
+ }
+ close(fd);
+
+ fd = open("ciphertext.pgp", O_RDONLY);
+ if (fd < 0) { perror("cipher open"); return 1; }
+ if ((ctext_len = read(fd, ctext, CTEXT_BUF)) < 0) {
+ perror("cipher read"); return 1;
+ }
+ close(fd);
+
+ if (spgp_init() != 0) {
+ fprintf(stderr, "error: %s\n", spgp_err_str(spgp_err()));
+ return 1;
+ }
+
+ spgp_debug_log_set(1);
+
+ pkt = spgp_decode_message(seckey, seckey_len);
+ if (NULL == pkt) {
+ fprintf(stderr, "error: %s\n", spgp_err_str(spgp_err()));
+ return 1;
+ }
+
+ if (spgp_decrypt_all_secret_keys(pkt, KEY_PASS, strlen(KEY_PASS)) != 0) {
+ fprintf(stderr, "error: %s\n", spgp_err_str(spgp_err()));
+ return 1;
+ }
+
+ pkt = spgp_decode_message(ctext, ctext_len);
+ if (NULL == pkt) {
+ fprintf(stderr, "error: %s\n", spgp_err_str(spgp_err()));
+ return 1;
+ }
+
+ spgp_close();
+
+ return 0;
+}
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libsimplepgp
+Description: Simple implementation of OpenPGP
+Requires.private: zlib
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir}/simplepgp -lsimplepgp
+Libs.private: `libgcrypt-config --libs` `gpg-error-config --libs`
+Cflags: -I${includedir}/simplepgp
+Cflags.private: `libgcrypt-config --cflags` `gpg-error-config --cflags`