From: Daniel Frank Date: 2010-01-17T23:51:23+09:00 Subject: Re: GPGME gem - cannot figure out how to decrypt data Am 17.01.2010 14:19, schrieb Daiki Ueno: > Daiki Ueno writes: > >> Could you try the attached script, which decrypts a file specified as >> the first command line argument? > > Sorry, I mistakenly posted a wrong script. Please use this one instead... > Results in the same problem, I had to interrupt the script and it was interrupted in the same line as with my script. $ uname -a SunOS backupdev 5.11 snv_111b i86pc i386 i86pc Solaris $ export | grep GPG $ time RUBYOPT=rubygems ruby decrypt.rb edata ^C/var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib/gpgme.rb:1212:in `decrypt_verify': Interrupt from /var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib/gpgme.rb:134:in `decrypt' from /var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib/gpgme.rb:943:in `new' from /var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib/gpgme.rb:130:in `decrypt' from decrypt.rb:22 real 0m12.420s user 0m0.079s sys 0m0.046s $ gpg --decrypt edata You need a passphrase to unlock the secret key for user: "xxxx xxxxxxxxxxx " 4096-bit RSA key, ID D2BBECEB, created 2010-01-12 (main key ID ADE8309D) gpg: encrypted with 4096-bit RSA key, ID D2BBECEB, created 2010-01-12 "xxxx xxxxxxxxxxx " Dummy test data Dummy test data Dummy test data Dummy test data Dummy test data $ ruby -v ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-solaris2.11] $ gem list --local *** LOCAL GEMS *** aws-s3 (0.6.2) builder (2.1.2) gpgme (1.0.8) mime-types (1.16) xml-simple (1.0.12) $ The line in the gem is 1212 err = GPGME::gpgme_op_decrypt_verify(self, cipher, plain) The only place I could find a probably definition of the gpgme_op_decrypt_verify function seems to be the C API to GPGME in gpgme_n.c in the gpgme-gem dir. It seems like the installation of the gem did not build a full working instance of the gem. I completely uninstalled the gem and reinstalled it: root@backupdev:~# gem i gpgme Building native extensions. This could take a while... ERROR: Error installing gpgme: ERROR: Failed to build gem native extension. /usr/ruby/1.8/bin/ruby extconf.rb i gpgme checking for gpgme-config... yes checking for gpgme >= 1.1.3... yes checking for gpgme_op_export_keys()... no creating Makefile make Makefile:143: warning: overriding commands for target `/var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib' Makefile:139: warning: ignoring old commands for target `/var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib' /usr/sfw/bin/gcc -I. -I. -I/usr/ruby/1.8/lib/ruby/1.8/i386-solaris2.11 -I. -I/usr/sfw/include -fPIC -g -O3 -fPIC -I/usr/local/include -I/usr/local/include -c gpgme_n.c /usr/sfw/bin/gcc -G -o gpgme_n.so gpgme_n.o -L. -L/usr/ruby/1.8/lib -R/usr/ruby/1.8/lib -L/usr/sfw/lib -R/usr/sfw/lib -R /usr/ruby/1.8/lib -L/usr/ruby/1.8/lib -lruby -L/usr/local/lib -lgpgme -L/usr/local/lib -lgpg-error -lsocket -lnsl -ldl -lcrypt -lm -lc make install Makefile:143: warning: overriding commands for target `/var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib' Makefile:139: warning: ignoring old commands for target `/var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib' /usr/bin/ginstall -c -m 0755 gpgme_n.so /var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib /usr/bin/ginstall -c -m 644 ./lib/gpgme/compat.rb /var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib/gpgme /usr/bin/ginstall: `./lib/gpgme/compat.rb' and `/var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib/gpgme/compat.rb' are the same file make: *** [/var/ruby/1.8/gem_home/gems/gpgme-1.0.8/lib/gpgme/compat.rb] Error 1 Gem files will remain installed in /var/ruby/1.8/gem_home/gems/gpgme-1.0.8 for inspection. Results logged to /var/ruby/1.8/gem_home/gems/gpgme-1.0.8/gem_make.out root@backupdev:~# gem i gpgme Building native extensions. This could take a while... Successfully installed gpgme-1.0.8 1 gem installed Installing ri documentation for gpgme-1.0.8... Installing RDoc documentation for gpgme-1.0.8... Could not find main page README Could not find main page README Could not find main page README Could not find main page README It looks like the installation is confused when the old data is not cleaned up, before a second try is done. On the other side the library seems to be built just fine, or the important error is not shown: root@backupdev:~# ldd /var/ruby/1.8/gem_home/gems/gpgme-1.0.8/gpgme_n.so libruby.so => /usr/ruby/1.8/lib/libruby.so libgpgme.so.11 => /usr/local/lib/libgpgme.so.11 libgpg-error.so.0 => /usr/local/lib/libgpg-error.so.0 libsocket.so.1 => /lib/libsocket.so.1 libnsl.so.1 => /lib/libnsl.so.1 libdl.so.1 => /lib/libdl.so.1 libcrypt.so.1 => /usr/lib/libcrypt.so.1 libm.so.2 => /lib/libm.so.2 libc.so.1 => /lib/libc.so.1 libcurses.so.1 => /usr/lib/libcurses.so.1 libgcc_s.so.1 => /usr/sfw/lib/libgcc_s.so.1 libmp.so.2 => /lib/libmp.so.2 libmd.so.1 => /lib/libmd.so.1 libscf.so.1 => /lib/libscf.so.1 libgen.so.1 => /lib/libgen.so.1 libuutil.so.1 => /lib/libuutil.so.1 I'm also wondering about the following line during installation of the gem: checking for gpgme_op_export_keys()... no What exactly is the gem doing here? Am I missing a library? Regards, Daniel