Project

General

Profile

Actions

Feature #3251

closed

Allow encoder to use multiple signature types

Added by Andrew Brown about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Start date:
10/08/2015
Due date:
% Done:

0%

Estimated time:

Description

In https://github.com/named-data/jndn/blob/master/src/net/named_data/jndn/encoding/Tlv0_1_1WireFormat.java#L844, the wire format encoder only recognizes certain built-in Signatures. I would like to add different Signature classes with minimal changes to the encoding code; can we add a way to register new signature types?

Here are two options:

  1. One possibility is to delegate the encoding to the Signature itself; this would require wireEncode() and wireDecode() methods on every signature. This is simple but custom signatures may unwittingly encode incorrectly. For decoding, some map (held perhaps in a global singleton) would have to track signature codes (like Tlv.SignatureType_SignatureSha256WithRsa, etc.) and their respective implementations; this map would have to have a public register(signatureTlvCode, signature) method so that external code like ours could add other Signature implementations.

  2. Another possibility is to keep all encoding in the wire formats and to query the Signature for a few new necessary methods (hasKeyLocator(), getTlvType()); this approach would still require a register(signatureTlvCode, signature) but perhaps at the wire format level (?). On the encode side, for example, it might look something like:

if (signature.hasKeyLocator()) {
      encodeKeyLocator(Tlv.KeyLocator, signature.getKeyLocator(), encoder);
}
encoder.writeNonNegativeIntegerTlv(Tlv.SignatureType, signature.getTlvType());

Thoughts?

Actions

Also available in: Atom PDF