Example code for rsakeygen, pubkey, sign and verify#4
Open
srinivasjc wants to merge 1 commit intopkkancharla:masterfrom
Open
Example code for rsakeygen, pubkey, sign and verify#4srinivasjc wants to merge 1 commit intopkkancharla:masterfrom
srinivasjc wants to merge 1 commit intopkkancharla:masterfrom
Conversation
ghost
reviewed
Sep 27, 2019
| while( (opt=getopt(argc, argv, "o:s:h")) != -1) { | ||
| switch(opt) { | ||
| case 's': | ||
| rsabits = atoi(optarg); |
| case 'h': | ||
| usage(); | ||
| goto end; | ||
| break; |
| break; | ||
|
|
||
| case 'o': | ||
| if((prtkeyfile = (char *) OPENSSL_malloc(strlen(optarg)+1)) == NULL) { |
There was a problem hiding this comment.
Why global variable prtkeyfile, just pass this as argument to generate_rsa().
| } | ||
| } | ||
|
|
||
| bio_log = BIO_new_fp(stdout, BIO_NOCLOSE); |
| end: | ||
|
|
||
| if(prtkeyfile) { | ||
| OPENSSL_free(prtkeyfile); |
There was a problem hiding this comment.
When you don't use prtkeyfile as global we don't need this.
| } | ||
| } | ||
|
|
||
| if (!PEM_write_bio_PrivateKey(prtbio, pkey, NULL, NULL, 0, NULL, NULL)) { |
There was a problem hiding this comment.
Output pem can be RSAPrivateKey(pkcs1?) or PrivateKey(pkcs8). The above one writes the key in pkcs8, what is our intention here whether to have pkcs1 or pkcs8, do you want to take an option from the user?.
| if (bn) { | ||
| BN_free(bn); | ||
| } | ||
|
|
| @@ -0,0 +1,13 @@ | |||
| all: | |||
| gcc genrsa.c -L/opt/openssl/lib -lcrypto -o genrsa | |||
There was a problem hiding this comment.
Why /opt/openssl/lib, we have to remove this. And change make file to use Makefile constructs to compiles all c files at ones instead of compiling them individually.
|
|
||
|
|
||
| clean: | ||
| rm genrsa -rf |
|
|
||
| char *prtkeyfile=NULL; | ||
| BIO *bio_log=NULL; | ||
| unsigned int rsabits = 2048; |
ghost
reviewed
Sep 27, 2019
| @@ -0,0 +1,13 @@ | |||
| all: | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example code for rsakeygen, pubkey, sign and verify