Here's how I manage to create a key pair and store files successfully, the problem comes when the private key is password-protected Reads while preserving where I always get the tap? Any tips to solve this issue? Thank you.
File * dsa_privatekey_file; File * dsa_publickey_file; Const char * pkeykey = "password"; Int results = 0; DeleteFile ("dsapub.pem"); DeleteFile ("dsapriv.pem"); Dsa_publickey_file = fopen ("dsapub.pem", "r"); Dsa_privatekey_file = fopen ("dsapriv.pem", "r"); If (dsa_privatekey_file == NULL || dsa_publickey_file == faucet) {if (dsa_privatekey_file! = NULL) {fclose (dsa_privatekey_file); } If (dsa_publickey_file! = NULL) {fclose (dsa_publickey_file); } Dsa_publickey_file = fopen ("dsapub.pem", "w"); Dsa_privatekey_file = fopen ("dsapriv.pem", "w"); DSA * dsa = DSA_new (); Result = DSA_generate_parameters_ex (DSA, 2048, zero, 0, zero, zero, zero); Results = DSA_generate_key (DSA); Result = PEM_write_DSAPrivateKey (dsa_privatekey_file, dsa, EVP_des_ede3_cbc (), zero, 0, zero, (zero *) pkeykey); // result = PEM_write_DSAPrivateKey (dsa_privatekey_file, dsa, EVP_des_ede3_cbc (), (unsigned char *) pkeykey, strlen (pkeykey), tap, tap); // result = PEM_write_DSAPrivateKey (dsa_privatekey_file, dsa, NULL, NULL, 0, NULL, NULL); Results = PEM_write_DSA_PUBKEY (dsa_publickey_file, dsa); Fclose (dsa_privatekey_file); Fclose (dsa_publickey_file); DSA_free (DSA); Dsa_publickey_file = fopen ("dsapub.pem", "r"); Dsa_privatekey_file = fopen ("dsapriv.pem", "r"); } DSA * dsa_sign = PEM_read_DSAPrivateKey (dsa_privatekey_file, NULL, default_set_password, (zero *) pkeykey); DSA * dsa_verify = PEM_read_DSA_PUBKEY (dsa_publickey_file, NULL, NULL, NULL);
This is a simple task that I use to password the hard work, but this is not being said anyway.
Fixed int default_set_password (char * buf, int size, int rwflag, zero * descr) {memcpy (buf, descr, size); Return size; }
one call
OpenSSL_add_all_algorithms ();
The required work was necessary.
No comments:
Post a Comment