> I'm trying to port our Thales adapter to use FSDMsg, more as a
> learning exercise than anything else.
> The "GW" Thales command (generate a MAC) has a fixed length "data
> length" field followed by a variable length "data to MAC" field.
This is interesting as the data is variable length (multiples of 8
bytes), but the terminator that follows this field is only present if
your are specifying a 'message trailer'.
So we need a variable length field with no terminator byte.
> How do you reflect this in the FSDMsg schema? Obviously, the schema
> field definitions have a length, so what sort of value would one use
> for a variable length field?
If you were specifying a message trailer then you would need a field
that terminated itself with a x'19' byte, which will need a new separator.
At the moment I don't think it is possible to achieve what is needed.
May I suggest adding a dummy separator type that will prevent padding,
that packs to nothing?
Like:-
<schema id='fsdmsg-test'>
<field id="length" type="N" length="4" />
<field id="vardata" type="ADS" length="32" />
</schema>
Where the DS type is a dummy separator and would satisfy the test case:-
FSDMsg m = new FSDMsg ("file:..[above]");
macData = "12345678123456781234567812345678";
m.set ("length", "32");
m.set ("vardata", macData);
assertEquals("Dummy separator long
data","003212345678123456781234567812345678",m.pack());
I have the code ready to commit, but would like to check no one sees a
way to support this asis.
--
Mark
--
Mark
> The HSM then complains when it
> receives the message, as it is given a message length much longer
> than the length of the actual message.
And rightly so.
>
> Is there some way around this?
I think may be some code to fix that does not currently know about the
dummy separator and that the whole length is not used, I will take a
look later and come back.
May I ask to see your schema - or at least the part including the "data
to be MAC'd" field?
>
> One other question that is tangentially related: if you're talking to
> a Thales HSM through a MUX, what MUX key fields do you use? We
> currently place a counter in the four byte header and override one of
> the MUX implementations to read the header data to match requests to
> responses, but I'm wondering if there is a better way?
I'm sorry to say I don't connect to any HSMs using jPOS or even java.
The header sounds ok, but remember the 'message trailer' that was
mentioned earlier?
I think I would seek to use that field - as long as the HSM echos it
back! There may be 'issues' as it's position probably varies across
message types? In the MUX, are the fields referenced by number
(position) or by name?
--
Mark
I am interested in the definition for the field that holds the data
requiring MACing.
Did you chnage you field definition to use the new type="ADS" on your
data field like :-
<schema id='fsdmsg-test'>
.
.
<field id="dataForMACing" type="ADS" length="32768" />
.
.
</schema>
I am hopeful there is a typo or something stopping this working, it
works for me you see.
--
Mark
My test cases were not using Binary type fields, instead I had assumed
alphanumeric data (Character hex in fact). Checking the spec the data
into the transaction is binary.
This is why it did not work, and should work for you now.
--
Mark
Without this detail we are blind to your issue?
--
Mark
This assumes that you are using field definitions that include an
indicator of the separator required. You say 'separator that you set'
rather than the separator that is defined, so...
...You could be rolling your own separators (by using distinct fields)
in which case the behaviour is different, and unless the field is set it
will have no content on pack.
If you had supplied even a subset of the schema you are using as I
requested, we might now have a better idea or been able to advise more
accurately.
FSDMsgs and their derivatives are working for many people. If they
didn't work I think those people would be asking questions here. This
therefore suggests to me that either your view of the flow is incorrect
or you do not have the correct schema.
Our answers could have been better perhaps, but your question and it's
content set the stage.
Take a(nother) read of the very useful and often referenced :-
http://www.catb.org/~esr/faqs/smart-questions.html
It may help us all in the future.
>
> my messages are sent and responded just fine..
So if your message exchanges are working, what caused you to look more
closely and worry that separators - I assume the target host is
expecting and parsing - are somehow absent?
--
Mark