gpgme 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -0
- data/COPYING +340 -0
- data/COPYING.LESSER +510 -0
- data/Makefile +172 -0
- data/Manifest.txt +18 -0
- data/README +86 -0
- data/Rakefile +17 -0
- data/THANKS +15 -0
- data/examples/edit.rb +77 -0
- data/examples/genkey.rb +55 -0
- data/examples/keylist.rb +6 -0
- data/examples/roundtrip.rb +39 -0
- data/examples/sign.rb +29 -0
- data/examples/verify.rb +6 -0
- data/extconf.rb +26 -0
- data/gpgme_n.c +2622 -0
- data/lib/gpgme.rb +1561 -0
- data/lib/gpgme/compat.rb +46 -0
- data/lib/gpgme/constants.rb +164 -0
- metadata +109 -0
- metadata.gz.sig +0 -0
data/Makefile
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = .
|
7
|
+
topdir = /usr/lib/ruby/1.8/x86_64-linux
|
8
|
+
hdrdir = $(topdir)
|
9
|
+
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
10
|
+
exec_prefix = $(prefix)
|
11
|
+
prefix = $(DESTDIR)/usr
|
12
|
+
sharedstatedir = $(prefix)/com
|
13
|
+
mandir = $(prefix)/share/man
|
14
|
+
psdir = $(docdir)
|
15
|
+
oldincludedir = $(DESTDIR)/usr/include
|
16
|
+
localedir = $(datarootdir)/locale
|
17
|
+
bindir = $(exec_prefix)/bin
|
18
|
+
libexecdir = $(prefix)/lib/ruby1.8
|
19
|
+
sitedir = $(DESTDIR)/usr/local/lib/site_ruby
|
20
|
+
htmldir = $(docdir)
|
21
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
22
|
+
includedir = $(prefix)/include
|
23
|
+
infodir = $(prefix)/share/info
|
24
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
25
|
+
sysconfdir = $(DESTDIR)/etc
|
26
|
+
libdir = $(exec_prefix)/lib
|
27
|
+
sbindir = $(exec_prefix)/sbin
|
28
|
+
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
29
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
30
|
+
dvidir = $(docdir)
|
31
|
+
vendordir = $(libdir)/ruby/vendor_ruby
|
32
|
+
datarootdir = $(prefix)/share
|
33
|
+
pdfdir = $(docdir)
|
34
|
+
archdir = $(rubylibdir)/$(arch)
|
35
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
36
|
+
datadir = $(datarootdir)
|
37
|
+
localstatedir = $(DESTDIR)/var
|
38
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
39
|
+
|
40
|
+
CC = cc
|
41
|
+
LIBRUBY = $(LIBRUBY_SO)
|
42
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
43
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
44
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
45
|
+
|
46
|
+
RUBY_EXTCONF_H =
|
47
|
+
CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags)
|
48
|
+
INCFLAGS = -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.
|
49
|
+
DEFS =
|
50
|
+
CPPFLAGS = -DHAVE_GPGME_OP_EXPORT_KEYS
|
51
|
+
CXXFLAGS = $(CFLAGS)
|
52
|
+
ldflags = -L. -rdynamic -Wl,-export-dynamic
|
53
|
+
dldflags =
|
54
|
+
archflag =
|
55
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
|
56
|
+
LDSHARED = $(CC) -shared
|
57
|
+
AR = ar
|
58
|
+
EXEEXT =
|
59
|
+
|
60
|
+
RUBY_INSTALL_NAME = ruby1.8
|
61
|
+
RUBY_SO_NAME = ruby1.8
|
62
|
+
arch = x86_64-linux
|
63
|
+
sitearch = x86_64-linux
|
64
|
+
ruby_version = 1.8
|
65
|
+
ruby = /usr/bin/ruby1.8
|
66
|
+
RUBY = $(ruby)
|
67
|
+
RM = rm -f
|
68
|
+
MAKEDIRS = mkdir -p
|
69
|
+
INSTALL = /usr/bin/install -c
|
70
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
71
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
72
|
+
COPY = cp
|
73
|
+
|
74
|
+
#### End of system configuration section. ####
|
75
|
+
|
76
|
+
preload =
|
77
|
+
|
78
|
+
libpath = . $(libdir)
|
79
|
+
LIBPATH = -L. -L$(libdir)
|
80
|
+
DEFFILE =
|
81
|
+
|
82
|
+
CLEANFILES = mkmf.log
|
83
|
+
DISTCLEANFILES =
|
84
|
+
|
85
|
+
extout =
|
86
|
+
extout_prefix =
|
87
|
+
target_prefix =
|
88
|
+
LOCAL_LIBS =
|
89
|
+
LIBS = $(LIBRUBYARG_SHARED) -lgpgme -lgpg-error -lpthread -lrt -ldl -lcrypt -lm -lc
|
90
|
+
SRCS = gpgme_n.c
|
91
|
+
OBJS = gpgme_n.o
|
92
|
+
TARGET = gpgme_n
|
93
|
+
DLLIB = $(TARGET).so
|
94
|
+
EXTSTATIC =
|
95
|
+
STATIC_LIB =
|
96
|
+
|
97
|
+
BINDIR = $(bindir)
|
98
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
99
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
100
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
101
|
+
|
102
|
+
TARGET_SO = $(DLLIB)
|
103
|
+
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
104
|
+
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
105
|
+
|
106
|
+
all: $(DLLIB)
|
107
|
+
static: $(STATIC_LIB)
|
108
|
+
|
109
|
+
clean:
|
110
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
111
|
+
|
112
|
+
distclean: clean
|
113
|
+
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
114
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
115
|
+
|
116
|
+
realclean: distclean
|
117
|
+
install: install-so install-rb
|
118
|
+
|
119
|
+
install-so: $(RUBYARCHDIR)
|
120
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
121
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
122
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
123
|
+
install-rb: pre-install-rb install-rb-default
|
124
|
+
install-rb-default: pre-install-rb-default
|
125
|
+
pre-install-rb: Makefile
|
126
|
+
pre-install-rb-default: Makefile
|
127
|
+
pre-install-rb-default: $(RUBYLIBDIR)
|
128
|
+
install-rb-default: $(RUBYLIBDIR)/gpgme.rb
|
129
|
+
$(RUBYLIBDIR)/gpgme.rb: $(srcdir)/lib/gpgme.rb $(RUBYLIBDIR)
|
130
|
+
$(INSTALL_DATA) $(srcdir)/lib/gpgme.rb $(@D)
|
131
|
+
pre-install-rb-default: $(RUBYLIBDIR)/gpgme
|
132
|
+
install-rb-default: $(RUBYLIBDIR)/gpgme/compat.rb
|
133
|
+
$(RUBYLIBDIR)/gpgme/compat.rb: $(srcdir)/lib/gpgme/compat.rb $(RUBYLIBDIR)/gpgme
|
134
|
+
$(INSTALL_DATA) $(srcdir)/lib/gpgme/compat.rb $(@D)
|
135
|
+
install-rb-default: $(RUBYLIBDIR)/gpgme/constants.rb
|
136
|
+
$(RUBYLIBDIR)/gpgme/constants.rb: $(srcdir)/lib/gpgme/constants.rb $(RUBYLIBDIR)/gpgme
|
137
|
+
$(INSTALL_DATA) $(srcdir)/lib/gpgme/constants.rb $(@D)
|
138
|
+
$(RUBYARCHDIR):
|
139
|
+
$(MAKEDIRS) $@
|
140
|
+
$(RUBYLIBDIR):
|
141
|
+
$(MAKEDIRS) $@
|
142
|
+
$(RUBYLIBDIR)/gpgme:
|
143
|
+
$(MAKEDIRS) $@
|
144
|
+
|
145
|
+
site-install: site-install-so site-install-rb
|
146
|
+
site-install-so: install-so
|
147
|
+
site-install-rb: install-rb
|
148
|
+
|
149
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
150
|
+
|
151
|
+
.cc.o:
|
152
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
153
|
+
|
154
|
+
.cxx.o:
|
155
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
156
|
+
|
157
|
+
.cpp.o:
|
158
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
159
|
+
|
160
|
+
.C.o:
|
161
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
162
|
+
|
163
|
+
.c.o:
|
164
|
+
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
165
|
+
|
166
|
+
$(DLLIB): $(OBJS) Makefile
|
167
|
+
@-$(RM) $@
|
168
|
+
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
$(OBJS): ruby.h defines.h
|
data/Manifest.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
COPYING
|
2
|
+
COPYING.LESSER
|
3
|
+
Makefile
|
4
|
+
Manifest.txt
|
5
|
+
README
|
6
|
+
Rakefile
|
7
|
+
THANKS
|
8
|
+
examples/edit.rb
|
9
|
+
examples/genkey.rb
|
10
|
+
examples/keylist.rb
|
11
|
+
examples/roundtrip.rb
|
12
|
+
examples/sign.rb
|
13
|
+
examples/verify.rb
|
14
|
+
extconf.rb
|
15
|
+
gpgme_n.c
|
16
|
+
lib/gpgme.rb
|
17
|
+
lib/gpgme/compat.rb
|
18
|
+
lib/gpgme/constants.rb
|
data/README
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= Ruby-GPGME
|
2
|
+
|
3
|
+
* http://rubyforge.org/projects/ruby-gpgme/
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Ruby-GPGME is a Ruby language binding of GPGME (GnuPG Made Easy).
|
8
|
+
|
9
|
+
GnuPG Made Easy (GPGME) is a library designed to make access to GnuPG
|
10
|
+
easier for applications. It provides a High-Level Crypto API for
|
11
|
+
encryption, decryption, signing, signature verification and key
|
12
|
+
management.
|
13
|
+
|
14
|
+
== Requirements
|
15
|
+
|
16
|
+
* Ruby 1.8 or later
|
17
|
+
* GPGME 1.1.2 or later
|
18
|
+
* gpg-agent (optional, but recommended)
|
19
|
+
|
20
|
+
== Installation
|
21
|
+
|
22
|
+
$ gem install ruby-gpgme
|
23
|
+
|
24
|
+
or
|
25
|
+
|
26
|
+
$ ruby extconf.rb
|
27
|
+
$ make
|
28
|
+
$ make install
|
29
|
+
|
30
|
+
== Examples
|
31
|
+
|
32
|
+
examples/genkey.rb Generate a key pair in your keyring.
|
33
|
+
examples/keylist.rb List your keyring like gpg --list-keys.
|
34
|
+
examples/roundtrip.rb Encrypt a plain text and then decrypt it.
|
35
|
+
examples/sign.rb Create a clear text signature.
|
36
|
+
examples/verify.rb Verify a clear text signature given from stdin.
|
37
|
+
|
38
|
+
== API
|
39
|
+
|
40
|
+
Ruby-GPGME provides three levels of API. The highest level API is
|
41
|
+
close to the command line interface of GnuPG. The mid level API looks
|
42
|
+
object-oriented (or rubyish). The lowest level API is close to the C
|
43
|
+
interface of GPGME.
|
44
|
+
|
45
|
+
=== The highest level API
|
46
|
+
|
47
|
+
For example, to create a cleartext signature of the plaintext from
|
48
|
+
stdin and write the result to stdout can be written as follows.
|
49
|
+
|
50
|
+
$ ruby -rgpgme -e 'GPGME.clearsign($stdin, $stdout)'
|
51
|
+
|
52
|
+
=== The mid level API
|
53
|
+
|
54
|
+
The same example can be rewritten in the mid level API as follows.
|
55
|
+
|
56
|
+
$ ruby -rgpgme -e <<End
|
57
|
+
ctx = GPGME::Ctx.new
|
58
|
+
plain = GPGME::Data.from_io($stdin)
|
59
|
+
sig = GPGME::Data.from_io($stdout)
|
60
|
+
ctx.sign(plain, sig, GPGME::SIG_MODE_CLEAR)
|
61
|
+
End
|
62
|
+
|
63
|
+
=== The lowest level API
|
64
|
+
|
65
|
+
The same example can be rewritten in the lowest level API as follows.
|
66
|
+
|
67
|
+
$ ruby -rgpgme -e <<End
|
68
|
+
ret = Array.new
|
69
|
+
GPGME::gpgme_new(ret)
|
70
|
+
ctx = ret.shift
|
71
|
+
GPGME::gpgme_data_new_from_fd(ret, 0)
|
72
|
+
plain = ret.shift
|
73
|
+
GPGME::gpgme_data_new_from_fd(ret, 1)
|
74
|
+
sig = ret.shift
|
75
|
+
GPGME::gpgme_op_sign(ctx, plain, sig, GPGME::SIG_MODE_CLEAR)
|
76
|
+
End
|
77
|
+
|
78
|
+
As you see, it's much harder to write a program in this API than the
|
79
|
+
highest level API. However, if you are already familier with the C
|
80
|
+
interface of GPGME and want to control detailed behavior of GPGME, it
|
81
|
+
might be useful.
|
82
|
+
|
83
|
+
== License
|
84
|
+
|
85
|
+
The library itself is licensed under LGPLv2.1+. See the file
|
86
|
+
COPYING.LESSER and each file for copyright and warranty information.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.spec("gpgme") do
|
7
|
+
self.rubyforge_name = "ruby-gpgme"
|
8
|
+
self.author = ['Daiki Ueno']
|
9
|
+
self.email = 'ueno@unixuser.org'
|
10
|
+
self.readme_file = "README"
|
11
|
+
self.spec_extras = {
|
12
|
+
"extensions" => ["extconf.rb"],
|
13
|
+
}
|
14
|
+
self.need_tar = false
|
15
|
+
self.need_tar_gz = true
|
16
|
+
self.source_prefix = 'ruby-'
|
17
|
+
end
|
data/THANKS
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Ruby-GPGME was originally written by Daiki Ueno. Other people
|
2
|
+
contributed by reporting problems, suggesting various improvements or
|
3
|
+
submitting actual code. Here is a list of those people. Help us keep
|
4
|
+
it complete and free of errors.
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
Carl Corliss
|
9
|
+
Jérémie Pierson
|
10
|
+
Kouhei Sutou
|
11
|
+
Kris Nuttycombe
|
12
|
+
Marc Dequènes
|
13
|
+
Rob Pitt
|
14
|
+
Rory McKinley
|
15
|
+
Sam Hall
|
data/examples/edit.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gpgme'
|
3
|
+
|
4
|
+
# If you do not have gpg-agent installed, comment out the following
|
5
|
+
# and set it as :passphrase_callback.
|
6
|
+
#
|
7
|
+
# def passfunc(hook, uid_hint, passphrase_info, prev_was_bad, fd)
|
8
|
+
# $stderr.write("Passphrase for #{uid_hint}: ")
|
9
|
+
# $stderr.flush
|
10
|
+
# begin
|
11
|
+
# system('stty -echo')
|
12
|
+
# io = IO.for_fd(fd, 'w')
|
13
|
+
# io.puts(gets)
|
14
|
+
# io.flush
|
15
|
+
# ensure
|
16
|
+
# (0 ... $_.length).each do |i| $_[i] = ?0 end if $_
|
17
|
+
# system('stty echo')
|
18
|
+
# end
|
19
|
+
# $stderr.puts
|
20
|
+
# end
|
21
|
+
|
22
|
+
unless ENV['GPG_AGENT_INFO']
|
23
|
+
$stderr.puts("gpg-agent is not running. See the comment in #{$0}.")
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
unless ENV['GNUPGHOME']
|
28
|
+
$stderr.write('As GNUPGHOME is not set, the generated key pair will be stored into *your* keyring. Really proceed? (y/N) ')
|
29
|
+
$stderr.flush
|
30
|
+
exit(1) unless gets.chomp == 'y'
|
31
|
+
end
|
32
|
+
|
33
|
+
unless ARGV.length == 1
|
34
|
+
$stderr.puts("Usage: #{$0} KEYGRIP")
|
35
|
+
exit(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
def progfunc(hook, what, type, current, total)
|
39
|
+
$stderr.write("#{what}: #{current}/#{total}\r")
|
40
|
+
$stderr.flush
|
41
|
+
end
|
42
|
+
|
43
|
+
def editfunc(hook, status, args, fd)
|
44
|
+
case status
|
45
|
+
when GPGME::GPGME_STATUS_GET_BOOL
|
46
|
+
begin
|
47
|
+
$stderr.write("#{args} (y/n) ")
|
48
|
+
$stderr.flush
|
49
|
+
line = gets
|
50
|
+
end until line =~ /\A\s*[ny]\s*\z/
|
51
|
+
io = IO.for_fd(fd)
|
52
|
+
io.puts(line.strip)
|
53
|
+
io.flush
|
54
|
+
when GPGME::GPGME_STATUS_GET_LINE, GPGME::GPGME_STATUS_GET_HIDDEN
|
55
|
+
$stderr.write("#{args}: ")
|
56
|
+
$stderr.flush
|
57
|
+
line = gets
|
58
|
+
io = IO.for_fd(fd)
|
59
|
+
io.puts(line)
|
60
|
+
io.flush
|
61
|
+
else
|
62
|
+
$stderr.puts([status, args].inspect)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
ctx = GPGME::Ctx.new({:progress_callback => method(:progfunc),
|
67
|
+
# :passphrase_callback => method(:passfunc)
|
68
|
+
})
|
69
|
+
keystr = ARGV.shift
|
70
|
+
keys = ctx.keys(keystr)
|
71
|
+
if keys.empty?
|
72
|
+
$stderr.puts("Can't find key for \"#{keystr}\"")
|
73
|
+
exit(1)
|
74
|
+
end
|
75
|
+
|
76
|
+
$stderr.puts(keys.first.inspect)
|
77
|
+
ctx.edit_key(keys.first, method(:editfunc))
|
data/examples/genkey.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gpgme'
|
3
|
+
|
4
|
+
# If you do not have gpg-agent installed, comment out the following
|
5
|
+
# and set it as :passphrase_callback.
|
6
|
+
#
|
7
|
+
# def passfunc(hook, uid_hint, passphrase_info, prev_was_bad, fd)
|
8
|
+
# $stderr.write("Passphrase for #{uid_hint}: ")
|
9
|
+
# $stderr.flush
|
10
|
+
# begin
|
11
|
+
# system('stty -echo')
|
12
|
+
# io = IO.for_fd(fd, 'w')
|
13
|
+
# io.puts(gets)
|
14
|
+
# io.flush
|
15
|
+
# ensure
|
16
|
+
# (0 ... $_.length).each do |i| $_[i] = ?0 end if $_
|
17
|
+
# system('stty echo')
|
18
|
+
# end
|
19
|
+
# $stderr.puts
|
20
|
+
# end
|
21
|
+
|
22
|
+
unless ENV['GPG_AGENT_INFO']
|
23
|
+
$stderr.puts("gpg-agent is not running. See the comment in #{$0}.")
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
unless ENV['GNUPGHOME']
|
28
|
+
$stderr.write('As GNUPGHOME is not set, the generated key pair will be stored into *your* keyring. Really proceed? (y/N) ')
|
29
|
+
$stderr.flush
|
30
|
+
exit(1) unless gets.chomp == 'y'
|
31
|
+
end
|
32
|
+
|
33
|
+
def progfunc(hook, what, type, current, total)
|
34
|
+
$stderr.write("#{what}: #{current}/#{total}\r")
|
35
|
+
$stderr.flush
|
36
|
+
end
|
37
|
+
|
38
|
+
ctx = GPGME::Ctx.new({:progress_callback => method(:progfunc),
|
39
|
+
# :passphrase_callback => method(:passfunc)
|
40
|
+
})
|
41
|
+
|
42
|
+
ctx.genkey(<<'EOF', nil, nil)
|
43
|
+
<GnupgKeyParms format="internal">
|
44
|
+
Key-Type: DSA
|
45
|
+
Key-Length: 1024
|
46
|
+
Subkey-Type: ELG-E
|
47
|
+
Subkey-Length: 1024
|
48
|
+
Name-Real: Joe Tester
|
49
|
+
Name-Comment: with stupid passphrase
|
50
|
+
Name-Email: joe@foo.bar
|
51
|
+
Expire-Date: 0
|
52
|
+
Passphrase: abc
|
53
|
+
</GnupgKeyParms>
|
54
|
+
EOF
|
55
|
+
$stderr.puts
|