Not exactly free, but signing functions of our SecureBlackbox product need just any license for any package, and prices for some packages are below $100.
Note, that for this price you get quite extensive functionality that covers PKCS#1 and PKCS#7 signing and encryption using RSA, DSA (signing only) and Elliptic Curves, as well as symmetric encryption, extensive certificate support and much more.
Alternatively you can use interface to OpenSSL, which also offers wide range of functions and is free. However, it's API is far from easy to understand, and as with any free software, support is questionable.
/dev/random
. – CodesInChaos