I have the binary blobs for the components of a private key including modulus, publicExponent, privateExponent, prime1, prime2, exponent1, exponent2 and coefficient, what is the easiest way to generate a PEM/DER file from them? Is there a easy to use Python API that can be used or do I have to use C? Likewise if I have the components of a public key as binary blobs, including modulus and exponent, what's the easiest method there? Another question in this process: are the python APIs to test the property of the components, like weather the prime is a prime or weather the public and private components match?
You could give
pycryptodome a try. Beware, it is meant as a replacement of
pycrypto. If you have the need to run pycrypto in parallel, you can use the separate, stand-alone package
It implements all crypto primitives from scratch (instead of relying on external libraries) and it offers a Key Construct Method that allows to construct a key from the components. If switched on, it can also perform a consistency check on the entered key components.