On 4/11/2013 8:31 PM, Dave Thompson wrote:
From: Lee Hambley
Sent: Thursday, 11 April, 2013 02:33
...
extern unsigned char _binary____certificates_der_start;
extern unsigned char _binary____certificates_der_size;
I see below this is apparently a very weird object-file trick.
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);
<snip>
A certificate and a publickey are very different things.
Your tool below seems to have chosen a very inapposite name
apparently by default; it would be nice if you can change that.
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).
Using a presumably-absolute "address" for a size? Yuck! The classic
way to do this was a _start address and an _end address. Oh well.
Actually, I think the only weird thing here is the way those
declarations are written, I would use
// Note: The 3 identifiers are generated from the input file name by
// code in GNU objcopy or the underlying GNU BFD.
// According to a Linux Journal article (the objcopy documentation
// is sorely lacking), the identifiers should have been
// replnoiseby_("_binary_" "../certificates/pubkey.der" "_suffix")
// == _binary____certificates_pubkey_der_suffix
// I suspect the OP's objcopy binary has a bug that drops the filename,
// leaving only the directory and extension.
// See also http://www.linuxjournal.com/content/
// embedding-file-executable-aka-hello-world-version-5967
// (URL does not fit code window width, so broken on two lines)
extern const unsigned char _binary____certificates_der_start[];
extern const unsigned char _binary____certificates_der_end[];
//??? howToDeclare _binary____certificates_der_size;
// Workaround expression, less efficient than finding a way to
// reference a non-pointer absolute external symbol
#define _binary____certificates_der_size ( \
(_binary____certificates_der_end - \
_binary____certificates_der_start) * \
sizeof(_binary____certificates_der_start[0]))
Enjoy
Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S. http://www.wisemo.com
Transformervej 29, 2730 Herlev, Denmark. Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org