bcgit / pc-dart

Pointy Castle - Dart Derived Bouncy Castle APIs
MIT License
237 stars 122 forks source link

ASN1BitString wrong encode #55

Closed ertong closed 3 years ago

ertong commented 3 years ago

print(base64.encode(ASN1BitString(stringValues: [1]).encode())); returns AwEB (030101) expected AwIAAQ== (03020001) (verified by other implementations)

It looks like there should be added extra byte "padding" for some reason.

I suppose, that it should be enough to add default value for unusedbits field to zero in ASN1BitString.

pointycastle: 2.0.0

Ephenodrom commented 3 years ago

I think it seems the unused bit was missing. Maybe this is fixed by #57. I will take a look at it next week.

mwcw commented 3 years ago

Fixed by: https://github.com/bcgit/pc-dart/pull/57