Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"The given key was not present in the dictionary." error decoding base64 encoded CMS structure #1

Open
audunn opened this issue Jul 22, 2018 · 8 comments
Labels
wontfix The behavior is by design, or we don't have an ability to fix this due to API restrictions.

Comments

@audunn
Copy link

audunn commented Jul 22, 2018

Hi,
I am trying to use your tool to decode some base64 CMS structure (from an S/MIME message). I am using the Data Converter tool of the asn.1 Editor but it does not decode showing an error of "The given key was not present in the dictionary."
This online decoder https://lapo.it/asn1js and and openssl do not seem to have an issue with it.
Also I am able to decode CMS structures from other messages, any idea as to what may be causing the error?

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIAwggaE
MIIFbKADAgECAhBAAWRglTQLOUMBZuEFvqZrMA0GCSqGSIb3DQEBCwUAMIGnMScwJQYDVQQK
DB5UaGUgUm95YWwgQmFuayBvZiBTY290bGFuZCBwbGMxQzBBBgNVBAsMOlRoZSBSb3lhbCBC
YW5rIG9mIFNjb3RsYW5kIHBsYyBUcnVzdEFzc3VyZWQgSW5mcmFzdHJ1Y3R1cmUxNzA1BgNV
BAMMLlRoZSBSb3lhbCBCYW5rIG9mIFNjb3RsYW5kIFBsYyBUcnVzdEFzc3VyZWQgQ0EwHhcN
MTgwNzAzMTQzOTA4WhcNMjEwNzAyMTQzOTA4WjB9MQswCQYDVQQGEwJHQjEiMCAGA1UEChMZ
VGhlIFRvcm9udG8tRG9taW5pb24gQmFuazEqMCgGA1UECxMhSW50ZXJuYXRpb25hbCBURCBE
aXJlY3QgSW52ZXN0aW5nMR4wHAYDVQQDExVwYXltZW50cy50ZGJhbmtudi5jb20wggEiMA0G
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDi3/lYip/P+CRejgNhkSj2J0BuU0aYm2YWsBW1
0bXz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EqMAsGCWCGSAFlAwQBFjALBglghkgBZQMEAQIwCgYIKoMajJpEAQQwDQYL
KoMIjJpLPQEBAQQwDQYLKoMIjJpLPQEBAQMwDQYLKoMIjJpLPQEBAQIwCwYJKoZIhvZ9B0IK
MAoGCCqGSIb3DQMHMA0GCSqGSIb3DQEBAQUABIIBAKLlNfW8ejRZgxGHm0u6RJhWAasjmWF4
9lJvXVZnn8nNRF4Voys4ESlFWKw4wquV0DH5OllsGn03fYy53d2BAX5XC9ddRm32x7gzf3Er
F12VZklThA8030dmg2W5WL6pGeAhMAZlSJQo5zrwvffCGa643sRTlLqdlKPO0aGJSYjUoIe1
tdxV0dzSGkpgz5anCaefxJKxSLbI7bx7F4V+7gDuUf5OEdc+0peswRE1lqWQVDybv36H1FIm
/Y1IY3eSOT01OQCFoJy036eV/sbpSULTrfRx3j0ljrVlPKWVLmyf9M1QitmFR8w9Jv7m/4L0
FBKlMFfvnjr0EbjAhNZTbByhAAAAAAAAAA==

@Crypt32
Copy link
Collaborator

Crypt32 commented Jul 23, 2018

I will take a look.

@Crypt32
Copy link
Collaborator

Crypt32 commented Jul 23, 2018

Got this. The problem is that your file uses indefinite length. I'm not supporting indefinite length, because it is not allowed in DER encoding. It is supported by BER, but X.509 uses DER encoding.

@audunn
Copy link
Author

audunn commented Jul 23, 2018

Thank you, missed that.
Is there a quick way to see this from the file?

@Crypt32
Copy link
Collaborator

Crypt32 commented Jul 23, 2018

What exactly?

@audunn
Copy link
Author

audunn commented Jul 23, 2018

Sorry for not being clear. I am not familiar with those structures, what I mean is there a way to easily tell if a structure such as this is using indefinite length or definite or what encoding it is?

@Crypt32
Copy link
Collaborator

Crypt32 commented Jul 23, 2018

You can convert this Base64-encoded string to a byte array and examine 2nd byte. If it is 0x80 (128), then ASN type uses indefinite length. DER forbids indefinite length encoding on the grounds that serialized representation of the same data may change on re-encoding. Since my ASN.1 Editor is primarily intended to decode X.509 objects and they explicitly use DER encoding, indefinite length decoding is not implemented in my code.

@FranklinYu
Copy link

FranklinYu commented May 2, 2019

@Crypt32 I understand that BER is out-of-scope for this decoder, but the error message can be improved.

@audunn You can still see (not edit) the inner structure with some online tool like https://lapo.it/asn1js/

@Crypt32 Crypt32 added the wontfix The behavior is by design, or we don't have an ability to fix this due to API restrictions. label Oct 23, 2023
@ralienpp
Copy link

@FranklinYu, you mean that the tool could instead say "This is a BER-encoded file, but only DER is supported"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix The behavior is by design, or we don't have an ability to fix this due to API restrictions.
Projects
None yet
Development

No branches or pull requests

4 participants