Hi List, I've been battling the following code for a couple of hours armed with my *Network Security With OpenSSL* book to little avail.
#include <openssl/rsa.h> #include <openssl/x509.h> #include <stdio.h> extern unsigned char _binary____certificates_der_start; extern unsigned char _binary____certificates_der_size; int main(int argc, char argv[]) { RSA *public_key = NULL; int public_key_len = (int)&_binary____certificates_der_size; const unsigned char *public_key_buffer = &_binary____certificates_der_start; public_key = d2i_RSAPublicKey(NULL, &public_key_buffer, public_key_len); if ( !public_key) { fprintf(stdout, "%s\n", ERR_error_string(ERR_get_error(), NULL)); return 1; } printf("Exiting Cleanly\n"); return 0; } I'm fairly sure that what I'm doing to inline the object file, and load it using the extern'ed addresses. However I'm seeing: error:0D0680A8:lib(13):func(104):reason(168) I'm heading in the direction of trying to generate a symmetrical key based on some random attributes (although this code won't have many sources of entropy in situ) in order to encrypt something ready to be sent up to a web server. The "dir.o" is being built with: "objcopy --input binary --output elf32-littlearm --binary-architecture arm ../certificates/pubkey.der der.o", which I believe is correct, although naturally the ".o" file is quite large, the `&_binary____certificates_der_size` reports the correct size (* 294* in my case). I've poked around Google and the list archives and couldn't come up with anything; but I also couldn't come up with results from many people who had been doing what I am doing (ie. reading from an inlined object blob). - Lee Hambley