piano: Check for libgcrypt errors

Fixes mysterious segfaults from issue #369 and #293.