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

encoding is not right in UniversalString #5

Closed
scegg opened this issue May 14, 2020 · 3 comments
Closed

encoding is not right in UniversalString #5

scegg opened this issue May 14, 2020 · 3 comments
Labels
bug Bug. An issue exist in our code.

Comments

@scegg
Copy link

scegg commented May 14, 2020

https://github.com/PKISolutions/Asn1DerParser.NET/blob/master/Asn1Parser/Universal/Asn1UniversalString.cs

Line 50 and 53:

The encoding of "abc" in UTF32 is (in dec): 97 00 00 00 98 00 00 00 99 00 00 00
The Reverse() will make it to: 00 00 00 99 00 00 00 98 00 00 00 97

That may not be your wanted result right?

@Crypt32 Crypt32 added the bug Bug. An issue exist in our code. label May 14, 2020
@Crypt32
Copy link
Collaborator

Crypt32 commented May 14, 2020

Agree. The intent was to reverse 4-byte block for every character. .NET returns strings in little-endian byte sequence and we need big-endian sequence for ASN.1

@scegg
Copy link
Author

scegg commented May 14, 2020

var data = Encoding.UTF32.GetBytes(value.Reverse().ToArray()).Reverse().ToArray();

Crypt32 added a commit that referenced this issue Jun 12, 2020
@Crypt32
Copy link
Collaborator

Crypt32 commented Jun 12, 2020

thanks for reporting, I've fixed this bug.

@Crypt32 Crypt32 closed this as completed Jun 12, 2020
@Crypt32 Crypt32 reopened this Jun 12, 2020
@Crypt32 Crypt32 closed this as completed Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug. An issue exist in our code.
Projects
None yet
Development

No branches or pull requests

2 participants