 |
|
 |
I've been using the ASN.1 Editor for a few weeks now and like it quite well.
It is however not possible to read nodes with an indefinite length.
Defined by 0x80 in the first length byte.
X.690-0207 states:
8.1.3.6 For the indefinite form, the length octets indicate that the contents octets are terminated by end-of-contents
octets (see 8.1.5), and shall consist of a single octet.
8.1.3.6.1 The single octet shall have bit 8 set to one, and bits 7 to 1 set to zero.
8.1.3.6.2 If this form of length is used, then end-of-contents octets (see 8.1.5) shall be present in the encoding following
the contents octets.
8.1.5 End-of-contents octets
The end-of-contents octets shall be present if the length is encoded as specified in 8.1.3.6, otherwise they shall not be
present.
The end-of-contents octets shall consist of two zero octets.
I have downloaded the source and looked in to this for a moment, but haven't come up with a solution yet.
If anyone knows if this has already been solved in some available copy, please let me know.
|
|
|
|
 |
|
 |
(in Asn1Util.cs, untested, and does not decode the content inside the the indefinite length block as it really should)
public static long DerLengthDecode(Stream bt, ref bool isIndefiniteLength) {
isIndefiniteLength = false;
long length = 0;
byte b;
b = (byte)bt.ReadByte();
if ((b & 0x80) == 0) {
length = b;
} else {
long lengthBytes = b & 0x7f;
if (lengthBytes == 0) {
isIndefiniteLength = true;
long sPos = bt.Position;
int l = (int)sPos;
byte b1 = 0xff;
while (l++ < bt.Length) {
byte b2 = (byte)bt.ReadByte();
if ((b1 | b2) == (byte)0) {
break;
}
b1 = b2;
}
bt.Position = sPos;
return (int)(l - sPos - 2);
}
length = 0;
while (lengthBytes-- > 0) {
if ((length >> (8 * (4 - 1))) > 0) {
return -1; }
b = (byte)bt.ReadByte();
length = (length << 8) | b;
}
}
return length;
}
Danny
modified 17 Nov '11.
|
|
|
|
 |
|
 |
Thanks dheijl, I'll definitely give this a try soon.
I'm just not sure if it'll work; what if, for example, an indefinite length tag contains an octet stream which contains data with two zero-bytes?
|
|
|
|
 |
|
 |
That's right, it should really decode and skip the content as ASN1 data, I only meant to show where the corrections should go.
The ASN1 type tags should be checked and a recursive call to DerLengthDecode may be needed.
|
|
|
|
 |
|
 |
Ok, thanks for your effort.
|
|
|
|
 |
|
 |
I've found this tool to be very useful. Thank you. I found a problem when processing a PKCS10 generated by a microsoft tool. A UTF8 string was empty, and the ASN.1 Editor could not display this file. It can be fixed by making this change in Asn1Node.cs: Change: dataStr = unicode.GetString(data); to: if (data == null) { dataStr = "EMPTY"; } else { dataStr = unicode.GetString(data); } The base64 encoded version of the file that triggers this problem follows: MIIEDDCCAvQCAQAwADCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANPk/lAOEvYikbMJvabzapKyJkqLnaXWm2FvnO6UNCtXWf9WchbbumLqkIas9BUcMiSEEh4tVZNFugi3bahnjUjTG9MIvAZd3/C0YfuLX8yl9mcIVWZhyYZVwUeMh4GYS5ht90NFZP0vXb7c0brSRyvhvWzq+kG7om24qMTZBgSIRsajcDVY+uGLdhixy4AtXNw5pzzRdS/1QBF1wsDT3C0bceWy2uej2hsLYolyGdd0fHk1y/tOusoyjc3itw2o3P9jk+bP4eDG2ukRjMMcjqxQ50OBze7hXQf2hrNEJRTd6pPIOdAub8Hz/DiPYaEY75XNEQepc11nLmq2GQ9YghcCAwEAAaCCAcUwGgYKKwYBBAGCNw0CAzEMFgo2LjEuNzA1My4yMGQGCSsGAQQBgjcVFDFXMFUCAQUMLzktMTM1MUMwNDA1QS5kOS0xMzUxQzA0MDZBLm50dGVzdC5taWNyb3NvZnQuY29tDBJEOS0xMzUxQzA0MDZBXGFiYnkMC0Nlc1Rlc3QuZXhlMHQGCisGAQQBgjcNAgIxZjBkAgEBHlwATQBpAGMAcgBvAHMAbwBmAHQAIABFAG4AaABhAG4AYwBlAGQAIABDAHIAeQBwAHQAbwBnAHIAYQBwAGgAaQBjACAAUAByAG8AdgBpAGQAZQByACAAdgAxAC4AMAMBADCBygYJKoZIhvcNAQkOMYG8MIG5MBcGCSsGAQQBgjcUAgQKHggAVQBzAGUAcjApBgNVHSUEIjAgBgorBgEEAYI3CgMEBggrBgEFBQcDBAYIKwYBBQUHAwIwDgYDVR0PAQH/BAQDAgWgMEQGCSqGSIb3DQEJDwQ3MDUwDgYIKoZIhvcNAwICAgCAMA4GCCqGSIb3DQMEAgIAgDAHBgUrDgMCBzAKBggqhkiG9w0DBzAdBgNVHQ4EFgQUavblZB2QWG6vt+ag4T4jZMPFe3owDQYJKoZIhvcNAQEFBQADggEBAGId8Dv9gvCVNgnSHkNuTiErtwIacv609MnMt2WxhnAjzGQZZS4bZ9JNH+CR49yswieFCS3zFiP5PxGL5CCogn2XHGs7LCCzHtrltAZBACTCtzLF5Qcj0Ki/H5GRa4Q+Ze1UrcM1cSnD52zY+V1vFXXlXc2P5hTB0bq8GbZME/MW84XE1sz75NqZeQ2vhO66ozAMywMtC26Q+7DOfBaPMxXrWgMQBm6qO/Yjj3vDY/U8T9rpJqGHHTG7E7E+/3EcgPeKNExxf0n+VXRwLO9C5wOS6Xy/JNGfuipw+SzaRbPsH5/6UiS+uqtSVzaJmAOa9vzxJQfgARCucr49wM3YUek=
|
|
|
|
 |
|
 |
Incredibly useful tool. Thank you for putting this on CP.
Alastair
|
|
|
|
 |
|
 |
Hi,
This seems to be an amazing little utility. Just wondering how to modify or assign ASN.1 BER file to get the expected result
|
|
|
|
 |
|
 |
I have created a Visualizer for Visual Studio based in your editor (but with my own implementation of the decoding, as i only needed reading the data, not creating). (It's at ASN1 Visualizer for Visual Studio 2008[^])
I would like your opinion if you can look at it for a moment (the article is not complete tho)
Also, if you feel that something is wrong with the way i used your code (licensing, copyright or something like that, plz let me know).
Thanks for all the work you put into this editor, it really helped me over the last year.
Juan Estrada
|
|
|
|
 |
|
|
 |
|
 |
I have signed data and i want to convert it to ASN1Node, so i can parse it.
Can it be done using the converter, or any other way?
Thanks
|
|
|
|
 |
|
 |
If the data is signed it should be "convertable" (if the data was originally asn1 encoded). Of course that the signature is an encoded BITSTRING so you wont be able to parse it.
A signed data structure is something like this:
Sequence:
-> DATA
-> Sequence
->-> Algorithm Information
->-> Signature (BitString)
The DATA part will be visible if it was originally encoded as ASN1
|
|
|
|
 |
|
 |
I am involved in a project where i need to write a specification for an audio file that have to transfer form one computer to another.
I am new at using ASN.1 and i am not even sure what type i am supposed to specify the file as.
I wrote the following specification:
________________________________________________
Module-user DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Voicemail ::= SEQUENCE {
mail OCTET STRING }
END
_________________________________________________
and converted it to a c++ class using the ASN.1 c++ tools from OSS Nokalva, but the audio file is not being encoded.
I simply need to know how to write an asn1 specification that will allow me to properly encode a .WAV audio file.
|
|
|
|
 |
|
 |
I need to convert a digitial certiifciate that is in BASE 64 format to DER format. thanks in advance.
yetty
|
|
|
|
 |
|
 |
Hi,
sorry for my english, I don't speak so good!
I have my request in txt format
(the request is for example:
SEQUENCE {
OBJECT IDENTIFIER signedData (1 2 840 113549 1 7 2)
[0] {
SEQUENCE { ....
)
and I want to convert this text file in Base64 and in DER.
When I have DER File, I have to send with a httpwebrequest.
With your application it's possible to do it???
You can help me??
Thank you so much.
Sara
Sara
|
|
|
|
 |
|
 |
Hi Sara,
The ASN.1 Editor doesn’t have the functionality to convert your text to DER file. You need to generate the DER data manually with the editor or you could do it by other programs. The data converter can help you convert the DER file into Base64 text.
Regards,
Liping
|
|
|
|
 |
|
 |
In a thread on April 03, I spoke about two new functions for ASN.1 Editor.
Initially, I spoke about passing a filename as an argument (so that I can right-click Open With) to the editor and have it opened. I vaguely recall downloading a version of ASN.1 Editor with this functionality. I then suggested perhaps to display the open file in the title bar of the window so that I know which file I have open. I download the latest version and the functionality for opening a file as a command line argument has disappeared - perhaps you have updated the wrong version?
Apologies if I have made a mistake somewhere.
|
|
|
|
 |
|
 |
Hi Tony,
I just verified the latest post. It does support command line file name.
You may want to double if the one you installed is newer. You should see "V2005.04.04 - V1.0.12" after you click "help->about".
Thanks,
Liping
|
|
|
|
 |
|
 |
My apologies - I downloaded the 2003 version from codeproject.com.
Tony Morris
|
|
|
|
 |
|
 |
I've been using this library for awhile now to great success, however recently another engineer started looking at some of the DER output and noticed a problem.
When encoding an INTEGER with value 0, the resulting DER from this library is:
02 00
When in fact it should be:
02 01 00
I tried some hacky fixes in Asn1Node.SaveData and Asn1Util.DERLengthEncode, but I just ended up breaking other things. I'm hoping you have some thoughts on a cleaner way to fix this.
Thanks!
--Joe Hartford
jhartford@corestreet.com
|
|
|
|
 |
|
 |
Hi Joe,
Sorry for the late reply. Somehow I didn’t receive the notification email from your posting; so I just got to know your question.
The library didn’t really implement the encoding routine to encode integer number. The editor only accepts a hex string as the integer content. The only thing the library does is calculating the data length and adjusts all the parent node data length. The library doesn’t verify the input data that included in the hex string.
You can provide “00” hex string as the integer value input to the editor. It will be encoded as “02 01 00”; which also means you need to set the integer node value to “00” after the new node is created by the library.
Best regards,
Liping
www.lipingshare.com
|
|
|
|
 |
|
 |
Is this ASN.1 Editor continuing development?
Is it possible to have a command line argument passed that is the name of the file to open?
Tony Morris
|
|
|
|
 |
|
 |
Hi Tony,
Yes, I still keep maintaining the project. Somehow, I got several requests for adding the command line support for the ASN.1 Editor. I just completed the minimal command line support for opening the binary and PEM formatted file this weekend. Here is the update URL: http://lipingshare.com/Asn1Editor/
Thanks,
Liping
www.lipingshare.com
|
|
|
|
 |
|
|
 |
|
 |
The reason for putting the updates on my site is I can update it very quickly and easily. Also, I want to keep the update history a while. I will consider sending a stabilized version to CodeProject for updating the source here after sometime.
Regards,
Liping
|
|
|
|
 |