1#! /usr/pkg/bin/perl -w
2
3# netpgp bindings for perl
4
5use lib "/usr/src/crypto/external/bsd/netpgp/dist/bindings/perl";
6
7use netpgpperl;
8
9# initializations
10$n = netpgpperlc::new_netpgp_t();
11netpgpperlc::netpgp_setvar($n, "homedir", $ENV{'HOME'}."/.gnupg");
12netpgpperlc::netpgp_setvar($n, "hash", "SHA256");
13netpgpperlc::netpgp_init($n);
14
15# get the default userid
16$userid = netpgpperlc::netpgp_getvar($n, "userid");
17
18foreach $i (0 .. $#ARGV) {
19	# set up file names
20	my $in = $ARGV[$i];
21	my $out = $in . ".gpg";
22
23	# sign the file, output is in $out
24	netpgpperlc::netpgp_sign_file($n, $userid, $in, $out, 0, 0, 0);
25
26	# verify the signed file $out
27	netpgpperlc::netpgp_verify_file($n, $out, "/dev/null", 0);
28}
29