Dear Ladies and Gentlemen,
I’m trying to use the ECC Addition primitive (on a Ubivelox card where this should be supported / implemented).
Unfortunately it seems that in the multos.h headers this primitive is not supported, so I tried to extend the headers by myself. From the documentation (MULTOS Developer’s Reference Manual) I found that the addresses domainAddr,
point1Addr, point2Addr, outAddr have to be placed on the stack. What is not quite clear to me however is what I have actually to place at the corresponding addresses in the memory.
From the example for “ECC Generate Key Pair” (MULTOS Developer’s Reference Manual) I copied the domain parameters (together with the corresponding structure) however what format do I need for the points (how many bytes?)?
In addition is seems to me that the primitives don’t just accept any random byte combination as points (I tried 48 random bytes per point) but one needs points that “make sense” (in my first test I always get “exchange error SCardTransmit unknown pcsc error 0x8010002f”). Is this correct?
Is there any extended documentation on this topic?
This primitive is one of those that has never really been used all that much. Hence why its not in multos.h and you’ll find isn’t in the current simulator either. For most applications the higher level ECC primitives are used. I’ve certainly never used it so don’t have any examples to hand.
Having said that I’ll be happy to put an example together for you. Give me a few days.
thank you very much for the fast reply and the offer to write an example. Perhaps it might be interesting for you to see what I already did.
I added the following to the header file (multos.h):
** void multosEccAdd(BYTE *domain, BYTE *point1, BYTE *point2, BYTE *outPoint)
void multosEccAdd(BYTE *domain, BYTE *point1, BYTE *point2, BYTE *outPoint);
#define multosEccAdd(domain, point1, point2, outPoint) \
__push (__typechk(BYTE *, domain)); \
__push (__typechk(BYTE *, point1)); \
__push (__typechk(BYTE *, point2)); \
__push (__typechk(BYTE *, outPoint)); \
__code (__PRIM, __PRIM_ECC_ADD); \
} while (0)
and started a first example:
#define SHORT_KEY_LEN 24
// Copy in information from APDU
memcpy(&point2;,apdu_data.pub + 2*SHORT_KEY_LEN,2*SHORT_KEY_LEN);
// Blank results
multosEccAdd((BYTE*)&domainParams;, (BYTE*)&point1;, (BYTE*)&point2;, (BYTE*)&outPoint;);
The eccpoint structure needs to start with a single byte which gives the representation. For affine points the value is 0x04, for projective points it is 0x84. It should say this in the MDRM, but doesn’t. Next time I do an update I’ll include that.
Having said that, I haven’t managed to get my example app to work. I’ve requested some help from the guys at Ubivelox.