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
Mutable Access to Encoded Values #240
Comments
Thank you for your issue! I don't think we can provide that kind of interface, because our parser "basic" or permissive, while our encoder is canonical, in other words we don't guarantee to preserve the original encoding when re-encoding through rasn. Additionally there are some encodings where that would not be possible to provide a mutable view, as SNMP uses BER right? I also found this part of the RFC that says this operation is required anyway.
However just because this re-encoding is required that doesn't mean we can't make this easy for developers to do. We can add a convenience function that makes it easy to just modify the message and then have the function handling the decoding, rehashing, and encoding for you. |
That's more or less what I figured. 👍
Yep
I think that is saying that the Transport (Subsystem) Model doesn't re-encode because that would violate the modularity that the various subsystems define. Unfortunately the authors of RFC3414 weren't quite as careful with the Security Subsystem/Model, talking about the procedures for the USM Security Subsystem Model's
I think, it means to imply that the rest of the message is already otherwise fully encoded and encoding just (Getting really off topic:) The only way that I've thought of to be able to make this work the way the RFC seem to be assuming, would be to make my own type that represents (for instance)
IMO, I think that's probably only worth it if you think it might be able to be more efficient, even just for some cases. If you think that the end result is still doing a full decode, modify, full reencode; then I think it's probably not worth your trouble to implement that just so that the current 3 lines of code in my codebase can become 1. Sorry if any of that doesn't make any sense, my brain is rather fried from spending 3+ weeks trying to make sense of these RFCs. |
Would it be possible to add some mechanism to get mutable access to an encoded value? In my current use case it's specifically for an OCTET STRING where the length is known before encoding, but not the value.
Authentication using SNMPv3's USM has the unfortunate design that needs to encode a full message with the auth parameters zeroed out, take a hash, and then overwrite the zeros with the actual hash. (And the reverse for verifying.) This means that when using rasn I have to encode the message twice. (Actually following SNMP's Abstract Programming Interfaces, I have to encode, decode, and then encode again.) I could avoid this if there were some way to mutate (or replace) the
authentication_parameters
in USMSecurityParameters (which is itself an OctetString in Message).I'm not really sure if/how this could be added. I pretty much expect this request to be closed as impossible / not fitting with rasn's design. I haven't even benchmarked anything to know if it's even anywhere near approaching a problem, it just feels unfortunate. But, if you have thoughts on some way this might be accomplished, I'm more than happy to handle the implementation myself.
The text was updated successfully, but these errors were encountered: