On Fri February 6 2009, Steffen DETTMER wrote: > Hi all, Hi Alistair! > > * Young, Alistair wrote on Fri, Feb 06, 2009 at 10:16 +0000: > > Ultimately I settled on the use of a shell script to act as an > > intermediary: > > > > #!/bin/bash > > If you can use bash you could pass the key in \xNN form for > $'\xNN' to avoid special characters like blanks and control chars > or binary zero issues: > pass a kind of hey dump instead of binary. > > First make some "escape hex dump" with something like > > > public static char[] > getbin(byte[] buf) > { > char[] result = null; > int pos = 0; > int len = buf.length; > { > String result = ""; > result = new char [len * 2]; > for (int i = 0; i < len; i++) { > byte b = buf[pos + i]; > // this is horrible slow because of many temp StringBuffers, > // just to illustrate > result = result + "\\x"; // we want \x in the String > result = result + hexnib((b & 0xF0) >> 4); > result = result + = hexnib((b & 0x0F)); > } > } > return result; > } > > public static final char > hexnib(int nibble) > { > if (nibble <= 9) return (char) ('0' + nibble); > return (char) ('A' + nibble - 10); > } > > For 'hello' you should get '\x68\x65\x6c\x6c\x6f'. >
?? print(%q ...) ?? Mike > Then pass this to your script as parameter like you now pass the > file name and in your script have something like > > #!/bin/bash > key_escaped="$1" > key_raw=`eval echo $\'$key_escaped\'` > echo openssl -option "$key_raw" > > which can be used like > > u...@host:~ $ ./x.sh '\x41\x42' > openssl -option "AB" > > (This does not mean that I'd recommend to do such things! Crypto via > shell scripts and stuff invitest potential security flaws etc.) > > oki, > > Steffen > > > ----[End of message]------------------------------------------------->8======= ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org