phillbush / rsa

RSA command-line utilities (THIS IS A COLLEGE PROJECT; USE IT FOR EDUCATIONAL PURPOSES ONLY!)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RSA(6)                           Games Manual                           RSA(6)

NAME
     genrsa, pubout, asn1parse, cksum, sign, verify - RSA utilities

SYNOPSIS
     genrsa [nbits] >rsa.key
     pubout <rsa.key >rsa.pub
     asn1parse <key

     cksum <file >digest

     sign key file >sigfile
     verify key file <sigfile

DESCRIPTION
     The genrsa utility generates an RSA private key, which essentially
     involves the generation of two prime numbers.  The generated private key,
     along with other information, is written into the standard output and
     encoded into PEM + ASN.1 format, containing the following data:
     o   The version (hardcoded to "0").
     o   The composite modulus, N.
     o   The public value, e.
     o   The private value, d.
     o   The private value, d.
     o   The first prime factor of N, p.
     o   The second prime factor of N, p.
     o   The first exponent, d % (p - 1).
     o   The second exponent, d % (q - 1).
     o   The coefficient, q^-1 mod p.

     The pubout utility extracts the public key (N and e) out of the private
     key.  The extracted public key is written into standard output.  The
     private key is read from standard input.

     The asn1parse utility parses a private or public key created with the
     genrsa or pubout utilities.

     The cksum utility hashes the contents read from standard input into a
     digest using the SHA256 algorithm for cryptographic hash function.  The
     processed digest is written into standard output.

     The sign utility signs the file file using the key key into a signature,
     which consists of the RSA+OAEP encryption of the SHA256 hash of the
     contents of the given file.  The signature is written into standard
     output.

     The verify utility verifies the authenticity of file by verifying its
     signature with the given key. The verification is done by comparing
     whether the SHA256 hash of the contents of the given file is equal to the
     RSA+OAEP decryption of the given signature.  The signature is read from
     standard input.

EXAMPLES
     Generate a 1024-bit private key into key and extract the public key into
     key.pub:

           $ genrsa 1024 | tee rsa1024.key | pubout >rsa1024.pub

     Check the structure of a previously-generated 1024-bit private key:

           $ asn1parse <rsa1024.key

     Create a signature for a given file using a previously-generated 1024-bit
     private key:

           $ sign rsa1024.key archive.zip > archive.sig

     Verify the signature of a given file using a previously-generated
     1024-bit private key:

           $ verify rsa1024.key archive.zip < archive.sig

SEE ALSO
     openssl(1)

     The following books were used during the development of these utilities:

     Jonathan Katz and Yehuda Lindell, Introduction to Modern Cryptography,
     CRC Press, 2021.

     Donald E. Knuth, The Art of Computer Programming, Addison Wesley Longman,
     2, 1998.

IMPLEMENTATION
     RSA is a cipher scheme that uses an asymmetric key pair (one private, and
     the other public) associated to a given bit length (at least 1024), and
     generated after two random prime numbers (whose product has the given bit
     length).  The security of RSA is based on the problem of factoring large
     numbers.

     Prime number generation is, perhaps, the slowest factor on the key
     generation, for it consists of generating random numbers and checking for
     their primality.  The primality test is performed using the Miller-Rabin
     test.

     The RSA cipher system, however, is deterministic and subject to Chosen-
     Plaintext Attacks.  OAEP is a padding scheme used with RSA to add
     randomness to RSA's deterministic encryption.

     The source code contains the following modules.  Modules are written as a
     .c source file and an optional .c header file.  The header file is
     present on shared modules; and absent on modules containing the program's
     entry point (the main function).

     The shared modules are as follows:
     bignum  Routines and structures for arbitrary-precision arithmetic.
     keyio   Routines for key I/O in the PEM+ASN.1 format.
     oaep    Routines for verifying and signing files using OAEP padding.
     sha     Routines and constants for SHA256 cryptographic hashing.

HISTORY
     These RSA utilities are the product of a project for 2022 2nd semester's
     course of Cyber Security of the Computer Science department of the
     University of Brasilia, Brazil.

BUGS
     The bignum.o module was written from scratch and is probably buggy; i
     should have used an already existant arbitrary-precision arithmetic
     library.

     Generating keys can take long time, especially for 1024 bits or more.

OpenBSD 7.2                    February 9, 2023                    OpenBSD 7.2

About

RSA command-line utilities (THIS IS A COLLEGE PROJECT; USE IT FOR EDUCATIONAL PURPOSES ONLY!)


Languages

Language:C 92.9%Language:Roff 5.5%Language:Makefile 1.5%