python-asn1
python-asn1 copied to clipboard
Encoder.output is different from version 2.8.0 to 3.0.0
Hi, i use asn1 to implement spnego, which worked for version 2.8.0, after i upgraded to 3.0.0, it stopped working because the new version leave() function appends b'\x00\x00'. the below code is an example to demonstrate the difference, please help if there is any wrong usage in the code.
import asn1
GENSEC_OID_SPNEGO = "1.3.6.1.5.5.2"
def encode_spnego():
encoder = asn1.Encoder()
encoder.start()
encoder.enter(0, asn1.Classes.Application)
encoder.write(GENSEC_OID_SPNEGO, asn1.Numbers.ObjectIdentifier)
encoder.leave()
out = encoder.output()
print("Encoded SPNEGO: %d" % len(out))
if __name__ == "__main__":
encode_spnego()
This is probably the same bug than #287. The new version does not respect DER encoding. I will fix that.