Last active
August 29, 2015 14:21
-
-
Save rzhw/8b006cd1ae689ece417b to your computer and use it in GitHub Desktop.
PEM RSA public key to RSA struct
This file contains 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
// gcc pempublickeytest.c -lssl -lcrypto -I/usr/include/openssl/ -o pempublickeytest | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <openssl/rsa.h> | |
#include <openssl/bio.h> | |
#include <openssl/pem.h> | |
int main() { | |
BIO *bio = BIO_new_file("blah_rsa.pub.pem", "r"); | |
RSA *rsa = PEM_read_bio_RSAPublicKey(bio, NULL, NULL, NULL); | |
printf("rsa: %p, rsa->n: %p, &rsa->n: %p\n", rsa, rsa->n, &rsa->n); | |
printf("BN_num_bits: %d\n", BN_num_bits(rsa->n)); | |
printf("rsa->version: %ld, &rsa->version: %p\n", rsa->version, &rsa->version); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment