Examples ======================================== DSA Examples ---------------------------------------- DSA Signature Generation ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reads a DSA private key and signs the specified file using SHA-1 .. literalinclude:: examples/dsa_sign.cpp DSA Signature Verification ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reads a DSA public key and a signature, and checks if the signature is valid for the specified file ..literalinclude:: examples/dsa_ver.cpp X.509 Certificate Examples ---------------------------------------- PKCS #10 Certificate Requests ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. literalinclude:: examples/pkcs10.cpp Self Signed Certificate ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Generate a 2048 bit RSA key, and then create a self-signed X.509v3 certificate with that key. If the do_CA variable is set to true, then it will be marked for CA use, otherwise it will get extensions appropriate for use with a client certificate. The private key is stored as an encrypted PKCS #8 object in another file. .. literalinclude:: examples/self_sig.cpp Certificate Authority ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Implement the functionality of a simple CA: read in a CA certificate, the associated private key, and a PKCS #10 certificate request. Sign the request and print the new certificate to stdout. File names are hardcoded for simplicity. The CA certificate is expected in "cacert.pem", the private key is expected in "caprivate.pem", and "req.pem" is a PKCS #10 certificate request. .. literalinclude:: examples/ca.cpp Format Preserving Encryption ---------------------------------------- Format preserving encryption is a way of mapping data with an arbitrarily specified format such that the ciphertext has the same formatting. This example encrypts a credit card number with a valid `Luhn checksum `_ to another number with the same format, including a correct checksum. .. literalinclude:: examples/fpe.cpp ASN.1 Parsing ---------------------------------------- This example is a simple ASN.1 parser .. literalinclude:: examples/asn1.cpp