Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <openssl/bn.h>
- #include <openssl/rsa.h>
- int main()
- {
- RSA *r;
- r = RSA_generate_key(2048,RSA_F4,NULL,NULL);
- if( r==NULL ) {
- printf("Key failed");
- exit(1);
- } else {
- printf("public modulus (n):\n");
- printf(" %s\n",BN_bn2hex(r->n));
- printf("public exponent (e):\n");
- printf(" %s\n",BN_bn2hex(r->e));
- printf("private exponent (d):\n");
- printf(" %s\n",BN_bn2hex(r->d));
- printf("secret prime factor (p):\n");
- printf(" %s\n",BN_bn2hex(r->p));
- printf("secret prime factor (q):\n");
- printf(" %s\n",BN_bn2hex(r->q));
- printf("dmp1 [ d mod (p-1) ]:\n");
- printf(" %s\n",BN_bn2hex(r->dmp1));
- printf("dmq1 [ d mod (q-1) ]:\n");
- printf(" %s\n",BN_bn2hex(r->dmq1));
- printf("iqmp [ q^-1 mod p ]:\n");
- printf(" %s\n",BN_bn2hex(r->iqmp));
- }
- printf("RSA SIZE: %d\n", RSA_size(r));
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement