Sponsored Content
Full Discussion: binary/hex output
Top Forums Shell Programming and Scripting binary/hex output Post 302225320 by era on Friday 15th of August 2008 06:12:58 AM
Old 08-15-2008
tr translates (replaces) all occurrences of one character with another. I arbitrarily chose dot to translate from; the idea is merely to use a character which doesn't need to survive past tr so you need to pick one which isn't present in your input. If you have ISO-8859-1 something like the section sign § used to be a popoular pick because you very rarely see it in any real-world data, but of course now with UTF-8 that no longer works.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Binary and hex in unix

not much familiar with binary and hex calculation in script programming.... explaination: binary format control the parameter turned on or off in the program stored in hex mode, the question is: how to change 39e to 19e using the binary calculation(although i don't know the command for... (2 Replies)
Discussion started by: trynew
2 Replies

2. UNIX for Advanced & Expert Users

Modifying binary file by editing Hex values ?

Hi , i'm using special binary file (lotus notes) and modifying an hexadecimal address range with windows hex editor and it works fine ! The file is an AIX one and i'm forced to transfert (ftp) it before modifying it and re-transfert ! NOW i would do this directly under AIX ! I can... (4 Replies)
Discussion started by: Nicol
4 Replies

3. Programming

After converting the hexstr to Hex and storing the Hex in a char*

Hi All, My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ',' This has to be done for all the hexstring char* is NULL. Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies

4. Shell Programming and Scripting

convert hex to binary and send to variable

Folks, can anyone help with a script to convert hex to binary digits, and break the 32 bit binary into packs of 4 and send them to 8 different variables.Any help is sincerely appreciated. Thanks venu Its in korn shell...... (24 Replies)
Discussion started by: venu
24 Replies

5. Shell Programming and Scripting

To log binary file output to a txt file

Hi, I wrote a small script whose function is to execute the postemsg provided if the threshold breaches. I want to log this postemsg messages to a log file. But I am not able to do. Can someone throw some light on how to log the output of this. I am pasting a snippet of that code. ... (2 Replies)
Discussion started by: dbashyam
2 Replies

6. Programming

What is the difference between ios::hex and std::hex?

Hi, Is there really a difference between these two, std::hex and ios::hex?? I stumbled upon reading a line, "std::ios::hex is a bitmask (8 on gcc) and works with setf(). std::hex is the operator". Is this true? Thanks (0 Replies)
Discussion started by: royalibrahim
0 Replies

7. Shell Programming and Scripting

Output redirection of c binary file to a file in shell script is failing

I am struck up with a problem and that is with output redirection. I used all the ways for the redirection of the output of c binary to a file, still it is failing. Here are the different ways which I have used: ./a.out | tee -a /root/tmp.txt 2>&1 ./a.out | tee -a /root/tmp.txt 1>&1 ./a.out |... (2 Replies)
Discussion started by: Maya29988
2 Replies

8. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

9. Shell Programming and Scripting

How to replace with "sed" some hex values by other hex values?

Assume I have a file \usr\home\\somedir\myfile123.txt and I want to replace all occurencies of the two (concatenated) hex values x'AD' x'A0' bytwo other (concatenated) hex values x'20' x'6E' How can I achieve this with the gnu sed tool? Additional question: Is there a way to let sed show... (1 Reply)
Discussion started by: pstein
1 Replies

10. Shell Programming and Scripting

Convert Binary File To Hex In Linux

dHi, I have the attached file(actual file can be extracted post unzipping it) & i am trying to use the following code for coversion to hex format. Starting hex value is 84 which is start of the record & termination is done using 00 00 followed by 84(hex) which i can see in the dump clearly using... (14 Replies)
Discussion started by: siramitsharma
14 Replies
PASSPHRASE-ENCODING(7SSL)					      OpenSSL						 PASSPHRASE-ENCODING(7SSL)

NAME
passphrase-encoding - How diverse parts of OpenSSL treat pass phrases character encoding DESCRIPTION
In a modern world with all sorts of character encodings, the treatment of pass phrases has become increasingly complex. This manual page attempts to give an overview over how this problem is currently addressed in different parts of the OpenSSL library. The general case The OpenSSL library doesn't treat pass phrases in any special way as a general rule, and trusts the application or user to choose a suitable character set and stick to that throughout the lifetime of affected objects. This means that for an object that was encrypted using a pass phrase encoded in ISO-8859-1, that object needs to be decrypted using a pass phrase encoded in ISO-8859-1. Using the wrong encoding is expected to cause a decryption failure. PKCS#12 PKCS#12 is a bit different regarding pass phrase encoding. The standard stipulates that the pass phrase shall be encoded as an ASN.1 BMPString, which consists of the code points of the basic multilingual plane, encoded in big endian (UCS-2 BE). OpenSSL tries to adapt to this requirements in one of the following manners: 1. Treats the received pass phrase as UTF-8 encoded and tries to re-encode it to UTF-16 (which is the same as UCS-2 for characters U+0000 to U+D7FF and U+E000 to U+FFFF, but becomes an expansion for any other character), or failing that, proceeds with step 2. 2. Assumes that the pass phrase is encoded in ASCII or ISO-8859-1 and opportunistically prepends each byte with a zero byte to obtain the UCS-2 encoding of the characters, which it stores as a BMPString. Note that since there is no check of your locale, this may produce UCS-2 / UTF-16 characters that do not correspond to the original pass phrase characters for other character sets, such as any ISO-8859-X encoding other than ISO-8859-1 (or for Windows, CP 1252 with exception for the extra "graphical" characters in the 0x80-0x9F range). OpenSSL versions older than 1.1.0 do variant 2 only, and that is the reason why OpenSSL still does this, to be able to read files produced with older versions. It should be noted that this approach isn't entirely fault free. A pass phrase encoded in ISO-8859-2 could very well have a sequence such as 0xC3 0xAF (which is the two characters "LATIN CAPITAL LETTER A WITH BREVE" and "LATIN CAPITAL LETTER Z WITH DOT ABOVE" in ISO-8859-2 encoding), but would be misinterpreted as the perfectly valid UTF-8 encoded code point U+00EF (LATIN SMALL LETTER I WITH DIARESIS) if the pass phrase doesn't contain anything that would be invalid UTF-8. A pass phrase that contains this kind of byte sequence will give a different outcome in OpenSSL 1.1.0 and newer than in OpenSSL older than 1.1.0. 0x00 0xC3 0x00 0xAF # OpenSSL older than 1.1.0 0x00 0xEF # OpenSSL 1.1.0 and newer On the same accord, anything encoded in UTF-8 that was given to OpenSSL older than 1.1.0 was misinterpreted as ISO-8859-1 sequences. OSSL_STORE ossl_store(7) acts as a general interface to access all kinds of objects, potentially protected with a pass phrase, a PIN or something else. This API stipulates that pass phrases should be UTF-8 encoded, and that any other pass phrase encoding may give undefined results. This API relies on the application to ensure UTF-8 encoding, and doesn't check that this is the case, so what it gets, it will also pass to the underlying loader. RECOMMENDATIONS
This section assumes that you know what pass phrase was used for encryption, but that it may have been encoded in a different character encoding than the one used by your current input method. For example, the pass phrase may have been used at a time when your default encoding was ISO-8859-1 (i.e. "naieve" resulting in the byte sequence 0x6E 0x61 0xEF 0x76 0x65), and you're now in an environment where your default encoding is UTF-8 (i.e. "naieve" resulting in the byte sequence 0x6E 0x61 0xC3 0xAF 0x76 0x65). Whenever it's mentioned that you should use a certain character encoding, it should be understood that you either change the input method to use the mentioned encoding when you type in your pass phrase, or use some suitable tool to convert your pass phrase from your default encoding to the target encoding. Also note that the sub-sections below discuss human readable pass phrases. This is particularly relevant for PKCS#12 objects, where human readable pass phrases are assumed. For other objects, it's as legitimate to use any byte sequence (such as a sequence of bytes from `/dev/urandom` that's been saved away), which makes any character encoding discussion irrelevant; in such cases, simply use the same byte sequence as it is. Creating new objects For creating new pass phrase protected objects, make sure the pass phrase is encoded using UTF-8. This is default on most modern Unixes, but may involve an effort on other platforms. Specifically for Windows, setting the environment variable "OPENSSL_WIN32_UTF8" will have anything entered on [Windows] console prompt converted to UTF-8 (command line and separately prompted pass phrases alike). Opening existing objects For opening pass phrase protected objects where you know what character encoding was used for the encryption pass phrase, make sure to use the same encoding again. For opening pass phrase protected objects where the character encoding that was used is unknown, or where the producing application is unknown, try one of the following: 1. Try the pass phrase that you have as it is in the character encoding of your environment. It's possible that its byte sequence is exactly right. 2. Convert the pass phrase to UTF-8 and try with the result. Specifically with PKCS#12, this should open up any object that was created according to the specification. 3. Do a naieve (i.e. purely mathematical) ISO-8859-1 to UTF-8 conversion and try with the result. This differs from the previous attempt because ISO-8859-1 maps directly to U+0000 to U+00FF, which other non-UTF-8 character sets do not. This also takes care of the case when a UTF-8 encoded string was used with OpenSSL older than 1.1.0. (for example, "ie", which is 0xC3 0xAF when encoded in UTF-8, would become 0xC3 0x83 0xC2 0xAF when re-encoded in the naieve manner. The conversion to BMPString would then yield 0x00 0xC3 0x00 0xA4 0x00 0x00, the erroneous/non-compliant encoding used by OpenSSL older than 1.1.0) SEE ALSO
evp(7), ossl_store(7), EVP_BytesToKey(3), EVP_DecryptInit(3), PEM_do_header(3), PKCS12_parse(3), PKCS12_newpass(3), d2i_PKCS8PrivateKey_bio(3) COPYRIGHT
Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>. 1.1.1a 2018-12-18 PASSPHRASE-ENCODING(7SSL)
All times are GMT -4. The time now is 05:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy