pk.c: rework DH API and improve PEM read/write
Description
Reorganized the DH APIs into groups. Reworked all DH APIs. Improved testing of DH API.
Implemented wolfSSL_PEM_read_RSAPublicKey() and wolfSSL_PEM_write_RSA_PUBKEY(). Fix public key PEM write implementations to use the correct header/footer names. Added support for "RSA PUBLIC KEY" in header and footer in DerToPemEx().
Reworked PEM read/write APIs to be independent. No longer create an EVP to use common function - common functionality refectored out. Similarly file APIs don't create a BIO and call the partner APIs.
Improved testing of PEM read/write APIs.
Generic read BIO from memory BIO now returns the buffer instead of allocating memory and reading. No longer reading chunks when a file BIO.
Added wolfssl_make_rng() to create or get get global random. All RSA and DH APIs now use this. DH_generate_parameters() creates a random object and use global on error rather than just using global random.
Changed implementations to use BIO_new_fp() instead of create a new BIO and setting file pointer.
Testing
Many different OpenSSL API configurations. CFLAGS=-DNO_BIO and --enable-smallstack tested.
Checklist
- [x] added tests
- [ ] updated/added doxygen
- [ ] updated appropriate READMEs
- [ ] Updated manual and documentation