DESCRIPTIONThe rsautl command can be used to sign, verify, encrypt and
decrypt data using the RSA algorithm. COMMAND OPTIONS
-in filename This specifies the input filename to read data from or standard
input if this option is not specified.
-out filename specifies the output filename to write to or standard output
by default.
-inkey file the input key file, by default it should be an RSA private
key.
-pubin the input file is an RSA public key.
-certin the input is a certificate containing an RSA public key.
-sign sign the input data and output the signed result. This requires
and RSA private key.
-verify verify the input data and output the recovered data.
-encrypt encrypt the input data using an RSA public key.
-decrypt decrypt the input data using an RSA private key.
-pkcs, -oaep, -ssl, -raw the padding to use: PKCS#1 v1.5 (the default), PKCS#1 OAEP,
special padding used in SSL v2 backwards compatible handshakes,
or no padding, respectively. For signatures, only -pkcs and -raw
can be used.
-hexdump hex dump the output data.
-asn1parse asn1parse the output data, this is useful when combined with
the -verify option.
NOTESrsautl because it uses the RSA algorithm directly can only
be used to sign or verify small pieces of data. EXAMPLESSign some data using a private key:
openssl rsautl -sign -in file -inkey key.pem -out sig
The PKCS#1 block formatting is evident from this. If this
was done using encrypt and decrypt the block would have been of
type 2 (the second byte) and random padding data visible instead
of the 0xff bytes.
It is possible to analyse the signature of certificates using
this utility in conjunction with asn1parse. Consider the self signed
example in certs/pca-cert.pem . Running asn1parse as follows yields:
This is the parsed version of an ASN1 DigestInfo structure.
It can be seen that the digest used was md5. The actual part of
the certificate that was signed can be extracted with: